neu_mark.roi_survey

What a node’s DVID ROIs are, measured: sizes, the containment tree, overlaps.

The input to a neu_mark.roi_layers spec, and the check when a node’s ROIs change. Every ROI’s parent is the smallest larger ROI holding more than half of it, which recovers the tree from the blocks alone; inside is the share within the parent, below contained when the child sticks out. For each ROI with children, coverage is the share of it that some child covers, and outside the share of the children’s union lying outside it. Siblings are overlapping ROIs neither of which is the other’s ancestor; past max_overlap of the smaller, roi-layers would refuse them in one layer.

Measurement works on DVID’s block ranges and needs no DVID; fetch_all() fetches them.

Attributes

Functions

check_spec(spec_path, regions, sizes, *, contained) → dict

The spec against this node: placement problems, each part's share inside its

compare(old, new, old_sizes, new_sizes) → dict

What changed between two nodes' ROIs, block for block.

composites(regions, tree) → dict[str, dict]

For each ROI with children: how well they cover it, and how far they stick out.

containment(regions, pairs) → dict[str, dict]

{roi: {"parent", "inside"}}: the smallest larger ROI holding most of it.

fetch_all(src, *[, prefer_locked, processes]) → dict

Every ROI on the node: {"provenance", "sizes", "regions", "seconds"}.

format_report(record) → str

The record as text: tree first, then everything that looks wrong.

identical(regions, pairs) → list[list[str]]

Groups of ROIs holding exactly the same blocks.

like_extent(like) → list[int]

like's level-0 extent in ROI blocks (zyx).

overlaps(regions) → list[dict]

Every intersecting pair, a before b by name, with each one's share.

past_extent(regions, extent) → dict[str, dict]

ROIs reaching outside [0, extent) blocks (zyx), by how many on each side.

run(src, *[, like, spec, compare_to, contained, ...]) → dict

Fetch the node's ROIs and survey them; optionally against a segmentation's extent,

siblings(pairs, tree, *, max_overlap[, twins]) → list[dict]

Overlapping pairs that are not ancestor and descendant, largest share first.

survey(regions, sizes, *[, contained, max_overlap, extent]) → dict

The measurements, as one JSON-ready record.

Module Contents

neu_mark.roi_survey.check_spec(spec_path: str, regions: Mapping[str, neu_mark.roi_layers.Region], sizes: Mapping[str, int], *, contained: float) → dict

The spec against this node: placement problems, each part’s share inside its top-level neuropil’s own ROI, and each layer’s overlaps or why it would be refused.

neu_mark.roi_survey.compare(old: Mapping[str, neu_mark.roi_layers.Region], new: Mapping[str, neu_mark.roi_layers.Region], old_sizes: Mapping[str, int], new_sizes: Mapping[str, int]) → dict

What changed between two nodes’ ROIs, block for block.

neu_mark.roi_survey.composites(regions: Mapping[str, neu_mark.roi_layers.Region], tree: Mapping[str, dict]) → dict[str, dict]

For each ROI with children: how well they cover it, and how far they stick out.

neu_mark.roi_survey.containment(regions: Mapping[str, neu_mark.roi_layers.Region], pairs: Sequence[dict]) → dict[str, dict]

{roi: {"parent", "inside"}}: the smallest larger ROI holding most of it.

neu_mark.roi_survey.fetch_all(src: str, *, prefer_locked: bool = False, processes: int = 8) → dict

Every ROI on the node: {"provenance", "sizes", "regions", "seconds"}. regions omits the empty ROIs, which sizes gives as 0.

neu_mark.roi_survey.format_report(record: Mapping) → str

The record as text: tree first, then everything that looks wrong.

neu_mark.roi_survey.identical(regions: Mapping[str, neu_mark.roi_layers.Region], pairs: Sequence[dict]) → list[list[str]]

Groups of ROIs holding exactly the same blocks.

neu_mark.roi_survey.like_extent(like: str) → list[int]

like’s level-0 extent in ROI blocks (zyx).

neu_mark.roi_survey.overlaps(regions: Mapping[str, neu_mark.roi_layers.Region]) → list[dict]

Every intersecting pair, a before b by name, with each one’s share.

neu_mark.roi_survey.past_extent(regions: Mapping[str, neu_mark.roi_layers.Region], extent: Sequence[int]) → dict[str, dict]

ROIs reaching outside [0, extent) blocks (zyx), by how many on each side.

neu_mark.roi_survey.run(src: str, *, like: str | None = None, spec: str | None = None, compare_to: str | None = None, contained: float = DEFAULT_CONTAINED, max_overlap: float = DEFAULT_MAX_OVERLAP, prefer_locked: bool = False) → dict

Fetch the node’s ROIs and survey them; optionally against a segmentation’s extent, a layer spec, and another node.

neu_mark.roi_survey.siblings(pairs: Sequence[dict], tree: Mapping[str, dict], *, max_overlap: float, twins: Sequence[Sequence[str]] = ()) → list[dict]

Overlapping pairs that are not ancestor and descendant, largest share first. twins are groups of identical ROIs, which count as one and are not listed.

neu_mark.roi_survey.survey(regions: Mapping[str, neu_mark.roi_layers.Region], sizes: Mapping[str, int], *, contained: float = DEFAULT_CONTAINED, max_overlap: float = DEFAULT_MAX_OVERLAP, extent: Sequence[int] | None = None) → dict

The measurements, as one JSON-ready record.

neu_mark.roi_survey.DEFAULT_CONTAINED = 0.95
neu_mark.roi_survey.logger