ImageVolume

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 ImageVolume(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>)[source]

Bases: object

An image array with explicit physical-space metadata.

data follows the NumPy convention used by SimpleITK.GetArrayFromImage. Physical metadata remains in SimpleITK axis order. Callers should use this object rather than infer geometry from array axes.

The volume also satisfies ImageRef: geometry returns a Geometry and load() returns the already-resident array.

__post_init__() → None[source]

Normalize arrays and immutable metadata at the public boundary.

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

Create a volume from an array using identity physical metadata by default.

classmethod from_geometry(array: ndarray, geometry: Geometry, *, modality: str | None = None, subject_id: str | None = None, timepoint: str | None = None, metadata: Mapping[str, Any] | None = None) → ImageVolume[source]

Build a volume from an array plus a Geometry value.

classmethod from_sitk(image: Any, *, modality: str | None = None, subject_id: str | None = None, timepoint: str | None = None, source: str | Path | None = None, metadata: Mapping[str, Any] | None = None) → ImageVolume[source]

Convert a SimpleITK.Image without discarding its physical metadata.

to_sitk() → Any[source]

Convert this public volume into a SimpleITK.Image lazily.

property geometry: Geometry

Return the spatial definition of this volume without copying data.

load() → ndarray[source]

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

__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>) → None

Examples using habit.contracts.ImageVolume

Load from SimpleITK

Load from SimpleITK

Load from NIfTI files

Load from NIfTI files

Voxel texture and GPU

Voxel texture and GPU

Supervoxel feature extraction and acceleration

Supervoxel feature extraction and acceleration

Extracting a voxel texture

Extracting a voxel texture

Clustering habitats from a texture field

Clustering habitats from a texture field

Comparing habitat maps with and without preprocessing

Comparing habitat maps with and without preprocessing

Per-habitat radiomics

Per-habitat radiomics

Whole-habitat radiomics

Whole-habitat radiomics

Why habitat ids must be matched

Why habitat ids must be matched

Matching maps of the same voxels by overlap

Matching maps of the same voxels by overlap

Precise voxel features

Precise voxel features