imfusion#

imfusion - ImFusion SDK for Medical Imaging#

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

exception imfusion.FileNotFoundError#

Bases: FileNotFoundError

exception imfusion.IOError#

Bases: OSError

exception imfusion.IncompatibleError#

Bases: ValueError

exception imfusion.MissingLicenseError#

Bases: RuntimeError

class imfusion.Algorithm#

Bases: Configurable

Re-exported from imfusion.algorithm.Algorithm.

class imfusion.BoundImageDescriptor#

Bases: pybind11_object

Immutable version of ImageDescriptor bound to an image.

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

clone(self: BoundImageDescriptor) → ImageDescriptor#

Return a mutable copy as ImageDescriptor.

coord(self: BoundImageDescriptor, index: SupportsInt | SupportsIndex) → Annotated[numpy.typing.NDArray[numpy.int32], '[4, 1]']#

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

has_index(self: BoundImageDescriptor, x: SupportsInt | SupportsIndex, y: SupportsInt | SupportsIndex, z: SupportsInt | SupportsIndex = 0, c: SupportsInt | SupportsIndex = 0) → bool#

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

image_to_pixel(self: BoundImageDescriptor, world: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert 3D image coordinates to pixel/voxel position

index(self: BoundImageDescriptor, x: SupportsInt | SupportsIndex, y: SupportsInt | SupportsIndex, z: SupportsInt | SupportsIndex = 0, c: SupportsInt | SupportsIndex = 0) → int#

Return a linear memory index for a pixel or voxel

is_compatible(self: BoundImageDescriptor, 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

is_valid(self: BoundImageDescriptor) → bool#

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

original_to_storage(self: BoundImageDescriptor, value: SupportsFloat | SupportsIndex) → 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: BoundImageDescriptor, pixel: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert a 3D pixel/voxel position to image coordinates

storage_to_original(self: BoundImageDescriptor, value: SupportsFloat | SupportsIndex) → 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 byte_size#

Return the size of the image in bytes

Type:

int

property channels#
Type:

int

property configuration#

Serialize an image descriptor to Properties

Type:

Properties

property dimension#
Type:

int

property dimensions#
Type:

Annotated[numpy.typing.NDArray[numpy.int32], ”[3, 1]”]

property extent#
Type:

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

property height#
Type:

int

property image_to_pixel_matrix#

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

Type:

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

property image_to_texture_matrix#

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

Type:

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

property is_metric#
Type:

bool

property pixel_to_image_matrix#

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

Type:

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

property pixel_type#
Type:

PixelType

property scale#
Type:

float

property shift#
Type:

float

property size#

Return the size (number of elements) of the image

Type:

int

property slices#
Type:

int

property spacing#

Physical extent of each voxel in [mm] stored as a namedtuple. Spacing for a specific dimension can be accessed via x, y, and z attributes.

Returns:

Named tuple with x, y, and z attributes.

Return type:

(collections.namedtuple)

Type:

Spacing

property texture_to_image_matrix#

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

Type:

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

property type_size#

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

Type:

int

property width#
Type:

int

class imfusion.BoundImageDescriptorWorld#

Bases: pybind11_object

Immutable version of ImageDescriptorWorld bound to an image.

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 for image resampling, or for one-line creation of a new SharedImage.

clone(self: BoundImageDescriptorWorld) → ImageDescriptorWorld#

Return a mutable copy as ImageDescriptorWorld.

image_to_pixel(self: BoundImageDescriptorWorld, world: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert 3D image coordinates to pixel/voxel position

is_spatially_compatible(self: BoundImageDescriptorWorld, 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.

pixel_to_image(self: BoundImageDescriptorWorld, pixel: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert a 3D pixel/voxel position to image coordinates

pixel_to_world(self: BoundImageDescriptorWorld, pixel: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert a 3D pixel/voxel position to world coordinates

world_to_pixel(self: BoundImageDescriptorWorld, world: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert 3D world coordinates to pixel/voxel position

property descriptor#
Type:

BoundImageDescriptor

property image_to_pixel_matrix#

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

Type:

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

property image_to_texture_matrix#

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

Type:

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

property matrix_from_world#

Return the matrix transforming world coordinates to image coordinates

Type:

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

property matrix_to_world#

Return the matrix transforming image coordinates to world coordinates

Type:

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

property pixel_to_image_matrix#

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

Type:

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

property pixel_to_world_matrix#

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

Type:

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

property texture_to_image_matrix#

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

Type:

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

property texture_to_world_matrix#

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

Type:

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

property world_to_pixel_matrix#

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

Type:

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

property world_to_texture_matrix#

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

Type:

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

class imfusion.Configurable#

Bases: pybind11_object

configuration(self: Configurable) → Properties#
configure(self: Configurable, properties: Properties) → None#
configure_defaults(self: Configurable) → None#
class imfusion.CroppingMask(self: CroppingMask, dimensions: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'])#

Bases: Mask

Simple axis-aligned cropping mask with optional roundness.

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

Bases: Enum

XY = 0#
XYZ = 3#
XZ = 2#
YZ = 1#
XY = 0#
XYZ = 3#
XZ = 2#
YZ = 1#
property border#

Number of pixels cropped away

Type:

tuple[Annotated[numpy.typing.NDArray[numpy.int32], ”[3, 1]”], Annotated[numpy.typing.NDArray[numpy.int32], ”[3, 1]”]]

property inverted#

Whether the mask is inverted

Type:

bool

property roundness#

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

Type:

float

property roundness_dims#

Which dimensions the roundness parameter should be applied

Type:

RoundDims

class imfusion.Data#

Bases: pybind11_object

Re-exported from imfusion.data.Data.

class imfusion.DataGroup#

Bases: Data

Re-exported from imfusion.data.DataGroup.

class imfusion.Deformation#

Bases: pybind11_object

configuration(self: Deformation) → Properties#
configure(self: Deformation, properties: Properties) → None#
displace_point(self: Deformation, at: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#
displace_points(self: Deformation, at: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']]) → list[Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']]#
displacement(self: Deformation, at: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#
displacement(self: Deformation, at: Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']
displacement(self: Deformation, at: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']]) → list[Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']]

Function overload documentation:

displacement(self: Deformation, at: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']
displacement(self: Deformation, at: Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']
displacement(self: Deformation, at: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']]) → list[Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']]
class imfusion.ExplicitIntensityMask(self: ExplicitIntensityMask, ref_image: SharedImage, mask_image: SharedImage)#

Bases: Mask

Combination of an ExplicitMask and an IntensityMask.

property border_clamp#

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

Type:

bool

property border_color#

Border color (normalized for integer images)

Type:

float

property intensity_range#

Range of allowed pixel values

Type:

Annotated[numpy.typing.NDArray[numpy.float32], ”[2, 1]”]

class imfusion.ExplicitMask(*args, **kwargs)#

Bases: Mask

Mask holding an individual mask value for every pixel.

Function overload documentation:

__init__(self: ExplicitMask, width: SupportsInt | SupportsIndex, height: SupportsInt | SupportsIndex, slices: SupportsInt | SupportsIndex, initial: SupportsInt | SupportsIndex = 0) → None
__init__(self: ExplicitMask, dimensions: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'], initial: SupportsInt | SupportsIndex = 0) → None
__init__(self: ExplicitMask, mask_image: MemImage) → None
mask_image(self: ExplicitMask) → SharedImage#

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

class imfusion.FrameworkInfo#

Bases: pybind11_object

Provides general information about the framework.

property framework_version#
Type:

object

property license#
Type:

LicenseInfo

property opengl#
Type:

GlPlatformInfo | None

property plugins#
Type:

list[PluginInfo]

class imfusion.FreeFormDeformation#

Bases: Deformation

configuration(self: FreeFormDeformation) → Properties#
configure(self: FreeFormDeformation, arg0: Properties) → None#
control_points(self: FreeFormDeformation) → list[Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']]#

Get current control point locations (including displacement)

property displacements#

Displacement in mm of all control points

Type:

list[Annotated[numpy.typing.NDArray[numpy.float32], ”[3, 1]”]]

property grid_spacing#

Spacing of the control point grid

Type:

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

property grid_transformation#

Transformation matrix of the control point grid

Type:

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

property subdivisions#

Subdivisions of the control point grid

Type:

Annotated[numpy.typing.NDArray[numpy.int32], ”[3, 1]”]

class imfusion.GlPlatformInfo#

Bases: pybind11_object

Provides information about the underlying OpenGL driver.

property extensions#
Type:

list[str]

property renderer#
Type:

str

property vendor#
Type:

str

property version#
Type:

str

class imfusion.ImageDescriptor(*args, **kwargs)#

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

Function overload documentation:

__init__(self: ImageDescriptor) → None
__init__(self: ImageDescriptor, type: PixelType, dimensions: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'], channels: SupportsInt | SupportsIndex = 1) → None
__init__(self: ImageDescriptor, type: PixelType, width: SupportsInt | SupportsIndex, height: SupportsInt | SupportsIndex, slices: SupportsInt | SupportsIndex = 1, channels: SupportsInt | SupportsIndex = 1) → None
__init__(self: ImageDescriptor, bound_image_descriptor: BoundImageDescriptor) → None
clone(self: ImageDescriptor) → ImageDescriptor#

Return a mutable copy of this descriptor.

configure(self: ImageDescriptor, properties: Properties) → None#

Deserialize an image descriptor from Properties

coord(self: ImageDescriptor, index: SupportsInt | SupportsIndex) → Annotated[numpy.typing.NDArray[numpy.int32], '[4, 1]']#

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

has_index(self: ImageDescriptor, x: SupportsInt | SupportsIndex, y: SupportsInt | SupportsIndex, z: SupportsInt | SupportsIndex = 0, c: SupportsInt | SupportsIndex = 0) → bool#

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

image_to_pixel(self: ImageDescriptor, world: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert 3D image coordinates to pixel/voxel position

index(self: ImageDescriptor, x: SupportsInt | SupportsIndex, y: SupportsInt | SupportsIndex, z: SupportsInt | SupportsIndex = 0, c: SupportsInt | SupportsIndex = 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

is_valid(self: ImageDescriptor) → bool#

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

original_to_storage(self: ImageDescriptor, value: SupportsFloat | SupportsIndex) → 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: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert a 3D pixel/voxel position to image coordinates

set_dimensions(self: ImageDescriptor, dimensions: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'], channels: SupportsInt | SupportsIndex = 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: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]'], is_metric: bool) → None#

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

storage_to_original(self: ImageDescriptor, value: SupportsFloat | SupportsIndex) → 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 byte_size#

Return the size of the image in bytes

Type:

int

property channels#
Type:

int

property configuration#

Serialize an image descriptor to Properties

Type:

Properties

property dimension#
Type:

int

property dimensions#
Type:

Annotated[numpy.typing.NDArray[numpy.int32], ”[3, 1]”]

property extent#
Type:

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

property height#
Type:

int

property image_to_pixel_matrix#

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

Type:

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

property image_to_texture_matrix#

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

Type:

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

property is_metric#
Type:

bool

property pixel_to_image_matrix#

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

Type:

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

property pixel_type#
Type:

PixelType

property scale#
Type:

float

property shift#
Type:

float

property size#

Return the size (number of elements) of the image

Type:

int

property slices#
Type:

int

property spacing#

Physical extent of each voxel in [mm] stored as a namedtuple. Spacing for a specific dimension can be accessed via x, y, and z attributes.

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).

Returns:

Named tuple with x, y, and z attributes.

Return type:

(collections.namedtuple)

Type:

Spacing

property texture_to_image_matrix#

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

Type:

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

property type_size#

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

Type:

int

property width#
Type:

int

class imfusion.ImageDescriptorWorld(*args, **kwargs)#

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 for image resampling, or for one-line creation of a new SharedImage.

Function overload documentation:

__init__(self: ImageDescriptorWorld, descriptor: ImageDescriptor, matrix_to_world: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]']) → None
__init__(self: ImageDescriptorWorld, shared_image: SharedImage) → None
__init__(self: ImageDescriptorWorld, bound_image_descriptor_world: BoundImageDescriptorWorld) → None
clone(self: ImageDescriptorWorld) → ImageDescriptorWorld#

Returns a copy of this world descriptor.

image_to_pixel(self: ImageDescriptorWorld, world: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert 3D image coordinates to pixel/voxel position

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.

pixel_to_image(self: ImageDescriptorWorld, pixel: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert a 3D pixel/voxel position to image coordinates

pixel_to_world(self: ImageDescriptorWorld, pixel: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert a 3D pixel/voxel position to world coordinates

world_to_pixel(self: ImageDescriptorWorld, world: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert 3D world coordinates to pixel/voxel position

property descriptor#
Type:

ImageDescriptor

property image_to_pixel_matrix#

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

Type:

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

property image_to_texture_matrix#

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

Type:

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

property matrix_from_world#
Type:

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

property matrix_to_world#
Type:

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

property pixel_to_image_matrix#

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

Type:

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

property pixel_to_world_matrix#

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

Type:

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

property texture_to_image_matrix#

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

Type:

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

property texture_to_world_matrix#

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

Type:

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

property world_to_pixel_matrix#

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

Type:

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

property world_to_texture_matrix#

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

Type:

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

class imfusion.IntensityMask(*args, **kwargs)#

Bases: Mask

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

Function overload documentation:

__init__(self: IntensityMask, type: PixelType, value: SupportsFloat | SupportsIndex = 0.0) → None
__init__(self: IntensityMask, image: MemImage, value: SupportsFloat | SupportsIndex = 0.0) → None
property masked_value#

Specific value that should be masked

Type:

float

property masked_value_range#

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

Type:

tuple[float, float]

property type#
Type:

PixelType

property use_range#

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

Type:

bool

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

Bases: Enum

LINEAR = 1#
NEAREST = 0#
class imfusion.InversionComponent#

Bases: DataComponentBase

Data component for storing the information needed to invert an operation.

class InversionInfo#

Bases: pybind11_object

Struct for storing the information needed to invert an operation.

property context_properties#
Type:

Properties | None

property identifier#
Type:

str

property operation_name#
Type:

str

property operation_properties#
Type:

Properties

get_all_inversion_infos(self: InversionComponent, arg0: str) → list[InversionInfo]#
get_inversion_info(self: InversionComponent, arg0: str) → InversionInfo#
class imfusion.LicenseInfo#

Bases: pybind11_object

Provides information about the currently used license.

property expiration_date#

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

Type:

str | None

property key#
Type:

str

class imfusion.Mask#

Bases: pybind11_object

Base interface for implementing polymorphic image masks.

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

Bases: Enum

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

DEEP_COPY = 0#
SHALLOW_COPY_IF_POSSIBLE = 1#
create_explicit_mask(self: Mask, image: SharedImage, create_option: CreateOption = CreateOption.DEEP_COPY) → 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(self: Mask, coord: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'], color: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 1]']) → int#
mask_value(self: Mask, coord: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'], value: SupportsFloat | SupportsIndex) → int

Function overload documentation:

mask_value(self: Mask, coord: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'], color: Annotated[numpy.typing.ArrayLike, 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).

mask_value(self: Mask, coord: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'], value: SupportsFloat | SupportsIndex) → 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).

DEEP_COPY = 0#
SHALLOW_COPY_IF_POSSIBLE = 1#
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.

Type:

bool

class imfusion.MemImage(*args, **kwargs)#

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:

>>> mem = imfusion.MemImage(imfusion.PixelType.BYTE, 10, 10)
>>> arr = np.array(mem, copy=False)
>>> arr.fill(0)
>>> int(np.sum(arr))
0

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

>>> int(np.sum(np.add(arr, 1)))
100
>>> int(np.sum(arr))
0

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

>>> np.copyto(arr, np.add(arr, 1))
>>> int(np.sum(arr))
100

Alternatively use the out argument of certain numpy functions:

>>> np.add(arr, 1, out=arr)
array(...)
>>> int(np.sum(arr))
200

Function overload documentation:

__init__(self: MemImage, type: PixelType, width: SupportsInt | SupportsIndex, height: SupportsInt | SupportsIndex, slices: SupportsInt | SupportsIndex = 1, channels: SupportsInt | SupportsIndex = 1) → None
__init__(self: MemImage, desc: ImageDescriptor) → None

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

__init__(self: MemImage, array: Annotated[numpy.typing.ArrayLike, 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.

__init__(self: MemImage, array: Annotated[numpy.typing.ArrayLike, numpy.uint8], greyscale: bool = False) → None
__init__(self: MemImage, array: Annotated[numpy.typing.ArrayLike, numpy.int16], greyscale: bool = False) → None
__init__(self: MemImage, array: Annotated[numpy.typing.ArrayLike, numpy.uint16], greyscale: bool = False) → None
__init__(self: MemImage, array: Annotated[numpy.typing.ArrayLike, numpy.int32], greyscale: bool = False) → None
__init__(self: MemImage, array: Annotated[numpy.typing.ArrayLike, numpy.uint32], greyscale: bool = False) → None
__init__(self: MemImage, array: Annotated[numpy.typing.ArrayLike, numpy.float32], greyscale: bool = False) → None
__init__(self: MemImage, array: Annotated[numpy.typing.ArrayLike, 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.

image_to_pixel(self: MemImage, world: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert a 3D image coordinate to a pixel position.

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_image(self: MemImage, pixel: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#

Convert a 3D pixel position to an image coordinate.

static zeros(desc: ImageDescriptor) → MemImage#

Factory method to create a zero-initialized image

property channels#
Type:

int

property dimension#
Type:

int

property dimensions#
Type:

Annotated[numpy.typing.NDArray[numpy.int32], ”[3, 1]”]

property extent#
Type:

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

property height#
Type:

int

property image_to_pixel_matrix#
Type:

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

property metric#
Type:

bool

property ndim#
Type:

int

property pixel_to_image_matrix#
Type:

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

property scale#
Type:

float

property shape#

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

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

Type:

tuple[int, int, int, int]

property shift#
Type:

float

property slices#
Type:

int

property spacing#
Type:

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

property type#
Type:

PixelType

property width#
Type:

int

class imfusion.Mesh(*args, **kwargs)#

Bases: Data

Re-exported from imfusion.data.Mesh.

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(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

Mode of operation when execute is called.

EVALUATE = 3#
OPT = 0#
PLOT = 2#
STUDY = 1#
__call__(self: Optimizer, x: Sequence[SupportsFloat | SupportsIndex]) → list[float]#

Delegates to: execute()

abort(self: Optimizer) → None#

Request to abort the optimization.

configuration(self: Optimizer) → Properties#

Returns the configuration of the object.

configure(self: Optimizer, arg0: Properties) → None#

Configures the object.

execute(self: Optimizer, x: Sequence[SupportsFloat | SupportsIndex]) → list[float]#

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

set_bounds(self: Optimizer, bounds: SupportsFloat | SupportsIndex) → None#
set_bounds(self: Optimizer, lower_bounds: SupportsFloat | SupportsIndex, upper_bounds: SupportsFloat | SupportsIndex) → None
set_bounds(self: Optimizer, bounds: Sequence[SupportsFloat | SupportsIndex]) → None
set_bounds(self: Optimizer, lower_bounds: Sequence[SupportsFloat | SupportsIndex], upper_bounds: Sequence[SupportsFloat | SupportsIndex]) → None
set_bounds(self: Optimizer, bounds: Sequence[tuple[SupportsFloat | SupportsIndex, SupportsFloat | SupportsIndex]]) → None

Function overload documentation:

set_bounds(self: Optimizer, bounds: SupportsFloat | SupportsIndex) → None

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

set_bounds(self: Optimizer, lower_bounds: SupportsFloat | SupportsIndex, upper_bounds: SupportsFloat | SupportsIndex) → None

Set the same lower and upper bounds for all parameters.

set_bounds(self: Optimizer, bounds: Sequence[SupportsFloat | SupportsIndex]) → None

Set individual symmetric bounds.

set_bounds(self: Optimizer, lower_bounds: Sequence[SupportsFloat | SupportsIndex], upper_bounds: Sequence[SupportsFloat | SupportsIndex]) → None

Set individual lower and upper bounds.

set_bounds(self: Optimizer, bounds: Sequence[tuple[SupportsFloat | SupportsIndex, SupportsFloat | SupportsIndex]]) → None

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

set_logging_level(self: Optimizer, file_level: SupportsInt | SupportsIndex | None = None, console_level: SupportsInt | SupportsIndex | 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 abort_eval#

Abort after a certain number of cost function evaluations.

Type:

int

property abort_fun_tol#

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

Type:

float

property abort_fun_val#

Abort if this function value is reached.

Type:

float

property abort_par_tol#

Abort if change in parameter values becomes too small.

Type:

float

property abort_time#

Abort after a certain elapsed number of seconds.

Type:

float

property aborted#

Whether the optimizer was aborted.

Type:

bool

property best_val#

Return best cost function value.

Type:

float

property dimension#

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

Type:

int

property first_val#

Return cost function value of first evaluation.

Type:

float

property minimizing#

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

Type:

bool

property mode#

Mode of operation when execute is called.

Type:

Mode

property num_eval#

Return number of cost function evaluations computed so far.

Type:

int

property param_names#

Names of the parameters.

Type:

list[str]

property selection#

Selected parameters.

Type:

list[bool]

property type#

Type of optimizer (see doc/header).

Type:

int

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

Bases: Enum

CLAMP = 2#
MIRROR = 1#
ZERO = 0#
class imfusion.ParametricDeformation#

Bases: Deformation

set_parameters(self: ParametricDeformation, parameters: Sequence[SupportsFloat | SupportsIndex]) → None#
class imfusion.PatchInfo#

Bases: pybind11_object

Struct for storing the descriptor of the image a patch was extracted from and the region of interest in the original image.

property original_image_descriptor#
Type:

ImageDescriptorWorld

property roi#
Type:

RegionOfInterest

class imfusion.PatchesFromImageDataComponent#

Bases: DataComponentBase

Data component for keeping track of the original location of a patch in the original image. This is set for instance by the SplitIntoPatchesOperation when extracting patches from the input image.

add(self: PatchesFromImageDataComponent, arg0: PatchInfo) → None#
property patch_infos#
Type:

list[PatchInfo]

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

Bases: Enum

BYTE = 5120#
DOUBLE = 5130#
FLOAT = 5126#
HFLOAT = 5131#
INT = 5124#
SHORT = 5122#
UBYTE = 5121#
UINT = 5125#
USHORT = 5123#
class imfusion.PluginInfo#

Bases: pybind11_object

Provides information about a framework plugin.

property name#
Type:

str

property path#
Type:

str

property version#
Type:

object

class imfusion.PointCloud(self: PointCloud, points: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']] = [], *, normals: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']] = [], colors: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']] = [])#

Bases: Data

Re-exported from imfusion.data.PointCloud.

class imfusion.PointCorrespondences(self: PointCorrespondences, first: PointsOnData, second: PointsOnData)#

Bases: pybind11_object

Class that handles point correspondences. Points at corresponding indices on the two PointsOnData instances are considered correspondences. When creating PointCorrespondences(first, second) names of points in first and second are made uniform giving precedence to names in first. Logic for matching points based on their names should be implemented outside of this class. The class supports both full-set and subset-based rigid fitting, allowing users to select specific point correspondences for the transformation calculation. The class supports estimation of a fitting error for any correspondence using complementary correspondences, which can assist with the identification of inconsistent correspondences.

class PointCorrespondenceIterator#

Bases: pybind11_object

Iterator for PointCorrespondences

__next__(self: PointCorrespondenceIterator) → object#
class Reduction(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

Reduction type used during distance evaluation

MAX = 2#
MEAN = 0#
MEDIAN = 1#
MIN = 3#
__getitem__(self: PointCorrespondences, index: SupportsInt | SupportsIndex) → tuple[Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]'], Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']]#

Get a point correspondences pair (in world coordinates) by index

__iter__(self: PointCorrespondences) → PointCorrespondenceIterator#

Iterate over all point correspondences in world coordinates

clear(self: PointCorrespondences) → None#

Remove all correspondences.

compute_pairwise_distances(self: PointCorrespondences, reduction: Reduction = Reduction.MEAN, weights: Sequence[SupportsFloat | SupportsIndex] = None) → float#

Compute the distance between pairs of correspondences. Parameters: reduction (PointCorrespondences.Reduction): The reduction method to use (MEAN, MEDIAN, MIN, MAX). weights (list of float): Optional weights for each correspondence. If provided, the individual errors are multiplied with these weights before reduction.

fit_rigid(self: PointCorrespondences, subset_indices: Sequence[SupportsInt | SupportsIndex] | None = None) → object#

Fit a rigid transformation that aligns the selected correspondences. :param subset_indices: Optional list of indices to use for fitting. If not provided, all selected correspondences are used.

is_selected(self: PointCorrespondences, index: SupportsInt | SupportsIndex) → bool#

Check if a correspondence is selected.

name(self: PointCorrespondences, index: SupportsInt | SupportsIndex) → str#

Return the name of a correspondence.

set_name(self: PointCorrespondences, index: SupportsInt | SupportsIndex, name: str) → None#

Set the name of a correspondence at index ‘index’.

set_selected(self: PointCorrespondences, index: SupportsInt | SupportsIndex, selected: bool) → None#

Set whether a correspondence is selected.

property point_handler#

The PointsOnData handlers.

Type:

tuple[PointsOnData, PointsOnData]

class imfusion.PointsOnData#

Bases: pybind11_object

Base interface for points linked to Data.

clear(self: PointsOnData) → None#

Remove all the points

empty(self: PointsOnData) → bool#

Check if the list of points is empty

find(self: PointsOnData, name: str, start: SupportsInt | SupportsIndex = 0) → int#

Get the first index of a point with the given name, starting from index start. Return -1 if not found

numpy(self: PointsOnData) → numpy.typing.NDArray[numpy.float64]#

Convert all points to a numpy array

property selected_points#

Return the selected points in world coordinates

Type:

list[Annotated[numpy.typing.NDArray[numpy.float64], ”[3, 1]”]]

class imfusion.PointsOnImage(self: PointsOnImage, image: SharedImageSet)#

Bases: PointsOnData

Class that hold a list of points on a volume or image. Points are automatically updated when the matrix or deformation changes.

Create a PointsOnImage object for the given SharedImageSet.

__getitem__(self: PointsOnImage, index: SupportsInt | SupportsIndex) → PyPointsOnImagePoint#
__getitem__(self: PointsOnImage, indices: Sequence[SupportsInt | SupportsIndex]) → list[PyPointsOnImagePoint]
__getitem__(self: PointsOnImage, slice: slice) → list[PyPointsOnImagePoint]
__getitem__(self: PointsOnImage, name: str) → PyPointsOnImagePoint

Function overload documentation:

__getitem__(self: PointsOnImage, index: SupportsInt | SupportsIndex) → PyPointsOnImagePoint
__getitem__(self: PointsOnImage, indices: Sequence[SupportsInt | SupportsIndex]) → list[PyPointsOnImagePoint]
__getitem__(self: PointsOnImage, slice: slice) → list[PyPointsOnImagePoint]
__getitem__(self: PointsOnImage, name: str) → PyPointsOnImagePoint

Get a point in world coordinates by name.

__iter__(self: PointsOnImage) → PyPointsIterator#

Iterate over all points in world coordinates

__setitem__(self: PointsOnImage, arg0: SupportsInt | SupportsIndex, arg1: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → None#

Set a point in world coordinates

add_image_point(self: PointsOnImage, point: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]'], frame: SupportsInt | SupportsIndex) → None#

Add a new point in image coordinates for a given frame.

add_world_point(self: PointsOnImage, point: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]'], find_closest_frame: bool = True) → None#

Add a new point in world coordinates. If find_closest_frame is true, assigns to closest frame.

image_point(self: PointsOnImage, index: SupportsInt | SupportsIndex) → tuple[Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]'], int]#

Return the point in image coordinates, paired with its associated frame.

property all_points#

Return the points in world coordinates.

Type:

list[Annotated[numpy.typing.NDArray[numpy.float64], ”[3, 1]”]]

property image_points#

Return the points in image coordinates, paired with their associated frame.

Type:

list[tuple[Annotated[numpy.typing.NDArray[numpy.float64], ”[3, 1]”], int]]

property selected_image_points#

Return only the selected points in image coordinates, paired with their associated frame.

Type:

list[tuple[Annotated[numpy.typing.NDArray[numpy.float64], ”[3, 1]”], int]]

class imfusion.Properties(*args, **kwargs)#

Bases: pybind11_object

Properties objects store arbitrary key-value pairs as strings in a hierarchical fashion. Properties are extensively used within the ImFusion frameworks for purposes such as:

  • Saving and loading the state of an application to and from files.

  • Configuring the View instances of the UI.

  • Configuring the Algorithm instances.

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 = imfusion.Properties()
>>> p.set_param('Spam', 5)

The parameter type will be set depending on the type of the Python 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 = imfusion.Properties()
>>> p['spam'] = 5

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

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

However, for matrix and vector types, the param() method needs 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 param_attributes() method:

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

A Properties object can be obtained from a dict:

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

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

>>> dict(p)
{'spam': 5, 'eggs': True, 'sub/0': <Properties(name=sub,...
>>> p.asdict()
{'spam': 5, 'eggs': True, 'sub/0': {'eggs': False}}

When a parameter needs to take values among a set of possible choices, the parameter can be assigned to an EnumStringParam:

>>> p["choice"] = imfusion.Properties.EnumStringParam(value="choice2", admitted_values={"choice1", "choice2"})
>>> p["choice"]
Properties.EnumStringParam(value="choice2", admitted_values={...})

Please refer to EnumStringParam for more information.

Function overload documentation:

__init__(self: Properties, name: str = '') → None
__init__(self: Properties, dictionary: dict) → None
class EnumStringParam(self: EnumStringParam, *, value: str, admitted_values: Set[str])#

Bases: pybind11_object

Parameter that can assume a certain value among a set of str possibilities.

A first way to instantiate this class, is to provide the value and the set of admitted values:

>>> p = imfusion.Properties()
>>> p["choice"] = imfusion.Properties.EnumStringParam(value="choice2", admitted_values={"choice1", "choice2"})
>>> p["choice"]
Properties.EnumStringParam(value="choice2", admitted_values={...})

If EnumStringParam is assigned to a value that is not in the set of possible choices, then a ValueError is raised:

>>> p["choice"] = imfusion.Properties.EnumStringParam(value="choice3", admitted_values={"choice1", "choice2"})
Traceback (most recent call last):
        ...
ValueError: EnumStringParam was assigned to 'choice3' but it is not in the set of admitted values: ...

An EnumStringParam instance can be constructed from a Enum member by using the from_enum() method, in which case the EnumStringParam instance gets its value from the given Enum member, and gets its admitted_values from the set of Enum members:

>>> import enum
>>> class Choices(enum.Enum):
...    CHOICE_1: str = "choice1"
...    CHOICE_2: str = "choice2"
...
>>> p["choice"] = imfusion.Properties.EnumStringParam.from_enum(Choices.CHOICE_2)
>>> p["choice"]
Properties.EnumStringParam(value="CHOICE_2", admitted_values={...})

An EnumStringParam instance that corresponds 1-to-1 to an Enum can be converted into the Enum member that corresponds to its current value:

>>> p["choice"].to_enum(Choices)
<Choices.CHOICE_2: 'choice2'>

In the example above, the Enum members were used to populated the admitted_values. However, it is also possible to populate the admitted_values from the Enum values:

>>> p["choice"] = imfusion.Properties.EnumStringParam.from_enum(Choices.CHOICE_2, take_enum_values=True)
>>> p["choice"]
Properties.EnumStringParam(value="choice2", admitted_values={...})
>>> p["choice"].to_enum(Choices)
<Choices.CHOICE_2: 'choice2'>
Parameters:
classmethod from_enum()#

(cls: object, enum_member: object, take_enum_values: bool = False) -> imfusion.Properties.EnumStringParam

Construct an EnumStringParam automatically out of the provided instance of an enumeration class.

Parameters:
  • enum_member – a member of an enumeration class. The current value will be assigned to this argument, while the admitted_values will be automatically constructed from the members of the enumeration class.

  • take_enum_values – is False, then the enumeration members are taken as values. If True, then the enumeration values are taken as values: please note that in this case all the enumeration values must be unique and of str type.

to_enum(self: EnumStringParam, enum_type: object) → object#

Casts into the corresponding member of the enum_type type. It raises when this is not possible.

Parameters:

enum_type – the enumeration class into which to cast the current value. Please note that this enumeration class must be compatible, which means it must correspond to the set of admitted_values.

property admitted_values#

The current set of admitted values.

Type:

set[str]

property value#

The current value that is assumed among the current set of admitted values.

Type:

str

__getitem__(self: Properties, arg0: str) → object#
__iter__(self: object) → Iterator#
__setitem__(self: Properties, name: str, value: bool) → None#
__setitem__(self: Properties, name: str, value: int) → None
__setitem__(self: Properties, name: str, value: float) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[3, 3]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[4, 4]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[3, 4]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float32], '[3, 3]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float32], '[4, 4]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[2, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[4, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[5, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float32], '[2, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float32], '[3, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float32], '[4, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.int32], '[2, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.int32], '[3, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.int32], '[4, 1]']) → None
__setitem__(self: Properties, name: str, value: str) → None
__setitem__(self: Properties, name: str, value: Path) → None
__setitem__(self: Properties, name: str, value: list[str]) → None
__setitem__(self: Properties, name: str, value: list[Path]) → None
__setitem__(self: Properties, name: str, value: list[bool]) → None
__setitem__(self: Properties, name: str, value: list[int]) → None
__setitem__(self: Properties, name: str, value: list[float]) → None
__setitem__(self: Properties, name: str, value: list[Annotated[numpy.typing.NDArray[numpy.float64], '[2, 1]']]) → None
__setitem__(self: Properties, name: str, value: list[Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']]) → None
__setitem__(self: Properties, name: str, value: list[Annotated[numpy.typing.NDArray[numpy.float64], '[4, 1]']]) → None
__setitem__(self: Properties, name: str, value: EnumStringParam) → None
__setitem__(self: Properties, name: str, value: object) → None

Function overload documentation:

__setitem__(self: Properties, name: str, value: bool) → None
__setitem__(self: Properties, name: str, value: int) → None
__setitem__(self: Properties, name: str, value: float) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[3, 3]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[4, 4]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[3, 4]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float32], '[3, 3]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float32], '[4, 4]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[2, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[4, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float64], '[5, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float32], '[2, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float32], '[3, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.float32], '[4, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.int32], '[2, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.int32], '[3, 1]']) → None
__setitem__(self: Properties, name: str, value: Annotated[numpy.typing.NDArray[numpy.int32], '[4, 1]']) → None
__setitem__(self: Properties, name: str, value: str) → None
__setitem__(self: Properties, name: str, value: Path) → None
__setitem__(self: Properties, name: str, value: list[str]) → None
__setitem__(self: Properties, name: str, value: list[Path]) → None
__setitem__(self: Properties, name: str, value: list[bool]) → None
__setitem__(self: Properties, name: str, value: list[int]) → None
__setitem__(self: Properties, name: str, value: list[float]) → None
__setitem__(self: Properties, name: str, value: list[Annotated[numpy.typing.NDArray[numpy.float64], '[2, 1]']]) → None
__setitem__(self: Properties, name: str, value: list[Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']]) → None
__setitem__(self: Properties, name: str, value: list[Annotated[numpy.typing.NDArray[numpy.float64], '[4, 1]']]) → None
__setitem__(self: Properties, name: str, value: EnumStringParam) → None
__setitem__(self: Properties, name: str, value: object) → 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(self: Properties, name: str, value: bool) → bool#
param(self: Properties, name: str, value: SupportsInt | SupportsIndex) → int
param(self: Properties, name: str, value: SupportsFloat | SupportsIndex) → float
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 3]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 3]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[4, 4]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 4]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 4]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 3]']) → Annotated[numpy.typing.NDArray[numpy.float32], '[3, 3]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 4]']) → Annotated[numpy.typing.NDArray[numpy.float32], '[4, 4]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[2, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[4, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[5, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[5, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[2, 1]']) → Annotated[numpy.typing.NDArray[numpy.float32], '[2, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float32], '[3, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 1]']) → Annotated[numpy.typing.NDArray[numpy.float32], '[4, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[2, 1]']) → Annotated[numpy.typing.NDArray[numpy.int32], '[2, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.int32], '[3, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[4, 1]']) → Annotated[numpy.typing.NDArray[numpy.int32], '[4, 1]']
param(self: Properties, name: str, value: str) → str
param(self: Properties, name: str, value: PathLike | str | bytes) → Path
param(self: Properties, name: str, value: Sequence[str]) → list[str]
param(self: Properties, name: str, value: Sequence[PathLike | str | bytes]) → list[Path]
param(self: Properties, name: str, value: Sequence[bool]) → list[bool]
param(self: Properties, name: str, value: Sequence[SupportsInt | SupportsIndex]) → list[int]
param(self: Properties, name: str, value: Sequence[SupportsFloat | SupportsIndex]) → list[float]
param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]']]) → list[Annotated[numpy.typing.NDArray[numpy.float64], '[2, 1]']]
param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']]) → list[Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']]
param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]']]) → list[Annotated[numpy.typing.NDArray[numpy.float64], '[4, 1]']]
param(self: Properties, name: str, value: EnumStringParam) → EnumStringParam

Function overload documentation:

param(self: Properties, name: str, value: bool) → bool
param(self: Properties, name: str, value: SupportsInt | SupportsIndex) → int
param(self: Properties, name: str, value: SupportsFloat | SupportsIndex) → float
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 3]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 3]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[4, 4]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 4]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 4]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 3]']) → Annotated[numpy.typing.NDArray[numpy.float32], '[3, 3]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 4]']) → Annotated[numpy.typing.NDArray[numpy.float32], '[4, 4]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[2, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[4, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[5, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[5, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[2, 1]']) → Annotated[numpy.typing.NDArray[numpy.float32], '[2, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float32], '[3, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 1]']) → Annotated[numpy.typing.NDArray[numpy.float32], '[4, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[2, 1]']) → Annotated[numpy.typing.NDArray[numpy.int32], '[2, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.int32], '[3, 1]']
param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[4, 1]']) → Annotated[numpy.typing.NDArray[numpy.int32], '[4, 1]']
param(self: Properties, name: str, value: str) → str
param(self: Properties, name: str, value: PathLike | str | bytes) → Path
param(self: Properties, name: str, value: Sequence[str]) → list[str]
param(self: Properties, name: str, value: Sequence[PathLike | str | bytes]) → list[Path]
param(self: Properties, name: str, value: Sequence[bool]) → list[bool]
param(self: Properties, name: str, value: Sequence[SupportsInt | SupportsIndex]) → list[int]
param(self: Properties, name: str, value: Sequence[SupportsFloat | SupportsIndex]) → list[float]
param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]']]) → list[Annotated[numpy.typing.NDArray[numpy.float64], '[2, 1]']]
param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']]) → list[Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']]
param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]']]) → list[Annotated[numpy.typing.NDArray[numpy.float64], '[4, 1]']]
param(self: Properties, name: str, value: EnumStringParam) → EnumStringParam
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) → bool#
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(self: Properties, name: str, value: bool) → None#
set_param(self: Properties, name: str, value: bool, default: bool) → None
set_param(self: Properties, name: str, value: SupportsInt | SupportsIndex) → None
set_param(self: Properties, name: str, value: SupportsInt | SupportsIndex, default: int) → None
set_param(self: Properties, name: str, value: SupportsFloat | SupportsIndex) → None
set_param(self: Properties, name: str, value: SupportsFloat | SupportsIndex, default: float) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 3]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 3]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[3, 3]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[4, 4]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 4]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 4]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[3, 4]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 3]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 3]'], default: Annotated[numpy.typing.NDArray[numpy.float32], '[3, 3]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 4]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 4]'], default: Annotated[numpy.typing.NDArray[numpy.float32], '[4, 4]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[2, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[4, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[5, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[5, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[5, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[2, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[2, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float32], '[2, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float32], '[3, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float32], '[4, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[2, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[2, 1]'], default: Annotated[numpy.typing.NDArray[numpy.int32], '[2, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'], default: Annotated[numpy.typing.NDArray[numpy.int32], '[3, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[4, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[4, 1]'], default: Annotated[numpy.typing.NDArray[numpy.int32], '[4, 1]']) → None
set_param(self: Properties, name: str, value: str) → None
set_param(self: Properties, name: str, value: str, default: str) → None
set_param(self: Properties, name: str, value: PathLike | str | bytes) → None
set_param(self: Properties, name: str, value: PathLike | str | bytes, default: Path) → None
set_param(self: Properties, name: str, value: Sequence[str]) → None
set_param(self: Properties, name: str, value: Sequence[str], default: list[str]) → None
set_param(self: Properties, name: str, value: Sequence[PathLike | str | bytes]) → None
set_param(self: Properties, name: str, value: Sequence[PathLike | str | bytes], default: list[Path]) → None
set_param(self: Properties, name: str, value: Sequence[bool]) → None
set_param(self: Properties, name: str, value: Sequence[bool], default: list[bool]) → None
set_param(self: Properties, name: str, value: Sequence[SupportsInt | SupportsIndex]) → None
set_param(self: Properties, name: str, value: Sequence[SupportsInt | SupportsIndex], default: list[int]) → None
set_param(self: Properties, name: str, value: Sequence[SupportsFloat | SupportsIndex]) → None
set_param(self: Properties, name: str, value: Sequence[SupportsFloat | SupportsIndex], default: list[float]) → None
set_param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]']]) → None
set_param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]']], default: list[Annotated[numpy.typing.NDArray[numpy.float64], '[2, 1]']]) → None
set_param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']]) → None
set_param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']], default: list[Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']]) → None
set_param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]']]) → None
set_param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]']], default: list[Annotated[numpy.typing.NDArray[numpy.float64], '[4, 1]']]) → None
set_param(self: Properties, name: str, value: EnumStringParam) → None
set_param(self: Properties, name: str, value: EnumStringParam, default: EnumStringParam) → None

Function overload documentation:

set_param(self: Properties, name: str, value: bool) → None
set_param(self: Properties, name: str, value: bool, default: bool) → None
set_param(self: Properties, name: str, value: SupportsInt | SupportsIndex) → None
set_param(self: Properties, name: str, value: SupportsInt | SupportsIndex, default: int) → None
set_param(self: Properties, name: str, value: SupportsFloat | SupportsIndex) → None
set_param(self: Properties, name: str, value: SupportsFloat | SupportsIndex, default: float) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 3]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 3]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[3, 3]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[4, 4]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 4]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 4]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[3, 4]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 3]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 3]'], default: Annotated[numpy.typing.NDArray[numpy.float32], '[3, 3]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 4]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 4]'], default: Annotated[numpy.typing.NDArray[numpy.float32], '[4, 4]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[2, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[4, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[5, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[5, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float64], '[5, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[2, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[2, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float32], '[2, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float32], '[3, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 1]'], default: Annotated[numpy.typing.NDArray[numpy.float32], '[4, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[2, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[2, 1]'], default: Annotated[numpy.typing.NDArray[numpy.int32], '[2, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'], default: Annotated[numpy.typing.NDArray[numpy.int32], '[3, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[4, 1]']) → None
set_param(self: Properties, name: str, value: Annotated[numpy.typing.ArrayLike, numpy.int32, '[4, 1]'], default: Annotated[numpy.typing.NDArray[numpy.int32], '[4, 1]']) → None
set_param(self: Properties, name: str, value: str) → None
set_param(self: Properties, name: str, value: str, default: str) → None
set_param(self: Properties, name: str, value: PathLike | str | bytes) → None
set_param(self: Properties, name: str, value: PathLike | str | bytes, default: Path) → None
set_param(self: Properties, name: str, value: Sequence[str]) → None
set_param(self: Properties, name: str, value: Sequence[str], default: list[str]) → None
set_param(self: Properties, name: str, value: Sequence[PathLike | str | bytes]) → None
set_param(self: Properties, name: str, value: Sequence[PathLike | str | bytes], default: list[Path]) → None
set_param(self: Properties, name: str, value: Sequence[bool]) → None
set_param(self: Properties, name: str, value: Sequence[bool], default: list[bool]) → None
set_param(self: Properties, name: str, value: Sequence[SupportsInt | SupportsIndex]) → None
set_param(self: Properties, name: str, value: Sequence[SupportsInt | SupportsIndex], default: list[int]) → None
set_param(self: Properties, name: str, value: Sequence[SupportsFloat | SupportsIndex]) → None
set_param(self: Properties, name: str, value: Sequence[SupportsFloat | SupportsIndex], default: list[float]) → None
set_param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]']]) → None
set_param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 1]']], default: list[Annotated[numpy.typing.NDArray[numpy.float64], '[2, 1]']]) → None
set_param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']]) → None
set_param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']], default: list[Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']]) → None
set_param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]']]) → None
set_param(self: Properties, name: str, value: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 1]']], default: list[Annotated[numpy.typing.NDArray[numpy.float64], '[4, 1]']]) → None
set_param(self: Properties, name: str, value: EnumStringParam) → None
set_param(self: Properties, name: str, value: EnumStringParam, default: EnumStringParam) → None
set_param_attributes(self: Properties, name: str, attributes: str) → None#
sub_properties(self: Properties, name: str, create_if_doesnt_exist: bool = False) → Properties#
sub_properties(self: Properties) → list[Properties]

