ImagePerturbation

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 ImagePerturbation(*args, **kwargs)[source]

Bases: Protocol

Turn one subject into a perturbed copy of itself: a simulated re-acquisition.

Scientific role: voxel-wise features are only worth clustering if they survive the small acquisition variations a scanner inevitably introduces (noise, sub-voxel patient shifts, slight angulation). An image perturbation replays those variations in silico so feature repeatability can be measured BEFORE any habitat is computed (Prior et al., Radiol Artif Intell 2024;6(2):e230118).

The contract is deliberately the narrowest possible: one subject in, one perturbed subject out, same grid, same keys. Chaining several perturbations composes a full simulated retest, and implementing this protocol is all a new perturbation family (bias fields, motion ghosts, resampling artefacts) has to do.

property spec: Spec

Return the algorithm specification.

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

Return a perturbed copy of subject.

Parameters:
  • subject – Subject providing images (and masks, for geometric perturbations).

  • rng – Random generator for the stochastic steps; supplied by the caller so one seed drives an entire perturbation chain. Deterministic perturbations accept and ignore it.

Returns:

A new subject on the SAME voxel grid with perturbed images (and perturbed masks for geometric perturbations); the original is left untouched.

__init__(*args, **kwargs)