imfusion.gui#

Submodule for GUI-related types.

class imfusion.gui.Annotation#

Bases: pybind11_object

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

Bases: Enum

BOX = 0#
CIRCLE = 1#
LINE = 2#
POINT = 3#
POLY_LINE = 4#
RECTANGLE = 5#
on_editing_finished(self: Annotation, callback: Callable) → SignalConnection#

Register a callback which is called when the annotation has been fully defined by the user.

The callback must not require any arguments.

>>> a = imfusion.app.annotation_model.create_annotation(imfusion.gui.Annotation.LINE)
>>> def callback():
...     print("All points are defined")
>>> a.on_editing_finished(callback)
>>> a.start_editing()
on_points_changed(self: Annotation, callback: Callable) → SignalConnection#

Register a callback which is called when any of the points have changed their position.

The callback must not require any arguments.

>>> a = imfusion.app.annotation_model.create_annotation(imfusion.gui.Annotation.LINE)
>>> def callback():
...     print("Points changed")
>>> a.on_points_changed(callback)
>>> a.start_editing()
start_editing(self: Annotation) → None#

Start interactive placement of the annotation.

This can currently only be called once.

BOX = 0#
CIRCLE = 1#
LINE = 2#
POINT = 3#
POLY_LINE = 4#
RECTANGLE = 5#
property color#

Color of the annotation as a normalized RGB tuple.

Type:

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

property editable#

Whether the annotation can be manipulated by the user.

Type:

bool

property label_text#

The text of the label of the annotation.

Type:

str

property label_visible#

Whether the label of the annotation needs to be drawn or not.

Type:

bool

property line_width#

The line width used to draw the annotation.

Type:

float

property max_points#

The maximum amount of points this annotation supports.

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

Type:

int

property name#

The name of the annotation.

Type:

str

property points#

The points which define the annotation in world coordinates.

It is possible to not immediately set all the points that the specific annotation requires: in this case the annotation is required to be manually completed using the mouse in the ImFusionSuite. It is not supported to partially set the points of multiple annotations at once: please complete the current partially-defined annotation before setting the points of another annotation.

Besides, it is not possible to set more points than the specific annotation requires.

Type:

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

property type#

Return the type of this annotation.

Raises if the annotation is no longer valid or if the annotation is not supported in Python.

Type:

AnnotationType

property visible#

Whether the annotation needs to be drawn or not.

Type:

bool

class imfusion.gui.AnnotationModel#

Bases: pybind11_object

create_annotation(self: AnnotationModel, arg0: AnnotationType) → Annotation#
property annotations#
Type:

list[Annotation]

class imfusion.gui.ApplicationController#

Bases: pybind11_object

A ApplicationController instance serves as the center of the ImFusionSDK.

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

add_algorithm(self: ApplicationController, id: str, data: list = [], properties: Properties = None) → object#

Add the algorithm with the given name to the application.

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

>>> app.add_algorithm("Create Synthetic Data", [])  
<imfusion.BaseAlgorithm object at ...>
close_all(self: ApplicationController) → None#

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

execute_algorithm(self: ApplicationController, id: str, data: list = [], properties: Properties = None) → list#

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

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

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

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

open(self: ApplicationController, path: str) → list#

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

remove_algorithm(self: ApplicationController, algorithm: Algorithm) → None#

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

save_workspace(self: ApplicationController, path: str) → bool#

Saves current workspace to a iws file

select_data(self: ApplicationController, arg0: Data) → None#
select_data(self: ApplicationController, arg0: Sequence[Data]) → None

Function overload documentation:

select_data(self: ApplicationController, arg0: Data) → None
select_data(self: ApplicationController, arg0: Sequence[Data]) → None
update(self: ApplicationController) → None#
update_display(self: ApplicationController) → None#
property algorithms#

Return a list of all open algorithms.

Type:

list[Algorithm]

property annotation_model#
Type:

AnnotationModel

property data_model#
Type:

DataModel

property display#
Type:

Display

property selected_data#
Type:

list[Data]

class imfusion.gui.ConsoleController(self: ConsoleController, name: str = 'ImFusion Python SDK')#

Bases: ApplicationController

ApplicationController without a UI interface.

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

class imfusion.gui.DataModel#

Bases: pybind11_object

The DataModel instance holds all datasets of an ApplicationController.

__getitem__(self: DataModel, index: SupportsInt | SupportsIndex) → Data#
__getitem__(self: DataModel, indices: Sequence[SupportsInt | SupportsIndex]) → list[Data]
__getitem__(self: DataModel, slice: slice) → list[Data]

Function overload documentation:

