Plexora

SegHandle

The project's segmentation mask, when it has one.

Generated from Plexora 0.0.55View source
from plexora.api import SegHandle
SegHandle(project: Project)

Constructor parameters

projectProjectrequired

The project record this handle wraps. A plugin gets one from ProjectData.segmentation, not by constructing this directly.

Properties

available

available: bool

Whether this project has a segmentation mask at all.

bool

True once a mask has been registered.

pending

pending: bool

Whether the background mask-conversion job is still running.

bool

True while the mask is being converted into tiles.

locator

locator: ResourceLocator

Where this project's segmentation mask is served from.

ResourceLocator

The 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 0

The frame of a time series; 0 for a single z-stack.

LabelVolume | NodeLabelVolume | None

None 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.

Value

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.

levelintrequired

The pyramid level to read at, 0 being full resolution.

boxtuplerequired

(x0, y0, x1, y1) in that level's own pixel coordinates.

max_pixelsintdefault 0

Downsample so the returned array has at most this many pixels. 0 (the default) means no limit.

Value

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() -> dict

The 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.

levelintrequired

The centroid cache's pyramid level.

tileslist[dict]required

Which 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 None

Thin each tile down to at most this many points. None (the default) returns every matching point.

Value

A numpy structured array with id, x and y fields, one row per centroid.

On this page