Giter VIP home page Giter VIP logo

slicertotalsegmentator's Introduction

TotalSegmentator

3D Slicer extension for fully automatic whole body CT segmentation using "TotalSegmentator" AI model. Computation time is less than one minute.

If you use the TotalSegmentator nn-Unet function from this software in your research, please cite:

Wasserthal J., Meyer M., , Hanns-Christian Breit H.C., Cyriac J., Shan Y., Segeroth, M.: TotalSegmentator: robust segmentation of 104 anatomical structures in CT images. https://arxiv.org/abs/2208.05868

Setup

  1. Setup your GPU driver (optional)

If you have a powerful GPU is available then a full-quality segmentation can be computed in a few minutes, instead of 40-50 minutes on the CPU. Therefore, it is recommended to set up GPU acceleration as described in this section.

  • If a strong GPU with 7GB or more memory is available:
  • If suitable GPU is not available: Graphics driver updates or CUDA installation is not necessary, everything will still work, it will just take more time.
  1. Install latest version of 3D Slicer

  2. Install TotalSegmentator extension in 3D Slicer

Tutorial

  • Start 3D Slicer
  • Go to Sample Data module and load CTA Abdomen (Panoramix) data set
  • Go to TotalSegmentator module
  • Select Input volume -> Panoramix-cropped
  • Select Segmentation -> Create new segmentation
  • Click Apply
    • When this module is used the first time:
      • It needs to download and install PyTorch and TotalSegmentator Python packages and weights for the AI models. This can take 5-10 minutes and several GB disk space.
      • You may get an error popup: Failed to compute results ... Command ... 'pip', 'install' ... returned non-zero exit status 1. This may be normal, see what to do in Troubleshooting section
    • Expected computation time:
      • With CUDA-capable GPU: 20-30 seconds in fast mode, 40-50 seconds in full-resolution mode.
      • Without GPU: 1 minute in fast mode, 40-50 minutes in full-resolution mode.
  • To display the segmentation in 3D: click the Show 3D button

User interface

  • Inputs
    • Input volume: input CT image
    • Segmentation task: instead of the default "total" segmentation, a more specialized segmentation model can be chosen
    • Fast: performs segmentation faster, but at lower resolution
  • Outputs
    • Segmentation: it will contain a brain segment, which specifies the brain region
    • Show 3D: show/hide segments in 3D views
  • Advanced:
    • Use standard segment names: use names defined in standard terminology files from DCMQI (enabled by default). If disabled then TotalSegmentator identifiers will be used as segment names.
    • Use latest development version: use latest development version from TotalSegmentator master branch during a forced reinstall.
    • Force reinstall: force reinstallation of the AI engine - TotalSegmentator Python package. This may be needed if other modules compromise the installation.
    • Import weights: When using TotalSegmentator, weights are often downloaded automatically. You can import any specialized or licensed weights you receive from the developer so that TotalSegmentator can find and use them.
    • Get TotalSegmentator package information: retrieve installed version of the AI engine - TotalSegmentator Python package.

Troubleshooting

Failed to compute results error at the first run

Problem: Error popup on the first run: Failed to compute results ... Command ... 'pip', 'install' ... returned non-zero exit status 1

Explanation: This happens because when TotalSegmentator is run for the first time, it needs to download and install PyTorch and TotalSegmentator Python packages. Since the application may have already loaded different versions of these packages, the packages need to be uninstalled first. This uninstallation may fail because some packages may be already in use. Restarting the application unloads these modules so they are no longer in use. Therefore after a restart, TotalSegmentator will be able to install all the necessary packages.

Solution: Restart Slicer and run TotalSegmentator module again.

Problem: Error popup on the first run: Failed to compute results ... Command ... 'PythonSlicer', TotalSegmentator.exe ... returned non-zero exit status 120

Explanation: This typically happens when PyTorch is not installed correctly or your computer runs out of memory.

Solution:

  • Check the message log (textbox under the Apply button). If you see a message like RuntimeError: ... DefaultCPUAllocator: not enough memory: you tried to allocate ... bytes. then it means that your computer has not enough memory to process the input image. You can use Crop volume module to crop the your image to the relevant region and/or resample it (with using a scaling factor >1) until the memory usage drops low enough so that your computer can handle it. Alternatively, you can install more physical RAM or configure your operating system to use more virtual memory.
  • If the problem does not seem to be due to running out of memory then reinstall PyTorch as described in solution of Segmentation fails while predicting issue.

Segmentation fails while predicting

RuntimeError: CUDA out of memory

Problem: Segmentation fails while predicting and the RuntimeError: CUDA out of memory. message is found in the message log (textbox under the Apply button).

Explanation: This means that a CUDA-capable GPU is available, but it is not powerful enough to be used by TotalSegmentator.

Solution: It is recommended to switch to use the CPU by the following steps:

  • Go to PyTorch Util module, click Uninstall PyTorch. An error may be reported at the end of this step, as some PyTorch files are in use. Click Restart the application button to unload all PyTorch files.
  • Go to PyTorch Util module, select cpu as Computation backend, and click Install PyTorch.

If your GPU has more than 7GB memory and you still get this error then the error message might indicate that the PyTorch CUDA version does not match the CUDA version installed on the system. Reinstall PyTorch with the correct CUDA version by following the instructions given below for GPU is not found.

numpy.core._exceptions._ArrayMemoryError: Unable to allocate

Problem: Segmentation fails while predicting and a message similar to this is found in the message log (textbox under the Apply button): numpy.core._exceptions._ArrayMemoryError: Unable to allocate 6.85 GiB for an array with shape (287, 233, 233, 118) and data type float32

Explanation: This means that your computer has ran out of memory (RAM) while performing the segmentation.

Solution: It is recommended to reduce the image size or increase avaialable memory size by one of the following options:

  • A. Crop and/or resample the input image using Crop volume module. Cropping the image to a smaller size will reduce memory need without decreasing the segmentation quality. Setting "Spacing scale" to value larger than 1 (for example 2 or 3) will preserve the extents of the image but small details may be lost (this should not be an issue when the object of interest is a large structure with a smooth surface).
  • B. Increase the available "virtual memory" (also known as "swap") size in your computer. On Windows and Linux, you can configure the virtual memory size in your system settings. On macOS, virtual memory is automatically allocated if there is sufficient free disk space. Increasing virtual memory size can avoid issues cause by short memory usage peaks, but can severely slow down the segmentation. To avoid slowdown, add more physical RAM to your computer.
  • C. Upgrade your computer hardware. Add physical RAM to your computer, or if it is not upgradeable then get a new computer or rent a virtual machine from a cloud computing provider. If you have more physical RAM then you can process larger images without making the segmentation take significantly longer time.

AttributeError: 'DummyFile' object has no attribute 'flush'

Problem: Segmentation fails while predicting and the 'DummyFile' object has no attribute 'flush' message is found in the message log (textbox under the Apply button).

Explanation: This error message can be safely ignored (it is just a small bug in the implementation of the helper class that suppresses nnunet output). If segmentation failed then it is due to another error in the output.

