structural
tit.pre.structural ¶
Preprocessing pipeline orchestration.
This module contains the top-level run_pipeline function that drives
all preprocessing steps for one or more subjects: DICOM conversion,
SimNIBS CHARM, FastSurfer deep segmentation, tissue analysis, DWI
preprocessing (QSIPrep, optional QSIRecon), and DTI tensor extraction
(DIPY on QSIPrep output).
Public API¶
run_pipeline Run the full preprocessing pipeline for one or more subjects.
See Also¶
tit.pre : Package-level overview and convenience re-exports.
run_pipeline ¶
run_pipeline(subject_ids: Iterable[str], *, convert_dicom: bool = False, run_fastsurfer: bool = False, charm_threads: int | None = None, charm_options: dict | None = None, fastsurfer_threads: int | None = None, run_freesurfer: bool = False, freesurfer_recon_all: bool = True, freesurfer_subregions: list[str] | None = None, freesurfer_threads: int | None = None, create_m2m: bool = False, run_tissue_analysis: bool = False, run_qsiprep: bool = False, run_qsirecon: bool = False, qsiprep_config: dict | None = None, qsi_recon_config: dict | None = None, extract_dti: bool = False, skip_existing_outputs: bool = False, replace_existing_outputs: bool = False, stop_event: object | None = None, logger_callback: Callable | None = None, runner: CommandRunner | None = None) -> int
Run the preprocessing pipeline for one or more subjects.
Orchestrates DICOM conversion, SimNIBS CHARM, FastSurfer deep segmentation, tissue analysis, QSIPrep/QSIRecon DWI preprocessing and DTI tensor extraction. Steps are enabled via boolean flags; disabled steps are skipped.
All step flags default to False; pass keyword arguments only.
Parameters¶
subject_ids : iterable of str
Subject identifiers without the sub- prefix (e.g.
["ernie", "101"]). Subjects run sequentially.
convert_dicom : bool, optional
Run DICOM-to-NIfTI conversion (sourcedata/sub-<id>/ to
sub-<id>/anat/).
run_fastsurfer : bool, optional
Run FastSurfer --seg_only deep segmentation.
charm_threads : int or None, optional
Thread count for SimNIBS charm; None uses its default.
charm_options : dict or None, optional
charm overrides: {"denoise": bool,
"segmentation_final_resolution": 0.5-2.0,
"skin_facet_size": 0.5-10.0} (keys optional; unknown keys
raise ValueError). None keeps the installed defaults.
fastsurfer_threads : int or None, optional
Thread count for FastSurfer inference.
run_freesurfer : bool, optional
Run FreeSurfer (requires a FreeSurfer install, which the standard
image does not ship).
freesurfer_recon_all : bool, optional
With run_freesurfer, run recon-all (default True); set
False to run only freesurfer_subregions on an existing
reconstruction.
freesurfer_subregions : list of str or None, optional
FreeSurfer subregion segmentations to add: any of
"thalamus", "hippo-amygdala".
freesurfer_threads : int or None, optional
Thread count for FreeSurfer.
create_m2m : bool, optional
Run SimNIBS charm to build m2m_<id> (also runs
subject_atlas for .annot files).
run_tissue_analysis : bool, optional
Run tissue-volume and thickness analysis.
run_qsiprep : bool, optional
Run QSIPrep DWI preprocessing via Docker.
run_qsirecon : bool, optional
Run QSIRecon reconstruction via Docker.
qsiprep_config : dict or None, optional
Extra configuration passed to run_qsiprep.
qsi_recon_config : dict or None, optional
Extra configuration passed to run_qsirecon.
extract_dti : bool, optional
Extract DTI tensor for SimNIBS anisotropic conductivity.
skip_existing_outputs : bool, optional
Skip selected preprocessing steps when their output already exists.
replace_existing_outputs : bool, optional
Remove selected existing outputs before rerunning their steps.
stop_event : object or None, optional
Threading event used to cancel running steps.
logger_callback : callable or None, optional
Callback used by the GUI to capture log lines.
runner : CommandRunner or None, optional
Subprocess runner used to stream command output.
Returns¶
int
0 on success, 1 on failure.
Raises¶
PreprocessError If no subjects are provided, both skip_existing_outputs and replace_existing_outputs are set, a required input is missing for a selected step (checked for every subject before anything runs), or a preprocessing step fails. PreprocessCancelled If stop_event is set during execution.
Examples¶
from tit.pre import run_pipeline run_pipeline(["ernie"], convert_dicom=True, create_m2m=True) # doctest: +SKIP 0 run_pipeline(["ernie", "101"], create_m2m=True, ... charm_options={"denoise": True}, ... skip_existing_outputs=True) # doctest: +SKIP 0
See Also¶
run_dicom_to_nifti : DICOM-to-NIfTI conversion step. run_fastsurfer : FastSurfer deep-segmentation step. run_charm : SimNIBS CHARM head-mesh step. run_tissue_analysis : Tissue analysis step. run_qsiprep : QSIPrep DWI preprocessing step. run_qsirecon : QSIRecon reconstruction step. extract_dti_tensor : DTI tensor extraction step.
Source code in tit/pre/structural.py
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | |