Reference

imfusion

imfusion - ImFusion SDK for Medical Imaging

This module provides Python bindings for the C++ ImFusion libraries.

class imfusion.Algorithm

Bases: BaseAlgorithm

Base class for Algorithms.

An Algorithm accepts certain Data as input and performs some computation on it.

Example for an algorithm that takes exactly one image and prints its name:

>>> class MyAlgorithm(Algorithm):
...     def __init__(self, image):
...         super().__init__()
...         self.image = image
...
...     @classmethod
...     def convert_input(cls, data):
...         images = data.images()
...         if len(images) == 1 and len(data) == 1:
...             return [images[0]]
...         raise IncompatibleError('Requires exactly one image')
...
...     def compute(self):
...         print(self.image.name)

In order to make an Algorithm available to the ImFusion Suite (i.e. the context menu when right-clicking on selected data), it has to be registered to the ApplicationController:

>>> imfusion.register_algorithm('Python.MyAlgorithm','My Algorithm', MyAlgorithm)  # DOCTEST: +skip

If the Algorithm is created through the ImFusion Suite, the convert_input() method is called to determine if the Algorithm is compatible with the desired input data. If this method does not raise an exception, the Algorithm is initialized with the data returned by convert_input(). The implementation is similar to this:

try:
    input = MyAlgorithm.convert_input(some_data)
    return MyAlgorithm(*input)
except IncompatibleError:
    return None

The Algorithm class also provides default implementations for the configuration() and configure() methods that automatically serialize attributes created with add_param().

__init__(self: BaseAlgorithm) None
add_param(name, value, attributes='')

Add a new parameter to the object.

The parameter is available as a new attribute with the given name and value. The attribute will be configured automatically.

>>> class MyAlgorithm(Algorithm):
...     def __init__(self):
...         super().__init__()
...         self.add_param('x', 5)
>>> a = MyAlgorithm()
>>> a.x
5
configuration(self: Configurable) Properties
configure(self: Configurable, properties: Properties) None
classmethod convert_input(data: List[Data]) List[Data]

Convert the given DataList to a valid input for the algorithm.

Must be overridden in derived classes. Raise an IncompatibleError if the given data does not exactly match the required input of the algorithm. Should return a list, a dict or a generator.

output()

Return the output generated by the previous call to compute(). The returned type must be a list of Data objects! The default implementation returns an empty list.

class imfusion.Annotation

Bases: pybind11_object

class AnnotationType

Bases: pybind11_object

Members:

CIRCLE

LINE

POINT

POLY_LINE

RECTANGLE

CIRCLE = <AnnotationType.CIRCLE: 0>
LINE = <AnnotationType.LINE: 1>
POINT = <AnnotationType.POINT: 2>
POLY_LINE = <AnnotationType.POLY_LINE: 3>
RECTANGLE = <AnnotationType.RECTANGLE: 4>
__init__(self: AnnotationType, value: int) None
property name
property value
CIRCLE = <AnnotationType.CIRCLE: 0>
LINE = <AnnotationType.LINE: 1>
POINT = <AnnotationType.POINT: 2>
POLY_LINE = <AnnotationType.POLY_LINE: 3>
RECTANGLE = <AnnotationType.RECTANGLE: 4>
__init__(*args, **kwargs)
property color

Color of the annotation as a normalized RGB tuple.

property editable

Whether the annotation can be manipulated by the user.

property label_text
property label_visible
property line_width
property max_points

The maximum amount of points this annotation supports.

A -1 indicates that this annotation supports any number of points.

property name
on_editing_finished(self: Annotation, callback: object) SignalConnection

Register a callback which is call when the annotation is fully defined by the user.

The callback must not require any arguments.

>>> a = imfusion.app.annotation_model.create_annotation(imfusion.Annotation.LINE)
>>> def callback():
...     printf("All points are defined:", a.points)
>>> a.on_editing_finished(callback)
>>> a.start_editing()
on_points_changed(self: Annotation, callback: object) SignalConnection

Register a callback which is call when any of the points change position.

The callback must not require any arguments.

>>> a = imfusion.app.annotation_model.create_annotation(imfusion.Annotation.LINE)
>>> def callback():
...     printf("Points changed to", a.points)
>>> a.on_points_changed(callback)
>>> a.start_editing()
property points

The points which define the annotation in world coordinates.

start_editing(self: Annotation) None

Start interactive placement of the annotation.

This can currently only be called once.

property type

Return the type of this annotation.

Return None if this type is only partially supported from Python.

property visible
class imfusion.AnnotationModel

Bases: pybind11_object

__init__(*args, **kwargs)
property annotations
create_annotation(self: AnnotationModel, arg0: AnnotationType) Annotation
class imfusion.ApplicationController

Bases: pybind11_object

A ApplicationController instance serves as the center of the ImFusionSDK.

It provides an OpenGL context, a DataModel, executes algorithms and more. While multiple instances are possible, in general there is only one instance.

__init__(*args, **kwargs)
add_algorithm(self: ApplicationController, id: str, data: list = [], properties: Properties = None) object

Add the algorithm with the given name to the application.

The algorithm will only be created if it is compatible with the given data. The optional Properties object will be used to configure the algorithm. Returns the created algorithm or None if no compatible algorithm could be found.

>>> app.add_algorithm("Create Synthetic Data", [])  
<imfusion._bindings.BaseAlgorithm object at ...>
property algorithms

Return a list of all open algorithms.

property annotation_model
close_all(self: ApplicationController) None

Delete all algorithms and datasets. Make sure to not reference any deleted objects after calling this!

property data_model
property display
execute_algorithm(self: ApplicationController, id: str, data: list = [], properties: Properties = None) list

Execute the algorithm with the given name and returns its output.

The algorithm will only be executed if it is compatible with the given data. The optional Properties object will be used to configure the algorithm before executing it. Any data created by the algorithm is added to the DataModel before being returned.

load_workspace(self: ApplicationController, path: str, **kwargs) bool

Loads a workspace file and returns True if the loading was successful. Placeholders can be specified as keyword arguments, for example: >>> app.load_workspace(“path/to/workspace.iws”, sweep=sweep, case=case)

open(self: ApplicationController, path: str) list

Tries to open the given filepath as data. If successful the data is added to DataModel and returned. Otherwise raises a FileNotFoundError.

remove_algorithm(self: ApplicationController, algorithm: BaseAlgorithm) None

Remove and deletes the given algorithm from the application. Don’t reference the given algorithm afterwards!

save_workspace(self: ApplicationController, path: str) bool

Saves current workspace to a iws file

select_data(*args, **kwargs)

Overloaded function.

  1. select_data(self: imfusion._bindings.ApplicationController, arg0: imfusion._bindings.Data) -> None

  2. select_data(self: imfusion._bindings.ApplicationController, arg0: imfusion._bindings.DataList) -> None

  3. select_data(self: imfusion._bindings.ApplicationController, arg0: list) -> None

property selected_data
update_display(self: ApplicationController) None
class imfusion.BaseAlgorithm

Bases: Configurable

Low-level base class for all algorithms.