Solution: Look for other messages in the output.

GPU is not found

Problem: Your computer has a CUDA-capable GPU but TotalSegmentator reports that GPU is not available.

Explanation: CUDA may not be installed on the system or CUDA version in PyTorch does not match the system CUDA version.

Solution:

  • Make sure that the the CUDA vesion installed on the system is one of those listed on pytorch website as "Compute platform" for your system. You can download CUDA from here.
  • Go to PyTorch Util module, click Uninstall PyTorch. An error may be reported at the end of this step, as some PyTorch files are in use. Click Restart the application button to unload all PyTorch files.
  • Go to PyTorch Util module, select the Computation backend that matches the system CUDA version, and click Install PyTorch. The CUDA computational backend name has the format cuNNN, where NNN corresponds to the CUDA major+minor version. For example, CUDA 11.7 backend name is cu117.

Face segment is inaccurate

Problem: There is a big segment called face at the front of the head, which is not an accurate segmentation of the face.

Explanation: This segment is not designed to match the shape of an anatomical feature, but it designates the general area of the face. It can be used to remove features (for example by masking or blurring the image or clipping models) that might otherwise identify the individual subject. Removing these features makes it easier to share 3D data.

Fail to download model files

Model files are hosted on github.com or Zenodo.org and downloaded automatically when segmenting the first time. Institutional firewall or proxy servers may prevent access or the server may be temporarily overloaded, which may cause an error report similar to requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://zenodo.org/record/6802052/files/Task256_TotalSegmentator_3mm_1139subj.zip?download=1. Potential solutions:

  • retry later when the server may be less overloaded
  • talk to IT administrators or use a VPN to access the server
  • download the file manually and unzip it in the .totalsegmentator folder in the user's profile (for example in c:\Users\(yourusername)\.totalsegmentator\nnunet\results\Dataset291_TotalSegmentator_part1_organs_1559subj)

Contributing

Contributions to this extensions are welcome. Please send a pull request with any suggested changes. 3D Slicer contribution guidelines apply.

Contact

Please post any questions to the Slicer Forum.

Developers of this extension are not associated with the developers of TotalSegmentator, just provide the convenient 3D Slicer based user interface.

slicertotalsegmentator's People

Contributors

evaherbst avatar fedorov avatar henrykrumb avatar jamesobutler avatar lassoan avatar mauigna06 avatar rbumm avatar subelf avatar vkt1414 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slicertotalsegmentator's Issues

utf-8 codec cant decode byte - invalid start byte

Hello, when I try to use the plugin with the supplied CTA abdomen, I get this error:
This is on Windows 10-64Bit - german locale.

Traceback (most recent call last):
  File "C:\Users\Ernie\AppData\Local\NA-MIC\Slicer 5.2.1\bin\Python\slicer\util.py", line 2961, in tryWithErrorDisplay
    yield
  File "C:/Users/Ernie/AppData/Local/NA-MIC/Slicer 5.2.1/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py", line 245, in onApplyButton
    self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),
  File "C:/Users/Ernie/AppData/Local/NA-MIC/Slicer 5.2.1/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py", line 516, in process
    self.logProcessOutput(proc)
  File "C:/Users/Ernie/AppData/Local/NA-MIC/Slicer 5.2.1/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py", line 418, in logProcessOutput
    line = proc.stdout.readline()
  File "C:\Users/Ernie/AppData/Local/NA-MIC/Slicer 5.2.1/bin/../lib/Python/Lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 366: invalid start byte

GPU not found

hello.
I am using slicer 5.6.0 Ver in a Windows 10 environment.
When using total-segmentation, the gpu is not recognized.
My gpu is GeForce RTX 3060 and I am using cuda version 11.8.

When the 'GPU is not found', I tried referring to the solution, but it did not solve the problem.

If you try to install pytorch by uninstalling it automatically from pytorch util and selecting cu118 in computation backend,
Installation does not proceed with a message indicating that 'torch' is not installed.

Is there anything else I should check?

I tried reinstalling the slicer program and module several times, but it did not solve the problem. Is there a solution???

thank you

Old UI present when used with 3D Slicer 5.4.0

3D Slicer 5.4.0 installed and updated Totalsegmentator extension.

Import license expects a zip license file, but currently, we circulate written licenses which can not be used (entered) with 5.4.0

image

In addition, we removed the "use latest development version" checkbox

So we have currently two UI´s ?

Wrong action for "fast" button

When I run this extension, I get a dialog box to select 'fast' or 'full' mode, It's ok, but after I select 'fast', the extension use 'full'.

I think it's a bug of

mbox.addButton("Fast (~2 minutes)", qt.QMessageBox.AcceptRole)
mbox.addButton("Full-resolution (~50 minutes)", qt.QMessageBox.RejectRole)

but, I changed it to :

mbox.addButton("Fast (~2 minutes)", qt.QMessageBox.RejectRole)
mbox.addButton("Full-resolution (~50 minutes)", qt.QMessageBox.AcceptRole)

still wrong, then I changed it to:

mbox.addButton("Full-resolution (~50 minutes)", qt.QMessageBox.RejectRole)
mbox.addButton("Fast (~2 minutes)", qt.QMessageBox.AcceptRole)

Now it's ok, but I am confused, I am not familiar with qt, why the sequence of addButton is relevant?

Installation on MacBook M2

I installed 3D Slicer with Totalsegmentator. I also installed PyTorch. However, when I try to segment for the first time, I get the error message:
Processing started
Writing input file to /private/var/folders/rv/l3by1n612h78zcsp9s7p29p00000gn/T/Slicer-maximilianmoos/__SlicerTemp__2024-06-09_15+08+06.709/total-segmentator-input.nii
Creating segmentations with TotalSegmentator AI...
Total Segmentator arguments: ['-i', '/private/var/folders/rv/l3by1n612h78zcsp9s7p29p00000gn/T/Slicer-maximilianmoos/__SlicerTemp__2024-06-09_15+08+06.709/total-segmentator-input.nii', '-o', '/private/var/folders/rv/l3by1n612h78zcsp9s7p29p00000gn/T/Slicer-maximilianmoos/__SlicerTemp__2024-06-09_15+08+06.709/segmentation', '--ml', '--task', 'total', '--fast']

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

