Installation#

The developer version of InVesalius runs on Windows, macOS, and Linux operating systems. On this page, instructions for installing and running InVesalius on these systems can be found.

Windows#

These instructions are tested on Windows 10 64-bit. The packages required by InVesalius can be installed either through a Python system installation, the Anaconda package manager, or using uv. In all cases, the following prerequisites apply:

Prerequisites#

  • Visual Studio (We are using the 2019 community edition).

    • It’s possible to install using chocolatey:

       choco install -y visualstudio2019buildtools
       choco install -y visualstudio2019-workload-vctools
      
  • Download InVesalius source code.

    git clone --recurse-submodules https://github.com/invesalius/invesalius3
    

Installation Options#

Option 2: Python System Installation#

  1. Download and install Python 3.8 from the Python website.

  2. Create a virtual environment using

    python3 -m venv .venv
    
  3. Activate the virtual environment using

    .venv\bin\activate
    
  4. Install InVesalius main dependencies and compile cython extensions using pip:

    pip install -e .
    
  5. If you are going to use the neuronavigation features, install the wrappers for tracking devices:

    pip install pyclaron polhemusFT polhemus pypolaris pypolarisP4
    
  6. Optional: To enable real-time tractography computation, install Trekker:

    pip install https://github.com/dmritrekker/trekker/raw/master/binaries/Trekker-0.9-cp38-cp38-win_amd64.whl
    

Option 3: Anaconda Installation#

  1. Install Anaconda, preferably the 64-bit version.

  2. In the Anaconda Powershell, navigate to the cloned InVesalius source code folder:

    cd C:\Users\%USERNAME%\repository\invesalius3\
    
  3. Install the required packages:

    conda env create -f environment.yml --name invesalius
    
  4. Activate the virtual environment:

    conda activate invesalius
    
  5. Compiling InVesalius:

    Some algorithms of InVesalius are written in Cython for performance. These need to be compiled manually:

    python setup.py build_ext --inplace
    

Running InVesalius#

Inside the InVesalius source code directory, run:

python app.py

Warning: If using Anaconda or pip , always activate the environment using .venv\bin\activate before running the command.

If using uv, simply run:

uv run app.py

MacOS#

This guide is based on High Sierra.

Prerequisites#

The first step is the installation of homebrew. Access the homebrew site to know how to install it.

We recommend installing Python 3 from brew, and also installing OpenMP (we use it):

brew install python3 libomp

If you are working with an Apple Silicon Mac, you also have to install hdf5:

brew install hdf5

Clone InVesalius 3 using git:

git clone --recurse-submodules https://github.com/invesalius/invesalius3

Installation#

To run the following commands, ensure your shell is inside the InVesalius folder:

cd invesalius3

Preferred Installation Method (Using uv)#

We have transitioned to using uv for dependency management and scikit-build-core with CMake for compiling Cython modules.

  1. Install uv:

    brew install uv
    
  2. Sync dependencies:

    a) First-time installation (or when compiling Cython extensions):

    OpenMP_ROOT=$(brew --prefix)/opt/libomp uv sync
    

    b) For subsequent dependency synchronization (when Cython compilation is not needed):

    uv sync
    

Alternative Installation Method (Legacy pip Workflow)#

Install dependencies using:

pip3 install -r requirements.txt
Compiling InVesalius (Legacy)#

If you are using a Mac with Apple Silicon, export the following environment variables before compiling:

export CFLAGS="-I/opt/homebrew/opt/libomp/include"
export CPPFLAGS="-I/opt/homebrew/opt/libomp/include"
export LDFLAGS="-L/opt/homebrew/opt/libomp/lib"

Compile the Cython packages used by InVesalius:

python3 setup.py build_ext --inplace

Running InVesalius#

Preferred Method (Using uv)#

After installation, launch InVesalius with:

uv run app.py

Alternative Method (Using Python Directly)#

python3 app.py

If you encounter the following error:

This program needs access to the screen. Please run with a
Framework build of python, and only when you are logged in
on the main display of your Mac.

Run InVesalius using:

pythonw app.py

Linux#

Packages Debian and Ubuntu#

InVesalius is already packaged and is in the main repos from Debian and Ubuntu. Install it using this command:

sudo apt install invesalius

If you want the most updated packages, there is also a PPA to Ubuntu:

sudo add-apt-repository ppa:tfmoraes/invesalius
sudo apt-get update
sudo apt install invesalius

After the installation, InVesalius appears in your system menu. You can also run it from the command line:

invesalius3

Other Distros#

InVesalius is packaged as Flatpak. First, you need to add the Flathub repo:

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

Then install InVesalius:

flatpak install flathub br.gov.cti.invesalius

After the installation, InVesalius appears in your system menu. You can also run it from the command line:

flatpak run br.gov.cti.invesalius

Source Code#

Use this command to get InVesalius source code from GitHub:

git clone --recurse-submodules https://github.com/invesalius/invesalius3

Installing Dependencies#

Using System Packages#
Debian and Ubuntu (Tested in Ubuntu 20.04)#

sudo apt install python3-wxgtk4.0 python3-numpy python3-scipy python3-pil python3-matplotlib python3-skimage python3-nibabel python3-serial python3-psutil python3-vtk7 python3-vtkgdcm python3-gdcm cython3 python3-h5py python3-imageio python3-keras python3-pubsub

Ubuntu don’t have PlaidML in their repositories, so install it using pip:

pip3 install --user plaidml-keras

Fedora (Tested in Fedora 32)#

sudo dnf install gcc gcc-g++ python3-wxpython4 python3-numpy python3-scipy python3-matplotlib python3-scikit-image python3-nibabel python3-pyserial python3-psutil python3-vtk python3-gdcm python3-Cython python3-h5py python3-pypubsub

Unfortunately, Fedora doesn’t have python3-imageio package. But it’s possible to install it using pip:

pip3 install --user imageio

Fedora don’t have PlaidML in their repositories, so install it using pip:

pip3 install --user plaidml-keras

Arch Linux#

sudo pacman -S cython python-pip python-numpy python-scipy python-scikit-learn python-wxpython python-pyserial python-psutil python-h5py python-pypubsub python-mpi4py python-matplotlib vtk clinfo opencl-headers gdal glew hdf5 jsoncpp netcdf pdal pugixml proj

You have to install some packages from AUR, I’m using Pikaur to install them:

pikaur -S --noconfirm gdcm python-nibabel python-scikit-image python-imageio python-plaidml python-plaidml-keras

Running InVesalius#

To run InVesalius, enter the InVesalius folder and use one of the following commands:

If using uv, run this command:

uv run app.py

If using pip,run this command:

python3 app.py

You can pass a DICOM folder as a parameter to make InVesalius start with the DICOM loaded.

Using uv:

uv run app.py -i /dicom/folder

Using Python:

python3 app.py -i /dicom/folder

It’s possible to make InVesalius load a DICOM folder,
create a surface (mesh) with the given threshold, and export the surface to an STL file without loading any GUI:

Using uv:

uv run app.py --no-gui -i /media/thiago/Documentos/dcm/0051 -t 200,3033 -e /tmp/0051.stl

Using Python:

python3 app.py --no-gui -i /media/thiago/Documentos/dcm/0051 -t 200,3033 -e /tmp/0051.stl