neu_morpho.ops.index_segments

Build the per-body metrics DB by a parallel scan of the segmentation.

Each block reports per-label bounding box and voxel count (full-res voxels); the driver merges them into the SQLite DB (min/max bbox, summed counts) atomically per block.

Consumers: voxel_count feeds the --min-voxels / --limit-bodies allowlist (MetricsDB.write_allowlist), and the bbox one-off crops (crop_at_scale); meshing and skeletonization are block-based and read neither. The bbox is the expensive half (about 10x the counts per dense block), so for per-body volume alone prefer neu-morpho measure volumes.

Functions

index_segments(seg_spec, db_path, *, scan_voxel_size) → dict

Scan seg_spec (opened at scan_scale) and fill the per-body metrics DB.

Module Contents

neu_morpho.ops.index_segments.index_segments(seg_spec: dict, db_path: str, *, scan_voxel_size: Sequence[float], scan_scale: int = 0, fullres_factor: Sequence[int] | None = None, block_shape: Sequence[int] = (256, 256, 256), roi: Sequence[int] | str | None = None, keep: Iterable[int] | None = None, client: Any | None = None, npartitions: int | None = None, resume: bool = True) → dict

Scan seg_spec (opened at scan_scale) and fill the per-body metrics DB.

scan_voxel_size (nm, zyx) is that scale’s voxel size (for volume). Bbox is stored in full-res voxels via fullres_factor (default 2**scan_scale).

roi (scan-scale voxels) restricts the scan to the blocks intersecting it; the bboxes and counts then describe only the scanned part of each body.

keep restricts which bodies are recorded while every block is read in full, so its rows are complete: the knob for a fragmented segmentation. A different cohort later needs another scan.