neu_morpho.measure.driver

Block-mapped per-body volume over a published segmentation.

Fills voxel_count / volume_nm3 in a MetricsDB, block by block, resumably; the pure per-block work is in sweep.py.

  • No occupancy or ROI prefilter by default: a compartment-mask ROI omits somata outside it, and V/L would divide a truncated volume by complete cable. An empty block costs about a tenth of a dense one, so reading everything is affordable.

  • Counts, not bboxes (see MetricsDB.apply_counts_block).

  • Per-block retry of transient errors; a persistent one still stops the run.

Functions

resolve_keep(sources) → set[int] | None

Union the body ids named by each source; None for "record every label".

sweep_volumes(seg_spec, db_path, *, voxel_size[, ...]) → dict

Count each body's voxels across seg_spec and accumulate into db_path.

Module Contents

neu_morpho.measure.driver.resolve_keep(sources: Iterable[str] | None) → set[int] | None

Union the body ids named by each source; None for “record every label”.

A source is a file of ids (one per line, or a first CSV column), or a neuroglancer_segment_properties source (a directory or URL with an info) whose ids are taken; os.path.isfile tells them apart. Several may be given, as a dataset may split its properties across sources. A properties source is usually a better cohort gate than a size threshold: only named bodies have properties.

neu_morpho.measure.driver.sweep_volumes(seg_spec: dict, db_path: str, *, voxel_size: Sequence[float], block: int | Sequence[int] = DEFAULT_BLOCK, keep: Iterable[int] | None = None, roi: Sequence[int] | str | None = None, background: int = 0, attempts: int = 5, client: Any | None = None, npartitions: int | None = None, resume: bool = True) → dict

Count each body’s voxels across seg_spec and accumulate into db_path.

voxel_size (nm, zyx) is the read level’s own voxel size, from neu_vol.read_scales (pyramids may be anisotropic, so never 2**level). keep restricts which bodies are recorded, not which blocks are read, so its rows are complete. Refuses a DB that already holds an index scan: both fill voxel_count.