No GPU detected. Running on CPU. This can be very slow. The '--fast' or the --roi_subset option can help to reduce runtime.
Traceback (most recent call last):
File "/Applications/Slicer.app/Contents/lib/Python/bin/TotalSegmentator", line 8, in
sys.exit(main())
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/site-packages/totalsegmentator/bin/TotalSegmentator.py", line 132, in main
totalsegmentator(args.input, args.output, args.ml, args.nr_thr_resamp, args.nr_thr_saving,
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/site-packages/totalsegmentator/python_api.py", line 88, in totalsegmentator
from totalsegmentator.nnunet import nnUNet_predict_image # this has to be after setting new env vars
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/site-packages/totalsegmentator/nnunet.py", line 30, in
from nnunetv2.inference.predict_from_raw_data import nnUNetPredictor
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/site-packages/nnunetv2/inference/predict_from_raw_data.py", line 11, in
from acvl_utils.cropping_and_padding.padding import pad_nd_image
ModuleNotFoundError: No module named 'acvl_utils'

Am I missing a module that I still need to install? Thank you for your help!!!"

Failed compute to results

Processing started
Writing input file to C:/Users/96524/AppData/Local/Temp/Slicer/__SlicerTemp__2023-12-23_23+48+04.063/total-segmentator-input.nii
Creating segmentations with TotalSegmentator AI...
Total Segmentator arguments: ['-i', 'C:/Users/96524/AppData/Local/Temp/Slicer/__SlicerTemp__2023-12-23_23+48+04.063/total-segmentator-input.nii', '-o', 'C:/Users/96524/AppData/Local/Temp/Slicer/_SlicerTemp__2023-12-23_23+48+04.063/segmentation', '--ml', '--task', 'total', '--fast']
C:\Users\96524\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-30\lib\Python\Lib\site-packages\requests_init
.py:102: RequestsDependencyWarning: urllib3 (1.26.12) or chardet (5.0.0)/charset_normalizer (2.0.12) doesn't match a supported version!
warnings.warn("urllib3 ({}) or chardet ({})/charset_normalizer ({}) doesn't match a supported "
Traceback (most recent call last):
File "C:\Users\96524\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-30\lib\Python\Scripts\TotalSegmentator", line 93, in
main()
File "C:\Users\96524\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-30\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\96524\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-30\lib\Python\Lib\site-packages\totalsegmentator\python_api.py", line 173, in totalsegmentator
seg = nnUNet_predict_image(input, output, task_id, model=model, folds=folds,
File "C:\Users\96524\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-30\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py", line 255, in nnUNet_predict_image
nnUNet_predict(tmp_dir, tmp_dir, task_id, model, folds, trainer, tta)
File "C:\Users\96524\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-30\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py", line 106, in nnUNet_predict
predict_from_folder(model_folder_name, dir_in, dir_out, folds, save_npz, num_threads_preprocessing,
File "C:\Users\96524\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-30\lib\Python\Lib\site-packages\nnunet\inference\predict.py", line 616, in predict_from_folder
shutil.copy(join(model, 'plans.pkl'), output_folder)
File "C:\Users\96524\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-30\lib\Python\Lib\shutil.py", line 427, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Users\96524\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-30\lib\Python\Lib\shutil.py", line 264, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\96524\.totalsegmentator\nnunet\results\nnUNet\3d_fullres\Task256_TotalSegmentator_3mm_1139subj\nnUNetTrainerV2_ep8000_nomirror__nnUNetPlansv2.1\plans.pkl'
Exception ignored in: <totalsegmentator.libs.DummyFile object at 0x0000015CA1C56C40>
AttributeError: 'DummyFile' object has no attribute 'flush'

Feature Request: Advanced Settings

Hi, Thanks for adding this Extension to 3D Slicer.

Under Outputs could you create GUI for these two options?

--statistics: This will generate a file statistics.json with volume (in mm³) and mean intensity of each class.
--radiomics: This will generate a file statistics_radiomics.json with radiomics features of each class. You have to install pyradiomics to use this (pip install pyradiomics).

As per https://github.com/wasserth/TotalSegmentator.

Thanks for all of your insights over the years. Brad

Telemetry details sent by default when using latest TotalSegmentor

It isn’t clear when using this Slicer extension (SlicerTotalSegmentor) that usage statistics are being sent to the total segmentor developers when using latest TotalSegmentor. This extension now recently supports using latest TotalSegmentor as added in 440dfc2. When not using latest, up to TotalSegementor 1.5.3, there was no telemetry to worry about. See https://github.com/wasserth/TotalSegmentator#other

Will this Slicer extension include the configuration to turn off telemetry? It is on by default.

cc @lassoan

nn-U-Net multiprocessing error with fix

@lassoan are you aware of the nnU-Net multiprocessing error that occurs on Windows? It did not let me run TotalSegmentator initially. There is still no response to the PR with the fix I made. 

MIC-DKFZ/nnUNet#1155

Are you solving this locally during installation or do I oversee a fix that they made?

Exception raised when CUDA not available for a CUDA-versioned torch

I modified TotalSegmentator.py going through some more CUDA availability test
Also this makes it possible to disable CUDA temporarily by setting up environment variable 'CUDA_VISIBLE_DEVICES'

And here is the patch:

+++ TotalSegmentator.py	2023-03-05 13:31:58.226645800 +0800
@@ -685,10 +685,14 @@
 
         # Recommend the user to switch to fast mode if no GPU or not enough memory is available
         import torch
-        if not fast and not torch.has_cuda:
+
+        cuda = torch.cuda if torch.has_cuda and torch.cuda.is_available() else None
+
+        if not fast and not cuda:
             if slicer.util.confirmYesNoDisplay("No GPU is detected. Enable 'fast' mode to get low-resolution result in about 1 minute (instead of full-resolution in 1 hour)?"):
                 fast = True
-        if not fast and torch.has_cuda and torch.cuda.get_device_properties(0).total_memory < 7e9:
+
+        if not fast and cuda and cuda.get_device_properties(cuda.current_device()).total_memory < 7e9:
             if slicer.util.confirmYesNoDisplay("You have less than 7 GB of GPU memory available. Enable 'fast' mode to ensure segmentation can be completed successfully?"):
                 fast = True

Consider updating mapping CSV file to include segment colors

Currently colors are stored in the JSON file, which also contains terminology codes. We merged them into the terminology, as you can see in https://github.com/ImagingDataCommons/Cloud-Resources-Workflows/blob/main/configs/TotalSegmentator/totalsegmentator_snomed_mapping_with_partial_colors.csv. If you like @lassoan, we can make a PR to update the CSV in this repo as well. We will probably make that PR to the upstream TotalSegmentator repo, since colors are not available there at all, and if that one is accepted, we can just use the mapping file for both terminology and colors from the upstream repo instead of maintaining it separately.

cc: @vkt1414

Distance between slices

Hi,

I am currently segmenting something from a screenshot. Therefore, it is a 2D image. I am wanting to make it into a 2D surface mesh. I was told since 3D slicer will only export as 3D .stl files, to duplicate the segment and put distance between them. As a beginner, I really have no idea how to do that. Could you help?

SlicerTotalSegmentor fails on initial apply

I'm currently using Slicer 5.2.2, have SlicerPyTorch installed and pointing to SlicerTotalSegmentor as of 493fa5b.

I start Slicer fresh, and when I go into TotalSegmentor and press apply, it appropriate warns that PyTorch needs to be downloaded and installed and then it installs the TotalSegmentor package. However I observe that the install process uninstall scipy 1.9.2 that is included as part of Slicer 5.2.2 and it installs scipy 1.9.1. This produces an exit code that results in TotalSegmentor not running. Is it expected for the uninstall/install of scipy to be successful in Slicer? If I close Slicer, reopen and then press "Apply" in TotalSegmentor then it is successful.

Is access denied because the scipy package is in-use as it has been imported in Slicer on startup?

ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Users\\butlej30383\\AppData\\Local\\NA-MIC\\Slicer 5.2.2\\lib\\Python\\Lib\\site-packages\\~cipy\\_lib\\_ccallback_c.cp39-win_amd64.pyd'
Consider using the `--user` option or check the permissions.

image

Additional FYI: The latest torch 2.0.0 was downloaded and installed here.

See full pip output here Python 3.9.10 (main, Feb 22 2023, 01:07:37) [MSC v.1930 64 bit (AMD64)] on win32 >>> Collecting light-the-torch>=0.5 Downloading light_the_torch-0.7.1-py3-none-any.whl (14 kB) Requirement already satisfied: pip<23.1,>=22.3 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from light-the-torch>=0.5) (23.0) Installing collected packages: light-the-torch WARNING: The script ltt.exe is installed in 'C:\Users\butlej30383\AppData\Local\NA-MIC\Slicer 5.2.2\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. Successfully installed light-the-torch-0.7.1

[notice] A new release of pip is available: 23.0 -> 23.0.1
[notice] To update, run: python-real.exe -m pip install --upgrade pip
Collecting torch
Downloading https://download.pytorch.org/whl/cu118/torch-2.0.0%2Bcu118-cp39-cp39-win_amd64.whl (2611.4 MB)
---------------------------------------- 2.6/2.6 GB 1.7 MB/s eta 0:00:00
Collecting jinja2
Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
-------------------------------------- 133.1/133.1 kB 1.6 MB/s eta 0:00:00
Collecting typing-extensions
Downloading typing_extensions-4.5.0-py3-none-any.whl (27 kB)
Collecting filelock
Downloading filelock-3.9.1-py3-none-any.whl (9.7 kB)
Collecting networkx
Downloading networkx-3.0-py3-none-any.whl (2.0 MB)
---------------------------------------- 2.0/2.0 MB 10.0 MB/s eta 0:00:00
Collecting sympy
Downloading sympy-1.11.1-py3-none-any.whl (6.5 MB)
---------------------------------------- 6.5/6.5 MB 29.5 MB/s eta 0:00:00
Collecting MarkupSafe>=2.0
Downloading MarkupSafe-2.1.2-cp39-cp39-win_amd64.whl (16 kB)
Collecting mpmath>=0.19
Downloading mpmath-1.3.0-py3-none-any.whl (536 kB)
------------------------------------- 536.2/536.2 kB 32.9 MB/s eta 0:00:00
Installing collected packages: mpmath, typing-extensions, sympy, networkx, MarkupSafe, filelock, jinja2, torch
WARNING: The script isympy.exe is installed in 'C:\Users\butlej30383\AppData\Local\NA-MIC\Slicer 5.2.2\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\butlej30383\AppData\Local\NA-MIC\Slicer 5.2.2\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.
Successfully installed MarkupSafe-2.1.2 filelock-3.9.1 jinja2-3.1.2 mpmath-1.3.0 networkx-3.0 sympy-1.11.1 torch-2.0.0+cu118 typing-extensions-4.5.0

[notice] A new release of pip is available: 23.0 -> 23.0.1
[notice] To update, run: python-real.exe -m pip install --upgrade pip
Collecting matplotlib
Downloading matplotlib-3.7.1-cp39-cp39-win_amd64.whl (7.6 MB)
---------------------------------------- 7.6/7.6 MB 18.8 MB/s eta 0:00:00
Collecting python-dateutil>=2.7
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
-------------------------------------- 247.7/247.7 kB 7.7 MB/s eta 0:00:00
Collecting kiwisolver>=1.0.1
Downloading kiwisolver-1.4.4-cp39-cp39-win_amd64.whl (55 kB)
---------------------------------------- 55.4/55.4 kB 1.5 MB/s eta 0:00:00
Collecting fonttools>=4.22.0
Downloading fonttools-4.39.0-py3-none-any.whl (1.0 MB)
---------------------------------------- 1.0/1.0 MB 12.7 MB/s eta 0:00:00
Collecting cycler>=0.10
Downloading cycler-0.11.0-py3-none-any.whl (6.4 kB)
Requirement already satisfied: pillow>=6.2.0 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from matplotlib) (9.4.0)
Requirement already satisfied: pyparsing>=2.3.1 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from matplotlib) (3.0.9)
Requirement already satisfied: packaging>=20.0 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from matplotlib) (23.0)
Collecting importlib-resources>=3.2.0
Downloading importlib_resources-5.12.0-py3-none-any.whl (36 kB)
Requirement already satisfied: numpy>=1.20 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from matplotlib) (1.23.4)
Collecting contourpy>=1.0.1
Downloading contourpy-1.0.7-cp39-cp39-win_amd64.whl (160 kB)
-------------------------------------- 160.2/160.2 kB 3.2 MB/s eta 0:00:00
Collecting zipp>=3.1.0
Downloading zipp-3.15.0-py3-none-any.whl (6.8 kB)
Requirement already satisfied: six>=1.5 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)
Installing collected packages: zipp, python-dateutil, kiwisolver, fonttools, cycler, contourpy, importlib-resources, matplotlib
WARNING: The scripts fonttools.exe, pyftmerge.exe, pyftsubset.exe and ttx.exe are installed in 'C:\Users\butlej30383\AppData\Local\NA-MIC\Slicer 5.2.2\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.
Successfully installed contourpy-1.0.7 cycler-0.11.0 fonttools-4.39.0 importlib-resources-5.12.0 kiwisolver-1.4.4 matplotlib-3.7.1 python-dateutil-2.8.2 zipp-3.15.0

