aimio

AIM file format.

This module implements support for reading and writing of AIM files.

class aimio.AimReader(filename: str)

Allows to read an AIM file.

aim_type: int

The AIM type. (See aimio.D1Tchar etc.)

aim_version_3: bool

Is it in AIMv3 format?

check_all_read() None

Check that all pixels have been read. Raise an exception otherwise.

close() None

Close the file reader.

data_offset: int

File offset of the pixel data.

header: tuple[Any, ...]

Raw AIM header fields.

log: ProcessingLog

The processing log.

offset: tuple[int, int, int]

The offset of the AIM.

pos: tuple[int, int, int]

The position of the AIM.

read_pixels(slices: int = None) ndarray

Read the pixels from the file. Optionally, read only the next few slices.

res_nano: tuple[int, int, int]

Resolution in nanometers.

size: tuple[int, int, int]

The size of the AIM.

slices_read: int

The number of pixel Z slices that have been read already.

class aimio.AimWriter(filename: str, size: Tuple[int, int, int], log: ProcessingLog, aim_type: int = 131074, res_nano: Tuple[int, int, int] = (1000000, 1000000, 1000000), pos: Tuple[int, int, int] = (0, 0, 0), offset: Tuple[int, int, int] = (0, 0, 0))

Allows to write an AIM file.

close() None

Close the file.

write_pixels(pixels: ndarray) None

Write the pixels to the open file.

class aimio.Calibrations

AIM calibrations.

default_unit_type: int

The default unit type.

dens_intercept: float

The intercept of the density calibration.

dens_slope: float

The slope of the density calibration.

dens_unit: str

The unit used for density calibration.

dens_valid: bool

Is the density calibration valid?

hu_valid: bool

Is the HU calibration valid?

mu_scaling: int

The mu calibration information.

mu_valid: bool

Is the mu calibration valid?

mu_water: float

The value of water for the HU calibration.

aimio.D1TbinCmp = 1376257

Compressed binary AIM type.

aimio.D1Tchar = 65537

Signed byte AIM type.

aimio.D1TcharCmp = 524290

Compressed byte AIM type.

aimio.D1Tint = 196612

Signed 32 bit AIM type.

aimio.D1Tpixel = 851969

Rendered pixels AIM type.

aimio.D1Tshort = 131074

Signed 16 bit AIM type.

aimio.D1Tuchar = 1441793

Unsigned byte AIM type.

aimio.D1Tushort = 1507330

Unsigned 16 bit AIM type.

class aimio.ProcessingLog(text: str = '')

Represents an AIM processing log.

append_field(key: str, value: str) None

Append a field to the log.

append_min_max_data_values(min_data_value: float, max_data_value: float) None

Append min and max data value fields to the log.

append_min_max_data_values_from_pixels(pixels: ndarray) None

Append min and max data value fields to the log.

append_parameter_name_and_units(name: str, units: str) None

Append parameter name and units fields to the log.

append_parameter_seg() None

Append parameter name and units fields to the log.

parse_calibrations() Calibrations

Parse calibration fields.

parse_max_data_value() float | None

Parse maximum data value

parse_min_data_value() float | None

Parse minimum data value

parse_parameter_units() str | None

Parse parameter units

aimio.get_aim_size(path: Path) List[int]

Helper function to read the 3D size of an AIM header.

aimio.load_aim(filename: str) Tuple[Any, ndarray, ProcessingLog]

Load an AIM file.

aimio.save_aim(filename: str, pixels: ndarray, log: ProcessingLog = None, aim_type: int = 131074, res_nano: Tuple[int, int, int] = (1000000, 1000000, 1000000), pos: Tuple[int, int, int] = (0, 0, 0), offset: Tuple[int, int, int] = (0, 0, 0)) None

Save an AIM file.