imfusion.data.components#

Submodule for data components.

class imfusion.data.components.DataComponentBase#

Bases: Configurable

property id#

Returns the unique string identifier of this component class.

Type:

str

class imfusion.data.components.DataComponentList#

Bases: pybind11_object

A list of DataComponent. The list contains properties for specific DataComponent types. Each DataComponent type can only occur once.

__getitem__(self: DataComponentList, index: SupportsInt | SupportsIndex) → object#
__getitem__(self: DataComponentList, indices: Sequence[SupportsInt | SupportsIndex]) → list[object]
__getitem__(self: DataComponentList, slice: slice) → list[object]
__getitem__(self: DataComponentList, id: str) → object

Function overload documentation:

__getitem__(self: DataComponentList, index: SupportsInt | SupportsIndex) → object
__getitem__(self: DataComponentList, indices: Sequence[SupportsInt | SupportsIndex]) → list[object]
__getitem__(self: DataComponentList, slice: slice) → list[object]
__getitem__(self: DataComponentList, id: str) → object
add(self: DataComponentList, component: TDataComponentBound) → TDataComponentBound#
add(self: DataComponentList, arg0: CameraCalibrationDataComponent) → DataComponentBase
add(self: DataComponentList, arg0: StereoCalibrationDataComponent) → DataComponentBase
add(self: DataComponentList, arg0: FrameGeometryMetadata) → DataComponentBase
add(self: DataComponentList, arg0: UltrasoundMetadata) → DataComponentBase
add(self: DataComponentList, arg0: ASCDisplayOptions) → DataComponentBase
add(self: DataComponentList, arg0: GeneralEquipmentModuleDataComponent) → DataComponentBase
add(self: DataComponentList, arg0: SourceInfoComponent) → DataComponentBase
add(self: DataComponentList, arg0: ReferencedInstancesComponent) → DataComponentBase
add(self: DataComponentList, arg0: RTStructureDataComponent) → DataComponentBase
add(self: DataComponentList, arg0: PulseEchoEvent) → DataComponentBase
add(self: DataComponentList, arg0: FrameAcquisition) → DataComponentBase
add(self: DataComponentList, arg0: Transducer) → DataComponentBase
add(self: DataComponentList, arg0: ChannelDataLayout) → DataComponentBase
add(self: DataComponentList, arg0: BeamformingRois) → DataComponentBase
add(self: DataComponentList, arg0: TargetTag) → DataComponentBase
add(self: DataComponentList, arg0: ProcessingRecordComponent) → DataComponentBase
add(self: DataComponentList, arg0: ReferenceImageDataComponent) → DataComponentBase
add(self: DataComponentList, arg0: PatchesFromImageDataComponent) → DataComponentBase
add(self: DataComponentList, arg0: InversionComponent) → DataComponentBase

Function overload documentation:

add(self: DataComponentList, component: TDataComponentBound) → TDataComponentBound

Adds the component to the component list and returns the stored component.

add(self: DataComponentList, arg0: CameraCalibrationDataComponent) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: StereoCalibrationDataComponent) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: FrameGeometryMetadata) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: UltrasoundMetadata) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: ASCDisplayOptions) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: GeneralEquipmentModuleDataComponent) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: SourceInfoComponent) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: ReferencedInstancesComponent) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: RTStructureDataComponent) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: PulseEchoEvent) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: FrameAcquisition) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: Transducer) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: ChannelDataLayout) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: BeamformingRois) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: TargetTag) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: ProcessingRecordComponent) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: ReferenceImageDataComponent) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: PatchesFromImageDataComponent) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

add(self: DataComponentList, arg0: InversionComponent) → DataComponentBase

Adds a copy of the component to the component list and returns a reference to the copy.

property asc_display_options#
Type:

ASCDisplayOptions

property beamforming_rois#
Type:

BeamformingRois

property camera_calibration#
Type:

CameraCalibrationDataComponent

property channel_data_layout#
Type:

ChannelDataLayout

property data_source#
Type:

DataSourceComponent

property dataset_license#
Type:

DatasetLicenseComponent

property display_options_2d#
Type:

DisplayOptions2d

property display_options_3d#
Type:

DisplayOptions3d

property frame_acquisition#
Type:

FrameAcquisition

property frame_geometry_metadata#
Type:

FrameGeometryMetadata

property general_equipment_module#
Type:

GeneralEquipmentModuleDataComponent

property image_info#
Type:

ImageInfoDataComponent

property inversion#
Type:

InversionComponent

property label#
Type:

LabelDataComponent