This interface mirrors the C++ interface very closely. Instances of this class are returned when you create an Algorithm that exists in the C++ SDK, either through add_algorithm() or :meth:~imfusion.create_algorithm`.

If you want to implement your own Algorithms from Python see Algorithm instead.

ERROR = <Status.ERROR: 1>
INCOMPLETE_INPUT = <Status.INCOMPLETE_INPUT: 3>
INVALID_INPUT = <Status.INVALID_INPUT: 2>
OUT_OF_MEMORY_GPU = <Status.OUT_OF_MEMORY_GPU: 5>
OUT_OF_MEMORY_HOST = <Status.OUT_OF_MEMORY_HOST: 4>
SUCCESS = <Status.SUCCESS: 0>
class Status

Bases: pybind11_object

Members:

UNKNOWN

SUCCESS

ERROR

INVALID_INPUT

INCOMPLETE_INPUT

OUT_OF_MEMORY_HOST

OUT_OF_MEMORY_GPU

UNSUPPORTED_GPU

UNKNOWN_ACTION

USER

ERROR = <Status.ERROR: 1>
INCOMPLETE_INPUT = <Status.INCOMPLETE_INPUT: 3>
INVALID_INPUT = <Status.INVALID_INPUT: 2>
OUT_OF_MEMORY_GPU = <Status.OUT_OF_MEMORY_GPU: 5>
OUT_OF_MEMORY_HOST = <Status.OUT_OF_MEMORY_HOST: 4>
SUCCESS = <Status.SUCCESS: 0>
UNKNOWN = <Status.UNKNOWN: -1>
UNKNOWN_ACTION = <Status.UNKNOWN_ACTION: 7>
UNSUPPORTED_GPU = <Status.UNSUPPORTED_GPU: 6>
USER = <Status.USER: 1000>
__init__(self: Status, value: int) None
property name
property value
UNKNOWN = <Status.UNKNOWN: -1>
UNKNOWN_ACTION = <Status.UNKNOWN_ACTION: 7>
UNSUPPORTED_GPU = <Status.UNSUPPORTED_GPU: 6>
USER = <Status.USER: 1000>
__init__(self: BaseAlgorithm) None
property actions
compute(self: BaseAlgorithm) None
property id
property input
property name
output(self: BaseAlgorithm) list
output_annotations(self: BaseAlgorithm) List[Annotation]
run_action(self: BaseAlgorithm, name: str) Status
property status
class imfusion.Configurable

Bases: pybind11_object

__init__(*args, **kwargs)
configuration(self: Configurable) Properties
configure(self: Configurable, properties: Properties) None
configure_defaults(self: Configurable) None
class imfusion.ConsoleController

Bases: ApplicationController

ApplicationController without a UI interface.

This class is not available in the embedded Python interpreter in the ImFusionSuite.

__init__(self: ConsoleController, name: str = 'ImFusion Python Module') None
class imfusion.CroppingMask

Bases: Mask

Simple axis-aligned cropping mask with optional roundness.

class RoundDims

Bases: pybind11_object

Members:

XY

YZ

XZ

XYZ

XY = <RoundDims.XY: 0>
XYZ = <RoundDims.XYZ: 3>
XZ = <RoundDims.XZ: 2>
YZ = <RoundDims.YZ: 1>
__init__(self: RoundDims, value: int) None
property name
property value
XY = <RoundDims.XY: 0>
XYZ = <RoundDims.XYZ: 3>
XZ = <RoundDims.XZ: 2>
YZ = <RoundDims.YZ: 1>
__init__(self: CroppingMask, dimensions: ndarray[numpy.int32[3, 1]]) None
property border

Number of pixels cropped away

property inverted

Whether the mask is inverted

property roundness

Roundness in percent (100 means an ellipse, 0 a rectangle)

property roundness_dims

Which dimensions the roundness parameter should be applied

class imfusion.Data

Bases: pybind11_object

class Kind

Bases: pybind11_object

Members:

UNKNOWN

IMAGE

VOLUME

IMAGE_SET

VOLUME_SET

IMAGE_STREAM

VOLUME_STREAM

POINT_SET

SURFACE

LIVE_TRACKING_STREAM

TRACKING_DATA

IMAGE = <Kind.IMAGE: 1>
IMAGE_SET = <Kind.IMAGE_SET: 3>
IMAGE_STREAM = <Kind.IMAGE_STREAM: 5>
LIVE_TRACKING_STREAM = <Kind.LIVE_TRACKING_STREAM: 9>
POINT_SET = <Kind.POINT_SET: 7>
SURFACE = <Kind.SURFACE: 8>
TRACKING_DATA = <Kind.TRACKING_DATA: 10>
UNKNOWN = <Kind.UNKNOWN: 0>
VOLUME = <Kind.VOLUME: 2>
VOLUME_SET = <Kind.VOLUME_SET: 4>
VOLUME_STREAM = <Kind.VOLUME_STREAM: 6>
__init__(self: Kind, value: int) None
property name
property value
class Modality

Bases: pybind11_object

Members:

NA

XRAY

CT

MRI

ULTRASOUND

VIDEO

NM

OCT

LABEL

CT = <Modality.CT: 2>
LABEL = <Modality.LABEL: 8>
MRI = <Modality.MRI: 3>
NA = <Modality.NA: 0>
NM = <Modality.NM: 6>
OCT = <Modality.OCT: 7>
ULTRASOUND = <Modality.ULTRASOUND: 4>
VIDEO = <Modality.VIDEO: 5>
XRAY = <Modality.XRAY: 1>
__init__(self: Modality, value: int) None
property name
property value
__init__(*args, **kwargs)
property components
property kind
property name
class imfusion.DataComponent

Bases: pybind11_object

Data components provide a way to generically attach custom information to Data.

Data and StreamData are the two main classes that hold a list of data components, allowing custom information (for example optional data or configuration settings) to be attached to instances of these classes. Data components are meant to be used for information that is bound to a specific Data instance and that can not be represented by the usual ImFusion data types.

Data components should implement the Configurable methods, in order to support generic (de)serialization.

Note

Data components are supposed to act as generic storage for custom information. When subclassing DataComponent, you should not implement any heavy evaluation logic since this is the domain of Algorithms or other classes accessing the DataComponents.

Example

class MyComponent(imfusion.DataComponent, factory_name="my_component"):
        def __init__(self, a):
                imfusion.DataComponent.__init__(self)
                self.a = a

        @property
        def a(self):
                return self._a

        @a.setter
        def a(self, value):
                if value and not isinstance(value, str):
                        raise TypeError('`a` must be of type `str`')
                self._a = value

        def configure(self, properties: imfusion.Properties) -> None:
                self.a = str(properties['a'])

        def configuration(self) -> imfusion.Properties:
                return imfusion.Properties({'a': self.a})

        def __eq__(self, other: 'MyComponent') -> bool:
                return self.a == other.a
__init__(self: DataComponent) None
configuration(self: DataComponent) Properties
configure(self: DataComponent, properties: Properties) None
property id

Returns a unique string identifier for this type of data component

class imfusion.DataComponentBase

Bases: Configurable

__init__(*args, **kwargs)
class imfusion.DataComponentList

Bases: pybind11_object

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

__getitem__(*args, **kwargs)

Overloaded function.

  1. __getitem__(self: imfusion._bindings.DataComponentList, index: int) -> object

  2. __getitem__(self: imfusion._bindings.DataComponentList, indices: List[int]) -> List[object]

  3. __getitem__(self: imfusion._bindings.DataComponentList, slice: slice) -> List[object]

  4. __getitem__(self: imfusion._bindings.DataComponentList, id: str) -> object

__init__(*args, **kwargs)
add(*args, **kwargs)

Overloaded function.

  1. add(self: imfusion._bindings.DataComponentList, component: imfusion._bindings.DataComponent) -> object

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.ImageInfoDataComponent) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.DisplayOptions2d) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.DisplayOptions3d) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.TransformationStashDataComponent) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.DataSourceComponent) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.LabelDataComponent) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.DatasetLicenseComponent) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.RealWorldMappingDataComponent) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.GeneralEquipmentModuleDataComponent) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.SourceInfoComponent) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.ReferencedInstancesComponent) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.RTStructureDataComponent) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.machinelearning.TargetTag) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.machinelearning.ProcessingRecordComponent) -> imfusion._bindings.DataComponentBase

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

  1. add(self: imfusion._bindings.DataComponentList, arg0: imfusion._bindings.ReferenceImageDataComponent) -> imfusion._bindings.DataComponentBase

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

property data_source
property dataset_license
property display_options_2d
property display_options_3d
property general_equipment_module
property image_info
property label
property processing_record
property real_world_mapping
property reference_image
property referenced_instances
property rt_structure
property source_info
property target_tag
property transformation_stash
class imfusion.DataGroup

Bases: Data

__init__(*args, **kwargs)
property children
children_recursive(self: DataGroup) DataList
property proxy_child
class imfusion.DataList

Bases: pybind11_object

List of Data. Is implicitly converted from and to regular Python lists.

Deprecated since version 2.15: Use a regular list instead.

__getitem__(*args, **kwargs)

Overloaded function.

  1. __getitem__(self: imfusion._bindings.DataList, index: int) -> imfusion._bindings.Data

  2. __getitem__(self: imfusion._bindings.DataList, indices: List[int]) -> List[imfusion._bindings.Data]

  3. __getitem__(self: imfusion._bindings.DataList, slice: slice) -> List[imfusion._bindings.Data]

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.DataList) -> None

  2. __init__(self: imfusion._bindings.DataList, list: list) -> None

add(self: DataList, arg0: Data) None
append(self: DataList, arg0: Data) None
get_images(self: imfusion._bindings.DataList, kind: imfusion._bindings.Data.Kind = <Kind.UNKNOWN: 0>, modality: imfusion._bindings.Data.Modality = <Modality.NA: 0>) list
class imfusion.DataModel

Bases: pybind11_object

The DataModel instance holds all datasets of an ApplicationController.

__getitem__(*args, **kwargs)

Overloaded function.

  1. __getitem__(self: imfusion._bindings.DataModel, index: int) -> imfusion._bindings.Data

  2. __getitem__(self: imfusion._bindings.DataModel, indices: List[int]) -> List[imfusion._bindings.Data]

  3. __getitem__(self: imfusion._bindings.DataModel, slice: slice) -> List[imfusion._bindings.Data]

__init__(*args, **kwargs)
add(*args, **kwargs)

Overloaded function.

  1. add(self: imfusion._bindings.DataModel, data: imfusion._bindings.Data, name: str = ‘’) -> imfusion._bindings.Data

Add data to the model. The data will be copied and a reference to the copy is returned. If the data cannot be added, a ValueError is raised.

  1. add(self: imfusion._bindings.DataModel, data_list: List[imfusion._bindings.Data]) -> list

Add multiple pieces of data to the model. The data will be copied and a reference to the copy is returned. If the data cannot be added, a ValueError is raised.

clear(self: DataModel) None

Remove all data from the model

contains(self: DataModel, data: Data) bool
create_group(self: DataModel, arg0: DataList) DataGroup

Groups a list of Data in the model. Only Data that is already part of the model can be grouped.

get(self: DataModel, name: str) Data
get_common_parent(self: DataModel, data_list: DataList) DataGroup

Return the most common parent of all given Data

get_parent(self: DataModel, data: Data) DataGroup

Return the parent DataGroup of the given Data or None if it is not part of the model. For top-level data this function will return get_root_node().

index(self: DataModel, data: Data) int

Return index of data. The index is depth-first for all groups.

remove(self: DataModel, data: Data) None

Remove and delete data from the model. Afterwards data must not be reference anymore!

property root_node

Return the parent DataGroup of the given Data or None if it does not have a parent

property size

Return the total amount of data in the model

class imfusion.DataSourceComponent

Bases: DataComponentBase

class DataSourceInfo

Bases: Configurable

__init__(self: DataSourceInfo, arg0: str, arg1: str, arg2: Properties, arg3: int, arg4: List[DataSourceInfo]) None
property filename
property history
property index_in_file
property io_algorithm_config
property io_algorithm_name
update(self: DataSourceInfo, arg0: DataSourceInfo) None
__init__(*args, **kwargs)
property filenames
property sources
class imfusion.DatasetLicenseComponent

Bases: DataComponentBase

class DatasetInfo

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.DatasetLicenseComponent.DatasetInfo) -> None

  2. __init__(self: imfusion._bindings.DatasetLicenseComponent.DatasetInfo, name: str, authors: str, website: str, license: str, attribution_required: bool, commercial_use_allowed: bool) -> None

property attribution_required
property authors
property commercial_use_allowed
property license
property name
property website
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.DatasetLicenseComponent) -> None

  2. __init__(self: imfusion._bindings.DatasetLicenseComponent, infos: List[imfusion._bindings.DatasetLicenseComponent.DatasetInfo]) -> None

infos(self: DatasetLicenseComponent) List[DatasetInfo]
class imfusion.Deformation

Bases: pybind11_object

__init__(*args, **kwargs)
configuration(self: Deformation) Properties
configure(self: Deformation, properties: Properties) None
displace_point(self: Deformation, at: ndarray[numpy.float64[3, 1]]) ndarray[numpy.float64[3, 1]]
displace_points(self: Deformation, at: List[ndarray[numpy.float64[3, 1]]]) List[ndarray[numpy.float64[3, 1]]]
displacement(*args, **kwargs)

Overloaded function.

  1. displacement(self: imfusion._bindings.Deformation, at: numpy.ndarray[numpy.float64[3, 1]]) -> numpy.ndarray[numpy.float64[3, 1]]

  2. displacement(self: imfusion._bindings.Deformation, at: numpy.ndarray[numpy.float64[2, 1]]) -> numpy.ndarray[numpy.float64[3, 1]]

  3. displacement(self: imfusion._bindings.Deformation, at: List[numpy.ndarray[numpy.float64[3, 1]]]) -> List[numpy.ndarray[numpy.float64[3, 1]]]

class imfusion.Display

Bases: pybind11_object

__init__(*args, **kwargs)
property focus_view
property layout_mode
maximize_view(self: Display, view: View) None
unmaximize_view(self: Display) None
views(self: Display) list
views2d(self: Display) list
views3d(self: Display) list
views_slice(self: Display) list
class imfusion.DisplayOptions2d

Bases: DataComponentBase

__init__(self: DisplayOptions2d, arg0: Data) None
property gamma
property invert
property level
property window
class imfusion.DisplayOptions3d

Bases: DataComponentBase

__init__(self: DisplayOptions3d, arg0: Data) None
property alpha
property invert
property level
property window
class imfusion.ExplicitIntensityMask

Bases: Mask

Combination of an ExplicitMask and an IntensityMask.

__init__(self: ExplicitIntensityMask, ref_image: SharedImage, mask_image: SharedImage) None
property border_clamp

If true, set sampler wrapping mode to CLAMP_TO_BORDER (default). If false, set to CLAMP_TO_EDGE.

property border_color

Border color (normalized for integer images)

property intensity_range

Range of allowed pixel values

class imfusion.ExplicitMask

Bases: Mask

Mask holding an individual mask value for every pixel.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.ExplicitMask, width: int, height: int, slices: int, initial: int = 0) -> None

  2. __init__(self: imfusion._bindings.ExplicitMask, dimensions: numpy.ndarray[numpy.int32[3, 1]], initial: int = 0) -> None

  3. __init__(self: imfusion._bindings.ExplicitMask, mask_image: imfusion._bindings.MemImage) -> None

mask_image(self: ExplicitMask) SharedImage

Returns a copy of the mask image held by the mask.

exception imfusion.FileNotFoundError

Bases: FileNotFoundError

class imfusion.FrameworkInfo

Bases: pybind11_object

Provides general information about the framework.

__init__(*args, **kwargs)
property license
property opengl
property plugins
class imfusion.FreeFormDeformation

Bases: Deformation

__init__(*args, **kwargs)
configuration(self: FreeFormDeformation) Properties
configure(self: FreeFormDeformation, arg0: Properties) None
control_points(self: FreeFormDeformation) List[ndarray[numpy.float64[3, 1]]]

Get current control point locations (including displacement)

property displacements

Displacement in mm of all control points

property grid_spacing

Spacing of the control point grid

property grid_transformation

Transformation matrix of the control point grid

property subdivisions

Subdivisions of the control point grid

class imfusion.GeneralEquipmentModuleDataComponent

Bases: DataComponentBase

__init__(self: GeneralEquipmentModuleDataComponent) None
property anatomical_orientation_type
property device_serial_number
property gantry_id
property institution_address
property institution_name
property institutional_departmentname
property manufacturer
property manufacturers_model_name
property software_versions
property spatial_resolution
property station_name
class imfusion.GlPlatformInfo

Bases: pybind11_object

Provides information about the underlying OpenGL driver.

__init__(*args, **kwargs)
property extensions
property renderer
property vendor
property version
exception imfusion.IOError

Bases: OSError

class imfusion.ImageDescriptor

Bases: pybind11_object

Struct describing the essential properties of an image.

The ImFusion framework distinguishes two main image pixel value domains, which are indicated by the shift and scale parameters of this image descriptor:

  • Original pixel value domain: Pixel values are the same as in their original source (e.g. when loaded from a file). Same as the storage pixel value domain if the image’s scale is 1 and the shift is 0

  • Storage pixel value domain: Pixel values as they are stored in a MemImage. The user may decide to apply such a rescaling in order to better use the available limits of the underlying type.

The following conversion rules apply:

  • OV = (SV / scale) - shift

  • SV = (OV + shift) * scale

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.ImageDescriptor) -> None

  2. __init__(self: imfusion._bindings.ImageDescriptor, type: imfusion._bindings.PixelType, dimensions: numpy.ndarray[numpy.int32[3, 1]], channels: int = 1) -> None

  3. __init__(self: imfusion._bindings.ImageDescriptor, type: imfusion._bindings.PixelType, width: int, height: int, slices: int = 1, channels: int = 1) -> None

property byte_size

Return the size of the image in bytes

property channels
property configuration

Serialize an image descriptor to Properties

configure(self: ImageDescriptor, properties: Properties) None

Deserialize an image descriptor from Properties

coord(self: ImageDescriptor, index: int) ndarray[numpy.int32[4, 1]]

Return the pixel/voxel coordinate (x,y,z,c) for a given index

property dimension
property dimensions
property extent
has_index(self: ImageDescriptor, x: int, y: int, z: int = 0, c: int = 0) int

Return true if the pixel at (x,y,z) exists, false otherwise

property height
image_to_pixel(self: ImageDescriptor, world: ndarray[numpy.float64[3, 1]]) ndarray[numpy.float64[3, 1]]

Convert 3D image coordinates to pixel/voxel position

property image_to_pixel_matrix

Return a 4x4 matrix to transform from texture space to image space

index(self: ImageDescriptor, x: int, y: int, z: int = 0, c: int = 0) int

Return a linear memory index for a pixel or voxel

is_compatible(self: ImageDescriptor, other: ImageDescriptor, ignore_type: bool = False, ignore_3D: bool = False, ignore_channels: bool = False, ignore_spacing: bool = True) bool

Convenience function to perform partial comparison of two image descriptors. Two descriptors are compatible if their width and height, and optionally number of slices, number of channels and type are the same

property is_metric
is_valid(self: ImageDescriptor) bool

Return if the descriptor is valid (a size of one is allowed)

original_to_storage(self: ImageDescriptor, value: float) float

Apply the image’s shift and scale in order to convert a value from original pixel value domain to storage pixel value domain

pixel_to_image(self: ImageDescriptor, pixel: ndarray[numpy.float64[3, 1]]) ndarray[numpy.float64[3, 1]]

Convert a 3D pixel/voxel position to image coordinates

property pixel_to_image_matrix

Return a 4x4 matrix to transform from image space to texture space

property pixel_type
property scale
set_dimensions(self: ImageDescriptor, dimensions: ndarray[numpy.int32[3, 1]], channels: int = 0) None

Convenience function for specifying the image dimensions and channels at once. If channels is 0, the number of channels will remain unchanged

set_spacing(self: ImageDescriptor, spacing: ndarray[numpy.float64[3, 1]], is_metric: bool) None

Convenience function for specifying spacing and metric flag at the same time

property shift
property size

Return the size (number of elements) of the image

property slices
property spacing

Access the image descriptor spacing. When setting the spacing, it is always assumed that the given spacing is metric. If you want to specify a non-metric spacing, use desc.set_spacing(new_spacing, is_metric=False)

storage_to_original(self: ImageDescriptor, value: float) float

Apply the image’s shift and scale in order to convert a value from storage pixel value domain to original pixel value domain

property type_size

Return the nominal size in bytes of the current component type, zero if unknown

property width
class imfusion.ImageDescriptorWorld

Bases: pybind11_object

Convenience struct extending an ImageDescriptor to also include a matrix describing the image orientation in world coordinates.

This struct can be useful for describing the geometrical properties of an image without need to hold the (heavy) image content. As such it can be used for representing reference geometries (see ImageResamplingAlgorithm), or for one-line creation of a new SharedImage.

__init__(self: ImageDescriptorWorld, descriptor: ImageDescriptor, matrix_to_world: ndarray[numpy.float64[4, 4]]) None
property descriptor
image_to_pixel(self: ImageDescriptorWorld, world: ndarray[numpy.float64[3, 1]]) ndarray[numpy.float64[3, 1]]

Convert 3D image coordinates to pixel/voxel position

property image_to_pixel_matrix

Return a 4x4 matrix to transform from image space to pixel space

is_spatially_compatible(self: ImageDescriptorWorld, other: ImageDescriptorWorld) bool

Convenience function to compare two image world descriptors (for instance to know whether a resampling is necessary). Two descriptors are compatible if their dimensions, matrix and spacing are identical.

property matrix_from_world
property matrix_to_world
pixel_to_image(self: ImageDescriptorWorld, pixel: ndarray[numpy.float64[3, 1]]) ndarray[numpy.float64[3, 1]]

Convert a 3D pixel/voxel position to image coordinates

property pixel_to_image_matrix

Return a 4x4 matrix to transform from pixel space to image space

property pixel_to_texture_matrix

Return a 4x4 matrix to transform from image space to texture space

pixel_to_world(self: ImageDescriptorWorld, pixel: ndarray[numpy.float64[3, 1]]) ndarray[numpy.float64[3, 1]]

Convert a 3D pixel/voxel position to world coordinates

property pixel_to_world_matrix

Return a 4x4 matrix to transform from pixel space to world space

property texture_to_pixel_matrix

Return a 4x4 matrix to transform from texture space to image space

property texture_to_world_matrix

Return a 4x4 matrix to transform from texture space to world space

world_to_pixel(self: ImageDescriptorWorld, world: ndarray[numpy.float64[3, 1]]) ndarray[numpy.float64[3, 1]]

Convert 3D world coordinates to pixel/voxel position

property world_to_pixel_matrix

Return a 4x4 matrix to transform from world space to pixel space

property world_to_texture_matrix

Return a 4x4 matrix to transform from world space to texture space

class imfusion.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

Bases: pybind11_object

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

Members:

UNKNOWN

BIPED

QUADRUPED

BIPED = <AnatomicalOrientationType.BIPED: 1>
QUADRUPED = <AnatomicalOrientationType.QUADRUPED: 2>
UNKNOWN = <AnatomicalOrientationType.UNKNOWN: 0>
__init__(self: AnatomicalOrientationType, value: int) None
property name
property value
class Laterality

Bases: pybind11_object

Laterality of (paired) body part examined

Members:

UNKNOWN

LEFT

RIGHT

LEFT = <Laterality.LEFT: 1>
RIGHT = <Laterality.RIGHT: 2>
UNKNOWN = <Laterality.UNKNOWN: 0>
__init__(self: Laterality, value: int) None
property name
property value
class PatientSex

Bases: pybind11_object

Gender of the patient

Members:

UNKNOWN

MALE

FEMALE

OTHER

FEMALE = <PatientSex.FEMALE: 2>
MALE = <PatientSex.MALE: 1>
OTHER = <PatientSex.OTHER: 3>
UNKNOWN = <PatientSex.UNKNOWN: 0>
__init__(self: PatientSex, value: int) None
property name
property value
__init__(self: ImageInfoDataComponent) None
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.

property laterality

Laterality of (paired) body part examined

property modality

DICOM modality string specifying the method used to create this series

property orientation_type

DICOM Anatomical Orientation Type

property patient_birth_date

Patient date of birth in yyyyMMdd format

property patient_comment

Additional information about the Patient

property patient_id

DICOM Patient ID

property patient_name

Patient name

property patient_position

Specifies position of the Patient relative to the imaging equipment.

property patient_sex

Patient sex

property photometric_interpretation

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

property responsible_person

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

property series_date

Series date in yyyyMMdd format

property series_description

Series description

property series_instance_uid

Unique identifier of the Series

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.

property series_time

Series time in HHmmss format

property series_time_exact

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

property study_date

Study date in yyyyMMdd format

property study_description

Study description

property study_id

DICOM Study ID

property study_instance_uid

Unique identifier for the Study

property study_time

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

property study_time_exact

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

property study_timezone

Study time zone abbreviation

class imfusion.ImageResamplingAlgorithm

Bases: BaseAlgorithm

Algorithm for resampling an image to a target dimension or resolution, optionally with respect to another image.

If a reference image is not provided the size of the output can be either explicitly specified, or implicitly determined by setting a target spacing, binning or relative size w.r.t. the input (in percentage). Only one of these strategies can be active at a time, as specified by the resamplingMode field. The value of the other target fields will be ignored. The algorithm offers convenience methods to jointly update the value of a target field and change the resampling mode accordingly.

In case you provide a reference image it will its pixel grid (dimensions, spacing, pose matrix) for the output. However, the pixel type as well as shift/scale will remain the same as in the input image.

The algorithm supports Linear and Nearest interpolation modes. In the Linear case (default), when accessing the input image at a fractional coordinate, the obtained value will be computed by linearly interpolating between the closest pixels/voxels. In the Nearest case, the value of the closest pixel/voxel will be used instead.

Furthermore, multiple reduction modes are also supported. In contrast to the interpolation mode, which affects how the value of the input image at a given (potentially fractional) coordinate is extracted, this determines what happens when multiple input pixels/voxels contribute to the value of a single output pixel/voxel. In Nearest mode, the value of the closest input pixel/voxel is used as-is. Alternatively, the Minimum, Maximum or Average value of the neighboring pixel/voxels can be used.

By default, the image will be modified in-place; a new one can be created instead by changing the value of the createNewImage parameter.

By default, the resulting image will have an altered physical extent, since the original extent may not be divisible by the target spacing. The algorithm can modify the target spacing to exactly maintain the physical extent, by toggling the preserveExtent parameter.

If the keepZeroValues parameter is set to true, the input pixels/voxels having zero value will not be modified by the resampling process.

class ResamplingMode

Bases: pybind11_object

Members:

TARGET_DIM

TARGET_PERCENT

TARGET_SPACING

TARGET_BINNING

TARGET_BINNING = <ResamplingMode.TARGET_BINNING: 3>
TARGET_DIM = <ResamplingMode.TARGET_DIM: 0>
TARGET_PERCENT = <ResamplingMode.TARGET_PERCENT: 1>
TARGET_SPACING = <ResamplingMode.TARGET_SPACING: 2>
__init__(self: ResamplingMode, value: int) None
property name
property value
TARGET_BINNING = <ResamplingMode.TARGET_BINNING: 3>
TARGET_DIM = <ResamplingMode.TARGET_DIM: 0>
TARGET_PERCENT = <ResamplingMode.TARGET_PERCENT: 1>
TARGET_SPACING = <ResamplingMode.TARGET_SPACING: 2>
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.ImageResamplingAlgorithm, input_images: imfusion._bindings.SharedImageSet, reference_images: imfusion._bindings.SharedImageSet = None) -> None

  2. __init__(self: imfusion._bindings.ImageResamplingAlgorithm, input_images: imfusion._bindings.SharedImageSet, reference_world_descriptors: List[imfusion._bindings.ImageDescriptorWorld]) -> None

property clone_deformation

Whether to clone deformation from original image before attaching to result

property create_new_image

Whether to compute the result in-place or in a newly allocated image

property force_cpu

Whether to force the computation on the CPU

property interpolation_mode

Mode for image interpolation

property keep_zero_values

Whether to update the target spacing to keep exactly the physical dimensions of the input image

property preserve_extent

Whether to update the target spacing to keep exactly the physical dimensions of the input image

property reduction_mode

Mode for image reduction (e.g. downsampling, resampling, binning)

property resampling_mode

How the output image size should be obtained (explicit dimensions, percentage relative to the input image, …)

resampling_needed(self: ImageResamplingAlgorithm, frame: int = -1) bool

Return whether resampling is needed or the specified settings result in the same image size and spacing

set_input(*args, **kwargs)

Overloaded function.

  1. set_input(self: imfusion._bindings.ImageResamplingAlgorithm, new_input_images: imfusion._bindings.SharedImageSet, new_reference_images: imfusion._bindings.SharedImageSet, reconfigure_from_new_data: bool) -> None

Replaces the input of the algorithm. If reconfigureFromNewData is true, the algorithm reconfigures itself based on meta data of the new input

  1. set_input(self: imfusion._bindings.ImageResamplingAlgorithm, new_input_images: imfusion._bindings.SharedImageSet, new_reference_world_descriptors: List[imfusion._bindings.ImageDescriptorWorld], reconfigure_from_new_data: bool) -> None

Replaces the input of the algorithm. If reconfigureFromNewData is true, the algorithm reconfigures itself based on meta data of the new input

set_target_min_spacing(*args, **kwargs)

Overloaded function.

  1. set_target_min_spacing(self: imfusion._bindings.ImageResamplingAlgorithm, min_spacing: float) -> bool

Set the target spacing with the spacing of the input image, replacing the value in each dimension with the maximum between the original and the provided value.

Parameters:

min_spacing – the minimum value that the target spacing should have in each direction

Returns:

True if the final target spacing is different than the input image spacing

  1. set_target_min_spacing(self: imfusion._bindings.ImageResamplingAlgorithm, min_spacing: numpy.ndarray[numpy.float64[3, 1]]) -> bool

Set the target spacing with the spacing of the input image, replacing the value in each dimension with the maximum between the original and the provided value.

Parameters:

min_spacing – the minimum value that the target spacing should have in each direction

Returns:

True if the final target spacing is different than the input image spacing

property target_binning

How many pixels from the input image should be combined into an output pixel

property target_dimensions

Target dimensions for the new image

property target_percent

Target dimensions for the new image, relatively to the input one

property target_spacing

Target spacing for the new image

property verbose

Whether to enable advanced logging

class imfusion.ImageView2D

Bases: View

__init__(*args, **kwargs)
class imfusion.ImageView3D

Bases: View

__init__(*args, **kwargs)
exception imfusion.IncompatibleError

Bases: ValueError

class imfusion.IntensityMask

Bases: Mask

Masks pixels with a specific value or values outside a specific range.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.IntensityMask, type: imfusion._bindings.PixelType, value: float = 0.0) -> None

  2. __init__(self: imfusion._bindings.IntensityMask, image: imfusion._bindings.MemImage, value: float = 0.0) -> None

property masked_value

Specific value that should be masked

property masked_value_range

Half-open range [min, max) of allowed pixel values

property type
property use_range

Whether the mask should operate in range mode (true) or single-value mode (false)

class imfusion.InterpolationMode

Bases: pybind11_object

Members:

NEAREST

LINEAR

LINEAR = <InterpolationMode.LINEAR: 1>
NEAREST = <InterpolationMode.NEAREST: 0>
__init__(self: InterpolationMode, value: int) None
property name
property value
class imfusion.LabelDataComponent

Bases: pybind11_object

AUTOMATIC = <SegmentationAlgorithmType.AUTOMATIC: 1>
class LabelConfig

Bases: pybind11_object

__init__(*args, **kwargs)
property color
property is_visible2d
property is_visible3d
property name
property segmentation_algorithm_name
property segmentation_algorithm_type
property snomed_category_code_meaning
property snomed_category_code_value
property snomed_type_code_meaning
property snomed_type_code_value
MANUAL = <SegmentationAlgorithmType.MANUAL: 3>
SEMI_AUTOMATIC = <SegmentationAlgorithmType.SEMI_AUTOMATIC: 2>
class SegmentationAlgorithmType

Bases: pybind11_object

Members:

UNKNOWN

AUTOMATIC

SEMI_AUTOMATIC

MANUAL

AUTOMATIC = <SegmentationAlgorithmType.AUTOMATIC: 1>
MANUAL = <SegmentationAlgorithmType.MANUAL: 3>
SEMI_AUTOMATIC = <SegmentationAlgorithmType.SEMI_AUTOMATIC: 2>
UNKNOWN = <SegmentationAlgorithmType.UNKNOWN: 0>
__init__(self: SegmentationAlgorithmType, value: int) None
property name
property value
UNKNOWN = <SegmentationAlgorithmType.UNKNOWN: 0>
__init__(self: LabelDataComponent) None
detect_labels(self: LabelDataComponent, image: SharedImageSet) None
has_label(self: LabelDataComponent, pixel_value: int) bool
label_config(self: LabelDataComponent, pixel_value: int) LabelConfig | None
label_configs(self: LabelDataComponent) Dict[int, LabelConfig]
remove_label(self: LabelDataComponent, pixel_value: int) None
remove_unused_labels(self: LabelDataComponent, image: SharedImageSet) None
set_default_label_config(self: LabelDataComponent, pixel_value: int) None
set_label_config(self: LabelDataComponent, pixel_value: int, config: LabelConfig) None
class imfusion.LayoutMode

Bases: pybind11_object

Members:

LAYOUT_ROWS

LAYOUT_FOCUS_PLUS_STACK

LAYOUT_FOCUS_PLUS_ROWS

LAYOUT_SIDE_BY_SIDE

LAYOUT_CUSTOM

LAYOUT_CUSTOM = <LayoutMode.LAYOUT_CUSTOM: 100>
LAYOUT_FOCUS_PLUS_ROWS = <LayoutMode.LAYOUT_FOCUS_PLUS_ROWS: 2>
LAYOUT_FOCUS_PLUS_STACK = <LayoutMode.LAYOUT_FOCUS_PLUS_STACK: 1>
LAYOUT_ROWS = <LayoutMode.LAYOUT_ROWS: 0>
LAYOUT_SIDE_BY_SIDE = <LayoutMode.LAYOUT_SIDE_BY_SIDE: 3>
__init__(self: LayoutMode, value: int) None
property name
property value
class imfusion.LicenseInfo

Bases: pybind11_object

Provides information about the currently used license.

__init__(*args, **kwargs)
property expiration_date

Date until the license is valid in ISO format or None if the license won’t expire.

property key
class imfusion.Mask

Bases: pybind11_object

Base interface for implementing polymorphic image masks.

class CreateOption

Bases: pybind11_object

Enumeration of available behavior for Mask::create_explicit_mask().

Members:

DEEP_COPY

SHALLOW_COPY_IF_POSSIBLE

DEEP_COPY = <CreateOption.DEEP_COPY: 0>
SHALLOW_COPY_IF_POSSIBLE = <CreateOption.SHALLOW_COPY_IF_POSSIBLE: 1>
__init__(self: CreateOption, value: int) None
property name
property value
DEEP_COPY = <CreateOption.DEEP_COPY: 0>
SHALLOW_COPY_IF_POSSIBLE = <CreateOption.SHALLOW_COPY_IF_POSSIBLE: 1>
__init__(*args, **kwargs)
create_explicit_mask(self: imfusion._bindings.Mask, image: imfusion._bindings.SharedImage, create_option: imfusion._bindings.Mask.CreateOption = <CreateOption.DEEP_COPY: 0>) MemImage

Creates an explicit mask representation of this mask for a given image.

is_compatible(self: Mask, arg0: SharedImage) bool

Returns True if the mask can be used with the given image or False otherwise.

mask_value(*args, **kwargs)

Overloaded function.

  1. mask_value(self: imfusion._bindings.Mask, coord: numpy.ndarray[numpy.int32[3, 1]], color: numpy.ndarray[numpy.float32[4, 1]]) -> int

Returns 0 if the given pixel is outside the mask (i.e. invisible/to be ignored) or a non-zero value if it is inside the mask (i.e. visible/to be considered).

  1. mask_value(self: imfusion._bindings.Mask, coord: numpy.ndarray[numpy.int32[3, 1]], value: float) -> int

Returns 0 if the given pixel is outside the mask (i.e. invisible/to be ignored) or a non-zero value if it is inside the mask (i.e. visible/to be considered).

property requires_pixel_value

Returns True if the mask_value() rely on the pixel value. If this method returns False, the mask_value() method can be safely used with only the coordinate.

class imfusion.MemImage

Bases: pybind11_object

A MemImage instance represents an image which resides in main memory.

The MemImage class supports the Buffer Protocol. This means that the underlying buffer can be wrapped in e.g. numpy without a copy:

>>> import numpy
>>> mem = MemImage(Image.BYTE, 10, 10)
>>> arr = numpy.array(mem, copy=False)
>>> arr.fill(0)
>>> numpy.sum(arr)
0

Be aware that most numpy operation create a copy of the data and don’t affect the original data:

>>> numpy.sum(numpy.add(arr, 1))
100
>>> numpy.sum(arr)
0

To update the buffer of a MemImage, use numpy.copyto:

>>> numpy.copyto(arr, numpy.add(arr, 1))
>>> numpy.sum(arr)
100

Alternatively use the out argument of certain numpy functions:

>>> numpy.add(arr, 1, out=arr)
array(...)
>>> numpy.sum(arr)
200
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.MemImage, type: imfusion._bindings.PixelType, width: int, height: int, slices: int = 1, channels: int = 1) -> None

  2. __init__(self: imfusion._bindings.MemImage, desc: imfusion._bindings.ImageDescriptor) -> None

Factory method to instantiate a MemImage from an ImageDescriptor. note This method does not initialize the underlying buffer

  1. __init__(self: imfusion._bindings.MemImage, array: numpy.ndarray[numpy.int8], greyscale: bool = False) -> None

Create a MemImage from a numpy.array.

The array must be contiguous and must have between 2 and 4 dimensions. The dimensions are interpreted as (slices, height, width, channels). Missing dimensions are set to one. The color dimension must always be present even for greyscale image in which case it would be 1.

Use the optional greyscale argument to specify that the color dimensions is missing and the buffer should be interpreted as greyscale.

The actual array data is copied into the MemImage.

  1. __init__(self: imfusion._bindings.MemImage, array: numpy.ndarray[numpy.uint8], greyscale: bool = False) -> None

  2. __init__(self: imfusion._bindings.MemImage, array: numpy.ndarray[numpy.int16], greyscale: bool = False) -> None

  3. __init__(self: imfusion._bindings.MemImage, array: numpy.ndarray[numpy.uint16], greyscale: bool = False) -> None

  4. __init__(self: imfusion._bindings.MemImage, array: numpy.ndarray[numpy.int32], greyscale: bool = False) -> None

  5. __init__(self: imfusion._bindings.MemImage, array: numpy.ndarray[numpy.uint32], greyscale: bool = False) -> None

  6. __init__(self: imfusion._bindings.MemImage, array: numpy.ndarray[numpy.float32], greyscale: bool = False) -> None

  7. __init__(self: imfusion._bindings.MemImage, array: numpy.ndarray[numpy.float64], greyscale: bool = False) -> None

apply_shift_and_scale(arr)

Return a copy of the array with storage values converted to original values. The dtype of the returned array is always DOUBLE.

astype(self: MemImage, image_type: object) MemImage

Create a copy of the current MemImage instance with the requested Image format.

This function accepts either: - an Image type (e.g. imfusion.Image.UINT); - most of the numpy’s dtypes (e.g. np.uint); - python’s float or int types.

If the requested Image format already matches the Image format of the current instance, then a clone of the current instance is returned.

property channels
clone(self: MemImage) MemImage
convert_to_gray(self: MemImage) MemImage
create_float(self: object, normalize: bool = True, calc_min_max: bool = True, apply_scale_shift: bool = False) object
crop(self: MemImage, width: int, height: int, slices: int = -1, ox: int = -1, oy: int = -1, oz: int = -1) MemImage
property dimension
property dimensions
downsample(self: imfusion._bindings.MemImage, dx: int, dy: int, dz: int = 1, zero_mask: bool = False, reduction_mode: imfusion._bindings.ReductionMode = <ReductionMode.AVERAGE: 1>) MemImage
property extent
flip(self: MemImage, dim: int) MemImage
property height
image_to_pixel(self: MemImage, world: ndarray[numpy.float64[3, 1]]) ndarray[numpy.float64[3, 1]]

Convert a 3D image coordinate to a pixel position.

image_to_pixel_matrix(self: MemImage) ndarray[numpy.float64[4, 4]]
invert(self: MemImage, use_image_range: bool) MemImage
property metric
property ndim
numpy()

Convenience method for converting a MemImage or a SharedImage into a newly created numpy array with scale and shift already applied.

Shift and scale may determine a complex change of pixel type prior the conversion into numpy array:

  • as a first rule, even if the type of shift and scale is float, they will still be considered as integers if they are representing integers (e.g. a shift of 2.000 will be treated as 2);

  • if shift and scale are such that the pixel values range (determined by the pixel_type) would not be fitting into the pixel_type, e.g. a negative pixel value but the type is unsigned, then the pixel_type will be promoted into a signed type if possible, otherwise into a single precision floating point type;

  • if shift and scale are such that the pixel values range (determined by the pixel_type) would be fitting into a demoted pixel_type, e.g. the type is signed but the range of pixel values is unsigned, then the pixel_type will be demoted;

  • if shift and scale do not certainly determine that all the possible pixel values (in the range determined by the pixel_type) would become integers, then the pixel_type will be promoted into a single precision floating point type.

  • in any case, the returned numpy array will be returned with type up to 32-bit integers. If the integer type would require more bits, then the resulting pixel_type will be DOUBLE.

Parameters:

self – instance of a MemImage or of a SharedImage

Returns:

numpy.ndarray

pad(self: MemImage, lower_left_front: ndarray[numpy.int32[3, 1]], upper_right_back: ndarray[numpy.int32[3, 1]], padding_mode: PaddingMode) MemImage
pixel_to_image(self: MemImage, pixel: ndarray[numpy.float64[3, 1]]) ndarray[numpy.float64[3, 1]]

Convert a 3D pixel position to an image coordinate.

property pixel_to_image_matrix
range_threshold(self: MemImage, inside_range: bool, lower_value: float, upper_value: float, use_original: bool = True, replace_with: float = 0) MemImage
resample(*args, **kwargs)

Overloaded function.

  1. resample(self: imfusion._bindings.MemImage, spacing_adjustment: imfusion._bindings.SpacingMode, spacing: numpy.ndarray[numpy.float64[3, 1]], zero_mask: bool = False, reduction_mode: imfusion._bindings.ReductionMode = <ReductionMode.AVERAGE: 1>, interpolation_mode: imfusion._bindings.InterpolationMode = <InterpolationMode.LINEAR: 1>, allowed_dimension_change: bool = False) -> imfusion._bindings.MemImage

  2. resample(self: imfusion._bindings.MemImage, dimensions: numpy.ndarray[numpy.int32[3, 1]], zero_mask: bool = False, reduction_mode: imfusion._bindings.ReductionMode = <ReductionMode.AVERAGE: 1>, interpolation_mode: imfusion._bindings.InterpolationMode = <InterpolationMode.LINEAR: 1>) -> imfusion._bindings.MemImage

resize(self: MemImage, width: int, height: int, slices: int, channels: int = 1) MemImage
rotate(*args, **kwargs)

Overloaded function.

  1. rotate(self: imfusion._bindings.MemImage, angle: int = 90, flip_dim: int = -1, axis: int = 2) -> imfusion._bindings.MemImage

  2. rotate(self: imfusion._bindings.MemImage, rot: numpy.ndarray[numpy.float64[3, 3]], tolerance: float = 0.0) -> imfusion._bindings.MemImage

property scale
property shape

Return a numpy compatible shape descripting the dimensions of this image.

The returned tuple has 4 entries: slices, height, width, channels

property shift
property slices
property spacing
threshold(self: MemImage, value: float, below: bool, apply_shift_scale: bool = True, merge_channels: bool = False, replace_with: float = 0) MemImage
property type
property width
static zeros(desc: ImageDescriptor) MemImage

Factory method to create a zero-initialized image

class imfusion.Mesh

Bases: Data

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.Mesh, mesh: imfusion._bindings.Mesh) -> None

  2. __init__(self: imfusion._bindings.Mesh, name: str = ‘’) -> None

add_face(self: Mesh, index: ndarray[numpy.int32[3, 1]], force: bool) int
add_vertex(self: Mesh, position: ndarray[numpy.float64[3, 1]]) int
property center
property extent
face_normal(self: Mesh, index: int) ndarray[numpy.float64[3, 1]]
face_vertices(self: Mesh, index: int) ndarray[numpy.int32[3, 1]]
property filename
halfedge_color(self: Mesh, vertex_index: int, face_index: int) ndarray[numpy.float32[4, 1]]
halfedge_normal(self: Mesh, vertex_index: int, face_index: int) ndarray[numpy.float64[3, 1]]
halfedge_vertices(self: Mesh, vertex_index: int, face_index: int) ndarray[numpy.int32[2, 1]]
property has_halfedge_colors
property has_halfedge_normals
property has_vertex_colors
property has_vertex_normals
is_closed(self: Mesh) bool
is_manifold(self: Mesh) bool
is_self_intersecting(self: Mesh) bool
is_vertex_manifold(self: Mesh, index: int) bool
is_watertight(self: Mesh, check_self_intersection: bool) bool
property number_of_faces
property number_of_vertices
remove_face(self: Mesh, index: int, remove_isolated_vertices: bool) bool
remove_faces(self: Mesh, indices: List[int], remove_isolated_vertices: bool) None
remove_halfedge_colors(self: Mesh) None
remove_halfedge_normals(self: Mesh) None
remove_vertex_colors(self: Mesh) None
remove_vertex_normals(self: Mesh) None
remove_vertices(self: Mesh, indices: List[int], remove_isolated_vertices: bool) None
set_halfedge_color(*args, **kwargs)

Overloaded function.

  1. set_halfedge_color(self: imfusion._bindings.Mesh, vertex_index: int, face_index: int, color: numpy.ndarray[numpy.float32[4, 1]]) -> None

  2. set_halfedge_color(self: imfusion._bindings.Mesh, vertex_index: int, face_index: int, color: numpy.ndarray[numpy.float32[3, 1]], alpha: float) -> None

set_halfedge_normal(self: Mesh, vertex_index: int, face_index: int, normal: ndarray[numpy.float64[3, 1]]) None
set_vertex(self: Mesh, index: int, vertex: ndarray[numpy.float64[3, 1]]) None
set_vertex_color(*args, **kwargs)

Overloaded function.

  1. set_vertex_color(self: imfusion._bindings.Mesh, index: int, color: numpy.ndarray[numpy.float32[4, 1]]) -> None

  2. set_vertex_color(self: imfusion._bindings.Mesh, index: int, color: numpy.ndarray[numpy.float32[3, 1]], alpha: float) -> None

set_vertex_normal(self: Mesh, index: int, normal: ndarray[numpy.float64[3, 1]]) None
vertex(self: Mesh, index: int) ndarray[numpy.float64[3, 1]]
vertex_color(self: Mesh, index: int) ndarray[numpy.float32[4, 1]]
vertex_normal(self: Mesh, index: int) ndarray[numpy.float64[3, 1]]
exception imfusion.MissingLicenseError

Bases: RuntimeError

class imfusion.Optimizer

Bases: pybind11_object

Object for non-linear optimization.

The current bindings are work in progress and therefore limited. They are so far mostly meant to be used for changing an existing optimizer rather than creating one from scratch.

class Mode

Bases: pybind11_object

Mode of operation when execute is called.

Members:

OPT : Standard optimization.

STUDY : Randomized study.

PLOT : Evaluate for 1D or 2D plot generation.

EVALUATE : Single evaluation.

EVALUATE = <Mode.EVALUATE: 3>
OPT = <Mode.OPT: 0>
PLOT = <Mode.PLOT: 2>
STUDY = <Mode.STUDY: 1>
__init__(self: Mode, value: int) None
property name
property value
__init__(*args, **kwargs)
abort(self: Optimizer) None

Request to abort the optimization.

property abort_eval

Abort after a certain number of cost function evaluations.

property abort_fun_tol

Abort if change in cost function value is becomes too small.

property abort_fun_val

Abort if this function value is reached.

property abort_par_tol

Abort if change in parameter values becomes too small.

property abort_time

Abort after a certain elapsed number of seconds.

property aborted

Whether the optimizer was aborted.

property best_val

Return best cost function value.

configuration(self: Optimizer) Properties

Retrieves the configuration of the object.

configure(self: Optimizer, arg0: Properties) None

Configures the object.

property dimension

Total number of parameters. The selection gets cleared when the dimension value is modified.

execute(self: Optimizer, x: List[float]) List[float]

Execute the optimization given a vector of initial parameters of full dimensionality.

property first_val

Return cost function value of first evaluation.

property minimizing

Whether the optimizer has a loss function (that it should minimize) or an objective function (that it should maximize).

property mode

Mode of operation when execute is called.

property num_eval

Return number of cost function evaluations computed so far.

property param_names

Names of the parameters.

property selection

Selected parameters.

set_bounds(*args, **kwargs)

Overloaded function.

  1. set_bounds(self: imfusion._bindings.Optimizer, bounds: float) -> None

Set the same symmetric bounds in all parameters. A value of zero disables the bounds.

  1. set_bounds(self: imfusion._bindings.Optimizer, lower_bounds: float, upper_bounds: float) -> None

Set the same lower and upper bounds for all parameters.

  1. set_bounds(self: imfusion._bindings.Optimizer, bounds: List[float]) -> None

Set individual symmetric bounds.

  1. set_bounds(self: imfusion._bindings.Optimizer, lower_bounds: List[float], upper_bounds: List[float]) -> None

Set individual lower and upper bounds.

  1. set_bounds(self: imfusion._bindings.Optimizer, bounds: List[Tuple[float, float]]) -> None

Set individual lower and upper bounds as a list of pairs.

set_logging_level(self: Optimizer, file_level: int | None = None, console_level: int | None = None) None

Set level of detail for logging to text file and the console. 0 = none (default), 1 = init/result, 2 = every evaluation, 3 = only final result after study.

property type

Type of optimizer (see doc/header).

class imfusion.PaddingMode

Bases: pybind11_object

Members:

CLAMP

MIRROR

ZERO

CLAMP = <PaddingMode.CLAMP: 2>
MIRROR = <PaddingMode.MIRROR: 1>
ZERO = <PaddingMode.ZERO: 0>
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.PaddingMode, value: int) -> None

  2. __init__(self: imfusion._bindings.PaddingMode, arg0: str) -> None

property name
property value
class imfusion.ParametricDeformation

Bases: Deformation

__init__(*args, **kwargs)
set_parameters(self: ParametricDeformation, parameters: List[float]) None
class imfusion.PixelType

Bases: pybind11_object

Members:

BYTE

UBYTE

SHORT

USHORT

INT

UINT

FLOAT

DOUBLE

HFLOAT

BYTE = <PixelType.BYTE: 5120>
DOUBLE = <PixelType.DOUBLE: 5130>
FLOAT = <PixelType.FLOAT: 5126>
HFLOAT = <PixelType.HFLOAT: 5131>
INT = <PixelType.INT: 5124>
SHORT = <PixelType.SHORT: 5122>
UBYTE = <PixelType.UBYTE: 5121>
UINT = <PixelType.UINT: 5125>
USHORT = <PixelType.USHORT: 5123>
__init__(self: PixelType, value: int) None
property name
property value
class imfusion.PluginInfo

Bases: pybind11_object

Provides information about a framework plugin.

__init__(*args, **kwargs)
property name
property path
class imfusion.PointCloud

Bases: Data

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.PointCloud) -> None

  2. __init__(self: imfusion._bindings.PointCloud, arg0: imfusion._bindings.PointCloud) -> None

property colors
property points
transform_point_cloud(self: PointCloud, transformation: ndarray[numpy.float64[4, 4]]) None
class imfusion.Properties

Bases: pybind11_object

Container for arbitrary properties, internally stored as strings.

The bindings provide two interfaces: a C++-like one based on param() and set_param(), and a more Pythonic interface using the [] operator. Both interfaces are equivalent and interchangeable.

Parameters can be set with the set_param method, e.g.:

>>> p = Properties()
>>> p.set_param('Spam', 5)

The ParamType will be set depending on the type of the value similar to C++. To retrieve a parameter, a value of the desired return type must be passed:

>>> spam = 0
>>> p.param('Spam', spam)
5

If the parameter doesn’t exists, the value of the second argument is returned:

>>> foo = 8
>>> p.param('Foo', foo)
8

The Properties object also exposes all its parameters as items, e.g. to add a new parameter just add a new key:

>>> p = Properties()
>>> p['spam'] = 5

When using the dictionary-like syntax with the basic types (bool, int, float, str and list), the returned values are correctly typed:

>>> type(p['spam'])
<class 'int'>

However, for matrix and vector types, the param() method has to be used which receives an extra variable of the same type that has to be returned:

>>> import numpy as np
>>> np_array = np.ones(3)
>>> p['foo'] = np_array
>>> p.param('foo', np_array)
array([1., 1., 1.])

In fact, the dictionary-like syntax would just return it as a string instead: >>> p[‘foo’] ‘1 1 1 ‘

Additionally, the attributes of parameters are available through the attributes() method:

>>> p.set_param_attributes('spam', 'max: 10')
>>> p.param_attributes('spam')
[('max', '10')]

A Properties object can be obtained from a dictionary:

>>> p = Properties({'spam': 5, 'eggs': True, 'sub': { 'eggs': False }})
>>> p['eggs']
True
>>> p['sub']['eggs']
False

There are two possible but slightly different ways to convert a Properties instance into a dictionary. The first method is by dict() casting, which returns a dictionary made by nested Properties, the second method is by calling the asdict() method, which returns a dictionary expanding also the nested Properties instances:

>>> dict(p)
{'spam': 5, 'eggs': True, 'sub': <imfusion._bindings.Properties object at 0x7fb0ac062b70>}
>>> p.asdict()
{'spam': 5, 'eggs': True, 'sub': {'eggs': False}}
__getitem__(self: Properties, arg0: str) object
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.Properties, name: str = ‘’) -> None

  2. __init__(self: imfusion._bindings.Properties, dictionary: dict) -> None

__setitem__(*args, **kwargs)

Overloaded function.

  1. __setitem__(self: imfusion._bindings.Properties, name: str, value: bool) -> None

  2. __setitem__(self: imfusion._bindings.Properties, name: str, value: int) -> None

  3. __setitem__(self: imfusion._bindings.Properties, name: str, value: float) -> None

  4. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[3, 3]]) -> None

  5. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[4, 4]]) -> None

  6. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[3, 4]]) -> None

  7. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[3, 3]]) -> None

  8. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[4, 4]]) -> None

  9. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[2, 1]]) -> None

  10. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[3, 1]]) -> None

  11. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[4, 1]]) -> None

  12. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[5, 1]]) -> None

  13. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[2, 1]]) -> None

  14. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[3, 1]]) -> None

  15. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[4, 1]]) -> None

  16. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.int32[2, 1]]) -> None

  17. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.int32[3, 1]]) -> None

  18. __setitem__(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.int32[4, 1]]) -> None

  19. __setitem__(self: imfusion._bindings.Properties, name: str, value: str) -> None

  20. __setitem__(self: imfusion._bindings.Properties, name: str, value: os.PathLike) -> None

  21. __setitem__(self: imfusion._bindings.Properties, name: str, value: List[str]) -> None

  22. __setitem__(self: imfusion._bindings.Properties, name: str, value: List[os.PathLike]) -> None

  23. __setitem__(self: imfusion._bindings.Properties, name: str, value: List[bool]) -> None

  24. __setitem__(self: imfusion._bindings.Properties, name: str, value: List[int]) -> None

  25. __setitem__(self: imfusion._bindings.Properties, name: str, value: List[float]) -> None

  26. __setitem__(self: imfusion._bindings.Properties, name: str, value: List[numpy.ndarray[numpy.float64[2, 1]]]) -> None

  27. __setitem__(self: imfusion._bindings.Properties, name: str, value: List[numpy.ndarray[numpy.float64[3, 1]]]) -> None

  28. __setitem__(self: imfusion._bindings.Properties, name: str, value: List[numpy.ndarray[numpy.float64[4, 1]]]) -> None

add_sub_properties(self: Properties, name: str) Properties
asdict(self: Properties) dict

Return the Properties as a dict.

The dictionary values have the correct type when they are basic (bool, int, float, str and list), all other param types are returned with a str type. Subproperties are turned into nested dicts.

clear(self: Properties) None
copy_from(self: Properties, arg0: Properties) None
get(self: Properties, key: str, default_value: object = None) object
get_name(self: Properties) str
items(self: Properties) list
keys(self: Properties) list
static load_from_json(path: str) Properties
static load_from_xml(path: str) Properties
param(*args, **kwargs)

Overloaded function.

  1. param(self: imfusion._bindings.Properties, name: str, value: bool) -> bool

  2. param(self: imfusion._bindings.Properties, name: str, value: int) -> int

  3. param(self: imfusion._bindings.Properties, name: str, value: float) -> float

  4. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[3, 3]]) -> numpy.ndarray[numpy.float64[3, 3]]

  5. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[4, 4]]) -> numpy.ndarray[numpy.float64[4, 4]]

  6. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[3, 4]]) -> numpy.ndarray[numpy.float64[3, 4]]

  7. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[3, 3]]) -> numpy.ndarray[numpy.float32[3, 3]]

  8. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[4, 4]]) -> numpy.ndarray[numpy.float32[4, 4]]

  9. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[2, 1]]) -> numpy.ndarray[numpy.float64[2, 1]]

  10. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[3, 1]]) -> numpy.ndarray[numpy.float64[3, 1]]

  11. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[4, 1]]) -> numpy.ndarray[numpy.float64[4, 1]]

  12. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[5, 1]]) -> numpy.ndarray[numpy.float64[5, 1]]

  13. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[2, 1]]) -> numpy.ndarray[numpy.float32[2, 1]]

  14. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[3, 1]]) -> numpy.ndarray[numpy.float32[3, 1]]

  15. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[4, 1]]) -> numpy.ndarray[numpy.float32[4, 1]]

  16. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.int32[2, 1]]) -> numpy.ndarray[numpy.int32[2, 1]]

  17. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.int32[3, 1]]) -> numpy.ndarray[numpy.int32[3, 1]]

  18. param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.int32[4, 1]]) -> numpy.ndarray[numpy.int32[4, 1]]

  19. param(self: imfusion._bindings.Properties, name: str, value: str) -> str

  20. param(self: imfusion._bindings.Properties, name: str, value: os.PathLike) -> os.PathLike

  21. param(self: imfusion._bindings.Properties, name: str, value: List[str]) -> List[str]

  22. param(self: imfusion._bindings.Properties, name: str, value: List[os.PathLike]) -> List[os.PathLike]

  23. param(self: imfusion._bindings.Properties, name: str, value: List[bool]) -> List[bool]

  24. param(self: imfusion._bindings.Properties, name: str, value: List[int]) -> List[int]

  25. param(self: imfusion._bindings.Properties, name: str, value: List[float]) -> List[float]

  26. param(self: imfusion._bindings.Properties, name: str, value: List[numpy.ndarray[numpy.float64[2, 1]]]) -> List[numpy.ndarray[numpy.float64[2, 1]]]

  27. param(self: imfusion._bindings.Properties, name: str, value: List[numpy.ndarray[numpy.float64[3, 1]]]) -> List[numpy.ndarray[numpy.float64[3, 1]]]

  28. param(self: imfusion._bindings.Properties, name: str, value: List[numpy.ndarray[numpy.float64[4, 1]]]) -> List[numpy.ndarray[numpy.float64[4, 1]]]

param_attributes(self: Properties, name: str) List[Tuple[str, str]]
params(self: Properties) List[str]

Return a list of all param names.

Params inside sub-properties will be prefixed with the name of the sub-properties (e.g. ‘sub/var’). If with_sub_params is false, only the top-level params are returned.

remove_param(self: Properties, name: str) None
save_to_json(self: Properties, path: str) None
save_to_xml(self: Properties, path: str) None
set_name(self: Properties, name: str) None
set_param(*args, **kwargs)

Overloaded function.

  1. set_param(self: imfusion._bindings.Properties, name: str, value: bool) -> None

  2. set_param(self: imfusion._bindings.Properties, name: str, value: bool, default: bool) -> None

  3. set_param(self: imfusion._bindings.Properties, name: str, value: int) -> None

  4. set_param(self: imfusion._bindings.Properties, name: str, value: int, default: int) -> None

  5. set_param(self: imfusion._bindings.Properties, name: str, value: float) -> None

  6. set_param(self: imfusion._bindings.Properties, name: str, value: float, default: float) -> None

  7. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[3, 3]]) -> None

  8. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[3, 3]], default: numpy.ndarray[numpy.float64[3, 3]]) -> None

  9. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[4, 4]]) -> None

  10. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[4, 4]], default: numpy.ndarray[numpy.float64[4, 4]]) -> None

  11. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[3, 4]]) -> None

  12. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[3, 4]], default: numpy.ndarray[numpy.float64[3, 4]]) -> None

  13. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[3, 3]]) -> None

  14. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[3, 3]], default: numpy.ndarray[numpy.float32[3, 3]]) -> None

  15. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[4, 4]]) -> None

  16. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[4, 4]], default: numpy.ndarray[numpy.float32[4, 4]]) -> None

  17. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[2, 1]]) -> None

  18. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[2, 1]], default: numpy.ndarray[numpy.float64[2, 1]]) -> None

  19. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[3, 1]]) -> None

  20. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[3, 1]], default: numpy.ndarray[numpy.float64[3, 1]]) -> None

  21. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[4, 1]]) -> None

  22. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[4, 1]], default: numpy.ndarray[numpy.float64[4, 1]]) -> None

  23. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[5, 1]]) -> None

  24. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float64[5, 1]], default: numpy.ndarray[numpy.float64[5, 1]]) -> None

  25. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[2, 1]]) -> None

  26. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[2, 1]], default: numpy.ndarray[numpy.float32[2, 1]]) -> None

  27. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[3, 1]]) -> None

  28. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[3, 1]], default: numpy.ndarray[numpy.float32[3, 1]]) -> None

  29. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[4, 1]]) -> None

  30. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.float32[4, 1]], default: numpy.ndarray[numpy.float32[4, 1]]) -> None

  31. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.int32[2, 1]]) -> None

  32. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.int32[2, 1]], default: numpy.ndarray[numpy.int32[2, 1]]) -> None

  33. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.int32[3, 1]]) -> None

  34. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.int32[3, 1]], default: numpy.ndarray[numpy.int32[3, 1]]) -> None

  35. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.int32[4, 1]]) -> None

  36. set_param(self: imfusion._bindings.Properties, name: str, value: numpy.ndarray[numpy.int32[4, 1]], default: numpy.ndarray[numpy.int32[4, 1]]) -> None

  37. set_param(self: imfusion._bindings.Properties, name: str, value: str) -> None

  38. set_param(self: imfusion._bindings.Properties, name: str, value: str, default: str) -> None

  39. set_param(self: imfusion._bindings.Properties, name: str, value: os.PathLike) -> None

  40. set_param(self: imfusion._bindings.Properties, name: str, value: os.PathLike, default: os.PathLike) -> None

  41. set_param(self: imfusion._bindings.Properties, name: str, value: List[str]) -> None

  42. set_param(self: imfusion._bindings.Properties, name: str, value: List[str], default: List[str]) -> None

  43. set_param(self: imfusion._bindings.Properties, name: str, value: List[os.PathLike]) -> None

  44. set_param(self: imfusion._bindings.Properties, name: str, value: List[os.PathLike], default: List[os.PathLike]) -> None

  45. set_param(self: imfusion._bindings.Properties, name: str, value: List[bool]) -> None

  46. set_param(self: imfusion._bindings.Properties, name: str, value: List[bool], default: List[bool]) -> None

  47. set_param(self: imfusion._bindings.Properties, name: str, value: List[int]) -> None

  48. set_param(self: imfusion._bindings.Properties, name: str, value: List[int], default: List[int]) -> None

  49. set_param(self: imfusion._bindings.Properties, name: str, value: List[float]) -> None

  50. set_param(self: imfusion._bindings.Properties, name: str, value: List[float], default: List[float]) -> None

  51. set_param(self: imfusion._bindings.Properties, name: str, value: List[numpy.ndarray[numpy.float64[2, 1]]]) -> None

  52. set_param(self: imfusion._bindings.Properties, name: str, value: List[numpy.ndarray[numpy.float64[2, 1]]], default: List[numpy.ndarray[numpy.float64[2, 1]]]) -> None

  53. set_param(self: imfusion._bindings.Properties, name: str, value: List[numpy.ndarray[numpy.float64[3, 1]]]) -> None

  54. set_param(self: imfusion._bindings.Properties, name: str, value: List[numpy.ndarray[numpy.float64[3, 1]]], default: List[numpy.ndarray[numpy.float64[3, 1]]]) -> None

  55. set_param(self: imfusion._bindings.Properties, name: str, value: List[numpy.ndarray[numpy.float64[4, 1]]]) -> None

  56. set_param(self: imfusion._bindings.Properties, name: str, value: List[numpy.ndarray[numpy.float64[4, 1]]], default: List[numpy.ndarray[numpy.float64[4, 1]]]) -> None

set_param_attributes(self: Properties, name: str, attributes: str) None
sub_properties(*args, **kwargs)

Overloaded function.

  1. sub_properties(self: imfusion._bindings.Properties, name: str, create_if_doesnt_exist: bool = False) -> imfusion._bindings.Properties

  2. sub_properties(self: imfusion._bindings.Properties) -> List[imfusion._bindings.Properties]

sub_properties_all(self: Properties, name: str) list
values(self: Properties) list
class imfusion.RTStructureDataComponent

Bases: DataComponentBase

DataComponent for PointClouds loaded from a DICOM RTStructureSet.

Provides information about the original structure/grouping of the points. See RTStructureIoAlgorithm for details about how RTStructureSets are loaded.

Warning

Since this component uses fixed indices into the PointCloud’s points structure, it can only be used if the PointCloud remains unchanged!

class Contour

Bases: pybind11_object

Represents a single item in the original ‘Contour Sequence’ (3006,0040).

__init__(*args, **kwargs)
property length
property start_index
property type
class GeometryType

Bases: pybind11_object

Defines how the points of a contour should be interpreted.

Members:

POINT

OPEN_PLANAR

CLOSED_PLANAR

OPEN_NONPLANAR

CLOSED_PLANAR = <GeometryType.CLOSED_PLANAR: 2>
OPEN_NONPLANAR = <GeometryType.OPEN_NONPLANAR: 3>
OPEN_PLANAR = <GeometryType.OPEN_PLANAR: 1>
POINT = <GeometryType.POINT: 0>
__init__(self: GeometryType, value: int) None
property name
property value
class ROIGenerationAlgorithm

Bases: pybind11_object

Defines how the RT structure was generated

Members:

UNKNOWN

AUTOMATIC

SEMI_AUTOMATIC

MANUAL

AUTOMATIC = <ROIGenerationAlgorithm.AUTOMATIC: 1>
MANUAL = <ROIGenerationAlgorithm.MANUAL: 3>
SEMI_AUTOMATIC = <ROIGenerationAlgorithm.SEMI_AUTOMATIC: 2>
UNKNOWN = <ROIGenerationAlgorithm.UNKNOWN: 0>
__init__(self: ROIGenerationAlgorithm, value: int) None
property name
property value
__init__(self: RTStructureDataComponent) None
property color
property contours
property generation_algorithm
property referenced_frame_of_reference_UID
class imfusion.RealWorldMappingDataComponent

Bases: DataComponentBase

class Mapping

Bases: pybind11_object

__init__(self: Mapping) None
property intercept
original_to_real_world(self: Mapping, value: float) float
property slope
storage_to_real_world(self: Mapping, image_descriptor: ImageDescriptor, value: float) float
property type
property unit
class MappingType

Bases: pybind11_object

Members:

REAL_WORLD_VALUES

STANDARDIZED_UPTAKE_VALUES

REAL_WORLD_VALUES = <MappingType.REAL_WORLD_VALUES: 0>
STANDARDIZED_UPTAKE_VALUES = <MappingType.STANDARDIZED_UPTAKE_VALUES: 1>
__init__(self: MappingType, value: int) None
property name
property value
REAL_WORLD_VALUES = <MappingType.REAL_WORLD_VALUES: 0>
STANDARDIZED_UPTAKE_VALUES = <MappingType.STANDARDIZED_UPTAKE_VALUES: 1>
__init__(self: RealWorldMappingDataComponent) None
property mappings
property units
class imfusion.ReductionMode

Bases: pybind11_object

Members:

LOOKUP

AVERAGE

MINIMUM

MAXIMUM

AVERAGE = <ReductionMode.AVERAGE: 1>
LOOKUP = <ReductionMode.LOOKUP: 0>
MAXIMUM = <ReductionMode.MAXIMUM: 3>
MINIMUM = <ReductionMode.MINIMUM: 2>
__init__(self: ReductionMode, value: int) None
property name
property value
class imfusion.ReferenceImageDataComponent

Bases: DataComponentBase

__init__(*args, **kwargs)
property reference
class imfusion.ReferencedInstancesComponent

Bases: DataComponentBase

DataComponent to store DICOM instances that are referenced by the dataset.

A DICOM dataset can reference a number of other DICOM datasets that are somehow related. The references in this component are determined by the ReferencedSeriesSequence.

__init__(self: ReferencedInstancesComponent) None
is_referencing(*args, **kwargs)

Overloaded function.

  1. is_referencing(self: imfusion._bindings.ReferencedInstancesComponent, arg0: imfusion._bindings.SourceInfoComponent) -> bool

    Returns true if the instances of the given SourceInfoComponent are referenced by this component.

    The instances and references have to only intersect for this to return true. This way, e.g. a segmentation would be considered referencing a CT if it only overlaps in a view slices.

  2. is_referencing(self: imfusion._bindings.ReferencedInstancesComponent, arg0: imfusion._bindings.SharedImageSet) -> bool

    Convenient method that calls the above method with SourceInfoComponent of sis.

    Only returns true if all elementwise SourceInfoComponents are referenced.

class imfusion.RegionOfInterest

Bases: pybind11_object

__init__(self: RegionOfInterest, arg0: ndarray[numpy.int32[3, 1]], arg1: ndarray[numpy.int32[3, 1]]) None
property offset
property size
class imfusion.Selection

Bases: Configurable

Utility class for describing a selection of elements out of a set. Conceptually, a Selection pairs a list of bools describing selected items with the index of a “focus” item and provides syntactic sugar on top. For instance, the set of selected items could define which ones to show in general while the focus item is additionally highlighted. The class is fully separate from the item set of which it describes the selection. This means for instance that it cannot know the actual number of items in the set and the user/parent class must manually make sure that they match. Also, a Selection only manages indices and offers no way of accessing the underlying elements. In order to iterate over all selected indices, you can do for instance the following:

for index in range(selection.start, selection.stop):
        if selection[index]:
                ...

The same effect can also be achieved in a much more terse fashion:

for selected_index in selection.selected_indices():
...

For convenience, the selection can also be converted to a slice object (if the selection has a regular spacing, see below):

selected_subset = container[selection.slice()]

Sometimes it can be more convenient to “thin out” a selection by only selecting every N-th element. To this end, the Selection constructor takes the arguments start, stop and step. Setting step to N will only select every N-th element, mimicking the signature of range, slice, etc.

ALL = <NonePolicy.ALL: 2>
EMPTY = <NonePolicy.EMPTY: 0>
FOCUS = <NonePolicy.FOCUS: 1>
class NonePolicy

Bases: pybind11_object

Members:

EMPTY

FOCUS

ALL

ALL = <NonePolicy.ALL: 2>
EMPTY = <NonePolicy.EMPTY: 0>
FOCUS = <NonePolicy.FOCUS: 1>
__init__(self: NonePolicy, value: int) None
property name
property value
__getitem__(self: Selection, index: int) bool
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.Selection) -> None

  2. __init__(self: imfusion._bindings.Selection, stop: int) -> None

  3. __init__(self: imfusion._bindings.Selection, start: int, stop: int, step: int = 1) -> None

  4. __init__(self: imfusion._bindings.Selection, indices: List[int]) -> None

__setitem__(self: Selection, index: int, selected: bool) None
clamp(self: Selection, last_selected_index: int) None
property first_selected
property focus
property has_regular_skip
property is_none
is_selected(self: Selection, index: int, none_policy: NonePolicy) bool
property last_selected
property range
select_only(self: Selection, index: int) None
select_up_to(self: Selection, stop: int) None
property selected_indices
set_first_last_skip(self: Selection, arg0: int, arg1: int, arg2: int) None
property size
property skip
property start
property step
property stop
class imfusion.SharedImage

Bases: pybind11_object

A SharedImage instance represents an image that resides in different memory locations, i.e. in CPU memory or GPU memory.

A SharedImage can be directly converted from and to a numpy array:

>>> import numpy
>>> img = SharedImage(numpy.ones([10, 10, 1], dtype='uint8'))
>>> arr = numpy.array(img)

See MemImage for details.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: imfusion._bindings.SharedImage, mem_image: imfusion._bindings.MemImage) -> None

  2. __init__(self: imfusion._bindings.SharedImage, desc: imfusion._bindings.ImageDescriptor) -> None

  3. __init__(self: imfusion._bindings.SharedImage, desc: imfusion._bindings.ImageDescriptorWorld) -> None

  4. __init__(self: imfusion._bindings.SharedImage, type: imfusion._bindings.PixelType, width: int, height: int, slices: int = 1, channels: int = 1) -> None

  5. __init__(self: imfusion._bindings.SharedImage, array: numpy.ndarray[numpy.int8], greyscale: bool = False) -> None

  6. __init__(self: imfusion._bindings.SharedImage, array: numpy.ndarray[numpy.uint8], greyscale: bool = False) -> None

  7. __init__(self: imfusion._bindings.SharedImage, array: numpy.ndarray[numpy.int16], greyscale: bool = False) -> None

  8. __init__(self: imfusion._bindings.SharedImage, array: numpy.ndarray[numpy.uint16], greyscale: bool = False) -> None

  9. __init__(self: imfusion._bindings.SharedImage, array: numpy.ndarray[numpy.int32], greyscale: bool = False) -> None

  10. __init__(self: imfusion._bindings.SharedImage, array: numpy.ndarray[numpy.uint32], greyscale: bool = False) -> None

  11. __init__(self: imfusion._bindings.SharedImage, array: numpy.ndarray[numpy.float32], greyscale: bool = False) -> None

  12. __init__(self: imfusion._bindings.SharedImage, array: numpy.ndarray[numpy.float64], greyscale: bool = False) -> None

apply_shift_and_scale(arr)

Return a copy of the array with storage values converted to original values. The dtype of the returned array is always DOUBLE.

argmax(self: SharedImage) List[ndarray[numpy.int32[4, 1]]]

Return a list of the indices of maximum values, channel-wise. The indices are represented as (x, y, z, image index).

argmin(self: SharedImage) List[ndarray[numpy.int32[4, 1]]]

Return a list of the indices of minimum values, channel-wise. The indices are represented as (x, y, z, image index).

assign_array(arr, casting='same_kind')

Copies the contents of arr to the SharedImage. Automatically calls setDirtyMem.

The casting parameters behaves like numpy.copyto.

astype(self: SharedImage, pixelType: object) SharedImage

Create a copy of the current SharedImage instance with the requested Image format.

This function accepts either: - a PixelType (e.g. imfusion.PixelType.UInt); - most of the numpy’s dtypes (e.g. np.uint); - python’s float or int types.

If the requested PixelType already matches the PixelType of the provided SharedImage, then a clone of the current instance is returned.

channel_swizzle(self: SharedImage, indices: List[int]) SharedImage

Reorders the channels of an image based on the input indices, e.g. indices[0] will correspond to the first channel of the output image.

Parameters:

indices (List[int]) – List of channels indices to swizzle the channels of SharedImage.

property channels
clone(self: SharedImage) SharedImage
property deformation
property descriptor
property descriptor_world
dimension(self: SharedImage) int
property extent
property height
property kind
property mask
property matrix

The transformation matrix from world space to image space.

max(self: SharedImage) ndarray[numpy.float64[m, 1]]

Return the list of the maximum elements of images, channel-wise.

mean(self: SharedImage) ndarray[numpy.float64[m, 1]]

Return a list of channel-wise average of image elements.

mem(self: SharedImage) MemImage
property metric
min(self: SharedImage) ndarray[numpy.float64[m, 1]]

Return the list of the minimum elements of images, channel-wise.

property modality
property ndim
norm(self: SharedImage, order: object = 2) ndarray[numpy.float64[m, 1]]

Returns the norm of an image instance, channel-wise.

Parameters:

order (int, float, 'inf') – Order of the norm. Default is L2 norm.

numpy()

Convenience method for converting a MemImage or a SharedImage into a newly created numpy array with scale and shift already applied.

Shift and scale may determine a complex change of pixel type prior the conversion into numpy array:

  • as a first rule, even if the type of shift and scale is float, they will still be considered as integers if they are representing integers (e.g. a shift of 2.000 will be treated as 2);

  • if shift and scale are such that the pixel values range (determined by the pixel_type) would not be fitting into the pixel_type, e.g. a negative pixel value but the type is unsigned, then the pixel_type will be promoted into a signed type if possible, otherwise into a single precision floating point type;

  • if shift and scale are such that the pixel values range (determined by the pixel_type) would be fitting into a demoted pixel_type, e.g. the type is signed but the range of pixel values is unsigned, then the pixel_type will be demoted;

  • if shift and scale do not certainly determine that all the possible pixel values (in the range determined by the pixel_type) would become integers, then the pixel_type will be promoted into a single precision floating point type.

  • in any case, the returned numpy array will be returned with type up to 32-bit integers. If the integer type would require more bits, then the resulting pixel_type will be DOUBLE.

Parameters:

self – instance of a MemImage or of a SharedImage

Returns:

numpy.ndarray

pixel_to_world(self: SharedImage, pixel_coordinates: ndarray[numpy.float64[3, 1]]) ndarray[numpy.float64[3, 1]]
property pixel_to_world_matrix
prepare(self: SharedImage, shift_only: bool = False) None
prod(self: SharedImage) ndarray[numpy.float64[m, 1]]

Return a list of channel-wise production of image elements.

property scale
set_dirty_mem(self: SharedImage) None
property shape

Return a numpy compatible shape descripting the dimensions of this image.

The returned tuple has 4 entries: slices, height, width, channels

property shift
property slices
property spacing
sum(self: SharedImage) ndarray[numpy.float64[m, 1]]

Return a list of channel-wise sum of image elements.

sync(self: SharedImage) None
torch(device: device = None, dtype: dtype = None,