attach_image
Point a project's image at a file a node is serving.
from plexora import attach_imageattach_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 | ProjectrequiredThe project to update, by name or object.
nodestrrequiredThe registered node serving the file.
resource_idstrrequiredThe image resource's id on that node.
channel_nameslist[str]default NoneA 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 TrueReload the project in this process after
saving. Defaults to True.
Returns
ProjectThe project, saved with the image pointed at the node and
(unless reload=False) reloaded.
Raises
KeyErrorIf project names an unknown project, or node names an
unregistered node.
ValueErrorIf 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")Related
attach_table
Point a project's cell table at a file a node is serving, and load it once.
attach_segmentation
Point a project's segmentation mask at a file a node is serving.