GradientWeightedPerturbation

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 GradientWeightedPerturbation(modality: str | None = None, roi: str | None = None, max_radius_voxels: int = 2, probability: float = 0.5)[source]

Bases: object

Locally grow/shrink ROI boundaries where image gradient is low.

Inter-rater disagreement concentrates where contrast is poor: sharp (high-gradient) edges are drawn consistently, fuzzy (low-gradient) edges vary. This operator flips boundary voxels with a probability that scales with 1 - normalised_gradient of a reference image, so the fuzzy parts of the contour move more than the sharp parts. Only masks change.

Parameters:
  • modality – Image modality supplying the gradient-magnitude map; None uses the subject’s first image. The map is normalised to [0, 1] over the ROI bounding region.

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

  • max_radius_voxels – Neighbourhood radius bounding each local flip.

  • probability – Base flip probability at zero gradient; effective probability is probability * (1 - gradient).

__init__(modality: str | None = None, roi: str | None = None, max_radius_voxels: int = 2, probability: float = 0.5) → 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 boundaries locally perturbed.

Parameters:
  • subject – Subject providing images (for the gradient) and masks.

  • rng – Random generator supplying the flip decisions.

Returns:

The perturbed subject copy.