I tried everything to run totalsegmentator pls help

I am having trouble with totalsegmentator, i tried most solution in the fourm but nothing worked. I tried the brevious version with slicer 5.4 and could not make it work, now I tried with slicer 5.5 review and totalsegmentator v2 and still no hope.

Traceback (most recent call last):
File “C:\Users\ahmad\AppData\Local\slicer.org\Slicer 5.5.0-2023-11-22\bin\Python\slicer\util.py”, line 3253, in tryWithErrorDisplay
yield
File “C:/Users/ahmad/AppData/Local/slicer.org/Slicer 5.5.0-2023-11-22/slicer.org/Extensions-32352/TotalSegmentator/lib/Slicer-5.5/qt-scripted-modules/TotalSegmentator.py”, line 292, in onApplyButton
self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),
File “C:/Users/ahmad/AppData/Local/slicer.org/Slicer 5.5.0-2023-11-22/slicer.org/Extensions-32352/TotalSegmentator/lib/Slicer-5.5/qt-scripted-modules/TotalSegmentator.py”, line 967, in process
self.logProcessOutput(proc)
File “C:/Users/ahmad/AppData/Local/slicer.org/Slicer 5.5.0-2023-11-22/slicer.org/Extensions-32352/TotalSegmentator/lib/Slicer-5.5/qt-scripted-modules/TotalSegmentator.py”, line 787, in logProcessOutput
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command ‘[‘C:/Users/ahmad/AppData/Local/slicer.org/Slicer 5.5.0-2023-11-22/bin/…/bin\PythonSlicer.EXE’, ‘C:\Users\ahmad\AppData\Local\slicer.org\Slicer 5.5.0-2023-11-22\lib\Python\Scripts\TotalSegmentator.exe’, ‘-i’, ‘C:/Users/ahmad/AppData/Local/Temp/Slicer/__SlicerTemp__٢٠٢٣-١١-٢٤_٠٦+٠٥+٢٤.٦٥٢/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/ahmad/AppData/Local/Temp/Slicer/__SlicerTemp__٢٠٢٣-١١-٢٤_٠٦+٠٥+٢٤.٦٥٢/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’, ‘–device’, ‘cpu’]’ returned non-zero exit status 1.

I also get this error:
Writing input file to C:/Users/ahmad/AppData/Local/Temp/Slicer/__SlicerTemp__٢٠٢٣-١١-٢٤_٠٦+١٤+٣٩.١٦٥/total-segmentator-input.nii

Creating segmentations with TotalSegmentator AI…

Total Segmentator arguments: [‘-i’, ‘C:/Users/ahmad/AppData/Local/Temp/Slicer/__SlicerTemp__٢٠٢٣-١١-٢٤_٠٦+١٤+٣٩.١٦٥/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/ahmad/AppData/Local/Temp/Slicer/__SlicerTemp__٢٠٢٣-١١-٢٤_٠٦+١٤+٣٩.١٦٥/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’, ‘–device’, ‘cpu’]

ERROR: The input file or directory does not exist.

If you use this tool please cite: https://pubs.rsna.org/doi/10.1148/ryai.230024

Using ‘fast’ option: resampling to lower resolution (3mm)
I am using the ct chest sample

Most likely the issue is that your regional settings in the operating system make the temporary folder name contain special characters. In the short term, you can fix this by changing your date&time settings in your operating system. We’ll try to change the temporary folder generation in TotalSegmentator later.

@lassoan Maybe we could use tempfile,

Me

Is there a better way to create an always working unique temp folder in Python ?

ChatGPT

Creating a universally compatible and unique temporary folder in Python can be done using the tempfile module, which is part of Python’s standard library. The tempfile module is designed to create temporary files and directories in a way that is secure and system-independent. This means it automatically handles the creation of unique directory names and ensures compatibility across different operating systems and file systems.

Here is a simple way to create a unique temporary directory using tempfile:

pythonCopy code

import tempfile
import os

# Create a new temporary directory
with tempfile.TemporaryDirectory() as temp_dir:
    print("Temporary directory created at:", temp_dir)
    # You can use the temporary directory here

# After the 'with' block, the temporary directory and all its contents are automatically deleted
print("Temporary directory and all its contents have been deleted")

This code snippet uses the TemporaryDirectory() function within a context manager (with statement). The temporary directory is automatically created and is guaranteed to be unique. The with statement ensures that the directory is cleaned up (deleted) when you are done with it, which is a good practice when dealing with temporary files and directories.

This method is recommended because it is secure, avoids conflicts, and is compatible with all operating systems where Python runs. It eliminates the need for manual handling of file paths, including issues related to character sets or naming conventions.

So I tried to change the regional setting and that did not work. Now I installed slicer and total segmentator on another PC that has English as system language so the special charecters will not be generated. However. I still can not run it. This is what I get:

Traceback (most recent call last):
File “C:\Users\Ahmad\AppData\Local\slicer.org\Slicer 5.4.0\bin\Python\slicer\util.py”, line 3146, in tryWithErrorDisplay
yield
File “C:/Users/Ahmad/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/Ahmad/AppData/Local/slicer.org/Slicer 5.4.0/slicer.org/Extensions-31938/TotalSegmentator/lib/Slicer-5.4/qt-scripted-modules/TotalSegmentator.py”, line 785, in process
self.logProcessOutput(proc)
File “C:/Users/Ahmad/AppData/Local/slicer.org/Slicer 5.4.0/slicer.org/Extensions-31938/TotalSegmentator/lib/Slicer-5.4/qt-scripted-modules/TotalSegmentator.py”, line 614, in logProcessOutput
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command ‘[‘C:/Users/Ahmad/AppData/Local/slicer.org/Slicer 5.4.0/bin/…/bin\PythonSlicer.EXE’, ‘C:\Users\Ahmad\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Scripts\TotalSegmentator.exe’, ‘-i’, ‘C:/Users/Ahmad/AppData/Local/Temp/Slicer/__SlicerTemp__2023-11-27_08+03+30.287/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/Ahmad/AppData/Local/Temp/Slicer/__SlicerTemp__2023-11-27_08+03+30.287/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]’ returned non-zero exit status 2.

Also this note:
Total Segmentator arguments: [‘-i’, ‘C:/Users/Ahmad/AppData/Local/Temp/Slicer/__SlicerTemp__2023-11-27_08+03+30.287/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/Ahmad/AppData/Local/Temp/Slicer/__SlicerTemp__2023-11-27_08+03+30.287/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]
C:\Users\Ahmad\AppData\Local\slicer.org\Slicer 5.4.0\bin.\python-real.exe: can’t open file ‘C:\Users\Ahmad\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Scripts\TotalSegmentator.exe’: [Errno 2] No such file or directory

I installed pytorch the cpu version since the gpu does not have 7 GB of memory although its Nvidia. and run the the process in fast mode

2023-11-27 (2)

OK, this is much better! It seems that the remaining issue is this:

The simplest solution would be to upgrade to Slicer-5.6.

We’ll fix TotalSegmentator on Arabic comptuers soon - see progress here:

Great thank you working fine now. Thanks for your help.