MaskVolume

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 MaskVolume(data: ~numpy.ndarray, spacing: ~typing.Tuple[float, ...], origin: ~typing.Tuple[float, ...], direction: ~typing.Tuple[float, ...], modality: str | None = None, subject_id: str | None = None, timepoint: str | None = None, source: ~pathlib.Path | None = None, metadata: ~typing.Mapping[str, ~typing.Any] = <factory>, labels: ~typing.Tuple[int, ...] = (), label_names: ~typing.Mapping[int, str] = <factory>)[source]

Bases: ImageVolume

An image-space segmentation mask with explicit label semantics.

__post_init__() → None[source]

Validate mask labels after the shared image-volume normalization.

classmethod from_array(data: ndarray, *, spacing: Tuple[float, ...] | None = None, origin: Tuple[float, ...] | None = None, direction: Tuple[float, ...] | None = None, modality: str | None = None, labels: Tuple[int, ...] = (), label_names: Mapping[int, str] | None = None, subject_id: str | None = None, timepoint: str | None = None, metadata: Mapping[str, Any] | None = None) → MaskVolume[source]

Create a mask from an array with explicit or inferred nonzero labels.

classmethod from_geometry(array: ndarray, geometry: Geometry, *, roi_name: str | None = None, labels: Tuple[int, ...] = (), label_names: Mapping[int, str] | None = None, subject_id: str | None = None, timepoint: str | None = None, metadata: Mapping[str, Any] | None = None) → MaskVolume[source]

Build a mask from a label array plus a Geometry value.

classmethod from_sitk(image: Any, *, modality: str | None = None, labels: Tuple[int, ...] = (), label_names: Mapping[int, str] | None = None, subject_id: str | None = None, timepoint: str | None = None, source: str | Path | None = None, metadata: Mapping[str, Any] | None = None) → MaskVolume[source]

Convert a SimpleITK.Image into a mask while retaining geometry.

load() → ndarray[source]

Return the already-resident label array (ImageRef conformance).

property roi_name: str | None

Return the ROI name for this mask, mapped from modality.

__init__(data: ~numpy.ndarray, spacing: ~typing.Tuple[float, ...], origin: ~typing.Tuple[float, ...], direction: ~typing.Tuple[float, ...], modality: str | None = None, subject_id: str | None = None, timepoint: str | None = None, source: ~pathlib.Path | None = None, metadata: ~typing.Mapping[str, ~typing.Any] = <factory>, labels: ~typing.Tuple[int, ...] = (), label_names: ~typing.Mapping[int, str] = <factory>) → None

Examples using habit.contracts.MaskVolume

Load from SimpleITK

Load from SimpleITK

Load from NIfTI files

Load from NIfTI files

Voxel texture and GPU

Voxel texture and GPU

Extracting a voxel texture

Extracting a voxel texture

Clustering habitats from a texture field

Clustering habitats from a texture field

Per-habitat radiomics

Per-habitat radiomics

Whole-habitat radiomics

Whole-habitat radiomics

Precise voxel features

Precise voxel features