aligned_image

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.

aligned_image(subject: Subject, modality: str, mask: ImageVolume, *, owner: str, on_geometry_mismatch: str = 'resample_mask') → ndarray[source]

Read one modality after ensuring it shares the ROI’s voxel grid.

Callers should normally obtain mask from roi_voxels() (or align_subject_masks()) so the mask already sits on a reference image grid. When a residual mismatch remains (for example another modality on a different grid than the reference), the default policy resamples the mask onto this modality for the compatibility check path used by single-modality reads; multi-modality extractors that share one voxel_index still require all modalities to agree with the mask returned by roi_voxels().

Parameters:
  • subject – Subject providing the image.

  • modality – Modality key to read.

  • mask – The ROI mask whose grid the image must match.

  • owner – Extractor name used in the error message.

  • on_geometry_mismatch – "resample_mask" (default) or "strict". Under resample_mask, a mismatch raises only when the mask cannot be treated as already aligned (see note above); the helper still raises GeometryError so shared voxel indices stay consistent across modalities.

Returns:

The modality’s voxel array.

Raises:

GeometryError – If the modality and the mask are on different grids.

Examples using habit.voxel_features.aligned_image

Custom features

Custom features