KAHIBARO
Discord Login Register

2.1. GATE Requirements

Python

GATE in this course means OpenGATE, the Python front end that controls Geant4. Your simulations are written in Python scripts, so a working Python installation is essential.

You should use a recent Python 3 version, typically Python 3.9 or later. Many scientific packages drop support for very old versions of Python, so staying reasonably up to date avoids problems.

On most systems you do not run the system Python directly. Instead you create an isolated environment for GATE, which you will do in the next chapter. For now, make sure:

  1. Python 3 is installed and available on your system.
  2. You know how to open a terminal and run
    python3 --version or python --version to see the installed version.
  3. You can install Python packages with either pip or conda (you will pick one workflow).

OpenGATE requires Python bindings for Geant4. These come through the OpenGATE / Geant4 build and will be imported in Python with:

python
import opengate

You do not write C++ code here, but the Python layer will communicate with Geant4 in the background. That is why both Python and Geant4 are required.

Geant4

Geant4 is the C++ simulation engine underneath GATE. It tracks particles through matter and handles all the physics processes. GATE is essentially a high level interface that configures and controls a Geant4 simulation in a way that is convenient for medical physics.

You need a Geant4 version that is compatible with the OpenGATE version you plan to use. The OpenGATE documentation specifies which Geant4 releases are supported. The basic requirements are:

Geant4 with multithreading support enabled.
Geant4 built with the same compiler toolchain as your Python environment (especially important on Linux).
Geant4 compiled with the necessary data libraries for electromagnetic and hadronic physics.

Visualization support in Geant4, for example using Qt or OpenGL, is strongly recommended. It allows you to inspect geometry visually, which is very important when you are learning.

On many systems you will not install Geant4 separately. Instead, you may use prebuilt containers or dedicated installers that already bundle a compatible Geant4 and OpenGATE together. However, it is still useful to understand that:

Geant4 provides the physics and geometry kernel.
GATE configures that kernel and adds medical-physics specific tools.
Python scripts control GATE and hence indirectly control Geant4.

If you compile Geant4 yourself, you typically use CMake and a C++ compiler, and you define an installation directory. OpenGATE then has to know where this Geant4 installation is located.

GATE packages

The core Python package you use in this course is called opengate. It provides:

The Simulation object that you create in your scripts.
Python classes for volumes, sources, physics lists, actors, digitizers, and many high level utilities.
Bindings that forward your Python configuration to the underlying Geant4 engine.

In addition to opengate, several helper packages are usually required or strongly recommended:

opengate-core or similar low level components, if your distribution separates the core from higher level utilities.
Optional modules for visualization or analysis, depending on the installation method.

The exact list of GATE related Python packages depends on how you install OpenGATE. For example:

If you use a conda distribution, there may be a meta package that installs OpenGATE and all its dependencies at once.
If you build from source, the installation may produce a local Python module named opengate that lives inside your build directory or installation prefix.

In this course you will assume that the opengate package is importable from Python. When you set up your environment, you will verify this with:

python
import opengate
print(opengate.__version__)

Internally, GATE also relies on Geant4 data libraries and, in some setups, on additional physics or visualization libraries. You normally do not install those separately; they are handled by the Geant4 or OpenGATE installation procedure.

Scientific Python environment

To do useful work with GATE you need more than opengate. You also need a basic scientific Python environment for data handling and analysis. The most common requirements are:

NumPy
NumPy provides multi dimensional arrays and basic numerical functions. Most array based operations in this course use NumPy. You will typically import it as:

python
import numpy as np

Pandas (optional but useful)
Pandas simplifies working with tabular data such as lists of hits, singles, or coincidences stored in ROOT derived formats or CSV files. It is often imported as:

python
import pandas as pd

Matplotlib
Matplotlib is used to create plots and figures, for example:

Energy spectra.
Depth dose curves.
Projection images and profiles.

You will usually import it as:

python
import matplotlib.pyplot as plt

Uproot (for ROOT file access)
GATE can write ROOT files. Uproot lets you read ROOT data directly from Python without a C++ ROOT installation. You can then convert data into NumPy arrays or Pandas DataFrames for analysis.

SciPy (optional)
SciPy adds optimization, interpolation, statistics, and other utilities that can be useful for more advanced analysis, fitting curves, or processing dose distributions.

The table below summarizes the most important scientific Python packages for this course:

PackageMain purpose
NumPyArrays, numerical calculations
MatplotlibPlots and figures
PandasTables, convenient data manipulation
UprootReading GATE ROOT files with Python
SciPyAdvanced numerical and statistical methods

You will install these packages inside a dedicated Python environment using either pip or conda. This keeps the GATE related setup separate from other projects and helps to avoid version conflicts.

Remember that your simulation workflow will typically follow this pattern:

Use Python with opengate to configure and run a GATE simulation.
Let GATE and Geant4 generate output files, such as ROOT or image files.
Use the scientific Python environment to read, analyze, and visualize these results.

Once all these components Python, Geant4, GATE packages, and the scientific Python stack are available and compatible, you are ready to move on to creating and managing a dedicated environment for your GATE work.

Views: 11

Comments

Please login to add a comment.

Don't have an account? Register now!