Subject
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 Subject(subject_id: str, images: ~typing.Mapping[str, ~habit.contracts.image.ImageRef], masks: ~typing.Mapping[str, ~habit.contracts.image.ImageRef], metadata: ~typing.Mapping[str, ~typing.Any] = <factory>)[source]
Bases:
objectOne imaging subject.
- images
Modality name to lazy image handle.
- Type:
Mapping[str, habit.contracts.image.ImageRef]
- masks
ROI name to lazy mask handle.
- Type:
Mapping[str, habit.contracts.image.ImageRef]
- metadata
Clinical or acquisition attributes. Never required for computation; consumed by downstream modelling and reporting.
- Type:
Mapping[str, Any]
- image(modality: str) ImageVolume[source]
Materialise one modality.
- Parameters:
modality – Key into
images.- Returns:
The loaded intensity volume.
- Raises:
KeyError – If the modality is absent for this subject.
- mask(roi_name: str | None = None) MaskVolume[source]
Materialise one ROI mask.
- Parameters:
roi_name – Key into
masks. WhenNoneand exactly one mask exists, that mask is returned.- Returns:
The loaded label volume.
- Raises:
KeyError – If the ROI is absent.
ValueError – If
roi_nameisNoneand the subject has more than one mask, since silently picking one would be unsafe.