[notice] A new release of pip is available: 23.0 -> 23.0.1
[notice] To update, run: python-real.exe -m pip install --upgrade pip
Collecting https://github.com/wasserth/TotalSegmentator/archive/b38eb449ad8652a987878a925203cbfa354e9b85.zip
Downloading https://github.com/wasserth/TotalSegmentator/archive/b38eb449ad8652a987878a925203cbfa354e9b85.zip
- 5.5 MB 16.0 MB/s 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: numpy in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from TotalSegmentator==1.5.3) (1.23.4)
Collecting psutil
Downloading psutil-5.9.4-cp36-abi3-win_amd64.whl (252 kB)
-------------------------------------- 252.5/252.5 kB 2.6 MB/s eta 0:00:00
Requirement already satisfied: SimpleITK in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from TotalSegmentator==1.5.3) (2.2.0rc2.dev368)
Collecting nibabel>=2.3.0
Downloading nibabel-5.0.1-py3-none-any.whl (3.3 MB)
---------------------------------------- 3.3/3.3 MB 17.4 MB/s eta 0:00:00
Collecting tqdm>=4.45.0
Downloading tqdm-4.65.0-py3-none-any.whl (77 kB)
---------------------------------------- 77.1/77.1 kB ? eta 0:00:00
Collecting p_tqdm
Downloading p_tqdm-1.4.0.tar.gz (5.2 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Collecting xvfbwrapper
Downloading xvfbwrapper-0.2.9.tar.gz (5.6 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Collecting fury
Downloading fury-0.8.0-py3-none-any.whl (349 kB)
------------------------------------- 349.2/349.2 kB 22.6 MB/s eta 0:00:00
Collecting batchgenerators==0.21
Downloading batchgenerators-0.21-py3-none-any.whl (74 kB)
---------------------------------------- 74.7/74.7 kB ? eta 0:00:00
Collecting nnunet-customized==1.2
Downloading nnunet_customized-1.2-py3-none-any.whl (474 kB)
------------------------------------- 474.0/474.0 kB 29.0 MB/s eta 0:00:00
Requirement already satisfied: requests in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from TotalSegmentator==1.5.3) (2.28.2)
Requirement already satisfied: scipy in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from batchgenerators==0.21->TotalSegmentator==1.5.3) (1.9.2)
Collecting future
Downloading future-0.18.3.tar.gz (840 kB)
------------------------------------- 840.9/840.9 kB 51.9 MB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Collecting scikit-learn
Downloading scikit_learn-1.2.2-cp39-cp39-win_amd64.whl (8.4 MB)
---------------------------------------- 8.4/8.4 MB 38.2 MB/s eta 0:00:00
Collecting scikit-image
Downloading scikit_image-0.20.0-cp39-cp39-win_amd64.whl (23.9 MB)
--------------------------------------- 23.9/23.9 MB 28.4 MB/s eta 0:00:00
Collecting threadpoolctl
Downloading threadpoolctl-3.1.0-py3-none-any.whl (14 kB)
Requirement already satisfied: pillow>=7.1.2 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from batchgenerators==0.21->TotalSegmentator==1.5.3) (9.4.0)
Collecting unittest2
Downloading unittest2-1.1.0-py2.py3-none-any.whl (96 kB)
---------------------------------------- 96.4/96.4 kB ? eta 0:00:00
Collecting dicom2nifti
Downloading dicom2nifti-2.4.8-py3-none-any.whl (43 kB)
---------------------------------------- 43.6/43.6 kB ? eta 0:00:00
Collecting pandas
Downloading pandas-1.5.3-cp39-cp39-win_amd64.whl (10.9 MB)
--------------------------------------- 10.9/10.9 MB 54.4 MB/s eta 0:00:00
Collecting tifffile
Downloading tifffile-2023.2.28-py3-none-any.whl (216 kB)
------------------------------------- 216.4/216.4 kB 12.9 MB/s eta 0:00:00
Collecting medpy
Downloading MedPy-0.4.0.tar.gz (151 kB)
---------------------------------------- 151.8/151.8 kB ? eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: torch>=1.6.0a in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from nnunet-customized==1.2->TotalSegmentator==1.5.3) (2.0.0+cu118)
Requirement already satisfied: packaging>=17 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from nibabel>=2.3.0->TotalSegmentator==1.5.3) (23.0)
Requirement already satisfied: setuptools in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from nibabel>=2.3.0->TotalSegmentator==1.5.3) (67.0.0)
Collecting colorama
Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Requirement already satisfied: vtk>=9.1.0 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from fury->TotalSegmentator==1.5.3) (9.1.20220125)
Collecting pathos>=0.2.5
Downloading pathos-0.3.0-py3-none-any.whl (79 kB)
---------------------------------------- 79.8/79.8 kB ? eta 0:00:00
Requirement already satisfied: six>=1.13.0 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from p_tqdm->TotalSegmentator==1.5.3) (1.16.0)
Requirement already satisfied: idna<4,>=2.5 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from requests->TotalSegmentator==1.5.3) (3.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from requests->TotalSegmentator==1.5.3) (2022.12.7)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from requests->TotalSegmentator==1.5.3) (3.0.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from requests->TotalSegmentator==1.5.3) (1.26.14)
Collecting multiprocess>=0.70.14
Downloading multiprocess-0.70.14-py39-none-any.whl (132 kB)
---------------------------------------- 132.9/132.9 kB ? eta 0:00:00
Collecting ppft>=1.7.6.6
Downloading ppft-1.7.6.6-py3-none-any.whl (52 kB)
---------------------------------------- 52.8/52.8 kB ? eta 0:00:00
Collecting dill>=0.3.6
Downloading dill-0.3.6-py3-none-any.whl (110 kB)
---------------------------------------- 110.5/110.5 kB ? eta 0:00:00
Collecting pox>=0.3.2
Downloading pox-0.3.2-py3-none-any.whl (29 kB)
Collecting lazy_loader>=0.1
Downloading lazy_loader-0.1-py3-none-any.whl (8.6 kB)
Collecting PyWavelets>=1.1.1
Downloading PyWavelets-1.4.1-cp39-cp39-win_amd64.whl (4.2 MB)
---------------------------------------- 4.2/4.2 MB 38.2 MB/s eta 0:00:00
Requirement already satisfied: networkx>=2.8 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from scikit-image->batchgenerators==0.21->TotalSegmentator==1.5.3) (3.0)
Collecting scipy
Downloading scipy-1.9.1-cp39-cp39-win_amd64.whl (38.6 MB)
--------------------------------------- 38.6/38.6 MB 40.9 MB/s eta 0:00:00
Collecting imageio>=2.4.1
Downloading imageio-2.26.0-py3-none-any.whl (3.4 MB)
---------------------------------------- 3.4/3.4 MB 30.8 MB/s eta 0:00:00
Requirement already satisfied: typing-extensions in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from torch>=1.6.0a->nnunet-customized==1.2->TotalSegmentator==1.5.3) (4.5.0)
Requirement already satisfied: sympy in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from torch>=1.6.0a->nnunet-customized==1.2->TotalSegmentator==1.5.3) (1.11.1)
Requirement already satisfied: jinja2 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from torch>=1.6.0a->nnunet-customized==1.2->TotalSegmentator==1.5.3) (3.1.2)
Requirement already satisfied: filelock in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from torch>=1.6.0a->nnunet-customized==1.2->TotalSegmentator==1.5.3) (3.9.1)
Collecting python-gdcm
Downloading python_gdcm-3.0.21-cp39-cp39-win_amd64.whl (27.2 MB)
--------------------------------------- 27.2/27.2 MB 36.4 MB/s eta 0:00:00
Requirement already satisfied: pydicom>=2.2.0 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from dicom2nifti->nnunet-customized==1.2->TotalSegmentator==1.5.3) (2.3.1)
Requirement already satisfied: python-dateutil>=2.8.1 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from pandas->nnunet-customized==1.2->TotalSegmentator==1.5.3) (2.8.2)
Collecting pytz>=2020.1
Downloading pytz-2022.7.1-py2.py3-none-any.whl (499 kB)
------------------------------------- 499.4/499.4 kB 15.8 MB/s eta 0:00:00
Collecting joblib>=1.1.1
Downloading joblib-1.2.0-py3-none-any.whl (297 kB)
------------------------------------- 298.0/298.0 kB 18.0 MB/s eta 0:00:00
Collecting argparse
Downloading argparse-1.4.0-py2.py3-none-any.whl (23 kB)
Collecting traceback2
Downloading traceback2-1.4.0-py2.py3-none-any.whl (16 kB)
Requirement already satisfied: MarkupSafe>=2.0 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from jinja2->torch>=1.6.0a->nnunet-customized==1.2->TotalSegmentator==1.5.3) (2.1.2)
Requirement already satisfied: mpmath>=0.19 in c:\users\butlej30383\appdata\local\na-mic\slicer 5.2.2\lib\python\lib\site-packages (from sympy->torch>=1.6.0a->nnunet-customized==1.2->TotalSegmentator==1.5.3) (1.3.0)
Collecting linecache2
Downloading linecache2-1.0.0-py2.py3-none-any.whl (12 kB)
Building wheels for collected packages: TotalSegmentator, p_tqdm, xvfbwrapper, future, medpy
Building wheel for TotalSegmentator (setup.py): started
Building wheel for TotalSegmentator (setup.py): finished with status 'done'
Created wheel for TotalSegmentator: filename=TotalSegmentator-1.5.3-py3-none-any.whl size=40473 sha256=72631d27e92da70d44e97e4309a78d20e685ff9af743f96d7e69538a655f33f7
Stored in directory: C:\Users\butlej30383\AppData\Local\Temp\pip-ephem-wheel-cache-98sqy9xm\wheels\9f\4f\c3\aa92a6088ded23ae736534c7fd546ac5aec3409f87bbed6852
Building wheel for p_tqdm (setup.py): started
Building wheel for p_tqdm (setup.py): finished with status 'done'
Created wheel for p_tqdm: filename=p_tqdm-1.4.0-py3-none-any.whl size=5411 sha256=fa28bb84f74c368e3ca9f728cac1ce3da2df3fb07f95dcf27cf8d23c317ab512
Stored in directory: c:\users\butlej30383\appdata\local\pip\cache\wheels\53\8b\76\19cce68cdb3253aee026a593ec9bc772607b85193cf65e1f53
Building wheel for xvfbwrapper (setup.py): started
Building wheel for xvfbwrapper (setup.py): finished with status 'done'
Created wheel for xvfbwrapper: filename=xvfbwrapper-0.2.9-py3-none-any.whl size=5027 sha256=b15a6b7c25585d54d8fb6e75a0c52c862db0ca6335cbbb1f53a9fb4607d54d0d
Stored in directory: c:\users\butlej30383\appdata\local\pip\cache\wheels\aa\09\0e\c0fa4c721cfb0a003121597a24181add912b7488054d2311ad
Building wheel for future (setup.py): started
Building wheel for future (setup.py): finished with status 'done'
Created wheel for future: filename=future-0.18.3-py3-none-any.whl size=492055 sha256=e5d845853ca1d4176cfadcbc5699dbe1277875648cb957ad91f9787813b5c77a
Stored in directory: c:\users\butlej30383\appdata\local\pip\cache\wheels\bf\5d\6a\2e53874f7ec4e2bede522385439531fafec8fafe005b5c3d1b
Building wheel for medpy (setup.py): started
Building wheel for medpy (setup.py): finished with status 'done'
Created wheel for medpy: filename=MedPy-0.4.0-py3-none-any.whl size=215911 sha256=47f6a0c552cdc868104caf188bd34e85fbd5fd46a2882b6893bc782b1b948d8c
Stored in directory: c:\users\butlej30383\appdata\local\pip\cache\wheels\41\46\a2\7c585b78f216a3dd8723dbab5f439822fa5dfbff563757a49e
Successfully built TotalSegmentator p_tqdm xvfbwrapper future medpy
Installing collected packages: xvfbwrapper, pytz, linecache2, argparse, traceback2, tifffile, threadpoolctl, scipy, PyWavelets, python-gdcm, psutil, ppft, pox, nibabel, lazy_loader, joblib, imageio, future, dill, colorama, unittest2, tqdm, scikit-learn, scikit-image, pandas, multiprocess, medpy, fury, dicom2nifti, pathos, batchgenerators, p_tqdm, nnunet-customized, TotalSegmentator
WARNING: The scripts lsm2bin.exe, tiff2fsspec.exe, tiffcomment.exe and tifffile.exe are installed in 'C:\Users\butlej30383\AppData\Local\NA-MIC\Slicer 5.2.2\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.
Attempting uninstall: scipy
Found existing installation: scipy 1.9.2
Uninstalling scipy-1.9.2:
Successfully uninstalled scipy-1.9.2
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\Users\butlej30383\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\site-packages\~cipy\_lib\_ccallback_c.cp39-win_amd64.pyd'
Consider using the --user option or check the permissions.

