nifreeze.analysis.registration module

Accuracy and time of registration on a phantom with known motion.

Each moved volume of a perturbed copy is registered to three fixed images, and the estimated transform is compared with the truth from the copy’s sidecar: the head’s motion, from the b=0’s frame to the volume’s (fixed to moving, as the estimator reports it).

oracle

The noise-free reference volume of the same gradient direction, at the true position: the error of registration alone.

unmoved

The model’s held-out prediction from the reference: registration on a model’s target that motion has not corrupted.

moved

The model’s held-out prediction from the copy itself, as in a run before any motion is corrected.

The three together separate the error of registration from that of the model. This analysis is about registration; the sensitivity analysis (nifreeze.analysis.sensitivity) involves none.

class nifreeze.analysis.registration.AntsRegistration(self, workdir: 'Path | str', seed: 'int | None' = 12345, **settings: 'Any')[source]

Bases: object

The estimator’s ANTs path, as it runs today: files, nipype and antsRegistration.

Register in workdir with the estimator’s defaults.

Parameters:
  • workdir (os.pathlike) – Where the images and transforms are written.

  • seed (int, optional) – Seed of ANTs’ random sampling.

  • **settings – Further arguments of _run_registration().

__call__(fixed: ndarray, moving: ndarray, affine: ndarray, mask: ndarray, index: int) → ndarray[source]

Call self as a function.

nifreeze.analysis.registration.FIXED = ('oracle', 'unmoved', 'moved')

The fixed images each moved volume is registered to.

nifreeze.analysis.registration.Register

the fixed-to-moving matrix (RAS).

Type:

register(fixed, moving, affine, mask, index)

alias of Callable[[ndarray, ndarray, ndarray, ndarray, int], ndarray]

nifreeze.analysis.registration.registration_accuracy(register: Callable[[ndarray, ndarray, ndarray, ndarray, int], ndarray], clean: DWI, reference: DWI, moved: DWI, truth: dict[int, ndarray], model: str | Callable[[...], Any] | None = None, fixed: Iterable[str] = ('oracle', 'unmoved', 'moved'), **model_kwargs: Any) → list[dict][source]

Register each moved volume to each fixed image and measure the error.

Parameters:
  • register (Callable) – The registration (see Register).

  • clean (DWI) – The noise-free reference, the source of the oracle targets.

  • reference (DWI) – The reference, with the noise of moved.

  • moved (DWI) – The perturbed copy.

  • truth (dict) – The true fixed-to-moving matrix of each volume registered, by index.

  • model (str or Callable, optional) – The model of the unmoved and moved targets (see held_out_predictions()); required unless fixed is only oracle.

  • fixed (Iterable, optional) – The fixed images (of FIXED).

  • **model_kwargs – Arguments for the model.

Returns:

One row per volume and fixed image, with the volume’s index and shell, the fixed image, the max and mean displacement (mm) within the brain between the estimated and true transforms, and the seconds the registration took.

Return type:

list of dict