Installation

The public beta release of imfusion package can be installed directly from pip:

pip install imfusion-sdk

We also offer a more advanced versions with specialty modules for ultrasound, x-ray & computed tomography, mesh-based anatomy representation and registration, spine workflows and many more. You can get them from our webshop or by contacting us directly for a custom package. For more information, see With the ImFusion Suite.

Warning

The imfusion module requires Python 3.8 or higher. We recommend using official Python interpreters from python.org. Currently, this package is not tested with interpreters from Anaconda so use them at your own risk.

Note

While pip install can be run with the base interpreter, we highly recommended to create a virtual environment to avoid potential conflicts with other packages. See venv documentation and virtualenv documentation for more information on virtual environments in Python.

Note

If your python interpreter does not come with pip (it normally does), please consult the pip installation guide from PyPA.

License Activation

Before you can import imfusion you need to activate it once. If you have purchased imfusion in a bundle with the ImFusion Suite from our webshop, you should already have a license key. For installations from pypi.org (i.e. pip install), please visit our webshop for a free license key.

The activation can be done either through the ImFusionSuite (a prompt will appear the first time you start it) or through the Python CLI:

Linux and macOS:

env IMFUSION_LICENSE_KEY=<your-license-key> python3 -c "import imfusion"

Windows CMD:

set IMFUSION_LICENSE_KEY=<your-license-key> && python.exe -c "import imfusion"

A successful activation will exit without an error, while an unsuccessful one will print details of why the activation failed. The activation requires an active internet connection. A proxy can be set with the HTTPS_PROXY environment variable. The IMFUSION_LICENSE_KEY only needs to be set once for the initial activation.

With the ImFusion Suite

The ImFusion Suite provides an embedded Python interpreter and console and comes bundled with the imfusion package (see Locating the imfusion package).

Note

The imfusion package requires the numpy package to be installed. While the ImFusion Suite installers provide the files of imfusion, it is not installing it for any specific interpreter. It is therefore on the user to install numpy for whichever interpreter they intend to use imfusion with.

On first start, the ImFusionSuite will try to automatically detect an installed Python environment. If this doesn’t work or if you want to use e.g. a different Python version, you can configure different versions in Settings -> Python -> Active Environment. Click on the ‘+’ button to add the path to the Python interpreter you want to use. If the interpreter is located inside of a virtual environment, the ImFusion Suite interpreter will use the corresponding environment.

Warning

The Python integration in the ImFusion Suite works only if you have a shared library for the interpreter you want to use on you system. On Windows / macOS, it is included in the form of a .dll / .dylib (e.g. libpython39.dll or libpython3.9.dylib) in the installers provided on python.org. If you are on Ubuntu and you install your Python interpreter from the deadsnakes PPA, you must install the pythonX.YY-dev package to also obtain the shared library. If loading the library fails, you won’t see the Python console and an error is printed in the log window.

Note

The interpreter in the ImFusion Suite currently only supports virtual environments created through venv or virtualenv. Anaconda is not supported at the moment.

It is also possible to select a Python dynamic library directly, instead of choosing an interpreter. You will have to change the filter (lower right) in the file dialog for dynamic libraries to show up. We don’t recommend using this, however, as this implies that you will be using the base interpreter and any packages you need would have to be installed in the base interpreter

If the environment is correctly configured, the interpreter is automatically initialised when the ImFusionPython plugin is loaded. Otherwise, an error is displayed in the log window. Depending on the size of your log window the error might go out of the visible scope and you have to scroll up to see it.

Note

If you cannot see a Python console in the bottom right of the window, go to Settings -> Python and select the desired console.

Locating the imfusion package

Ubuntu

If you installed the ImFusionSuite through the Ubuntu .deb package. The imfusion module is installed to the default Python module location (/usr/lib/python3/dist-packages) and is therefore available if you are using the system interpreter (i.e. python3). If you are working with virtual environments you have to pass the --system-site-packages flag during the creation of the environment to include this directory in its Python path. You also have the option enabling this behavior for existing environments by setting the value of ìnclude-system-site-packages to true in <path-to-your-venv>/pyvenv.cfg.

Standalone Linux

With the Standalone Linux installer, you have to point your PYTHONPATH or sys.path to the directory containing the imfusion module. The actual path depends on where you installed the ImFusionLib, e.g. if installed to opt, the path is /opt/ImFusionSuite/lib/python3/dist-packages.

Windows

On Windows you also have to set the PYTHONPATH or sys.path.

set PYTHONPATH=%PYTHONPATH%;C:\\Program Files\\ImFusion\\ImFusion Suite\\Suite