FileImageRef

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 FileImageRef(path: str | Path, *, is_mask: bool, role_name: str)[source]

Bases: object

Lazy ImageRef backed by one image file.

Holds only the path plus lazily-read header metadata, so a cohort of thousands of subjects can cross a process boundary without carrying a single voxel. Header fields are cached after the first access; pixel data is only read by load() / load_volume().

Parameters:
  • path – Image file readable by SimpleITK.

  • is_mask – Whether the file holds a label mask (selects MaskVolume materialisation and nearest-neighbour semantics downstream).

  • role_name – Modality or ROI name attached to materialised volumes.

__init__(path: str | Path, *, is_mask: bool, role_name: str) → None[source]
property geometry: Geometry

Return the grid definition, reading only the file header.

load() → ndarray[source]

Materialise and return the voxel array.

load_volume() → ImageVolume | MaskVolume[source]

Materialise with full physical metadata in one read.

Returns:

An ImageVolume, or a MaskVolume when the reference was created for a mask file.

Examples using habit.adapters.FileImageRef

Load from NIfTI files

Load from NIfTI files