[notice] A new release of pip is available: 23.0 -> 23.0.1
[notice] To update, run: python-real.exe -m pip install --upgrade pip
[Python] Failed to compute results.
[Python] Command '['C:/Users/butlej30383/AppData/Local/NA-MIC/Slicer 5.2.2/bin/../bin\PythonSlicer.EXE', '-m', 'pip', 'install', 'https://github.com/wasserth/TotalSegmentator/archive/b38eb449ad8652a987878a925203cbfa354e9b85.zip']' returned non-zero exit status 1.
Traceback (most recent call last):
File "C:/GitHub/SlicerTotalSegmentator/TotalSegmentator/TotalSegmentator.py", line 255, in onApplyButton
self.logic.setupPythonRequirements()
File "C:/GitHub/SlicerTotalSegmentator/TotalSegmentator/TotalSegmentator.py", line 624, in setupPythonRequirements
slicer.util.pip_install(self.totalSegmentatorPythonPackageDownloadUrl)
File "C:\Users\butlej30383\AppData\Local\NA-MIC\Slicer 5.2.2\bin\Python\slicer\util.py", line 3578, in pip_install
_executePythonModule('pip', args)
File "C:\Users\butlej30383\AppData\Local\NA-MIC\Slicer 5.2.2\bin\Python\slicer\util.py", line 3540, in _executePythonModule
logProcessOutput(proc)
File "C:\Users\butlej30383\AppData\Local\NA-MIC\Slicer 5.2.2\bin\Python\slicer\util.py", line 3509, in logProcessOutput
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command '['C:/Users/butlej30383/AppData/Local/NA-MIC/Slicer 5.2.2/bin/../bin\PythonSlicer.EXE', '-m', 'pip', 'install', 'https://github.com/wasserth/TotalSegmentator/archive/b38eb449ad8652a987878a925203cbfa354e9b85.zip']' returned non-zero exit status 1.