Function overload documentation:

sub_properties(self: Properties, name: str, create_if_doesnt_exist: bool = False) → Properties
sub_properties(self: Properties) → list[Properties]
sub_properties_all(self: Properties, name: str) → list#
values(self: Properties) → list#
class imfusion.PyPointsIterator#

Bases: pybind11_object

__iter__(self: PyPointsIterator) → PyPointsIterator#
__next__(self: PyPointsIterator) → PyPointsOnImagePoint#
class imfusion.PyPointsOnImagePoint#

Bases: pybind11_object

property image_frame#

Gets/sets the image frame of a point.

Type:

int

property image_position#

Gets/sets the image position of a point.

Type:

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

property name#

Gets/sets the name of a point.

Type:

str

property selected#

Gets/sets whether a point is selected. By default all points are selected.

Type:

bool

property world_position#

Gets/sets the world position of a point.

Type:

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

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

Bases: Enum

AVERAGE = 1#
LOOKUP = 0#
MAXIMUM = 3#
MINIMUM = 2#
class imfusion.ReferenceImageDataComponent#

Bases: DataComponentBase

Data component used to store a reference image. The reference image is used to keep track of the input of a processing pipeline or a machine learning model, and can be used to set the correct image descriptor for the output of the pipeline.

property reference#
Type:

