Python Environment

TI-Toolbox runs inside a container that wraps around SimNIBS. simnibs_python is SimNIBS’s own bundled interpreter, and it is where the tit package is installed — every simulation, optimization and analysis runs under it.

Where you actually type Python

  How to get there What it is
Notebooks, in the app The Notebooks page JupyterLab-style notebooks running against a kernel inside the container, so import tit works with no setup. This is the normal way to script the toolbox in v3.
Terminal, on a run page Select a submitted job A read-only live job log, not an interactive shell. Use Notebooks or docker exec to run your own code.
docker exec docker exec -it ti-toolbox-<hash>-tit-1 bash The same shell from your own terminal. tit launch --status prints the container’s name.
Your host pip install tit Only the launcher. tit launch starts the container; the science needs SimNIBS, which is in the image, not on your host.

If you want to add a package for a new feature, follow the steps below.

Environment Management

Task Command
Check location which simnibs_python
List installed packages simnibs_python -m pip list
Install package simnibs_python -m pip install <package>

Key Points

  • Containerized Setup: The environment is defined in container/blueprint/Dockerfile.ti-toolbox, with scientific dependency constraints in container/blueprint/runtime-constraints.txt. Scientific preparation uses SimNIBS 4.6 with NumPy 2.3.5. Montage rendering runs pinned standalone Blender 4.4.3 in a background process with its own Python environment; do not install bpy into SimNIBS or downgrade scientific NumPy to satisfy Blender. See Blender Integration. See the full-net montage memory guidance before allocating container resources.

  • Script executions: Inside the container, run scripts with simnibs_python script.py, not python.

  • Changes do not survive a rebuild: simnibs_python -m pip install <package> installs into the running container only. To keep it, add it to the Dockerfile and rebuild (container/blueprint/build.sh), or install it at the top of the notebook that needs it.

One-liner imports for common operations:

# Core (logging auto-initializes on import — no setup needed)
from tit import get_path_manager, paths, constants

# Simulation
from tit.sim import SimulationConfig, Montage, run_simulation, load_montages

# Optimization
from tit.opt import FlexConfig, run_flex_search
from tit.opt import ExConfig, run_ex_search

# Analysis
from tit.analyzer import Analyzer, run_group_analysis

# Statistics
from tit.stats import run_group_comparison, GroupComparisonConfig
from tit.stats import run_correlation, CorrelationConfig

# Preprocessing
from tit.pre import run_pipeline

Scientific modules import their scientific dependencies when used. The Docker image supplies SimNIBS and nibabel; importing the top-level tit package on the host does not load every scientific module.

JSON Config Modules

Each major module can be invoked as a subprocess accepting a JSON config file:

simnibs_python -m tit.sim        config.json
simnibs_python -m tit.analyzer   config.json
simnibs_python -m tit.opt.flex   config.json
simnibs_python -m tit.opt.ex     config.json
simnibs_python -m tit.opt.mex    config.json
simnibs_python -m tit.stats      config.json
simnibs_python -m tit.pre        config.json
simnibs_python -m tit.source     config.json
simnibs_python -m tit.blender    config.json

Config files are generated programmatically via tit.config_io.write_config_json(). See the Scripting page for details.