base
tit.sim.base ¶
Base simulation class with shared logic for TI and mTI simulations.
BaseSimulation factors out the identical code shared by
TISimulation and mTISimulation:
__init__-- config, montage, logger, path manager, m2m_dir_apply_tissue_conductivities--SimulationConfig.tissue_conductivitiesoverridesrun-- template method (setup dirs, viz, build session, post-process)_init_session-- common SESSION setup (subpath, tensor, eeg_cap, flags)_add_electrode_pair-- electrode creation on a TDCS list_cropped_carriers/_write_volume_mesh/_write_central_surface-- the field outputs (:mod:tit.calcover all channel fields, any even count)
Subclasses implement the following abstract interface:
_simulation_mode-- property returningSimulationMode.TIor.MTI_montage_type_label-- property returning"TI"or"mTI"_montage_imgs_key-- property returning dirs key for montage images_build_session-- mode-specific (TI or mTI) session construction_post_process-- field computation and file organization
See Also¶
TISimulation : Two-channel TI implementation. mTISimulation : N-channel mTI implementation. SimulationConfig : Configuration consumed by simulations. run_simulation : Top-level orchestration entry point.
BaseSimulation ¶
BaseSimulation(config: SimulationConfig, montage: Montage, logger)
Bases: ABC
Abstract base class for TI/mTI simulations.
Provides the template-method run pipeline that subclasses
customise by implementing _build_session and _post_process.
Parameters¶
config : SimulationConfig Fully specified simulation configuration. montage : Montage The electrode montage to simulate. logger : logging.Logger Logger instance for status and diagnostic messages.
Attributes¶
config : SimulationConfig
Simulation configuration supplied at construction.
montage : Montage
Electrode montage supplied at construction.
logger : logging.Logger
Logger instance used throughout the pipeline.
pm : tit.paths.PathManager
Singleton path manager for BIDS path resolution.
m2m_dir : str
Absolute path to the subject's m2m_<subject> directory.
See Also¶
TISimulation : Concrete two-channel TI subclass.
mTISimulation : Concrete N-channel mTI subclass.
run_simulation : Orchestrates BaseSimulation.run across montages.
Source code in tit/sim/base.py
run ¶
Execute the full simulation pipeline for one montage.
This template method orchestrates directory setup, montage visualisation, SimNIBS FEM execution, and subclass-specific post-processing.
Parameters¶
simulation_dir : str
Root simulations directory for the subject.
overwrite : bool
Replace an earlier result of this montage. The earlier run's
derived outputs are removed first (see
:func:tit.sim.utils.clear_previous_outputs), so the folder holds
exactly what the new config.json says.
Returns¶
dict
Result dictionary with keys montage_name, montage_type,
status, and output_mesh.
Raises¶
FileExistsError
If overwrite is False and the montage folder already holds a
result mesh. Nothing is written, config.json included.
See Also¶
run_simulation : Calls run for each montage in a config.
Source code in tit/sim/base.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |