Plexora

attach_image

Point a project's image at a file a node is serving.

Generated from Plexora 0.0.55View source
from plexora import attach_image
attach_image(
    project,
    node,
    resource_id,
    channel_names=None,
    image_type=None,
    reload=True,
)

The geometry -- dimensions, pyramid depth, tile size, channel count -- comes back from the node and is recorded here, because the viewer needs all of it before it can ask for a single tile. The channel NAMES stay the project's own: renaming a panel is something a user does on the primary, and the node never needs to hear about it.

Whether the image is brightfield or a fluorescence channel stack is also decided here, from the node's own detection -- a node:// address is not something this process can open to run the usual detector -- unless image_type overrides it.

Parameters

projectstr | Projectrequired

The project to update, by name or object.

nodestrrequired

The registered node serving the file.

resource_idstrrequired

The image resource's id on that node.

channel_nameslist[str]default None

A name for each channel, in order. Ignored for a brightfield image, which has one layer. Defaults to "<resource_id>_<index>" for each channel.

image_typestrdefault None

"brightfield" to read the file as an RGB image regardless of what the node detected. Any other value is read as a fluorescence channel stack. Leave unset to use the node's own detection. An override given here is remembered, so re-attaching later -- a laptop that came back, a project repointed at another node -- reads the image the same way without being told again.

reloadbooldefault True

Reload the project in this process after saving. Defaults to True.

Returns

Project

The project, saved with the image pointed at the node and (unless reload=False) reloaded.

Raises

KeyError

If project names an unknown project, or node names an unregistered node.

ValueError

If channel_names is given with a different length than the node reports channels, or if the image the node serves does not match the project's existing one in size and channel count -- attaching a DIFFERENT image is refused, because every ROI, figure and cell coordinate in the project is expressed in that image's pixel space.

Examples

import plexora

plexora.attach_image("tonsil", node="hpc", resource_id="slide")

Guides

On this page