Skip to content

Fix radiomics pipeline: swapped arguments and path type error#556

Merged
wasserth merged 1 commit intowasserth:masterfrom
mhalle:fix/radiomics-pipeline-bugs
Mar 30, 2026
Merged

Fix radiomics pipeline: swapped arguments and path type error#556
wasserth merged 1 commit intowasserth:masterfrom
mhalle:fix/radiomics-pipeline-bugs

Conversation

@mhalle
Copy link
Copy Markdown
Contributor

@mhalle mhalle commented Mar 24, 2026

Summary

  • Swapped CT/mask arguments: get_radiomics_features_for_entire_dir() in statistics.py passed ct_file as the first argument to get_radiomics_features(), but the function signature is (seg_file, img_file). This reversed the CT and mask roles, producing incorrect radiomics features and keying all results under the CT filename instead of individual mask names.
  • TypeError on TemporaryDirectory path: In python_api.py, tempfile.TemporaryDirectory() returns a str, but the code used the / operator on it (tmp_folder / "ct.nii.gz"), which raises TypeError when radiomics is called on a Nifti1Image input. Wrapped with Path() to fix.

Both bugs make the radiomics pipeline (--radiomics flag) non-functional.

Test plan

  • Run totalsegmentator with --radiomics flag on a nifti input and verify features are computed per-mask
  • Run with a Nifti1Image object via the Python API with radiomics=True and verify no TypeError
  • Verify statistics_radiomics.json keys are mask names (e.g., liver, spleen) not the CT filename

Fix two bugs in the radiomics feature extraction pipeline:

1. get_radiomics_features_for_entire_dir() passed ct_file as the first
   argument to get_radiomics_features(), but the function signature
   expects (seg_file, img_file). This reversed the CT and mask roles,
   causing incorrect feature extraction and keying all results under
   the CT filename instead of individual mask names.

2. In python_api.py, the TemporaryDirectory context manager returns a
   string, but the code used the / operator on it (tmp_folder / "ct.nii.gz"),
   which raises TypeError. Wrap with Path() to fix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wasserth wasserth merged commit 9c7f0bf into wasserth:master Mar 30, 2026
@mhalle mhalle deleted the fix/radiomics-pipeline-bugs branch April 3, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants