omni¶
OMNI file format.
This module implements support for reading and writing of OMNI image files.
- class omni.Calibration(metadata: Optional[dict] = None, *, type: Optional[str] = None, unit_type: Optional[str] = None, unit_name: Optional[str] = None, slope: Optional[float] = None, intercept: Optional[float] = None, indirect_base_unit_type: Optional[str] = None)¶
OMNI pixel calibration
- calibrated_to_raw(calibrated: float) float ¶
Convert a calibrated value to a raw value.
- property indirect_base_unit_type: Optional[str]¶
The base unit_type for slope_intercept_indirect calibrations.
- property intercept: float¶
The intercept value of the slope / intercept calibration.
- raw_stddev_to_calibrated_stddev(raw_stddev: float) float ¶
Convert a raw standard deviation value to a calibrated standard deviation value.
- raw_to_calibrated(raw: float) float ¶
Convert a raw value to a calibrated value.
- raw_variance_to_calibrated_variance(raw_variance: float) float ¶
Convert a raw variance value to a calibrated variance value.
- property slope: float¶
The slope value of the slope / intercept calibration.
- property type: str¶
The type of calibration.
- property unit_name: Optional[str]¶
Optional: The name of the physical unit.
- property unit_type: str¶
The type of physical unit.
- class omni.Image(metadata_path: pathlib.Path, metadata: dict)¶
OMNI Image or Segments
- property additional_pixels_filenames: List[str]¶
Additional filenames of files containing pixel bulk data. E.g. for compressed multi-file formats like DRAINv1_DRY.
- property default_pixel_calibration_unit_type: Optional[str]¶
The unit_type of the pixel calibration that should be used by default.
- derive_image(derived_omni_path: pathlib.Path, derived_raw_path: pathlib.Path, override_metadata: dict = {}) omni.Image ¶
Create a derived OMNI image, that inherits (and optionally overrides) metadata.
- derive_segments(derived_omni_path: pathlib.Path, derived_raw_path: pathlib.Path, override_metadata: dict = {}) omni.Image ¶
Create a derived OMNI segments Image(), defaulting to metadata for a single binary object uint8 mask.
- property dimensions: int¶
The number of dimensions.
- ensure_pixels_loaded() numpy.ndarray ¶
Ensure the pixels are loaded. May trigger lazy-loading from file.
- property format: str¶
The format of this file: OMNI-1.0
- static from_numpy_array(pixels: numpy.ndarray, metadata_path: pathlib.Path, metadata: Optional[dict] = None) omni.Image ¶
Initialize from a numpy array
- get_relative_voi_pos_of_target_image(target_image: omni.Image) List[int] ¶
Get the relative VOI position of the target image in the coordinate system of this (source) image.
- property image_relations: List[omni.ImageRelation]¶
Image relations.
- inherit_metadata(**kwargs) dict ¶
Copy the inheritable metadata properties of this image for a derived image.
- Unknown and the following non-inheritable metadata properties are ommitted by default:
pixels_filename additional_pixels_filenames pixels_file_data_offset pixels_compression pixel_calibrations default_pixel_calibration_unit_type invalid_pixels pixel_value_objects
DROP_INHERITED_METADATA can be used to drop individual inheritable metadata properties. INHERIT_METADATA can be used to force inheriting individual unknown or non-inheritable metadata properties.
- property invalid_pixels: List[omni.InvalidPixels]¶
Invalid pixels.
- static load(metadata_path: pathlib.Path) omni.Image ¶
Load metadata from file.
- property pixel_calibrations: List[omni.Calibration]¶
Pixel calibrations.
- pixel_calibrations_of_unit_type(unit_type: str) List[omni.Calibration] ¶
Pixel calibrations of the given type.
- property pixel_max_value: Optional[Union[int, float]]¶
The maximum pixel value that occurs in the image.
- property pixel_min_value: Optional[Union[int, float]]¶
The minimum pixel value that occurs in the image.
- property pixel_size_mm: List[float]¶
The physical size of one pixel in millimeters.
- property pixel_size_mm_3d: List[float]¶
The physical size of one pixel in millimeters in 3D.
- property pixel_type: str¶
The type of one pixel.
- property pixel_value_objects: List[omni.PixelValueObject]¶
E.g. for multi-segments different pixel values could be named objects.
- property pixels: numpy.ndarray¶
The pixels NumPy array. May trigger lazy-loading from file.
- property pixels_compression: str¶
The compression method.
- property pixels_count: int¶
The total number of pixels.
- property pixels_file_data_offset: int¶
The byte offset in the pixels file where the pixel data begins.
- property pixels_filename: str¶
The filename of the file containing the pixel bulk data.
- remove_image_relation(relation_type: str) None ¶
Remove (if it exists) the image relation of the given type.
- resave_all(override_metadata: dict = {})¶
Save the metadata and the raw pixels to files again, e.g. with compression.
- resave_compressed()¶
Save the metadata and the raw pixels to files again, with compression.
- save_all()¶
Save the metadata and the raw pixels to files.
- save_derived_image(derived_omni_path: pathlib.Path, derived_raw_path: pathlib.Path, override_metadata: dict = {}) omni.Image ¶
Save metadata of a derived OMNI image.
- save_derived_segments(derived_omni_path: pathlib.Path, derived_raw_path: pathlib.Path, override_metadata: dict = {}) omni.Image ¶
Save metadata of a derived OMNI segments Image().
- save_metadata()¶
Save the metadata to a file.
- save_pixels()¶
Save the raw pixels as specified in the metadata.
Can modify the metadata! Only supports saving at offset 0.
- save_pixels_as(pixels_path: pathlib.Path, pixels_compression: str)¶
Save the raw pixels to the specified file with the specified compression.
- property segments_type: Optional[str]¶
The type of segments: Object, Millimeter or Component
- set_default_image_relation(relation_type: str) omni.ImageRelation ¶
Set (if missing) and get a default image relation of the given type.
- set_image_relation(relation: omni.ImageRelation) None ¶
Set (or replace) the image relation of the given type.
- property size: List[int]¶
The number of pixels per dimension.
- property size_3d: List[int]¶
The number of pixels in 3D.
- property size_3d_tuple: Tuple[int, int, int]¶
The number of pixels in 3D as a tuple.
- property type: str¶
The type of object: Image or Segments
- verify_pixel_type()¶
Raise an exception if the pixel type metadata does not match the pixels numpy array dtype.
- class omni.ImageRelation(metadata: Optional[dict] = None, *, voi_pixel_position: Optional[List[int]] = None)¶
OMNI image relation description
- set_or_add_voi_pixel_position(pos: List[int]) None ¶
Set (if missing) or add to the VOI position.
- property type: str¶
The type of image relation description.
- property voi_pixel_position: List[int]¶
The position (in pixels) of this image in the parent image.
- class omni.InvalidPixels(metadata: Optional[dict] = None, *, border_size: Optional[List[int]] = None)¶
OMNI invalid pixels description
- property border_size: List[int]¶
The size (in pixels) of the border.
- property type: str¶
The type of invalid pixels description.
- class omni.PixelValueObject(metadata: Optional[dict] = None, *, pixel_value: Optional[Union[int, float]] = None, name: Optional[str] = None)¶
OMNI pixel value object description
- property name: str¶
The name of that object.
- property pixel_value: Union[int, float]¶
The pixel value of that object.
- omni.Segments(metadata_path: pathlib.Path, metadata: dict, segments_type: str) omni.Image ¶
Create an Image(), but set type metadata to Image.TYPE_SEGMENTS.
- omni.import_from_aim(aim_path: pathlib.Path, load_pixels: bool = True) omni.Image ¶
Create OMNI metadata for an AIM file.
- omni.import_from_isq(isq_path: pathlib.Path, load_pixels: bool = True) omni.Image ¶
Create OMNI metadata for an ISQ file.
- omni.import_from_mlsd(mlsd_path: pathlib.Path, sd_paths: List[pathlib.Path], load_pixels: bool = True) omni.Image ¶
Create OMNI metadata for an MLSD file.