SharedImageSet

class imfusion.RegionOfInterest(self: RegionOfInterest, offset: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'], size: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'])#

Bases: pybind11_object

Class representing a rectangular region of interest (ROI) in an image.

The ROI is defined by an offset (starting position) and a size (dimensions).

Parameters:
  • offset – Starting position of the ROI as a 3D vector (x, y, z) in voxel coordinates

  • size – Size of the ROI as a 3D vector (width, height, depth) in voxels

property offset#

Starting position of the ROI in voxel coordinates

Type:

Annotated[numpy.typing.NDArray[numpy.int32], ”[3, 1]”]

property size#

Size of the ROI in voxels

Type:

Annotated[numpy.typing.NDArray[numpy.int32], ”[3, 1]”]

class imfusion.Selection(*args, **kwargs)#

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]:
...             pass

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

>>> for selected_index in selection.selected_indices:
...     pass

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.to_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.

Function overload documentation:

__init__(self: Selection) → None
__init__(self: Selection, stop: SupportsInt | SupportsIndex) → None
__init__(self: Selection, start: SupportsInt | SupportsIndex, stop: SupportsInt | SupportsIndex, step: SupportsInt | SupportsIndex = 1) → None
__init__(self: Selection, indices: Sequence[SupportsInt | SupportsIndex]) → None
class NonePolicy(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

ALL = 2#
EMPTY = 0#
FOCUS = 1#
__getitem__(self: Selection, index: SupportsInt | SupportsIndex) → bool#
__iter__(self: Selection) → object#
__setitem__(self: Selection, index: SupportsInt | SupportsIndex, selected: bool) → None#
clamp(self: Selection, last_selected_index: SupportsInt | SupportsIndex) → None#
is_selected(self: Selection, index: SupportsInt | SupportsIndex, none_policy: NonePolicy) → bool#
select_only(self: Selection, index: SupportsInt | SupportsIndex) → None#
select_up_to(self: Selection, stop: SupportsInt | SupportsIndex) → None#
set_first_last_skip(self: Selection, arg0: SupportsInt | SupportsIndex, arg1: SupportsInt | SupportsIndex, arg2: SupportsInt | SupportsIndex) → None#
to_slice(self: Selection) → slice#
ALL = 2#
EMPTY = 0#
FOCUS = 1#
property first_selected#
Type:

int

property focus#
Type:

int

property has_regular_skip#
Type:

bool

property is_none#
Type:

bool

property last_selected#
Type:

int

property range#
Type:

int

property selected_indices#
Type:

list[int]

property size#
Type:

int

property skip#
Type:

int

property start#
Type:

object

property step#
Type:

object

property stop#
Type:

object

class imfusion.SharedImage(*args, **kwargs)#

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:

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

See MemImage for details.

Function overload documentation:

__init__(self: SharedImage, mem_image: MemImage) → None
__init__(self: SharedImage, desc: ImageDescriptor) → None
__init__(self: SharedImage, desc: ImageDescriptorWorld) → None
__init__(self: SharedImage, type: PixelType, width: SupportsInt | SupportsIndex, height: SupportsInt | SupportsIndex, slices: SupportsInt | SupportsIndex = 1, channels: SupportsInt | SupportsIndex = 1) → None
__init__(self: SharedImage, array: Annotated[numpy.typing.ArrayLike, numpy.int8], greyscale: bool = False) → None
__init__(self: SharedImage, array: Annotated[numpy.typing.ArrayLike, numpy.uint8], greyscale: bool = False) → None
__init__(self: SharedImage, array: Annotated[numpy.typing.ArrayLike, numpy.int16], greyscale: bool = False) → None
__init__(self: SharedImage, array: Annotated[numpy.typing.ArrayLike, numpy.uint16], greyscale: bool = False) → None
__init__(self: SharedImage, array: Annotated[numpy.typing.ArrayLike, numpy.int32], greyscale: bool = False) → None
__init__(self: SharedImage, array: Annotated[numpy.typing.ArrayLike, numpy.uint32], greyscale: bool = False) → None
__init__(self: SharedImage, array: Annotated[numpy.typing.ArrayLike, numpy.float32], greyscale: bool = False) → None
__init__(self: SharedImage, array: Annotated[numpy.typing.ArrayLike, numpy.float64], greyscale: bool = False) → None
all(self: SharedImage) → bool#

Returns True if all pixels / voxels is non-zero

any(self: SharedImage) → bool#

Returns True if at least one pixel / voxel is non-zero

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[Annotated[numpy.typing.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).

Returns:

List of indices (x, y, z, image index) returned as a list of numpy arrays.

argmin(self: SharedImage) → list[Annotated[numpy.typing.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).

Returns:

List of indices (x, y, z, image index) returned as a list of numpy arrays.

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: Sequence[SupportsInt | SupportsIndex]) → 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 of channel indices to swizzle the channels of the input.

Returns:

SharedImage instance with reordered channels.

clone(self: SharedImage) → SharedImage#
dimension(self: SharedImage) → int#
exclusive_mem(self: SharedImage) → None#

Clear representations that are not CPU memory

image_to_world(self: SharedImage, image_coordinates: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#
max(self: SharedImage) → Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']#

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

Returns:

Channel-wise values returned as a numpy array.

mean(self: SharedImage) → Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']#

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

Returns:

Channel-wise values returned as a numpy array.

mem(self: SharedImage) → MemImage#
min(self: SharedImage) → Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']#

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

Returns:

Channel-wise values returned as a numpy array.

norm(self: SharedImage, order: SupportsInt | SupportsIndex | SupportsFloat | SupportsIndex | str = 2) → Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']#

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

Parameters:

order – Order of the norm. Use a number (e.g., 1 or 2) or ‘inf’. The default is the L2 norm.

Returns:

Norm values per channel returned as a numpy array.

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: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#
prepare(self: SharedImage, shift_only: bool = False) → None#
Prepare the image:

Integral types are converted to unsigned representation if applicable, double-precision will be converted to single-precision float. Furthermore, if shift_only is False it will rescale the present intensity range to [0..1] for floating point types or to the entire available value range for integral types.

prod(self: SharedImage) → Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']#

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

Returns:

Channel-wise values returned as a numpy array.

set_dirty_mem(self: SharedImage) → None#
sum(self: SharedImage) → Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']#

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

Returns:

Channel-wise values returned as a numpy array.

sync(self: SharedImage) → None#
torch(device: device = None, dtype: dtype = None, same_as: Tensor = None) → Tensor#

Convert SharedImageSet or a SharedImage to a torch.Tensor.

Parameters:
  • self (DataElement | SharedImageSet | SharedImage) – Instance of SharedImageSet or SharedImage (this function bound as a method to SharedImageSet and SharedImage)

  • device (device) – Target device for the new torch.Tensor

  • dtype (dtype) – Type of the new torch.Tensor

  • same_as (Tensor) – Template tensor whose device and dtype configuration should be matched. device and dtype are still applied afterwards.

Returns:

New torch.Tensor

Return type:

Tensor

world_to_image(self: SharedImage, world_coordinates: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#
world_to_pixel(self: SharedImage, world_coordinates: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) → Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#
property channels#
Type:

int

property deformation#
Type:

Deformation

property descriptor#

Read-only descriptor view of this image.

Type:

BoundImageDescriptor

property descriptor_world#

Read-only world descriptor view of this image.

Type:

BoundImageDescriptorWorld

property extent#
Type:

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

property height#
Type:

int

property image_to_world_matrix#
Type:

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

property kind#
Type:

Kind

property mask#
Type:

Mask

property metric#
Type:

bool

property modality#
Type:

Modality

property ndim#
Type:

int

property pixel_to_world_matrix#
Type:

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

property scale#
Type:

float

property shape#

Numpy compatible shape describing the dimensions of this image, stored as a namedtuple.

Returns:

Named tuple with slices, height, width, and channels attributes.

Return type:

(collections.namedtuple)

Type:

object

property shift#
Type:

float

property slices#
Type:

int

property spacing#

Physical extent of each voxel in [mm] stored as a namedtuple. Spacing for a specific dimension can be accessed via x, y, and z attributes.

Returns:

Named tuple with x, y, and z attributes.

Return type:

(collections.namedtuple)

Type:

Spacing

property width#
Type:

int

property world_to_image_matrix#
Type:

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

property world_to_pixel_matrix#
Type:

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

class imfusion.SharedImageSet(*args, **kwargs)#

Bases: Data

Re-exported from imfusion.data.SharedImageSet.

class imfusion.SkippingMask(self: SkippingMask, shape: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'], skip: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'])#

Bases: Mask

Basic mask where only every N-th pixel is considered inside.

property skip#

Step size in pixels for the mask

Type:

Annotated[numpy.typing.NDArray[numpy.int32], ”[3, 1]”]

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

Bases: Enum

ADJUST = 1#
EXACT = 0#
class imfusion.TrackedSharedImageSet(*args, **kwargs)#

Bases: SharedImageSet

Re-exported from imfusion.data.TrackedSharedImageSet.

class imfusion.TrackerID(*args, **kwargs)#

Bases: pybind11_object

Function overload documentation:

__init__(self: TrackerID) → None
__init__(self: TrackerID, id: str = '', model_number: str = '', name: str = '') → None
empty(self: TrackerID) → bool#
from_string(self: str) → TrackerID#
to_model_name_string(self: TrackerID, arg0: bool) → str#
to_string(self: TrackerID, arg0: bool) → str#
property id#
Type:

str

property model_number#
Type:

str

property name#
Type:

str

class imfusion.TrackingSequence(self: TrackingSequence, name: str = '')#

Bases: Data

Re-exported from imfusion.data.TrackingSequence.

imfusion.algorithm_properties(id: str, data: list) → object#

Returns the default properties of the given algorithm. This is useful to figure out what properties are supported by an algorithm.

Deprecated since version 0.12.0: Use imfusion.algorithm.get_properties() instead.

imfusion.auto_window(image: SharedImageSet, change2d: bool = True, change3d: bool = True, lower_limit: SupportsFloat | SupportsIndex = 0.0, upper_limit: SupportsFloat | SupportsIndex = 0.0) → None#

Update window/level of input image to show the entire intensity range of the image.

Parameters:
  • image (SharedImageSet) – Image to change the windowing for.

  • change2d (bool) – Flag whether update the DisplayOptions2d attached to a img.

  • change3d (bool) – Flag whether update the DisplayOptions3d attached to a img.

  • lower_limit (double) – Ratio of lower values removed by the auto windowing.

  • upper_limit (double) – Ratio of upper values removed by the auto windowing.

imfusion.available_algorithms(sub_string: str = '', case_sensitive: bool = False) → object#

Return a list of all available algorithm ids.

Optionally, a substring can be given to filter the list (case-insensitive by default).

Deprecated since version 0.12.0: Use imfusion.algorithm.list_available() instead.

imfusion.create_algorithm(id: str, data: list = [], properties: Properties = None) → object#

Create the algorithm with the given id without executing it.

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.

Deprecated since version 0.12.0: Use imfusion.algorithm.create() instead.

imfusion.documentation_url() → str#

Returns the URL to the ImFusion Python SDK documentation.

imfusion.execute_algorithm(id: str, data: list = [], properties: Properties = None) → object#

Execute the algorithm with the given id and return 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.

Deprecated since version 0.12.0: Use imfusion.algorithm.execute() instead.

imfusion.gpu_info() → str | None#

Return string with information about GPU to check if hardware support for OpenGL is available.

imfusion.has_gl_context() → bool#
imfusion.info(*, show_license_key: bool = False) → FrameworkInfo#

Provides general information about the framework.

imfusion.init(pluginFolders: list = [], initOpenGL: bool = True) → None#
imfusion.is_compatible_imfusion_plugin(path: PathLike | str | bytes) → bool#

Returns True if the given plugin is compatible, False otherwise.

imfusion.load(path: PathLike | str | bytes) → object#

Deprecation alias for imfusion.io.load().

imfusion.load_plugin(path: PathLike | str | bytes) → str#

Load a single ImFusionLib plugin from the given file. WARNING: This might execute arbitary code. Only use with trusted files!

imfusion.load_plugins(folder: PathLike | str | bytes) → None#

Loads all ImFusionLib plugins from the given folder. WARNING: This might execute arbitary code. Only use with trusted folders!

imfusion.save(object: object, path: PathLike | str | bytes) → object#
imfusion.save(image: SharedImageSet, path: PathLike | str | bytes, **kwargs) → object

Function overload documentation:

imfusion.save(object: object, path: PathLike | str | bytes) → object

Deprecation alias for imfusion.io.save().

imfusion.save(image: SharedImageSet, path: PathLike | str | bytes, **kwargs) → object

Deprecation alias for imfusion.io.save().

imfusion.show(*args, **kwargs)#

Re-exported from imfusion.gui.show().