# Automated brain segmentation into White Matter Volume, GMV, and CSF Vol?

**URL:** <https://discourse.slicer.org/t/automated-brain-segmentation-into-white-matter-volume-gmv-and-csf-vol/19322>\
**Category:** Support\
**Tags:** segmentation, extensions-manager\
**Created:** [August 23, 2021, 4:18pm UTC](https://discourse.slicer.org/t/automated-brain-segmentation-into-white-matter-volume-gmv-and-csf-vol/19322 "2021-08-23T16:18:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![J1234](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@J1234](https://discourse.slicer.org/u/J1234)\
**Post date:** [August 23, 2021, 4:18pm UTC](https://discourse.slicer.org/t/automated-brain-segmentation-into-white-matter-volume-gmv-and-csf-vol/19322/1 "2021-08-23T16:18:45Z")

</div>

Does anyone know if there is an extension that facilitates whole brain segmentation into CSF, gray, and white matter? I downloaded BrainVolumeRefinement, which seemed to have this capability for Slicer 4.10, but since installing I haven’t been able to find it in my modules. This makes me think it wasn’t updated to be compatible with 4.11.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 23, 2021, 4:28pm UTC](https://discourse.slicer.org/t/automated-brain-segmentation-into-white-matter-volume-gmv-and-csf-vol/19322/2 "2021-08-23T16:28:40Z")

</div>

I’ve had good luck with this one:

> **[GitHub - fepegar/SlicerParcellation: 3D Slicer modules for brain segmentation...](https://github.com/fepegar/SlicerParcellation)**
>
> 3D Slicer modules for brain segmentation using deep learning. - GitHub - fepegar/SlicerParcellation: 3D Slicer modules for brain segmentation using deep learning.

---

<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:** [August 25, 2021, 2:37am UTC](https://discourse.slicer.org/t/automated-brain-segmentation-into-white-matter-volume-gmv-and-csf-vol/19322/3 "2021-08-25T02:37:18Z")

</div>

@fepegar It seems that this extension is not in the extension index. Is there some issue with it, or you just have not had the time to submit it a pull request yet?

---

<div class="post-metadata">

**Author:** ![J1234](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@J1234](https://discourse.slicer.org/u/J1234)\
**Post date:** [August 26, 2021, 3:54am UTC](https://discourse.slicer.org/t/automated-brain-segmentation-into-white-matter-volume-gmv-and-csf-vol/19322/4 "2021-08-26T03:54:00Z")

</div>

@pieper thank you. if I can get it to work this looks like it should fit the bill.

I downloaded a copy to my Desktop and added it to “Additional Module Paths” in Slicer. However, whenever I try to run a segmentation I get the below error. Is this related to @lassoan’s comment about this module not being in the extension index yet?

Importing torch…

Requirement already satisfied: light-the-torch in /Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages (0.3.4)

Requirement already satisfied: pip\<20.3._,\>=20.1._ in /Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages (from light-the-torch) (20.2.4)

WARNING: You are using pip version 20.2.4; however, version 21.2.4 is available.

You should consider upgrading via the ‘/Applications/Slicer.app/Contents/bin/./python-real -m pip install --upgrade pip’ command.  
Traceback (most recent call last):  
File “/Users/Jesse/Desktop/SlicerParcellation-master/PyTorchUtils.py”, line 44, in importTorch  
import torch  
ModuleNotFoundError: No module named ‘torch’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “/Users/Jesse/Desktop/SlicerParcellation-master/BrainParcellation.py”, line 62, in onRunButton  
super().onRunButton()  
File “/Users/Jesse/Desktop/SlicerParcellation-master/InferenceUtils.py”, line 175, in onRunButton  
if not self.logic.confirmDeviceOk():  
File “/Users/Jesse/Desktop/SlicerParcellation-master/InferenceUtils.py”, line 257, in confirmDeviceOk  
if self.torchLogic.getDevice() == ‘cpu’:  
File “/Users/Jesse/Desktop/SlicerParcellation-master/PyTorchUtils.py”, line 73, in getDevice  
torch = self.torch  
File “/Users/Jesse/Desktop/SlicerParcellation-master/PyTorchUtils.py”, line 39, in torch  
self.\_torch = self.importTorch()  
File “/Users/Jesse/Desktop/SlicerParcellation-master/PyTorchUtils.py”, line 47, in importTorch  
torch = self.installTorch()  
File “/Users/Jesse/Desktop/SlicerParcellation-master/PyTorchUtils.py”, line 53, in installTorch  
wheelUrl = self.getTorchUrl()  
File “/Users/Jesse/Desktop/SlicerParcellation-master/PyTorchUtils.py”, line 62, in getTorchUrl  
import light\_the\_torch as ltt  
File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/light\_the\_torch/ **init**.py”, line 3, in   
from .\_pip import \*  
File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/light\_the\_torch/\_pip/ **init**.py”, line 1, in   
from .extract import \*  
File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/light\_the\_torch/\_pip/extract.py”, line 5, in   
from pip.\_internal.req.req\_install import InstallRequirement  
File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/pip/\_internal/req/ **init**.py”, line 10, in   
from .req\_install import InstallRequirement  
File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/pip/\_internal/req/req\_install.py”, line 35, in   
from pip.\_internal.utils.direct\_url\_helpers import direct\_url\_from\_link  
File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/pip/\_internal/utils/direct\_url\_helpers.py”, line 12, in   
from pip.\_internal.vcs import vcs  
File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/pip/\_internal/vcs/ **init**.py”, line 9, in   
import pip.\_internal.vcs.subversion # noqa: F401  
File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/pip/\_internal/vcs/subversion.py”, line 336, in   
vcs.register(Subversion)  
File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/pip/\_internal/vcs/versioncontrol.py”, line 317, in register  
self.\_registry[cls.name] = cls()  
File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/pip/\_internal/vcs/subversion.py”, line 191, in **init**  
use\_interactive = is\_console\_interactive()  
File “/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/pip/\_internal/utils/misc.py”, line 906, in is\_console\_interactive  
return sys.stdin is not None and sys.stdin.isatty()  
AttributeError: ‘PythonQtStdInRedirect’ object has no attribute ‘isatty’

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 26, 2021, 12:50pm UTC](https://discourse.slicer.org/t/automated-brain-segmentation-into-white-matter-volume-gmv-and-csf-vol/19322/5 "2021-08-26T12:50:46Z")

</div>

> [@J1234](#):
>
> return sys.stdin is not None and sys.stdin.isatty()  
> AttributeError: ‘PythonQtStdInRedirect’ object has no attribute ‘isatty’

This was fixed during [Project Week](https://projectweek.na-mic.org/PW35_2021_Virtual/Projects/PyTorchIntegration/), so everything should be good if you use a current nightly (not the stable release).

---

<div class="post-metadata">

**Author:** ![J1234](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@J1234](https://discourse.slicer.org/u/J1234)\
**Post date:** [August 27, 2021, 3:47am UTC](https://discourse.slicer.org/t/automated-brain-segmentation-into-white-matter-volume-gmv-and-csf-vol/19322/6 "2021-08-27T03:47:11Z")

</div>

Can you clarify what you mean by current nightly? I re-downloaded the most current software just to be safe and I’m still getting the error. I’m using Slicer 4.11.20210226.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 27, 2021, 12:40pm UTC](https://discourse.slicer.org/t/automated-brain-segmentation-into-white-matter-volume-gmv-and-csf-vol/19322/7 "2021-08-27T12:40:27Z")

</div>

> [@J1234](#):
>
> Can you clarify what you mean by current nightly?

I mean when you go to [download.slicer.org](http://download.slicer.org) you pick the preview version with the most recent date.
