preflight
tit.pre.preflight ¶
Preprocessing output preflight and rerun policy helpers.
PreprocessingOutput
dataclass
¶
PreprocessingOutput(subject_id: str, step: str, label: str, path: Path, cleanup_paths: tuple[Path, ...] = (), missing: tuple[str, ...] = ())
Existing output for one preprocessing step.
missing names the files the step's producer writes when it finishes and that
are not there: a non-empty value means an earlier run was interrupted, so the
output is incomplete -- "skip" must not keep it, only "replace" can clear it.
PreprocessingInputProblem
dataclass
¶
Missing or invalid input for one selected preprocessing step.
missing_inputs_for_step ¶
missing_inputs_for_step(project_dir: str, subject_id: str, step: str, *, qsirecon_atlases: Sequence[str] = ()) -> list[PreprocessingInputProblem]
Return missing required inputs for one subject and preprocessing step.
Each check is the one the step's runner makes before it starts, read from disk as it
is now. qsirecon_atlases are the QSIRecon atlases requested: they need the MNI
transform in the QSIPrep output. :func:find_missing_preprocessing_inputs drops the
problems a step selected earlier in the same run will fix.
Source code in tit/pre/preflight.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 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 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
find_missing_preprocessing_inputs ¶
find_missing_preprocessing_inputs(project_dir: str, subject_ids: Iterable[str], *, steps: Sequence[str] | None = None, convert_dicom: bool = False, create_m2m: bool = False, run_fastsurfer: bool = False, run_freesurfer: bool = False, freesurfer_recon_all: bool = True, freesurfer_subregions: Sequence[str] = (), run_tissue_analysis: bool = False, run_qsiprep: bool = False, run_qsirecon: bool = False, extract_dti: bool = False, skip_existing_outputs: bool = False, qsiprep_config: Mapping[str, Any] | None = None, qsi_recon_config: Mapping[str, Any] | None = None) -> list[PreprocessingInputProblem]
Return missing inputs that can be detected before running subprocesses.
qsiprep_config and qsi_recon_config are the run's settings dicts (only
mni_normalization and atlases are read): QSIRecon atlases need QSIPrep's MNI
transform. Under skip_existing_outputs, tissue analysis and QSIRecon are not
checked where their output already exists, since the runner skips them there.
Source code in tit/pre/preflight.py
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 410 411 412 413 414 415 416 417 418 419 420 421 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 | |
missing_freesurfer_license ¶
missing_freesurfer_license(selected_steps: Sequence[str], subject_ids: Sequence[str] = ()) -> list[PreprocessingInputProblem]
One problem naming exactly which selected stages need a license, or none.
Only :data:LICENSED_STEPS are checked, so a FastSurfer segmentation-only
run is never held up by a missing license.
Source code in tit/pre/preflight.py
existing_outputs_for_step ¶
existing_outputs_for_step(project_dir: str, subject_id: str, step: str) -> list[PreprocessingOutput]
Return existing outputs for one subject and preprocessing step.
Source code in tit/pre/preflight.py
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | |
step_output_complete ¶
Return True when step has an output for subject_id and it is finished.
A folder an interrupted run left behind is an existing output (replace can clear it) but not a complete one: FastSurfer without its segmentation, charm without its mesh and final segmentation, QSIPrep without a preprocessed DWI, tissue analysis without every tissue's report, a zero-byte DTI tensor. Callers that show whether a stage is done use this, not the folder's existence. FreeSurfer recon-all and QSIRecon have no completion marker, so any non-empty output of theirs counts as complete.
Source code in tit/pre/preflight.py
selected_preprocessing_steps ¶
selected_preprocessing_steps(*, convert_dicom: bool = False, create_m2m: bool = False, run_fastsurfer: bool = False, run_freesurfer: bool = False, freesurfer_recon_all: bool = True, freesurfer_subregions: Sequence[str] = (), run_tissue_analysis: bool = False, run_qsiprep: bool = False, run_qsirecon: bool = False, extract_dti: bool = False) -> list[str]
Return output-producing steps enabled by the current run options.
Source code in tit/pre/preflight.py
find_existing_preprocessing_outputs ¶
find_existing_preprocessing_outputs(project_dir: str, subject_ids: Iterable[str], *, steps: Sequence[str] | None = None, convert_dicom: bool = False, create_m2m: bool = False, run_fastsurfer: bool = False, run_freesurfer: bool = False, freesurfer_recon_all: bool = True, freesurfer_subregions: Sequence[str] = (), run_tissue_analysis: bool = False, run_qsiprep: bool = False, run_qsirecon: bool = False, extract_dti: bool = False) -> list[PreprocessingOutput]
Return outputs that already exist for selected subjects and steps.
Source code in tit/pre/preflight.py
remove_preprocessing_output ¶
remove_preprocessing_output(output: PreprocessingOutput) -> None
Remove an existing preprocessing output before an explicit rerun.