Hello,
I’ve been using total segmentator manually for some time and it was working well.
I’ve recently tried too automatize the process and installed total segmentator directly by running
pip install TotalSegmentator
in the window powershell. After some trial and error, I think I got total-segmentator working directly outside of slicer.
After that, I tried to run a segmentation in slicer and it’s not working anymore, I get the following error:
Traceback (most recent call last):
File “C:\Users\matte\AppData\Local\slicer.org\Slicer 5.4.0\bin\Python\slicer\util.py”, line 3146, in tryWithErrorDisplay
yield
File “C:/Users/matte/AppData/Local/slicer.org/Slicer 5.4.0/slicer.org/Extensions-31938/TotalSegmentator/lib/Slicer-5.4/qt-scripted-modules/TotalSegmentator.py”, line 271, in onApplyButton
self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),
File “C:/Users/matte/AppData/Local/slicer.org/Slicer 5.4.0/slicer.org/Extensions-31938/TotalSegmentator/lib/Slicer-5.4/qt-scripted-modules/TotalSegmentator.py”, line 868, in process
self.logProcessOutput(proc)
File “C:/Users/matte/AppData/Local/slicer.org/Slicer 5.4.0/slicer.org/Extensions-31938/TotalSegmentator/lib/Slicer-5.4/qt-scripted-modules/TotalSegmentator.py”, line 701, in logProcessOutput
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command ‘[‘C:/Users/matte/AppData/Local/slicer.org/Slicer 5.4.0/bin/…/bin\PythonSlicer.EXE’, ‘C:\Users\matte\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Scripts\TotalSegmentator’, ‘-i’, ‘C:/Users/matte/AppData/Local/Temp/Slicer/__SlicerTemp__2023-10-13_13+50+57.707/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/matte/AppData/Local/Temp/Slicer/__SlicerTemp__2023-10-13_13+50+57.707/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]’ returned non-zero exit status 1.
I tried to uninstall/reinstall slicer and the total segmentator extension but the error doesn’t change.
If somebody has a fix I would be very interested.
TotalSegmentator has some incorrectly hardcoded dependencies for Python-3.9, which makes it incompatible with many Python environments, including Slicer’s. In SlicerTotalSegmentator extension we run a custom installation procedure that discards these incorrect entries.
To fix your TotalSegmentator in Slicer: delete your entire Slicer installation tree, reinstall Slicer, and install TotalSegmentator using the TotalSegmentator Slicer extension. You can do this from Python scripts, too.
You can use pip to install TotalSegmentator in a virtual Python environment where you don’t need to run anything else than TotalSegmentator.
I tried to do that and it’s still not working.
Is there some hidden part of the Slicer installation tree ? I just uninstall slicer from window and deleted the slicer.org file is there something else I should have done ?
When reinstalling total segmentator module I got these warnings
WARNING: The script isympy.exe is installed in 'C:\Users\matte\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts convert-caffe2-to-onnx.exe, convert-onnx-to-caffe2.exe and torchrun.exe are installed in 'C:\Users\matte\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Scripts' which is not on PATH.
WARNING: The scripts lsm2bin.exe, tiff2fsspec.exe, tiffcomment.exe and tifffile.exe are installed in 'C:\Users\matte\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Scripts' which is not on PATH.
Should I add them to the path ? If yes how do I do it ?
Sorry if my questions are obvious, I’m not very familiar with python
To add information, the error changed, now this is what I get:
File "C:\Users\matte\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Scripts\TotalSegmentator", line 93, in <module>
main()
File "C:\Users\matte\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Scripts\TotalSegmentator", line 86, in main
totalsegmentator(args.input, args.output, args.ml, args.nr_thr_resamp, args.nr_thr_saving,
File "C:\Users\matte\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Lib\site-packages\totalsegmentator\python_api.py", line 157, in totalsegmentator
download_pretrained_weights(task_id)
File "C:\Users\matte\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Lib\site-packages\totalsegmentator\libs.py", line 183, in download_pretrained_weights
download_url_and_unpack(WEIGHTS_URL, config_dir)
File "C:\Users\matte\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Lib\site-packages\totalsegmentator\libs.py", line 69, in download_url_and_unpack
raise e
File "C:\Users\matte\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Lib\site-packages\totalsegmentator\libs.py", line 56, in download_url_and_unpack
r.raise_for_status()
File "C:\Users\matte\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Lib\site-packages\requests\models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://zenodo.org/record/6802052/files/Task256_TotalSegmentator_3mm_1139subj.zip?download=1
It seems like the issue is that I can’t download the weight for the network
This is a valid, working download URL. If Slicer has problems accessing this URL then your organization might interfere with your network access. You can find more information about this issue and how to resolve it here.
I’m just adding in case anyone read this later. I tried to manually import the weight but it was failing.
The reason it was failing was because one of the charater of the path where the downoladed weight were contained a special caracter (é) wich was making it impossible for slicer to manually import the weight.
I just moved the weight to another folder and imported them again to fix the issue