Medical Imaging Interaction Toolkit  2023.12.99-77685e7b
Medical Imaging Interaction Toolkit
Python Module

Brief description

The MITK Python Module provides a service class to interactively run python code (passed as C++ strings) and evaluate the results. Furthermore the service class offers means to convert an MITK Image to an ITK image in their wrapped python environment. Thus, one can process MITK images with Python Code from the ITK wrapping system. Furthermore one can convert an mitk::Surface to a vtkPolyData in its Python environment.
Under the hood, the MITK build system takes care that the wrapping build process for SimpleITK/VTK is correctly initiated and all paths are correctly set within MITK code. To use the features of the different toolkits make sure they are enabled during the superbuild process.

Build Instructions

Have a look at Suported Data Types on how to build MITK-Python with Qt6. The following CMake build options are available:

  • MITK_USE_Python3

MITK_USE_Python3

MITK_USE_Python3 enables the python wrapping in MITK. When the option is activated the build of the additional dependency SimpleITK is also enabled. The default behaviour is to use the python runtime from the system is used. Only Python 3.x is supported. The user can also specify it's own runtime by modifying the variables added by the FindPythonLib.cmake script. Note: A Python runtime with numpy is needed to use the MITK Python wrapping. When using this options all additional libraries installed in the python runtime will be available within the MITK-Python console.

Suported Data Types

The following data types in MITK are supported in the MITK Python Wrapping:

  • Image
  • Surface

Image

Mitk Images can be transferred to python. The images are copied in-memory and transferred as a numpy array to Python and vice versa. The MITK python wrapping creates a SimpleITK image using the numpy array with the properties of the MITK Image.

Surface

Surfaces within mitk can be transferred as a vtkPolyData Object to Python. The surfaces are fully memory mapped. When changing a python wrapped surface the original object is also modified on the C++ side of MITK.