neu_vol.ops.occupancy¶
Where a sparse volume’s data actually is: occupied chunks, covered by maximal boxes.
Analysis, not presentation: boxes in level-0 voxels, zyx. neu-glance bboxes turns
them into a layer; ops.relabel, ops.maskvalue and --sparse use them directly.
The boxes come from the volume itself, in three steps, cheapest first:
Which chunk objects exist. TensorStore never persists an all-fill chunk, so the present keys are the occupied footprint. No voxel reads.
Cover the occupied cells with maximal boxes. Connected components would merge two regions written face to face.
Tighten each box to its nonzero voxels at a coarse level, nearly free, quantized to one coarse voxel. Raise
tighten_levelfor cheaper,0for exact.
Attributes¶
Exceptions¶
No chunk key under the level's prefix could be read as a chunk index. |
Functions¶
|
Occupied boxes of |
|
Cover a set of grid cells with axis-aligned boxes, as |
|
The zyx chunk-grid cells that have a stored object at |
Module Contents¶
- exception neu_vol.ops.occupancy.NoOccupancy¶
Bases:
RuntimeErrorNo chunk key under the level’s prefix could be read as a chunk index.
Initialize self. See help(type(self)) for accurate signature.
- neu_vol.ops.occupancy.labeled_regions(volume: str, *, level: int = 0, tighten_level: int | None = 2, fmt: str | None = None) tuple[list[dict], dict]¶
Occupied boxes of
volume, in level-0 voxels, zyx, plus a context dict.Each region is
{"lo", "hi", "cells", "n_labels"};n_labelsis the number of distinct nonzero values seen attighten_leveland isNonewhen tightening is off. It is a floor: a label too small to survive to that level is invisible there.
- neu_vol.ops.occupancy.maximal_boxes(cells: set[tuple[int, ...]]) list[tuple[tuple, tuple]]¶
Cover a set of grid cells with axis-aligned boxes, as
(lo, hi)cell ranges.Each pass takes the smallest remaining cell and grows it along each axis in turn while every cell of the box is present. For a union of a few written blocks this recovers the blocks; at worst it is one box per cell. It never emits a box containing an absent cell.
- neu_vol.ops.occupancy.occupied_cells(volume: str, fmt: str, level: int, cell: tuple[int, ...]) set[tuple[int, ...]]¶
The zyx chunk-grid cells that have a stored object at
level.One listing; an all-fill chunk is never written, so presence is occupancy.
- neu_vol.ops.occupancy.ZARR_METADATA¶