modelarrayio.utils.mif_image.MifHeader
- class modelarrayio.utils.mif_image.MifHeader(shape: tuple = (1,), zooms: tuple | None = None, layout: list[int] | None = None, dtype: dtype | None = None, transform: ndarray | None = None, intensity_offset: float = 0.0, intensity_scale: float = 1.0, keyval: dict | None = None)[source]
Header for MIF (.mif / .mif.gz) image files.
The MIF format uses a text header with
key: valuepairs followed byEND, then binary image data at the byte offset given by thefile: . <offset>entry.The transform stored in the file contains unit direction cosines for each voxel axis; voxel sizes are stored separately in the
voxfield. The nibabel 4x4 affine is reconstructed as:affine[:3, :3] = transform[:3, :3] * zooms # column-wise scaling affine[:3, 3] = transform[:3, 3] # translation unchanged
- __init__(shape: tuple = (1,), zooms: tuple | None = None, layout: list[int] | None = None, dtype: dtype | None = None, transform: ndarray | None = None, intensity_offset: float = 0.0, intensity_scale: float = 1.0, keyval: dict | None = None) None[source]
Methods
__init__([shape, zooms, layout, dtype, ...])copy()Copy object to independent representation
from_fileobj(fileobj)Read a MIF header from a binary file-like object.
from_header([header])get_best_affine()Return the 4x4 affine mapping canonical voxel indices to scanner space (mm).
get_data_dtype()get_data_shape()get_intensity_scaling()Return
(offset, scale)for intensity rescaling.get_keyval()get_layout()get_transform()Return a copy of the 3x4 direction-cosine + translation matrix.
get_zooms()set_data_dtype(dtype)set_data_shape(shape)set_zooms(zooms)write_to(fileobj[, data_offset])Write the MIF header to fileobj, returning the data byte offset.