Python Environment

The TI-Toolbox operates within a containerized environment that includes SimNIBS. The simnibs_python interpreter is SimNIBS’s bundled Python environment that provides all libraries for TI-Toolbox operations. 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.simnibs, which installs SimNIBS v4.6.0 and additional Python packages (meshio, nilearn, PyOpenGL-accelerate, trimesh, seaborn) required for TI-Toolbox functionality.

  • Script executions: All python scripts should be executed using the simnibs_python script.py.

Import Patterns

As of v2.2.4, the tit.core sub-package has been dissolved. Modules that used to live under tit.core are now top-level within the tit package:

Old import (removed) New import
from tit.core.paths import PathManager from tit.paths import PathManager
from tit.core.constants import ... from tit.constants import ...
from tit.core.calc import ... from tit.calc import ...
from tit.core.errors import ... from tit.errors import ...

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

# Preprocessing
from tit.pre import run_pipeline

All imports are eager — SimNIBS and nibabel are always available in the Docker environment.

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.stats      config.json
simnibs_python -m tit.pre        config.json

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