1. Download the code

Go to GitLab - OpenTPS

git clone https://gitlab.com/openmcsquare/opentps.git

Don’t hesitate to register as OpenTPS user and tell us more about your project by clicking here

2. Install OpenTPS libraries on your computer

To set up OpenTPS on your computer, you have three options (and you only need to choose one of these).

  1. Install the latest version of Anaconda. Download the latest version from https://www.anaconda.com/.

  2. In a conda prompt, create a new virtual environment with python 3.9 and activate it:
    conda create --name OpenTPS python=3.9
    conda activate OpenTPS
  3. Install OpenTPS:
    pip install opentps
  4. start it with:

Always ensure that you have the “OpenTPS” environment activated before launching the software

/!\ Only available on windows and linux

2.2.1 On Windows :

After cloning the git repository, you will find two .bat files in the main directory: (install_opentps_windows.bat and start_opentps_windows.bat).

To begin, open a command prompt and navigate to the main directory. Run first :


Which will create a new Python environment named “OpenTPS” and download all the necessary packages.

Once that is done, still in the same directory, execute


To launch the OpenTPS software

2.2.2 On Linux :

After cloning the git repository, you will find two .sh files in the main directory: (install_opentps_linux.sh and start_opentps_linux.sh).

To begin, open a command prompt and navigate to the main directory. Run first :

bash install_opentps_linux.sh

Which will create a new Python environment named “OpenTPS” and download all the necessary packages.

Once that is done, still in the same directory, execute

bash start_opentps_linux.sh

To launch the OpenTPS software

2.3. Configure Python or your IDE

OpenTPS is split within a single package named opentps into two separate distribution packages: opentps_core and opentps_gui. To import modules from those subpackages as

from opentps.core import ...
from opentps.gui import ...

python or your IDE must be appropriately configured.

NB: We recommend using Visual Studio Code or PyCharm as IDEs, as we have experienced issues with others IDE (Spyder,…).

2.3.1. Using Anaconda

Tell conda to add opentps_core and opentps_gui to its site-packages directory list. This works by creating a conda.pth file in site-packages.

conda-develop path/to/opentps/opentps_core
conda-develop path/to/opentps/opentps_gui

If command conda-develop is not available. You might need to install conda-build first

conda install conda-build

NB: if the option “install for all users” has been selected at installation of anaconda, the conda-develop need admin privileges and after closing the prompt, the open_tps packages are “lost”. The only fix known is to re-install anaconda for only one user

2.3.2. Without Anaconda
a. On Linux

Tell Python to add opentps_core and opentps_gui to its sys.path directory list.

export PYTHONPATH="path/to/opentps/opentps_core:path/to/opentps/opentps_gui:$PYTHONPATH"

Note that you will need to use this command each time you launch a new terminal. To make this change permanent: add this line to your .bashrc file

b. On Windows:

Add new environment variable PYTHONPATH:

Windows11 :

  1. Open “Settings” -> “System”
  2. On the right side, at lower end, click on “About”.
  3. Then click on “Advanced systems settings”.

Previous version of Windows

  1. Got to the Windows menu, right-click on “Computer” and select “Properties”:
  2. From the computer properties dialog, select “Advanced system settings” on the left:

From the advanced system settings dialog, choose the “Environment variables” button:

In the Environment variables dialog, click the “New” button in the top half of the dialog, to make a new user variable:

Give the variable name as PYTHONPATH and the value is the path to the code directory (i.e. path/to/opentps/opentps_core and path/to/opentps/opentps_gui). Choose OK and OK again to save this variable.

c. Configure PyCharm

Once you have opened the cloned folder in pycharm you should have this on the project panel on the left.

alt text

If you did not configure your Python to add the core and gui package (See Configure Python section above), the opentps_core and opentps_gui folder will not be considered as packages. You have to add them as content roots such as Pycharm has access to both folders as if they were individual projects (which they kind of are).

In File > Settings > Project > Project Structure, remove the current content root on the right panel.

alt text

And add the opentps_core and opentps_gui folders as content root

alt text

Examples from the opentps_core > opentps > core > examples folder should now run, as well as the main.py file in opentps_gui > opentps > gui to launch the GUI.

NB: Tutorial made using pycharm 2022.2.1 community edition

d. Configure VS Code

When using VS Code with anaconda (for information on how to set up anaconda with VS code, see here), following the python with anaconda configuration should set up VS Code properly.

If this does not work or you are not using Anaconda, follow the guidelines from VS code website on multi-root workspaces to add opentps_core and opentps_gui to content root.

2.3.3. Launch the GUI

The gui may be launched by executing opentps_core/opentps/gui/main.pyor via a script with:

import opentps.gui as opentps_gui

Note that the GUI will block the main thread.

Latest Posts

OpenTPS at BHPA 2024

Last february second, Ana M. Barragán-Montero has been given the chance to present the OpenTPS project at the Belgian Hospital Physics Association (BHPA) annual symposium. This talk was the opportunity to present our project to the medical physics community. The OpenTPS team is looking forward to future occasion of presenting our work to the community. Our philosophy is based on open-source therefore we are grateful of such ways of exchanging with other medical physics experts.

Optimization of proton arc therapy treatment plans


For abstract refer to the full text link down below

Towards fast plan adaptation for ArcPT technology

Current approaches for dose optimization of arc proton therapy (arcPT) plans suffer from optimization times ranging from several minutes to hours. In the context of adaptive proton therapy, we aim to speed up the plan reoptimization process. To achieve this, instead of optimizing a new arcPT plan from scratch for each adaptive fraction, we propose to update the initial spot positions and their corresponding energies to the new anatomy of the day. Following this, we proceed to re-optimize only the most pertinent spot weights, which comprise less than 15% of all the spots. Currently, this approach allows arcPT plans to be adapted in less than 1 hour on a laptop (future evaluations will require more powerful computers).