__getitem__(self: DataModel, index: SupportsInt | SupportsIndex) → Data
__getitem__(self: DataModel, indices: Sequence[SupportsInt | SupportsIndex]) → list[Data]
__getitem__(self: DataModel, slice: slice) → list[Data]
add(self: DataModel, data: Data, name: str = '') → Data#
add(self: DataModel, data_list: Sequence[Data]) → list

Function overload documentation:

add(self: DataModel, data: Data, name: str = '') → Data

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

add(self: DataModel, data_list: Sequence[Data]) → list

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

clear(self: DataModel) → None#

Remove all data from the model

contains(self: DataModel, data: Data) → bool#
create_group(self: DataModel, arg0: Sequence[Data]) → DataGroup#

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

get(self: DataModel, name: str) → Data#
get_common_parent(self: DataModel, data_list: Sequence[Data]) → DataGroup#

Return the most common parent of all given Data

get_parent(self: DataModel, data: Data) → DataGroup#

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

index(self: DataModel, data: Data) → int#

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

remove(self: DataModel, data: Data) → None#

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

property root_node#

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

Type:

DataGroup

property size#

Return the total amount of data in the model

Type:

int

class imfusion.gui.Display#

Bases: pybind11_object

maximize_view(self: Display, view: View) → None#
unmaximize_view(self: Display) → None#
views(self: Display) → list#
views2d(self: Display) → list#
views3d(self: Display) → list#
views_slice(self: Display) → list#
property focus_view#
Type:

View

property layout_mode#
Type:

LayoutMode

class imfusion.gui.ImageView2D#

Bases: View

class imfusion.gui.ImageView3D#

Bases: View

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

Bases: Enum

LAYOUT_CUSTOM = 100#
LAYOUT_FOCUS_PLUS_ROWS = 2#
LAYOUT_FOCUS_PLUS_STACK = 1#
LAYOUT_ROWS = 0#
LAYOUT_SIDE_BY_SIDE = 3#
class imfusion.gui.SignalConnection#

Bases: pybind11_object

disconnect(self: SignalConnection) → bool#
property is_active#
Type:

bool

property is_blocked#
Type:

bool

property is_connected#
Type:

bool

class imfusion.gui.View#

Bases: pybind11_object

reset(self: View) → None#
property visible#
Type:

bool

class imfusion.gui.VisualizerHandle#

Bases: pybind11_object

The handle to a visualizer. It allows to close a specific visualizer when needed. Example:

>>> visualizer_handle = imfusion.show(data_list, title="MyData")  
>>> assert visualizer_handle.title() == "MyData"  
>>> ...  
>>> visualizer_handle.close() 
close(self: VisualizerHandle) → None#

Close the visualizer associated to this handle.

Note for Jupyter notebook users: closing the visualizer programmatically (via this method or by leaving the with block when used as a context manager) does not save the screenshot into the Jupyter notebook. The inline screenshot is only produced when the visualizer window is closed manually.

title(self: VisualizerHandle) → str#

Get the title of the visualizer associated to this handle.

imfusion.gui.close_viewers() → None#

Close all the visualizers that were opened with show().

imfusion.gui.list_viewers() → list[VisualizerHandle]#

Return a list of visualization handles that were created with show(). Please note that this method may return viewers that have been closed without VisualizerHandle.close() or close_viewers().

imfusion.gui.open_in_suite(data: Sequence[Data]) → None#

Starts the ImFusion Suite with the input data list. The ImFusionSuite executable must be in your PATH.

imfusion.gui.show(data: Data | Sequence[Data], *, title: str | None = None, block: bool | None = None) → VisualizerHandle#
imfusion.gui.show(path: PathLike | str | bytes, *, title: str | None = None, block: bool | None = None) → VisualizerHandle

Function overload documentation:

imfusion.gui.show(data: Data | Sequence[Data], *, title: str | None = None, block: bool | None = None) → VisualizerHandle

Launch a visualizer displaying the input Data (e.g. a SharedImageSet).

Parameters:
  • data – Input data to be displayed.

  • title – Optional window title.

  • block – Option to control whether to block or not the python interpreter while the visualizer is running. In case of None, the visualizer automatically becomes non-blocking when the Python interpreter is in interactive mode.

Returns:

A VisualizerHandle for the opened visualizer.

imfusion.gui.show(path: PathLike | str | bytes, *, title: str | None = None, block: bool | None = None) → VisualizerHandle

Launch a visualizer displaying the content of the file at the requested path.

Parameters:
  • path – Path to the file to be displayed. Please note that only .imf files are supported at this point.

  • title – Optional window title.

  • block – Option to control whether to block or not the python interpreter while the visualizer is running. In case of None, the visualizer automatically becomes non-blocking when the Python interpreter is in interactive mode.

Returns:

A VisualizerHandle for the opened visualizer.