# Problem running TotalSegmentator in Slicer-5.4

**URL:** <https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491>\
**Category:** Support\
**Tags:** segmentation, totalsegmentator\
**Created:** [October 30, 2023, 6:41pm UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491 "2023-10-30T18:41:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Investigacion\_y\_des1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/investigacion_y_des1/32/68050_2.png) [@Investigacion\_y\_des1](https://discourse.slicer.org/u/Investigacion_y_des1)\
**Post date:** [October 30, 2023, 6:41pm UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491/1 "2023-10-30T18:41:44Z")

</div>

Hi ! I have a question, do the previous version works with Slicer 5.4? because I’m not been able to run it on my pc. I will appreciate an answer, best regards.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 30, 2023, 6:58pm UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491/2 "2023-10-30T18:58:40Z")

</div>

Yes, TotalSegmentator extension still works well in Slicer-5.4. It uses the TotalSegmentator v1 model. There are constant updates in Python packages and so we had to make some fixes recently. If you experience any problems then I would recommend to reinstall Slicer (remove the existing application installation folder completely; or reinstall Slicer in a completely new folder) and then install TotalSegmentator extension.

---

<div class="post-metadata">

**Author:** ![philippe](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@philippe](https://discourse.slicer.org/u/philippe)\
**Post date:** [February 19, 2024, 6:15pm UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491/3 "2024-02-19T18:15:41Z")

</div>

Hello,

I tried TotalSegmentator v2 within Slicer 5.6.1.  
The limbs are missing (below the knee / humerus) on all CTs I tried (5).

Version 5.5 is mentioned there:

> <https://github.com/wasserth/TotalSegmentator/issues/238>
>
> \`\`\`
> Traceback (most recent call last):
> File "/home/i/Downloads/Slicer-5.4.0-…linux-amd64/bin/Python/slicer/util.py", line 3146, in tryWithErrorDisplay
> yield
> File "/home/i/Downloads/Slicer-5.4.0-linux-amd64/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 "/home/i/Downloads/Slicer-5.4.0-linux-amd64/slicer.org/Extensions-31938/TotalSegmentator/lib/Slicer-5.4/qt-scripted-modules/TotalSegmentator.py", line 790, in process
> self.readSegmentation(outputSegmentation, outputSegmentationFile, task)
> File "/home/i/Downloads/Slicer-5.4.0-linux-amd64/slicer.org/Extensions-31938/TotalSegmentator/lib/Slicer-5.4/qt-scripted-modules/TotalSegmentator.py", line 864, in readSegmentation
> labelValueToSegmentName = class\_map\[task\]
> KeyError: 'bones\_extremities'
> \`\`\`
> Using CPU only on Fedora. Reproduce is as usual: selected bones extremities, create new segmentation on apply, then clicked on Apply.
> More logs
> 
> \<details\>\<summary\>Details\</summary\>
> \<p\>
> 
> \`\`\`
> Processing started
> Writing input file to /tmp/Slicer-i/\_\_SlicerTemp\_\_2023-11-26\_09+37+05.403/total-segmentator-input.nii
> Creating segmentations with TotalSegmentator AI (pre-run)...
> Total Segmentator arguments: \['-i', '/tmp/Slicer-i/\_\_SlicerTemp\_\_2023-11-26\_09+37+05.403/total-segmentator-input.nii', '-o', '/tmp/Slicer-i/\_\_SlicerTemp\_\_2023-11-26\_09+37+05.403/segmentation', '--fast'\]
> /home/i/Downloads/Slicer-5.4.0-linux-amd64/lib/Python/bin/TotalSegmentator:5: DeprecationWarning: pkg\_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg\_resources.html
> from pkg\_resources import require
> /home/i/Downloads/Slicer-5.4.0-linux-amd64/lib/Python/lib/python3.9/site-packages/requests/\_\_init\_\_.py:102: RequestsDependencyWarning: urllib3 (1.26.18) or chardet (5.1.0)/charset\_normalizer (2.0.12) doesn't match a supported version!
> warnings.warn("urllib3 ({}) or chardet ({})/charset\_normalizer ({}) doesn't match a supported "
> /home/i/Downloads/Slicer-5.4.0-linux-amd64/lib/Python/lib/python3.9/site-packages/torch/cuda/amp/grad\_scaler.py:125: UserWarning: torch.cuda.amp.GradScaler is enabled, but CUDA is not available. Disabling.
> warnings.warn(
> /home/i/Downloads/Slicer-5.4.0-linux-amd64/lib/Python/lib/python3.9/site-packages/torch/amp/autocast\_mode.py:250: UserWarning: User provided device\_type of 'cuda', but CUDA is not available. Disabling
> warnings.warn(
> 
> 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 3.14s
> Predicting...
> 
> 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 3.14s
> Predicting...
> Predicted in 10.04s
> Resampling...
> Saving segmentations...
> 
> 0%| | 0/104 \[00:00\<?, ?it/s\]
> 1%| | 1/104 \[00:11\<20:03, 11.69s/it\]
> 7%|▋ | 7/104 \[00:12\<02:13, 1.38s/it\]
> 8%|▊ | 8/104 \[00:15\<02:36, 1.63s/it\]
> 9%|▊ | 9/104 \[00:15\<02:08, 1.35s/it\]
> 10%|▉ | 10/104 \[00:15\<01:41, 1.08s/it\]
> 12%|█▎ | 13/104 \[00:16\<00:53, 1.69it/s\]
> 13%|█▎ | 14/104 \[00:16\<00:54, 1.66it/s\]
> 14%|█▍ | 15/104 \[00:17\<01:02, 1.44it/s\]
> 15%|█▌ | 16/104 \[00:18\<00:55, 1.59it/s\]
> 17%|█▋ | 18/104 \[00:18\<00:34, 2.47it/s\]
> 18%|█▊ | 19/104 \[00:18\<00:35, 2.41it/s\]
> 19%|█▉ | 20/104 \[00:18\<00:28, 2.95it/s\]
> 20%|██ | 21/104 \[00:19\<00:24, 3.43it/s\]
> 21%|██ | 22/104 \[00:20\<00:39, 2.06it/s\]
> 22%|██▏ | 23/104 \[00:20\<00:32, 2.47it/s\]
> 23%|██▎ | 24/104 \[00:20\<00:26, 3.04it/s\]
> 24%|██▍ | 25/104 \[00:21\<00:30, 2.56it/s\]
> 25%|██▌ | 26/104 \[00:21\<00:26, 2.94it/s\]
> 26%|██▌ | 27/104 \[00:21\<00:21, 3.61it/s\]
> 27%|██▋ | 28/104 \[00:21\<00:23, 3.23it/s\]
> 28%|██▊ | 29/104 \[00:22\<00:24, 3.12it/s\]
> 30%|██▉ | 31/104 \[00:22\<00:21, 3.34it/s\]
> 31%|███ | 32/104 \[00:23\<00:24, 2.94it/s\]
> 33%|███▎ | 34/104 \[00:23\<00:19, 3.56it/s\]
> 34%|███▎ | 35/104 \[00:23\<00:21, 3.21it/s\]
> 36%|███▌ | 37/104 \[00:24\<00:18, 3.66it/s\]
> 37%|███▋ | 38/104 \[00:24\<00:21, 3.12it/s\]
> 38%|███▊ | 39/104 \[00:25\<00:20, 3.19it/s\]
> 38%|███▊ | 40/104 \[00:25\<00:17, 3.65it/s\]
> 39%|███▉ | 41/104 \[00:25\<00:23, 2.67it/s\]
> 41%|████▏ | 43/104 \[00:26\<00:18, 3.26it/s\]
> 42%|████▏ | 44/104 \[00:26\<00:19, 3.15it/s\]
> 43%|████▎ | 45/104 \[00:27\<00:26, 2.19it/s\]
> 44%|████▍ | 46/104 \[00:27\<00:24, 2.33it/s\]
> 45%|████▌ | 47/104 \[00:29\<00:44, 1.28it/s\]
> 47%|████▋ | 49/104 \[00:30\<00:28, 1.91it/s\]
> 48%|████▊ | 50/104 \[00:30\<00:24, 2.17it/s\]
> 49%|████▉ | 51/104 \[00:30\<00:20, 2.62it/s\]
> 50%|█████ | 52/104 \[00:30\<00:16, 3.06it/s\]
> 51%|█████ | 53/104 \[00:31\<00:18, 2.78it/s\]
> 53%|█████▎ | 55/104 \[00:31\<00:14, 3.40it/s\]
> 54%|█████▍ | 56/104 \[00:31\<00:14, 3.39it/s\]
> 55%|█████▍ | 57/104 \[00:31\<00:12, 3.86it/s\]
> 56%|█████▌ | 58/104 \[00:32\<00:10, 4.21it/s\]
> 57%|█████▋ | 59/104 \[00:32\<00:12, 3.59it/s\]
> 59%|█████▊ | 61/104 \[00:32\<00:10, 4.21it/s\]
> 60%|█████▉ | 62/104 \[00:33\<00:10, 3.86it/s\]
> 61%|██████ | 63/104 \[00:33\<00:09, 4.13it/s\]
> 62%|██████▏ | 64/104 \[00:33\<00:08, 4.45it/s\]
> 62%|██████▎ | 65/104 \[00:34\<00:11, 3.47it/s\]
> 64%|██████▍ | 67/104 \[00:34\<00:08, 4.32it/s\]
> 65%|██████▌ | 68/104 \[00:34\<00:11, 3.15it/s\]
> 66%|██████▋ | 69/104 \[00:35\<00:10, 3.21it/s\]
> 67%|██████▋ | 70/104 \[00:35\<00:09, 3.74it/s\]
> 68%|██████▊ | 71/104 \[00:35\<00:10, 3.00it/s\]
> 70%|███████ | 73/104 \[00:36\<00:07, 4.20it/s\]
> 71%|███████ | 74/104 \[00:36\<00:08, 3.48it/s\]
> 72%|███████▏ | 75/104 \[00:36\<00:08, 3.42it/s\]
> 73%|███████▎ | 76/104 \[00:37\<00:07, 3.75it/s\]
> 74%|███████▍ | 77/104 \[00:37\<00:07, 3.44it/s\]
> 76%|███████▌ | 79/104 \[00:37\<00:05, 4.88it/s\]
> 77%|███████▋ | 80/104 \[00:37\<00:05, 4.00it/s\]
> 78%|███████▊ | 81/104 \[00:38\<00:05, 3.92it/s\]
> 79%|███████▉ | 82/104 \[00:38\<00:05, 4.12it/s\]
> 80%|███████▉ | 83/104 \[00:38\<00:05, 3.87it/s\]
> 82%|████████▏ | 85/104 \[00:38\<00:03, 5.56it/s\]
> 83%|████████▎ | 86/104 \[00:39\<00:04, 4.38it/s\]
> 84%|████████▎ | 87/104 \[00:39\<00:04, 4.07it/s\]
> 85%|████████▍ | 88/104 \[00:39\<00:04, 3.87it/s\]
> 86%|████████▌ | 89/104 \[00:40\<00:03, 3.76it/s\]
> 88%|████████▊ | 91/104 \[00:40\<00:02, 5.52it/s\]
> 88%|████████▊ | 92/104 \[00:40\<00:02, 4.29it/s\]
> 89%|████████▉ | 93/104 \[00:40\<00:02, 4.35it/s\]
> 90%|█████████ | 94/104 \[00:41\<00:02, 3.77it/s\]
> 91%|█████████▏| 95/104 \[00:41\<00:02, 3.75it/s\]
> 93%|█████████▎| 97/104 \[00:41\<00:01, 5.29it/s\]
> 94%|█████████▍| 98/104 \[00:42\<00:01, 4.40it/s\]
> 95%|█████████▌| 99/104 \[00:42\<00:01, 4.50it/s\]
> 96%|█████████▌| 100/104 \[00:42\<00:01, 3.94it/s\]
> 97%|█████████▋| 101/104 \[00:42\<00:00, 4.18it/s\]
> 99%|█████████▉| 103/104 \[00:43\<00:00, 6.11it/s\]
> 100%|██████████| 104/104 \[00:43\<00:00, 6.56it/s\]
> 100%|██████████| 104/104 \[00:43\<00:00, 2.41it/s\]
> Saved in 44.44s
> Creating segmentations with TotalSegmentator AI...
> Total Segmentator arguments: \['-i', '/tmp/Slicer-i/\_\_SlicerTemp\_\_2023-11-26\_09+37+05.403/total-segmentator-input.nii', '-o', '/tmp/Slicer-i/\_\_SlicerTemp\_\_2023-11-26\_09+37+05.403/segmentation', '--ml', '--task', 'bones\_extremities'\]
> /home/i/Downloads/Slicer-5.4.0-linux-amd64/lib/Python/bin/TotalSegmentator:5: DeprecationWarning: pkg\_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg\_resources.html
> from pkg\_resources import require
> /home/i/Downloads/Slicer-5.4.0-linux-amd64/lib/Python/lib/python3.9/site-packages/requests/\_\_init\_\_.py:102: RequestsDependencyWarning: urllib3 (1.26.18) or chardet (5.1.0)/charset\_normalizer (2.0.12) doesn't match a supported version!
> warnings.warn("urllib3 ({}) or chardet ({})/charset\_normalizer ({}) doesn't match a supported "
> 
> 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.
> 
> This model is only available upon purchase of a license (free licenses available for academic projects).
> Contact jakob.wasserthal@usb.ch if you are interested.
> 
> Importing segmentation results...
> \`\`\`
> 
> \</p\>
> \</details\>

but not available in the collection of older slicer packages on Kitware’s site (5.4-\>5.6).

Did anyone have luck with the limbs?  
Using which version of slicer?

Thanks  
Philippe  
PS: i’ll post on github too and update if I have a response

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [February 19, 2024, 8:22pm UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491/4 "2024-02-19T20:22:59Z")

</div>

TotalSegmentator v2 began to work with Slicer Preview 5.5 which ultimately became Slicer Stable 5.6.x. So using Slicer 5.6.1 is sufficient for your case and going back to Slicer 5.5 won’t get you anything more.

Are the segment tasks that you are expecting in the list of the ones available in v2? Do you have a license for the ones that require a license? See below:

> **[GitHub - wasserth/TotalSegmentator: Tool for robust segmentation of \>100...](https://github.com/wasserth/TotalSegmentator?tab=readme-ov-file#subtasks)**
>
> Tool for robust segmentation of \>100 important anatomical structures in CT images - wasserth/TotalSegmentator

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [February 20, 2024, 10:33am UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491/5 "2024-02-20T10:33:53Z")

</div>

Maybe you can get a free academic license if you contact Jakob Wasserthal from TotalSegmentator.

---

<div class="post-metadata">

**Author:** ![philippe](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@philippe](https://discourse.slicer.org/u/philippe)\
**Post date:** [February 20, 2024, 10:44am UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491/6 "2024-02-20T10:44:32Z")

</div>

> [@philippe](#):
>
> Philippe  
> PS: i’ll post on git

Dummy me. I did not realize that they called the extremities “appendicular bones”.  
Thanks for the pointer. I’ll ask a license

---

<div class="post-metadata">

**Author:** ![philippe](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@philippe](https://discourse.slicer.org/u/philippe)\
**Post date:** [February 20, 2024, 12:31pm UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491/7 "2024-02-20T12:31:58Z")

</div>

Sorry to post again.  
I got a license but there is an error installing it:

```auto
Failed to set TotalSegmentator license.

Command '['C:/Users/-------/AppData/Local/slicer.org/Slicer 5.6.1/bin/../bin\\PythonSlicer.EXE', 'C:\\Users\\-------\\AppData\\Local\\slicer.org\\Slicer 5.6.1\\lib\\Python\\Scripts\\totalseg_set_license.exe', '-l', '

Traceback (most recent call last):
  File "C:\\Users\\-------\\AppData\\Local\\slicer.org\\Slicer 5.6.1\\bin\\Python\\slicer\\util.py", line 3255, in tryWithErrorDisplay
    yield
  File "C:/Users/-------/AppData/Local/slicer.org/Slicer 5.6.1/slicer.org/Extensions-32438/TotalSegmentator/lib/Slicer-5.6/qt-scripted-modules/TotalSegmentator.py", line 318, in onSetLicense
    self.logic.setlicense(self.ui.licenseLineEdit.text)
  File "C:/Users/-------/AppData/Local/slicer.org/Slicer 5.6.1/slicer.org/Extensions-32438/TotalSegmentator/lib/Slicer-5.6/qt-scripted-modules/TotalSegmentator.py", line 831, in setlicense
    licenseToolOutput = self.logProcessOutput(proc, returnOutput=True)
  File "C:/Users/-------/AppData/Local/slicer.org/Slicer 5.6.1/slicer.org/Extensions-32438/TotalSegmentator/lib/Slicer-5.6/qt-scripted-modules/TotalSegmentator.py", line 779, in logProcessOutput
    if not line:
UnboundLocalError: local variable \'line\' referenced before assignment']' returned non-zero exit status 1.

