SliceExtentPerturbation

Note

This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

class SliceExtentPerturbation(grow_slices: int = 0, shrink_slices: int = 0, max_slices: int = 0, roi: str | None = None)[source]

Bases: object

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. Only the z (first) axis is touched. Only masks change.

Provide fixed grow_slices / shrink_slices (applied to each end), or set max_slices > 0 to draw a random per-end count in [-max_slices, +max_slices] (positive grows, negative shrinks). When max_slices is set the fixed counts are ignored.

Parameters:
  • grow_slices – Slices to append at each occupied end (copy of the nearest occupied slice’s labels).

  • shrink_slices – Occupied slices to remove at each end.

  • max_slices – Bound for random per-end counts; 0 uses the fixed counts.

  • roi – Restrict the perturbation to one mask key; None perturbs all masks.

__init__(grow_slices: int = 0, shrink_slices: int = 0, max_slices: int = 0, roi: str | None = None) → None[source]
property spec: Spec

Return the algorithm specification used for provenance.

__call__(subject: Subject, *, rng: Generator) → Subject[source]

Return a copy of subject with ROI slice extents perturbed.

Parameters:
  • subject – Subject providing the masks.

  • rng – Random generator for random mode (max_slices > 0).

Returns:

The perturbed subject copy.