TotalSegmentator icon indicating copy to clipboard operation
TotalSegmentator copied to clipboard

Segmentation fails due to dicom2nifti v2.6.0

Open anongeek opened this issue 9 months ago • 3 comments

Hello,

Segmentation is failing:

Traceback (most recent call last): File "/home/user/tmp/Slicer-5.8.1-linux-amd64/lib/Python/bin/TotalSegmentator", line 8, in <module> sys.exit(main()) File "/home/user/tmp/Slicer-5.8.1-linux-amd64/lib/Python/lib/python3.9/site-packages/totalsegmentator/bin/TotalSegmentator.py", line 143, in main totalsegmentator(args.input, args.output, args.ml, args.nr_thr_resamp, args.nr_thr_saving, File "/home/user/tmp/Slicer-5.8.1-linux-amd64/lib/Python/lib/python3.9/site-packages/totalsegmentator/python_api.py", line 137, in totalsegmentator from totalsegmentator.nnunet import nnUNet_predict_image # this has to be after setting new env vars File "/home/user/tmp/Slicer-5.8.1-linux-amd64/lib/Python/lib/python3.9/site-packages/totalsegmentator/nnunet.py", line 54, in <module> from totalsegmentator.dicom_io import dcm_to_nifti, save_mask_as_rtstruct File "/home/user/tmp/Slicer-5.8.1-linux-amd64/lib/Python/lib/python3.9/site-packages/totalsegmentator/dicom_io.py", line 13, in <module> import dicom2nifti File "/home/user/tmp/Slicer-5.8.1-linux-amd64/lib/Python/lib/python3.9/site-packages/dicom2nifti/__init__.py", line 19, in <module> from dicom2nifti.convert_dicom import dicom_series_to_nifti File "/home/user/tmp/Slicer-5.8.1-linux-amd64/lib/Python/lib/python3.9/site-packages/dicom2nifti/convert_dicom.py", line 17, in <module> import dicom2nifti.common as common File "/home/user/tmp/Slicer-5.8.1-linux-amd64/lib/Python/lib/python3.9/site-packages/dicom2nifti/common.py", line 16, in <module> from pydicom.pixels import apply_modality_lut ModuleNotFoundError: No module named 'pydicom.pixels' ERROR: Failed to compute results.

Downgrading to dicom2nifti v2.5.1 solves the issue.

It seems this bug was introduced in dicom2nifti v2.6.0 released on 27 March 2025.

Thanks!

anongeek avatar Mar 30 '25 09:03 anongeek

In order to downgrade dicom2nifti to version 2.5.1 follow this link: https://github.com/icometrix/dicom2nifti/tree/36a8740e12a9e9f1b6ae2afcaca610ff08be6085

Download the ZIP, Extract and replace the Slicer 5.8.1 dicom2nifti folder with the one contained in the downloaded ZIP file.

TotalSegmentator should now operate correctly.

fornicatory avatar Mar 31 '25 16:03 fornicatory

Hello,

In python environment: pip install --force-reinstall dicom2nifti==2.5.1

In 3D Slicer into the python command line , launch the following commands: from slicer.util import pip_install pip_install("dicom2nifti==2.5.1")

Doc : https://slicer.readthedocs.io/en/latest/developer_guide/slicer.html#slicer.util.pip_install

Best regards,

anongeek avatar Mar 31 '25 18:03 anongeek

It seems that dicom2nifti is creating a fix for this (https://github.com/icometrix/dicom2nifti/issues/155) and hopefully they soon publish a new version on pypi. Then this should not happen anymore.

wasserth avatar Apr 01 '25 11:04 wasserth