```

The error is related to line 779:

```auto
try:
                line = proc.stdout.readline()
except UnicodeDecodeError as e:
                # Code page conversion happens because `universal_newlines=True` sets process output to text mode,
                # and it fails because probably system locale is not UTF8. We just ignore the error and discard the string,
                # as we only guarantee correct behavior if an UTF8 locale is used.

```

My PC is in french. Slicer is set in english.  
There are no special characters in the license key;  
Total segmentator works fine otherwise.

Any idea on how to solve it?  
Thanks  
Philippe

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [February 20, 2024, 3:18pm UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491/8 "2024-02-20T15:18:18Z")

</div>

@lassoan could you please check this? Thank you

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 20, 2024, 6:46pm UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491/9 "2024-02-20T18:46:20Z")

</div>

Thank you, I’ve [pushed a fix](https://github.com/lassoan/SlicerTotalSegmentator/commit/f838b29c191fa799394324f66d348661ce489f60) that will be available in the extensions manager from tomorrow. Please update the extension tomorrow and try again.

---

<div class="post-metadata">

**Author:** ![philippe](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@philippe](https://discourse.slicer.org/u/philippe)\
**Post date:** [February 21, 2024, 7:17pm UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491/10 "2024-02-21T19:17:24Z")

</div>

Thanks a lot.  
I confirm the license is working now.  
Philippe

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 21, 2024, 7:18pm UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491/11 "2024-02-21T19:18:19Z")

</div>

Awesome, thanks for testing.

---

<div class="post-metadata">

**Author:** ![rnvwnvvir](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rnvwnvvir/32/69459_2.png) [@rnvwnvvir](https://discourse.slicer.org/u/rnvwnvvir)\
**Post date:** [February 23, 2024, 8:43am UTC](https://discourse.slicer.org/t/problem-running-totalsegmentator-in-slicer-5-4/32491/12 "2024-02-23T08:43:06Z")

</div>

Hello,my slicer is 3.6.1.The following error occurs when using TotalSegmentator.  
Restart is unuseful.

Application is required to complete installation of required Python packages.

Press OK to restart.
