neu_morpho.roi

Restrict a run to a portion of the volume, without moving the block grid.

The grid is tiled over the whole volume and then filtered, so a block’s index and region are the same in an ROI run as in a later full run: a test run over one cube is a prefix of the full run, and its fragments and manifest keys carry over.

ROIs are half-open (z0, y0, x0, z1, y1, x1) in the voxels of the scale being read. Intersecting blocks are kept whole, never clipped, so a block index always holds the same data.

Functions

clip_to_shape(roi, shape) → tuple[int, ...] | None

Clamp an ROI to a volume's bounds, so an over-wide stop is not an error.

filter_blocks(blocks, roi) → list

Keep the blocks of the global grid that intersect roi (all, if None).

intersects(region, roi) → bool

Does a block region overlap the ROI (half-open, per axis)?

parse_roi(text) → tuple[int, ...] | None

Parse "z0,y0,x0,z1,y1,x1" (or a 6-sequence) into a tuple, or None.

scale_roi(roi, factor_zyx) → tuple[int, ...] | None

Convert an ROI between scales; factor_zyx = target voxels per source voxel.

Module Contents

neu_morpho.roi.clip_to_shape(roi: Sequence[int] | None, shape: Sequence[int]) → tuple[int, ...] | None

Clamp an ROI to a volume’s bounds, so an over-wide stop is not an error.

neu_morpho.roi.filter_blocks(blocks, roi: Sequence[int] | None) → list

Keep the blocks of the global grid that intersect roi (all, if None).

neu_morpho.roi.intersects(region: Sequence[slice], roi: Sequence[int]) → bool

Does a block region overlap the ROI (half-open, per axis)?

neu_morpho.roi.parse_roi(text: str | Sequence[int] | None) → tuple[int, ...] | None

Parse "z0,y0,x0,z1,y1,x1" (or a 6-sequence) into a tuple, or None.

neu_morpho.roi.scale_roi(roi: Sequence[int] | None, factor_zyx: Sequence[float]) → tuple[int, ...] | None

Convert an ROI between scales; factor_zyx = target voxels per source voxel.

Starts floor, stops ceil, so the scaled ROI always covers the original region rather than shaving a partial voxel off its edge.