engine
tit.opt.ex.engine ¶
Single-class exhaustive search engine.
Replaces: runner.py (5 classes), roi_utils.py (4 functions). Direct SimNIBS usage — ROI metrics are computed inline.
ExSearchEngine ¶
ExSearchEngine(leadfield_hdf: str, roi_file: str | tuple[str, int] | list[str | tuple[str, int]], roi_name: str, logger: Logger)
Exhaustive TI electrode search engine.
Owns the full pipeline: leadfield loading, ROI resolution, simulation loop, and ROI CRUD.
Source code in tit/opt/ex/engine.py
initialize ¶
initialize(roi_radius: float = 3.0) -> None
Load leadfield, resolve the ROI (CSV/mask/atlas), find ROI + GM elements.
Source code in tit/opt/ex/engine.py
compute_ti_fields ¶
compute_ti_fields(e1_plus: str, e1_minus: str, e2_plus: str, e2_minus: str, current_ratios: list[tuple[float, float]]) -> list[dict[str, float]]
ROI metrics of one electrode montage at every current split.
The field is linear in the injected current, so each channel's
unit-current field is gathered once and scaled per split -- the
same current * (lf[a] - lf[b]) arithmetic TI.get_field
performs, restricted to the elements the metrics read.
Source code in tit/opt/ex/engine.py
compute_ti_field ¶
compute_ti_field(e1_plus: str, e1_minus: str, current_ch1_mA: float, e2_plus: str, e2_minus: str, current_ch2_mA: float) -> dict[str, float]
Compute TI field for one montage and return ROI metrics.
Source code in tit/opt/ex/engine.py
run ¶
run(e1_plus: list[str], e1_minus: list[str], e2_plus: list[str], e2_minus: list[str], current_ratios: list[tuple[float, float]], all_combinations: bool, output_dir: str, n_jobs: int = 1, symmetry_mirror_map: dict[str, str] | None = None, symmetry_pairing: str = 'within_pairs') -> dict[str, dict[str, float]]
Run the full simulation loop. Returns {mesh_key: metrics}.
Candidates are evaluated in enumeration order, one electrode
montage (all its current splits) per task, on n_jobs forked
workers (n_jobs < 1: the job's CPU budget, see
:func:tit.opt.ex.parallel.resolve_n_jobs; 1: in-process).
A symmetry_mirror_map (bucket mode) restricts the enumeration to
left/right mirrored montages (see :mod:tit.opt.ex.symmetry).
Source code in tit/opt/ex/engine.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
get_available_rois
staticmethod
¶
List ROI CSV files for a subject.
Source code in tit/opt/ex/engine.py
create_roi
staticmethod
¶
Create an ROI CSV from coordinates.
Source code in tit/opt/ex/engine.py
delete_roi
staticmethod
¶
Delete an ROI file and remove from roi_list.txt.
Source code in tit/opt/ex/engine.py
get_roi_coordinates
staticmethod
¶
Read ROI center coordinates from CSV.