property patches_from_image#
Type:

PatchesFromImageDataComponent

property processing_record#
Type:

ProcessingRecordComponent

property pulse_echo_event#
Type:

PulseEchoEvent

property real_world_mapping#
Type:

RealWorldMappingDataComponent

property reference_image#
Type:

ReferenceImageDataComponent

property referenced_instances#
Type:

ReferencedInstancesComponent

property rt_structure#
Type:

RTStructureDataComponent

property source_info#
Type:

SourceInfoComponent

property stereo_calibration#
Type:

StereoCalibrationDataComponent

property target_tag#
Type:

TargetTag

property transducer#
Type:

Transducer

property transformation_stash#
Type:

TransformationStashDataComponent

property ultrasound_metadata#
Type:

UltrasoundMetadata

class imfusion.data.components.DataSourceComponent#

Bases: DataComponentBase

class DataSourceInfo(self: DataSourceInfo, arg0: str, arg1: str, arg2: Properties, arg3: SupportsInt | SupportsIndex, arg4: Sequence[DataSourceInfo])#

Bases: Configurable

update(self: DataSourceInfo, arg0: DataSourceInfo) → None#
property filename#
Type:

str

property history#
Type:

list[DataSourceInfo]

property index_in_file#
Type:

int

property io_algorithm_config#
Type:

Properties

property io_algorithm_id#
Type:

str

property io_algorithm_name#
Type:

str

property filenames#
Type:

list[str]

property sources#
Type:

list[DataSourceInfo]

class imfusion.data.components.DatasetLicenseComponent(*args, **kwargs)#

Bases: DataComponentBase

Function overload documentation:

__init__(self: DatasetLicenseComponent) → None
__init__(self: DatasetLicenseComponent, infos: Sequence[DatasetInfo]) → None
class DatasetInfo(*args, **kwargs)#

Bases: pybind11_object

Function overload documentation:

__init__(self: DatasetInfo) → None
__init__(self: DatasetInfo, name: str, authors: str, website: str, license: str, attribution_required: bool, commercial_use_allowed: bool) → None
property attribution_required#
Type:

bool

property authors#
Type:

str

property commercial_use_allowed#
Type:

bool

property license#
Type:

str

property name#
Type:

str

property website#
Type:

str

infos(self: DatasetLicenseComponent) → list[DatasetInfo]#
class imfusion.data.components.DisplayOptions2d(self: DisplayOptions2d, arg0: Data)#

Bases: DataComponentBase

property gamma#
Type:

float

property invert#
Type:

bool

property level#
Type:

float

property window#
Type:

float

class imfusion.data.components.DisplayOptions3d(self: DisplayOptions3d, arg0: Data)#

Bases: DataComponentBase

property alpha#
Type:

float

property invert#
Type:

bool

property level#
Type:

float

property window#
Type:

float

class imfusion.data.components.ImageInfoDataComponent(self: ImageInfoDataComponent)#

Bases: DataComponentBase

DataComponent storing general information on the image origin.

Modeled after the DICOM patient-study-series hierarchy, it stores information on the patient, study and series the data set belongs to.

class AnatomicalOrientationType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

The anatomical orientation type used in Instances generated by this equipment.

