slice_extent_perturbation
Note
This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.
- slice_extent_perturbation(mask: ndarray, grow_slices: int = 0, shrink_slices: int = 0, rng: Generator | None = None, max_slices: int = 0) ndarray[source]
Add or remove whole axial slices at the superior/inferior ROI ends.
Models z-axis delineation variability: observers often agree in-plane but differ on the first and last slice they call tumour (slice-extent or “end-slice” disagreement). Operates on the
z(first) axis only.Provide either fixed
grow_slices/shrink_slicesor a randommax_sliceswithrng(each end independently draws a count in[-max_slices, +max_slices]; positive grows, negative shrinks).- Parameters:
mask – Integer / boolean label array in
(z, y, x)order.grow_slices – Number of slices to append at each occupied end by copying the nearest occupied slice’s labels.
shrink_slices – Number of occupied slices to remove at each end.
rng – Random generator enabling random per-end counts; requires
max_slices > 0.max_slices – Bound for the random per-end slice count.
- Returns:
A new label array, same shape and dtype as
mask.- Raises:
ValueError – If shrinking removes every occupied slice, or if both fixed and random modes are mixed inconsistently.