Pipeline & Run¶
Top-level orchestration: process a single image or a whole dataset, and shared pipeline helpers.
spineps.seg_run¶
spineps.seg_run
¶
Top-level SPINEPS pipeline orchestration for running spine segmentation over datasets and single niftys.
process_dataset
¶
process_dataset(
dataset_path: Path,
model_instance: Segmentation_Model,
model_semantic: list[Segmentation_Model]
| Segmentation_Model
| None = None,
model_labeling: VertLabelingClassifier | None = None,
rawdata_name: str = "rawdata",
derivative_name: str = "derivatives_seg",
modalities: list[Modality_Pair] | Modality_Pair = [
(Modality.T2w, Acquisition.sag)
],
save_debug_data: bool = False,
save_modelres_mask: bool = False,
save_softmax_logits: bool = False,
save_log_data: bool = True,
override_semantic: bool = False,
override_instance: bool = False,
override_postpair: bool = False,
override_ctd: bool = False,
snapshot_copy_folder: Path | None | bool = None,
pad_size: int = 4,
proc_sem_crop_input: bool = True,
proc_sem_n4_bias_correction: bool = True,
proc_sem_remove_inferior_beyond_canal: bool = False,
proc_sem_clean_beyond_largest_bounding_box: bool = True,
proc_sem_clean_small_cc_artifacts: bool = True,
proc_inst_corpus_clean: bool = True,
proc_inst_clean_small_cc_artifacts: bool = True,
proc_inst_largest_k_cc: int = 0,
proc_inst_detect_and_solve_merged_corpi: bool = True,
proc_lab_force_no_tl_anomaly: bool = False,
proc_fill_3d_holes: bool = True,
proc_assign_missing_cc: bool = True,
proc_clean_inst_by_sem: bool = True,
proc_vertebra_inconsistency: bool = True,
ignore_model_compatibility: bool = False,
ignore_inference_compatibility: bool = False,
ignore_bids_filter: bool = False,
log_inference_time: bool = True,
verbose: bool = False,
)
Runs the SPINEPS framework over a whole BIDS-conform dataset.
Iterates over every subject in the BIDS dataset, queries the matching scans for each requested modality pair and runs process_img_nii on each, producing semantic (subregion), vertebra (instance) and centroid outputs plus a snapshot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_path
|
Path
|
Path to the BIDS dataset. |
required |
model_instance
|
Segmentation_Model
|
Model for the vertebra (instance) segmentation. |
required |
model_semantic
|
list[Segmentation_Model] | Segmentation_Model | None
|
Models for the subregion (semantic) segmentation, one per modality pair. If None, attempts to find a matching model for each modality. Defaults to None. |
None
|
model_labeling
|
VertLabelingClassifier | None
|
Classifier used to label the vertebra instances. Defaults to None. |
None
|
rawdata_name
|
str
|
Name of the rawdata folder. Defaults to "rawdata". |
'rawdata'
|
derivative_name
|
str
|
Name of the derivatives output folder. Defaults to "derivatives_seg". |
'derivatives_seg'
|
modalities
|
list[Modality_Pair] | Modality_Pair
|
Modality/acquisition pairs to segment in the dataset. Defaults to [(Modality.T2w, Acquisition.sag)]. |
[(T2w, sag)]
|
save_debug_data
|
bool
|
If true, saves intermediate debug data. Increases space usage. Defaults to False. |
False
|
save_modelres_mask
|
bool
|
If true, additionally saves the semantic mask in the resolution of the model. Defaults to False. |
False
|
save_softmax_logits
|
bool
|
If true, additionally saves the softmax logits (averaged over folds) as an npz. Defaults to False. |
False
|
save_log_data
|
bool
|
If true, writes the log to a file in the dataset folder. Defaults to True. |
True
|
override_semantic
|
bool
|
If true, redoes existing semantic segmentations. Defaults to False. |
False
|
override_instance
|
bool
|
If true, redoes existing instance segmentations. Defaults to False. |
False
|
override_postpair
|
bool
|
If true, redoes the combined post-processing step. Defaults to False. |
False
|
override_ctd
|
bool
|
If true, redoes existing centroid files. Defaults to False. |
False
|
snapshot_copy_folder
|
Path | None | bool
|
If a path, copies all created snapshots there; if True, uses a "snaps_seg" subfolder of the dataset; if None/False, no copy is made. Defaults to None. |
None
|
pad_size
|
int
|
Padding added in each dimension before inference. Defaults to 4. |
4
|
proc_sem_crop_input
|
bool
|
If true, crops the input to the foreground before semantic segmentation. Defaults to True. |
True
|
proc_sem_n4_bias_correction
|
bool
|
If true, applies N4 bias field correction before semantic segmentation (MRI only). Defaults to True. |
True
|
proc_sem_remove_inferior_beyond_canal
|
bool
|
If true, removes semantic structures inferior to and beyond the spinal canal. Defaults to False. |
False
|
proc_sem_clean_beyond_largest_bounding_box
|
bool
|
If true, removes semantic voxels outside the largest bounding box. Defaults to True. |
True
|
proc_sem_clean_small_cc_artifacts
|
bool
|
If true, removes small connected-component artifacts from the semantic mask. Defaults to True. |
True
|
proc_inst_corpus_clean
|
bool
|
If true, cleans the vertebra corpus during instance processing. Defaults to True. |
True
|
proc_inst_clean_small_cc_artifacts
|
bool
|
If true, removes small connected-component artifacts from the instance mask. Defaults to True. |
True
|
proc_inst_largest_k_cc
|
int
|
If greater than 0, keeps only the largest k connected components of the instance mask. Defaults to 0. |
0
|
proc_inst_detect_and_solve_merged_corpi
|
bool
|
If true, detects and splits merged vertebra corpi. Defaults to True. |
True
|
proc_lab_force_no_tl_anomaly
|
bool
|
If true, forces the labeling to assume no thoracolumbar transition anomaly. Defaults to False. |
False
|
proc_fill_3d_holes
|
bool
|
If true, fills 3D holes during post-processing. Defaults to True. |
True
|
proc_assign_missing_cc
|
bool
|
If true, assigns unlabeled connected components to the nearest instance. Defaults to True. |
True
|
proc_clean_inst_by_sem
|
bool
|
If true, cleans the instance mask using the semantic mask. Defaults to True. |
True
|
proc_vertebra_inconsistency
|
bool
|
If true, detects and resolves vertebra labeling inconsistencies. Defaults to True. |
True
|
ignore_model_compatibility
|
bool
|
If true, ignores model/modality initialization compatibility issues. Defaults to False. |
False
|
ignore_inference_compatibility
|
bool
|
If true, ignores compatibility issues between models and individual inputs. Defaults to False. |
False
|
ignore_bids_filter
|
bool
|
If true, disables the BIDS query filters and processes all niftys found. Defaults to False. |
False
|
log_inference_time
|
bool
|
If true, logs the inference time of each step. Defaults to True. |
True
|
verbose
|
bool
|
If true, prints verbose information. Defaults to False. |
False
|
Source code in spineps/seg_run.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 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 | |
process_img_nii
¶
process_img_nii(
img_ref: BIDS_FILE,
model_semantic: Segmentation_Model,
model_instance: Segmentation_Model,
model_labeling: VertLabelingClassifier | None = None,
derivative_name: str = "derivatives_seg",
save_modelres_mask: bool = False,
save_softmax_logits: bool = False,
save_debug_data: bool = False,
save_raw: bool = True,
override_semantic: bool = False,
override_instance: bool = False,
override_postpair: bool = False,
override_ctd: bool = False,
proc_pad_size: int = 4,
proc_normalize_input: bool = True,
crop: tuple[slice, slice, slice] | None = None,
auto_crop_to_spine: bool | Literal["auto"] = "auto",
auto_crop_when_max_res_leq: float = 1.2,
auto_crop_req_crop_min_dim: int = 200,
proc_sem_crop_input: bool = True,
proc_sem_n4_bias_correction: bool = True,
proc_sem_remove_inferior_beyond_canal: bool = False,
proc_sem_clean_beyond_largest_bounding_box: bool = True,
proc_sem_clean_small_cc_artifacts: bool = True,
proc_inst_corpus_clean: bool = True,
proc_inst_clean_small_cc_artifacts: bool = True,
proc_inst_largest_k_cc: int = 0,
proc_inst_detect_and_solve_merged_corpi: bool = True,
vertebra_instance_labeling_offset=2,
proc_lab_force_no_tl_anomaly: bool = False,
proc_fill_3d_holes: bool = True,
proc_assign_missing_cc: bool = True,
proc_assign_missing_cc_fast: bool = False,
proc_clean_inst_by_sem: bool = True,
proc_vertebra_inconsistency: bool = True,
lambda_semantic: Callable[[NII], NII] | None = None,
snapshot_copy_folder: Path | None = None,
ignore_bids_filter: bool = False,
ignore_compatibility_issues: bool = False,
log_inference_time: bool = True,
return_output_instead_of_save: bool = False,
timing=False,
verbose: bool = False,
) -> tuple[dict[str, Path], ErrCode]
Runs the SPINEPS framework over one nifty.
Runs the full pipeline on a single input image: semantic (subregion) segmentation, vertebra (instance) segmentation, combined post-processing/labeling, centroid computation and a snapshot. Existing outputs are reused unless overridden.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img_ref
|
BIDS_FILE
|
Input BIDS_FILE referencing the image to segment. |
required |
model_semantic
|
Segmentation_Model
|
Model for the subregion (semantic) segmentation. |
required |
model_instance
|
Segmentation_Model
|
Model for the vertebra (instance) segmentation. |
required |
model_labeling
|
VertLabelingClassifier | None
|
Classifier used to label the vertebra instances. Defaults to None. |
None
|
derivative_name
|
str
|
Name of the derivatives output folder. Defaults to "derivatives_seg". |
'derivatives_seg'
|
save_modelres_mask
|
bool
|
If true, additionally saves the semantic mask in the resolution of the model. Defaults to False. |
False
|
save_softmax_logits
|
bool
|
If true, additionally saves the softmax logits (averaged over folds) as an npz. Defaults to False. |
False
|
save_debug_data
|
bool
|
If true, saves intermediate debug data. Increases space usage. Defaults to False. |
False
|
save_raw
|
bool
|
If true, saves the raw (pre-cleanup) semantic and vertebra masks. Defaults to True. |
True
|
override_semantic
|
bool
|
If true, redoes an existing semantic segmentation. Defaults to False. |
False
|
override_instance
|
bool
|
If true, redoes an existing instance segmentation. Defaults to False. |
False
|
override_postpair
|
bool
|
If true, redoes the combined post-processing step. Defaults to False. |
False
|
override_ctd
|
bool
|
If true, redoes an existing centroid file. Defaults to False. |
False
|
proc_pad_size
|
int
|
Padding added in each dimension before inference. Defaults to 4. |
4
|
proc_normalize_input
|
bool
|
If true, normalizes the input intensities (disabled automatically for CT). Defaults to True. |
True
|
crop
|
tuple[slice, slice, slice] | None
|
If provided, segment only within the specified crop. |
None
|
auto_crop_to_spine
|
bool | 'auto'
|
Speeds up high-resolution models by first predicting the spine with VIBESeg (https://link.springer.com/article/10.1007/s00330-025-12035-9) and cropping to the spine region (works for any MR or CT image). |
'auto'
|
auto_crop_when_max_res_leq
|
float
|
Enables automatic spine cropping when auto_crop_to_spine="auto" and the largest spacing value of the semantic model is less than or equal to this threshold. |
1.2
|
auto_crop_req_crop_min_dim
|
int
|
When auto_crop_to_spine="auto", compute the crop only if the image size exceeds this value cubed. |
200
|
proc_sem_crop_input
|
bool
|
If true, crops the input to the foreground before semantic segmentation. Defaults to True. |
True
|
proc_sem_n4_bias_correction
|
bool
|
If true, applies N4 bias field correction before semantic segmentation (MRI only). Defaults to True. |
True
|
proc_sem_remove_inferior_beyond_canal
|
bool
|
If true, removes semantic structures inferior to and beyond the spinal canal. Defaults to False. |
False
|
proc_sem_clean_beyond_largest_bounding_box
|
bool
|
If true, removes semantic voxels outside the largest bounding box. Defaults to True. |
True
|
proc_sem_clean_small_cc_artifacts
|
bool
|
If true, removes small connected-component artifacts from the semantic mask. Defaults to True. |
True
|
proc_inst_corpus_clean
|
bool
|
If true, cleans the vertebra corpus during instance processing. Defaults to True. |
True
|
proc_inst_clean_small_cc_artifacts
|
bool
|
If true, removes small connected-component artifacts from the instance mask. Defaults to True. |
True
|
proc_inst_largest_k_cc
|
int
|
If greater than 0, keeps only the largest k connected components of the instance mask. Defaults to 0. |
0
|
proc_inst_detect_and_solve_merged_corpi
|
bool
|
If true, detects and splits merged vertebra corpi. Defaults to True. |
True
|
vertebra_instance_labeling_offset
|
int
|
Offset applied when mapping instance ids to vertebra labels (set to 1 for CT models that include C1). Defaults to 2. |
2
|
proc_lab_force_no_tl_anomaly
|
bool
|
If true, forces the labeling to assume no thoracolumbar transition anomaly. Defaults to False. |
False
|
proc_fill_3d_holes
|
bool
|
If true, fills 3D holes during post-processing. Defaults to True. |
True
|
proc_assign_missing_cc
|
bool
|
If true, assigns unlabeled connected components to the nearest instance. Defaults to True. |
True
|
proc_assign_missing_cc_fast
|
bool
|
If true, uses the faster variant of the missing-cc assignment. Defaults to False. |
False
|
proc_clean_inst_by_sem
|
bool
|
If true, cleans the instance mask using the semantic mask. Defaults to True. |
True
|
proc_vertebra_inconsistency
|
bool
|
If true, detects and resolves vertebra labeling inconsistencies. Defaults to True. |
True
|
lambda_semantic
|
Callable[[NII], NII] | None
|
Optional function applied to the semantic mask before saving. Defaults to None. |
None
|
snapshot_copy_folder
|
Path | None
|
If given, copies the created snapshot there. Defaults to None. |
None
|
ignore_bids_filter
|
bool
|
If true, builds output paths in non-strict mode. Defaults to False. |
False
|
ignore_compatibility_issues
|
bool
|
If true, continues despite input/model incompatibilities. Defaults to False. |
False
|
log_inference_time
|
bool
|
If true, logs the inference time of each step. Defaults to True. |
True
|
return_output_instead_of_save
|
bool
|
If true, returns the result NIIs/centroids instead of saving them. Defaults to False. |
False
|
timing
|
bool
|
If true, logs the timing of each pipeline step. Defaults to False. |
False
|
verbose
|
bool
|
If true, prints verbose information. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
tuple[dict[str, Path], ErrCode]
|
tuple[dict[str, Path], ErrCode]: Mapping of output names to their file paths and an error code indicating success. If return_output_instead_of_save is True, instead returns (seg_nii, vert_nii, centroids, ErrCode). |
Source code in spineps/seg_run.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 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 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 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 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 | |
output_paths_from_input
¶
output_paths_from_input(
img_ref: BIDS_FILE,
derivative_name: str,
snapshot_copy_folder: Path | str | None,
input_format: str,
non_strict_mode: bool = False,
) -> dict[str, Path]
Derives all pipeline output file paths for a given input image.
Builds the BIDS-conform output paths (semantic/vertebra masks, raw masks, centroids, snapshots, logits, debug and VIBESeg crop) used throughout the pipeline, keyed by a descriptive name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img_ref
|
BIDS_FILE
|
Input BIDS_FILE the outputs are derived from. |
required |
derivative_name
|
str
|
Name of the derivatives output folder. |
required |
snapshot_copy_folder
|
Path | str | None
|
If given, location to which the snapshot is additionally copied (used to build out_snap2). |
required |
input_format
|
str
|
Format string of the input, used to name the debug and raw output subfolders. |
required |
non_strict_mode
|
bool
|
If true, builds the paths in non-strict BIDS mode. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Path]
|
dict[str, Path]: Mapping of output names (e.g. "out_spine", "out_vert", "out_ctd", "out_snap") to their file paths. |
Source code in spineps/seg_run.py
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 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 | |
save_nparray
¶
Saves an numpy array to the disk
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
ndarray
|
numpy array to be saved |
required |
out_path
|
Path
|
output path |
required |
Source code in spineps/seg_run.py
spineps.seg_pipeline¶
spineps.seg_pipeline
¶
Segmentation-pipeline helpers: shared logger, subregion label sets, centroid computation, and pipeline version reporting.
predict_centroids_from_both
¶
predict_centroids_from_both(
vert_nii_cleaned: NII,
seg_nii: NII,
models: list[Segmentation_Model | None],
parameter: dict[str, Any],
) -> poi.POI
Calculate the centroids of each vertebra corpus using both the semantic and instance masks.
Strips the IVD and endplate derived instance labels from the instance mask, computes the per-vertebra centroids from the instance and semantic masks, adds an S1 corpus centroid when sacrum is present, and records pipeline metadata (model descriptions, version, revision, timestamp, and the given parameters) on the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vert_nii_cleaned
|
NII
|
Cleaned vertebra instance segmentation mask. |
required |
seg_nii
|
NII
|
Subregion semantic segmentation mask. |
required |
models
|
list[Segmentation_Model | None]
|
Models used in the pipeline, recorded in the centroid metadata. |
required |
parameter
|
dict[str, Any]
|
Pipeline parameters to record on the centroid metadata. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
POI |
POI
|
The computed point-of-interest / centroid object with pipeline metadata attached. |
Source code in spineps/seg_pipeline.py
pipeline_version
¶
Return the pipeline version string derived from the git commit count on main.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A version like |
Source code in spineps/seg_pipeline.py
pipeline_revision
¶
Return the current git revision string for the pipeline.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
|
Source code in spineps/seg_pipeline.py
spineps.seg_utils¶
spineps.seg_utils
¶
Utilities for matching segmentation models to inputs by modality, acquisition, and resolution compatibility.
find_best_matching_model
¶
find_best_matching_model(
modality_pair: Modality_Pair,
expected_resolution: ZOOMS | None,
) -> Segmentation_Model
Select the segmentation model best matching a modality/acquisition pair and resolution.
Not yet implemented: intended to iterate over model configs and pick the one best matching the requested resolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modality_pair
|
Modality_Pair
|
The desired |
required |
expected_resolution
|
ZOOMS | None
|
The desired voxel resolution, or None. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Segmentation_Model |
Segmentation_Model
|
The best-matching model (once implemented). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Always, as this function is not yet implemented; also for an unmapped modality pair. |
Source code in spineps/seg_utils.py
check_model_modality_acquisition
¶
check_model_modality_acquisition(
model: Segmentation_Model,
mod_pair: Modality_Pair,
verbose: bool = True,
) -> bool
Check whether a model supports a given modality/acquisition pair.
Compares the model's supported modalities and acquisition against the requested pair and logs a warning describing any
mismatch when verbose is True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Segmentation_Model
|
The model to check. |
required |
mod_pair
|
Modality_Pair
|
The required |
required |
verbose
|
bool
|
If True, log a warning when incompatible. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the model supports all required modalities and the acquisition, otherwise False. |
Source code in spineps/seg_utils.py
add_ignore_text
¶
Mark the last accumulated log message as ignored.
Drops the trailing character of the last message (its period) and appends an "(IGNORED)." suffix in place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logger_texts
|
list[str]
|
Accumulated log messages; the last entry is modified in place. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
|
Source code in spineps/seg_utils.py
check_input_model_compatibility
¶
check_input_model_compatibility(
img_ref: BIDS_FILE,
model: Segmentation_Model,
ignore_modality: bool = False,
ignore_acquisition: bool = False,
ignore_labelkey: bool = False,
verbose: bool = True,
) -> bool
Check whether an input image file is compatible with a model's expected modality, acquisition, and naming.
Validates the input's format/modality, acquisition plane, and BIDS keys against what the model expects. Individual mismatches
can be tolerated via the ignore_* flags (annotated as "(IGNORED)" in the log). Debug files are always rejected, and the
image plane must be isotropic or one of the model's allowed acquisitions. Warnings are logged when verbose is True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img_ref
|
BIDS_FILE
|
Reference to the input image file. |
required |
model
|
Segmentation_Model
|
The model to check against. |
required |
ignore_modality
|
bool
|
If True, tolerate a modality/format mismatch. |
False
|
ignore_acquisition
|
bool
|
If True, tolerate an acquisition mismatch. |
False
|
ignore_labelkey
|
bool
|
If True, tolerate an unexpected |
False
|
verbose
|
bool
|
If True, log warnings describing incompatibilities. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the input is compatible with the model (after applying the ignore flags), otherwise False. |
Source code in spineps/seg_utils.py
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 | |