roi_voxels

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.

roi_voxels(subject: Subject, roi: str | None, *, reference_modality: str | None = None, on_geometry_mismatch: str = 'resample_mask') → Tuple[MaskVolume, ndarray, ndarray][source]

Return the ROI mask together with its boolean selector and coordinates.

When the mask and a reference image modality disagree on geometry, the default policy nearest-neighbour resamples the mask onto the image grid (see habit.image_preprocessing.geometry). Pass on_geometry_mismatch="strict" to raise GeometryError instead.

Parameters:
  • subject – Subject providing the mask (and images for alignment).

  • roi – Mask key, or None for the subject’s single mask.

  • reference_modality – Image key used as the alignment target. When None, the first modality in insertion order is used.

  • on_geometry_mismatch – "resample_mask" (default) or "strict".

Returns:

(mask, inside, voxel_index) where inside selects ROI voxels on the (possibly resampled) mask grid and voxel_index lists their coordinates in the same C order the selector produces.

Examples using habit.voxel_features.roi_voxels

Custom features

Custom features