Total segmentator not running after restart

I am new to segmentation software. I have read that all you have to do is restart the 3D slicer; however, nothing is working still. I am getting the same error message each time.

Feature Request: Segment all volumes in a sequence

I tried segmenting the CT cardio sequence from "Download example data". The segmentation itself worked fine and didn't produce any errors, however the segmentation mask remains the same for all frames of the sequence.

I followed the instructions in this thread:
https://discourse.slicer.org/t/segmentation-of-multi-volume-sequence/5187/2
and it did work – I had to enable the segmentation mask to be recorded in the sequence as well, after running TotalSegmentator once. However, I had to manually run TotalSegmentator on each frame individually. This could be cumbersome on longer sequences.

I would thus suggest to implement the following:

  1. If a user runs TotalSegmentator on an image tracked by a sequence, they will be asked if they want to auto-segment the full sequence. Similar to the dialog I see when I run TotalSegmentator on CPU without enabling "fast" mode.
  2. If the user confirmed, add the resulting segmentation node to be tracked in a new sequence.
  3. Run TotalSegmentator on each frame of the volume sequence. And give the user some feedback about its progress.

while download the pretrained weights, the url can't fetch.

requests.exceptions.SSLError: HTTPSConnectionPool(host='zenodo.org', port=443): Max retries exceeded with url: /record/6802342/files/Task251_TotalSegmentator_part1_organs_1139subj.zip?download=1 (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

Exception run on sample data

I run this extension on CTA Abdomen (Panoramix) dataset, and get this exception:

Processing started
Writing input file to C:/Users/z/AppData/Local/Temp/Slicer/__SlicerTemp__2023-04-24_16+17+51.391/total-segmentator-input.nii
Creating segmentations with TotalSegmentator AI...
Total Segmentator arguments: ['-i', 'C:/Users/z/AppData/Local/Temp/Slicer/__SlicerTemp__2023-04-24_16+17+51.391/total-segmentator-input.nii', '-o', 'C:/Users/z/AppData/Local/Temp/Slicer/__SlicerTemp__2023-04-24_16+17+51.391/segmentation', '--ml', '--task', 'total', '--fast']


Please cite the following paper when using nnUNet:

Isensee, F., Jaeger, P.F., Kohl, S.A.A. et al. "nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation." Nat Methods (2020). https://doi.org/10.1038/s41592-020-01008-z


If you have questions or suggestions, feel free to open an issue at https://github.com/MIC-DKFZ/nnUNet

preprocessing C:\Users\z\AppData\Local\Temp\nnunet_tmp_zk3wskdc\s01.nii.gz
using preprocessor GenericPreprocessor
before crop: (1, 108, 79, 109) after crop: (1, 108, 79, 108) spacing: [3. 3. 3.]

no resampling necessary
no resampling necessary
before: {'spacing': array([3., 3., 3.]), 'spacing_transposed': array([3., 3., 3.]), 'data.shape (data is transposed)': (1, 108, 79, 108)}
after:  {'spacing': array([3., 3., 3.]), 'data.shape (data is resampled)': (1, 108, 79, 108)}

(1, 108, 79, 108)
This worker has ended successfully, no errors to report
D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\torch\cuda\amp\grad_scaler.py:116: UserWarning: torch.cuda.amp.GradScaler is enabled, but CUDA is not available.  Disabling.
  warnings.warn("torch.cuda.amp.GradScaler is enabled, but CUDA is not available.  Disabling.")
D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\torch\cuda\amp\autocast_mode.py:118: UserWarning: torch.cuda.amp.autocast only affects CUDA ops, but CUDA is not available.  Disabling.
  warnings.warn("torch.cuda.amp.autocast only affects CUDA ops, but CUDA is not available.  Disabling.")
Traceback (most recent call last):
  File "D:\dev\Slicer 5.2.2\lib\Python\Scripts\TotalSegmentator", line 93, in <module>
    main()
  File "D:\dev\Slicer 5.2.2\lib\Python\Scripts\TotalSegmentator", line 86, in main
    totalsegmentator(args.input, args.output, args.ml, args.nr_thr_resamp, args.nr_thr_saving,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\totalsegmentator\python_api.py", line 173, in totalsegmentator
    seg = nnUNet_predict_image(input, output, task_id, model=model, folds=folds,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py", line 255, in nnUNet_predict_image
    nnUNet_predict(tmp_dir, tmp_dir, task_id, model, folds, trainer, tta)
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py", line 106, in nnUNet_predict
    predict_from_folder(model_folder_name, dir_in, dir_out, folds, save_npz, num_threads_preprocessing,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\nnunet\inference\predict.py", line 668, in predict_from_folder
    return predict_cases_fastest(model, list_of_lists[part_id::num_parts], output_files[part_id::num_parts], folds,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\nnunet\inference\predict.py", line 493, in predict_cases_fastest
    res = trainer.predict_preprocessed_data_return_seg_and_softmax(d, do_mirroring=do_tta,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\nnunet\training\network_training\nnUNetTrainerV2.py", line 211, in predict_preprocessed_data_return_seg_and_softmax
    ret = super().predict_preprocessed_data_return_seg_and_softmax(data,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\nnunet\training\network_training\nnUNetTrainer.py", line 516, in predict_preprocessed_data_return_seg_and_softmax
    ret = self.network.predict_3D(data, do_mirroring=do_mirroring, mirror_axes=mirror_axes,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\nnunet\network_architecture\neural_network.py", line 147, in predict_3D
    res = self._internal_predict_3D_3Dconv_tiled(x, step_size, do_mirroring, mirror_axes, patch_size,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\nnunet\network_architecture\neural_network.py", line 348, in _internal_predict_3D_3Dconv_tiled
    gaussian_importance_map[gaussian_importance_map == 0] = gaussian_importance_map[
RuntimeError: "min_all" not implemented for 'Half'
Exception ignored in: <totalsegmentator.libs.DummyFile object at 0x000002829F8B86D0>
AttributeError: 'DummyFile' object has no attribute 'flush'

If you use this tool please cite: https://doi.org/10.48550/arXiv.2208.05868

No GPU detected. Running on CPU. This can be very slow. The '--fast' option can help to some extend.
Using 'fast' option: resampling to lower resolution (3mm)
Resampling...
  Resampled in 1.24s
Predicting...

Force reinstall fail...

Traceback (most recent call last):
  File "/Users/liguimei/Documents/GitHub/SlicerTotalSegmentator/TotalSegmentator/TotalSegmentator.py", line 284, in onPackageUpgrade
    self.logic.setupPythonRequirements(upgrade=True)
  File "/Users/liguimei/Documents/GitHub/SlicerTotalSegmentator/TotalSegmentator/TotalSegmentator.py", line 659, in setupPythonRequirements
    slicer.util.pip_install("git+https://github.com/wasserth/TotalSegmentator.git")
  File "/Applications/Slicer.app/Contents/bin/Python/slicer/util.py", line 3613, in pip_install
    _executePythonModule('pip', args)
  File "/Applications/Slicer.app/Contents/bin/Python/slicer/util.py", line 3575, in _executePythonModule
    logProcessOutput(proc)
  File "/Applications/Slicer.app/Contents/bin/Python/slicer/util.py", line 3544, in logProcessOutput
    raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command '['/Applications/Slicer.app/Contents/bin/../bin/PythonSlicer', '-m', 'pip', 'install', 'git+https://github.com/wasserth/TotalSegmentator.git']' returned non-zero exit status 1.

I want to 'use latest development version' and 'Force reinstall'... but failed 👆🏻

TotalSegmentator exits with code 2

Traceback (most recent call last):
  File "/Applications/Slicer3.app/Contents/bin/Python/slicer/util.py", line 2967, in tryWithErrorDisplay
    yield
  File "/Users/liguimei/Documents/GitHub/SlicerTotalSegmentator/TotalSegmentator/TotalSegmentator.py", line 271, in onApplyButton
    self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),
  File "/Users/liguimei/Documents/GitHub/SlicerTotalSegmentator/TotalSegmentator/TotalSegmentator.py", line 868, in process
    self.logProcessOutput(proc)
  File "/Users/liguimei/Documents/GitHub/SlicerTotalSegmentator/TotalSegmentator/TotalSegmentator.py", line 701, in logProcessOutput
    raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command '['/Applications/Slicer3.app/Contents/bin/../bin/PythonSlicer', '/Applications/Slicer3.app/Contents/lib/Python/bin/TotalSegmentator', '-i', '/private/var/folders/9b/mhf79phj3ss95qk4p1_vw6gh0000gn/T/Slicer-liguimei/__SlicerTemp__2023-10-02_06+12+36.781/total-segmentator-input.nii', '-o', '/private/var/folders/9b/mhf79phj3ss95qk4p1_vw6gh0000gn/T/Slicer-liguimei/__SlicerTemp__2023-10-02_06+12+36.781/segmentation', '--ml', '--task', 'bones_tissue_test']' returned non-zero exit status 2.
Traceback (most recent call last):
  File "/Applications/Slicer3.app/Contents/bin/Python/slicer/util.py", line 2967, in tryWithErrorDisplay
    yield
  File "/Users/liguimei/Documents/GitHub/SlicerTotalSegmentator/TotalSegmentator/TotalSegmentator.py", line 271, in onApplyButton
    self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),
  File "/Users/liguimei/Documents/GitHub/SlicerTotalSegmentator/TotalSegmentator/TotalSegmentator.py", line 868, in process
    self.logProcessOutput(proc)
  File "/Users/liguimei/Documents/GitHub/SlicerTotalSegmentator/TotalSegmentator/TotalSegmentator.py", line 701, in logProcessOutput
    raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command '['/Applications/Slicer3.app/Contents/bin/../bin/PythonSlicer', '/Applications/Slicer3.app/Contents/lib/Python/bin/TotalSegmentator', '-i', '/private/var/folders/9b/mhf79phj3ss95qk4p1_vw6gh0000gn/T/Slicer-liguimei/__SlicerTemp__2023-10-02_06+06+56.467/total-segmentator-input.nii', '-o', '/private/var/folders/9b/mhf79phj3ss95qk4p1_vw6gh0000gn/T/Slicer-liguimei/__SlicerTemp__2023-10-02_06+06+56.467/segmentation', '--ml', '--task', 'test']' returned non-zero exit status 1.

Pytorch 2.0 cu18 win - very slow

Updating from torch1.13.1 cu17 to torch 2.0 cu18 increases computation time more than 2x. From 80 s to 180 s when segmentating CTA abdomen (panoramix) in a GTX1660 super in a windows system.

Not sure if it is due to pytorch or cuda version.

Tests

This is a nice addon!

Desktop Windows RTX 3070 Ti

Test with Slicer 5.3 preview:

-> Working well, would automatic threedview generation and centering be helpful?  

Test with Slicer 5.0.3:

 -> TotalSegmentator runs from extension but does not create segments

Laptop Windows RTX 1060

Test with a fresh Slicer 5.3 preview:

error message (details follow) 

Test with Slicer 5.0.3:

 error message (details follow)

Basic error

I'm using Slicer ver5.2 and trying to use TotalSegmentor, but I'm getting the error below. How would you like to fix it? Sorry for the basic question.

Command '['C:/Users/Owner/AppData/Local/NA-MIC/Slicer 5.2.1/bin/../bin\PythonSlicer.EXE', '-m', 'pip', 'install', 'git+https://github.com/wasserth/TotalSegmentator.git', '--no-deps']' returned non-zero exit status 1.

Traceback (most recent call last):
File "C:\Users\Owner\AppData\Local\NA-MIC\Slicer 5.2.1\bin\Python\slicer\util.py", line 2961, in tryWithErrorDisplay
yield
File "C:/Users/Owner/AppData/Local/NA-MIC/Slicer 5.2.1/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py", line 238, in onApplyButton
self.logic.setupPythonRequirements()
File "C:/Users/Owner/AppData/Local/NA-MIC/Slicer 5.2.1/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py", line 372, in setupPythonRequirements
slicer.util.pip_install(totalSegmentatorPackage + " --no-deps" + (" --upgrade" if upgrade else ""))
File "C:\Users\Owner\AppData\Local\NA-MIC\Slicer 5.2.1\bin\Python\slicer\util.py", line 3571, in pip_install
_executePythonModule('pip', args)
File "C:\Users\Owner\AppData\Local\NA-MIC\Slicer 5.2.1\bin\Python\slicer\util.py", line 3533, in _executePythonModule
logProcessOutput(proc)
File "C:\Users\Owner\AppData\Local\NA-MIC\Slicer 5.2.1\bin\Python\slicer\util.py", line 3502, in logProcessOutput
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command '['C:/Users/Owner/AppData/Local/NA-MIC/Slicer 5.2.1/bin/../bin\PythonSlicer.EXE', '-m', 'pip', 'install', 'git+https://github.com/wasserth/TotalSegmentator.git', '--no-deps']' returned non-zero exit status 1.

Feature request: Add a backend support e.g. GPU on different machine.

It would be nice to add a backend support so the extension runs using a GPU on a different machine e.g.:

  1. The user installs the backend, e.g. flask server, and required libs
  2. In 3D Slicer, a user adds the GPU server, the extension sends the input image and other parameters, the backend runs the segmentation task, and sends the result back to 3D Slicer.

Feature request: Add body crop

TotalSegmentator and SlicerTotalSegmentator are awesome, congratulations for the great job! We are currently testing it for autosegmentation in radiation oncology. We use 8GB GPUs which sometimes fails to allocate all the memory with big studysets. It turns out that the TotalSegmentation option '--body_seg' makes the process error free and takes less time as well.
We have modified SlicerTotal to always use this option, can it be added to the extension maybe just as the --fast option is currently implemented?

TotalSegmentator fails to launch on Windows with Slicer 5.4

The script failed to launch the process TotalSegmentator on Windows.

On line 719 of TotalSegmentator.py (branch 5.4)

totalSegmentatorPath = os.path.join(sysconfig.get_path('scripts'), "TotalSegmentator")

totalSegmentatorPath = os.path.join(sysconfig.get_path('scripts'), "TotalSegmentator")

should be:

totalSegmentatorPath = os.path.join(sysconfig.get_path('scripts'), "TotalSegmentator")
if os.name == 'nt':
    totalSegmentatorPath += ".exe"

This change fixes the issue for me

EDIT: I see that the code in latest version handles this issue. But this is not what it is installed by default in Slicer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.