SegHandle
The project's segmentation mask, when it has one.
from plexora.api import SegHandleSegHandle(project: Project)Constructor parameters
projectProjectrequiredThe project record this handle wraps. A plugin
gets one from ProjectData.segmentation, not by constructing
this directly.
Properties
available
available: boolWhether this project has a segmentation mask at all.
boolTrue once a mask has been registered.
pending
pending: boolWhether the background mask-conversion job is still running.
boolTrue while the mask is being converted into tiles.
locator
locator: ResourceLocatorWhere this project's segmentation mask is served from.
ResourceLocatorThe mask's location -- local, or on a data node.
Methods
label_volume
label_volume(t: int = 0)The mask as a 3-D label volume -- one id per cell across planes -- at frame t of a time series, or None for a 2-D mask (one segmentation drawn on every plane).
Its read(level, z0, z1, rows, cols) gives (Z, H, W) label ids;
plane(z) one plane's 2-D pyramid; depth, height, width,
frames. A mask held on a data node comes back as a
providers.node.NodeLabelVolume, the same face read over the wire.
tintdefault 0The frame of a time series; 0 for a single z-stack.
LabelVolume | NodeLabelVolume | NoneNone for a 2-D mask or a project without one.
provider
provider()The object that reads this mask's labels.
Constructs the provider without opening anything: a node's provider when the mask is on one, otherwise the local file's.
An object with a read_region(level, box, max_pixels=0) method
-- the same call read_region below already makes for you.
read_region
read_region(level, box, max_pixels=0)Read cell-label pixels for a rectangle of the mask.
Reads wherever the mask physically is -- local file or data node -- without the caller having to choose.
levelintrequiredThe pyramid level to read at, 0 being full resolution.
boxtuplerequired(x0, y0, x1, y1) in that level's own pixel
coordinates.
max_pixelsintdefault 0Downsample so the returned array has at most this many pixels. 0 (the default) means no limit.
An array of uint32 cell-label ids, one per pixel of the box that actually existed; 0 where the box runs off the mask.
centroid_manifest
centroid_manifest() -> dictThe cell-centroid tile cache's manifest, building it if needed.
dict{"status": "missing"} when this project has no feature
table or no resolved x/y role, since there are then no positions
to place. Otherwise the manifest, with "status": "ready" and
the tile grid it describes.
centroid_tiles
centroid_tiles(level, tiles, gates=None, max_points=None)Cell centroids for a set of tiles, optionally gated.
levelintrequiredThe centroid cache's pyramid level.
tileslist[dict]requiredWhich tiles to read, each {"x": ..., "y": ...}
in that level's tile grid, as named by centroid_manifest().
gatesdictdefault None{column: (low, high)} ranges; only cells
whose rows satisfy every range are returned. None (the
default) returns every cell in the requested tiles.
max_pointsintdefault NoneThin each tile down to at most this many points. None (the default) returns every matching point.
A numpy structured array with id, x and y fields, one row
per centroid.