BIPED = 1#
QUADRUPED = 2#
UNKNOWN = 0#
class Laterality(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

Laterality of (paired) body part examined

LEFT = 1#
RIGHT = 2#
UNKNOWN = 0#
class PatientSex(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

Gender of the patient

FEMALE = 2#
MALE = 1#
OTHER = 3#
UNKNOWN = 0#
property frame_of_reference_uid#

Uniquely identifies the Frame of Reference for a Series. Multiple Series within a Study may share a Frame of Reference UID.

Type:

str

property laterality#

Laterality of (paired) body part examined

Type:

Laterality

property modality#

DICOM modality string specifying the method used to create this series

Type:

str

property orientation_type#

DICOM Anatomical Orientation Type

Type:

AnatomicalOrientationType

property patient_birth_date#

Patient date of birth in yyyyMMdd format

Type:

str

property patient_comment#

Additional information about the Patient

Type:

str

property patient_id#

DICOM Patient ID

Type:

str

property patient_name#

Patient name

Type:

str

property patient_position#

Specifies position of the Patient relative to the imaging equipment.

Type:

str

property patient_sex#

Patient sex

Type:

PatientSex

property photometric_interpretation#

Specifies the intended interpretation of the pixel data (e.g. RGB, HSV, …).

Type:

str

property responsible_person#

Name of person with medical or welfare decision making authority for the Patient.

Type:

str

property series_date#

Series date in yyyyMMdd format

Type:

str

property series_description#

Series description

Type:

str

property series_instance_uid#

Unique identifier of the Series

Type:

str

property series_number#

DICOM Series number. The value of this attribute should be unique for all Series in a Study created on the same equipment.

Type:

str

property series_time#

Series time in HHmmss format

Type:

str

property series_time_exact#

Series time in microseconds. 0 if the original series time was empty.

Type:

timedelta

property study_date#

Study date in yyyyMMdd format

Type:

str

property study_description#

Study description

Type:

str

property study_id#

DICOM Study ID

Type:

str

property study_instance_uid#

Unique identifier for the Study

Type:

str

property study_time#

Study time in HHmmss format, optionally with time zone offset &ZZXX

Type:

str

property study_time_exact#

Study time in microseconds. 0 if the original study time was empty.

Type:

timedelta

property study_timezone#

Study time zone abbreviation

Type:

str

class imfusion.data.components.LabelDataComponent(self: LabelDataComponent, label_map: SharedImageSet = None)#

Bases: DataComponentBase

Stores metadata for a label map, supporting up to 255 labels.

Creates a LabelDataComponent. If a label map of type uint8 is provided, detects labels in the label map.

class LabelConfig(self: LabelConfig, name: str = '', color: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]'] = array([0., 0., 0., 0.]), is_visible2d: bool = True, is_visible3d: bool = True)#

Bases: pybind11_object

Encapsulates metadata for a label value in a label map.

Constructor for LabelConfig.

Parameters:
  • name – Name of the label.

  • color – RGBA color used for rendering the label.

  • is_visible2d – Visibility flag for 2D/MPR views.

  • is_visible3d – Visibility flag for 3D views.

property color#

RGBA color used for rendering the label. Values should be in the range [0, 1].

Type:

Annotated[numpy.typing.NDArray[numpy.float64], ”[4, 1]”]

property is_visible2d#

Visibility flag for 2D/MPR views.

Type:

bool

property is_visible3d#

Visibility flag for 3D views.

Type:

bool

property name#

Name of the label.

Type:

str

property segmentation_algorithm_name#

Name of the algorithm used to generate the segmentation.

Type:

str

property segmentation_algorithm_type#

Type of algorithm used to generate the segmentation.

Type:

SegmentationAlgorithmType

property snomed_category_code_meaning#

Human-readable meaning of the category code.

Type:

str

property snomed_category_code_value#

SNOMED CT code for the category this label represents.

Type:

str

property snomed_type_code_meaning#

Human-readable meaning of the type code.

Type:

str

property snomed_type_code_value#

SNOMED CT code for the type this label represents.

Type:

str

class SegmentationAlgorithmType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

AUTOMATIC = 1#
MANUAL = 3#
SEMI_AUTOMATIC = 2#
UNKNOWN = 0#
detect_labels(self: LabelDataComponent, image: SharedImageSet) → None#

Detects labels present in an image of type uint8 and creates configurations for non-existing labels using default configurations.

has_label(self: LabelDataComponent, pixel_value: SupportsInt | SupportsIndex) → bool#

Checks if a label configuration exists for a pixel value.

label_config(self: LabelDataComponent, pixel_value: SupportsInt | SupportsIndex) → LabelConfig | None#

Gets label configuration for a pixel value.

label_configs(self: LabelDataComponent) → dict[int, LabelConfig]#

Returns known label configurations.

remove_label(self: LabelDataComponent, pixel_value: SupportsInt | SupportsIndex) → None#

Removes label configuration for a pixel value.

remove_unused_labels(self: LabelDataComponent, image: SharedImageSet) → None#

Removes configurations for non-existing labels in an image.

set_default_label_config(self: LabelDataComponent, pixel_value: SupportsInt | SupportsIndex) → None#

Sets default label configuration for a pixel value.

set_label_config(self: LabelDataComponent, pixel_value: SupportsInt | SupportsIndex, config: LabelConfig) → None#

Sets label configuration for a pixel value.

set_label_configs(self: LabelDataComponent, configs: Mapping[SupportsInt | SupportsIndex, LabelConfig]) → None#

Sets known label configurations from a dictionary mapping pixel values to LabelConfig objects.

AUTOMATIC = 1#
MANUAL = 3#
SEMI_AUTOMATIC = 2#
UNKNOWN = 0#
class imfusion.data.components.RealWorldMappingDataComponent(self: RealWorldMappingDataComponent)#

Bases: DataComponentBase

class Mapping(self: Mapping)#

Bases: pybind11_object

original_to_real_world(self: Mapping, value: SupportsFloat | SupportsIndex) → float#
storage_to_real_world(self: Mapping, image_descriptor: ImageDescriptor, value: SupportsFloat | SupportsIndex) → float#
property intercept#
Type:

float

property slope#
Type:

float

property type#
Type:

MappingType

property unit#
Type:

str

class MappingType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

REAL_WORLD_VALUES = 0#
STANDARDIZED_UPTAKE_VALUES = 1#
REAL_WORLD_VALUES = 0#
STANDARDIZED_UPTAKE_VALUES = 1#
property mappings#
Type:

list[Mapping]

property units#
Type:

str

class imfusion.data.components.TransformationStashDataComponent(self: TransformationStashDataComponent)#

Bases: DataComponentBase

property original#
Type:

list[Annotated[numpy.typing.NDArray[numpy.float64], ”[4, 4]”]]

property transformations#
Type:

list[tuple[str, list[Annotated[numpy.typing.NDArray[numpy.float64], ”[4, 4]”]]]]

class imfusion.data.components.VitalsDataComponent#

Bases: DataComponentBase

DataComponent for storing a collection of time dependent vital signs like ECG, heart rate or pulse oximeter measurements.

class VitalsKind(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

ECG = 0#
HEARTH_RATE = 2#
OTHER = 3#
PULSE_OXIMETER = 1#
class VitalsTimeSeries#

Bases: pybind11_object

property signal#
Type:

list[float]

property timestamps#
Type:

list[datetime]

__getitem__(self: VitalsDataComponent, kind: VitalsKind) → list[VitalsTimeSeries]#
ECG = 0#
HEARTH_RATE = 2#
OTHER = 3#
PULSE_OXIMETER = 1#
property kinds#
Type:

list[VitalsKind]

imfusion.data.components.create(id: str, properties: Properties = None) → object#

Instantiates a DataComponent specified by the given ID.

Parameters:
  • id – Unique ID of the DataComponent to create.

  • properties – Optional Properties object. If not None, it will used to configure the newly created DataComponent.

imfusion.data.components.field(*, serializer: Callable[[TValueType], str] | None = None, deserializer: Callable[[str], TValueType] | None = None) → TValueType#

Create a serializable field descriptor for a Python data component.

Values are stored in a per-instance imfusion.Properties object. As a result, assigned values are directly validated to ensure they can be stored in :class:imfusion.Properties.

None is a valid value, distinct from a field being unset. Accessing an unset field raises AttributeError.

Optional serializer and deserializer callbacks allow storing types that Properties does not natively support (e.g. dicts via JSON). The serializer must return a str. Both must be provided together.

Default field values can be assigned in __init__.

Example:

>>> @imfusion.data.components.register(name="my_component")

… class MyComponent: … value: int = imfusion.data.components.field() … … def __init__(self, value=42): … self.value = value

imfusion.data.components.list_available() → list[str]#

Returns the Unique IDs of all DataComponents registered in DataComponentFactory.

imfusion.data.components.register(*, name: str) → Callable[[type[TPyDataComponent]], type[TPyDataComponent]]#

Decorator for registering a Python data component.

The name is used as both the factory ID (see create()) and named attribute on DataComponentList.

Attributes of the component can be defined using field(). Field values are stored internally in an imfusion.Properties object. Types not natively supported by imfusion.Properties can be supported using the serialization options provided by field().

The decorated class must be constructible without arguments. Default field values can be assigned in __init__ using default arguments.

The decorator injects the following into the registered class to conform to the ImFusion data component interface:

  • id (str) and name (str): the registration name.

  • configure(properties): applies field values from a Properties object (partial update).

  • configuration(): returns the current field values as a Properties object.

Defining any of the above in the class body raises TypeError at registration time.

If __eq__ or __repr__ are not defined, field-based implementations are generated automatically. Generated equality compares only attributes declared with field(). Other instance attributes are ignored. Define __eq__ explicitly if those attributes must participate in equality. User-defined versions are preserved.

For static type-checker support, the class may optionally inherit from imfusion.data.components.typing.PyDataComponent. This is not required at runtime. Its sole purpose is to declare the injected methods and attributes for static type checking.

Example:

>>> @imfusion.data.components.register(name="my_component")
... class MyComponent(imfusion.data.components.typing.PyDataComponent):  # Optional typing base class
...     value: int = imfusion.data.components.field()
...
...     def __init__(self, value: int = 42):
...         self.value = value