# Spinal cord not being masked out

**URL:** <https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884>\
**Category:** SlicerDMRI\
**Created:** [August 24, 2018, 2:13pm UTC](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884 "2018-08-24T14:13:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saba\_Shahab](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Saba\_Shahab](https://discourse.slicer.org/u/Saba_Shahab)\
**Post date:** [August 24, 2018, 2:13pm UTC](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884/1 "2018-08-24T14:13:53Z")

</div>

Operating system:  
NAME=“Ubuntu”  
VERSION=“16.04.3 LTS (Xenial Xerus)”  
ID=ubuntu  
ID\_LIKE=debian  
PRETTY\_NAME=“Ubuntu 16.04.3 LTS”  
VERSION\_ID=“16.04”

Slicer version:  
Slicer nightly (updated as of 2018-08-20)

For a subset of subjects (all subjects from a single site), the mask generated includes the spinal cord. I am concerned that this may be a problem when subjects across all sites are being registered.

Is it a problem to have the spinal cord included in a subset of tractography results? If so, how do I mask it out?

Here is the code I am running: [https://github.com/sabashahab/STOPPD\_DTI/blob/master/SlicerTractography\_edit.sh](https://github.com/sabashahab/STOPPD_DTI/blob/master/SlicerTractography_edit.sh)

---

<div class="post-metadata">

**Author:** ![ljod](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ljod/32/652_2.png) [@ljod](https://discourse.slicer.org/u/ljod)\
**Post date:** [August 24, 2018, 2:30pm UTC](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884/2 "2018-08-24T14:30:03Z")

</div>

Hi Saba. One possibility is to manually edit the mask to disconnect the brain part from the spinal cord part, then to remove the “island” of the spinal cord.

---

<div class="post-metadata">

**Author:** ![Saba\_Shahab](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Saba\_Shahab](https://discourse.slicer.org/u/Saba_Shahab)\
**Post date:** [August 24, 2018, 2:51pm UTC](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884/3 "2018-08-24T14:51:38Z")

</div>

Would that mean manually editing it for every single subject? There are 72 subjects - manually editing them would be very time-consuming.

---

<div class="post-metadata">

**Author:** ![ljod](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ljod/32/652_2.png) [@ljod](https://discourse.slicer.org/u/ljod)\
**Post date:** [August 24, 2018, 3:13pm UTC](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884/4 "2018-08-24T15:13:39Z")

</div>

IT could be pretty quick. Choose one axial slice, erase the connection between brain and spinal cord, then save only the largest island (the brain). This should be only a few minutes at most. Others on here know more about the new Segment Editor, which may be even faster. With the old Editor I think this should take maybe 2-3 minutes per subject once you have decided how to do it.

---

<div class="post-metadata">

**Author:** ![Saba\_Shahab](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Saba\_Shahab](https://discourse.slicer.org/u/Saba_Shahab)\
**Post date:** [August 24, 2018, 7:07pm UTC](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884/5 "2018-08-24T19:07:01Z")

</div>

Sure. Where can I find instructions on how to do this?

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [August 25, 2018, 5:51pm UTC](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884/6 "2018-08-25T17:51:38Z")

</div>

> Where can I find instructions on how to do this?

[https://slicer.readthedocs.io/en/latest/user\_guide/module\_segmenteditor.html](https://slicer.readthedocs.io/en/latest/user_guide/module_segmenteditor.html)

and

[https://www.slicer.org/wiki/Documentation/Nightly/Training#Slicer4\_Image\_Segmentation](https://www.slicer.org/wiki/Documentation/Nightly/Training#Slicer4_Image_Segmentation)

Specifically, for the task @ljod mentioned, you can use the scissors tool to quickly clear all of the unwanted label region with a cut in one slice. For example:

 ![2](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/8/38b1b4d8e93c407a2de323f7c31ee95356a814bf.gif)

---

<div class="post-metadata">

**Author:** ![ljod](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ljod/32/652_2.png) [@ljod](https://discourse.slicer.org/u/ljod)\
**Post date:** [August 25, 2018, 8:34pm UTC](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884/7 "2018-08-25T20:34:02Z")

</div>

Thanks Isaiah. Regarding the video, it is probably faster if you edit in one axial slice to separate the brain and spinal cord at the level corresponding to the other scans in your study. Then figure out how to remove the smaller segmented “island” of the spinal cord. If I understand the video it is only removing some of the spinal cord and instead you want to do it all by separating it.

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [August 26, 2018, 12:57am UTC](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884/8 "2018-08-26T00:57:10Z")

</div>

> [@ljod](#):
>
> edit in one axial slice to separate the brain and spinal cord at the level corresponding to the other scans in your study. Then figure out how to remove the smaller segmented “island” of the spinal cord.

 ![4](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/0/80d3bd30155c2521ca5b8617f6cd9053e7bb6723.gif)

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [August 26, 2018, 1:03am UTC](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884/9 "2018-08-26T01:03:59Z")

</div>

> [@ljod](#):
>
> If I understand the video it is only removing some of the spinal cord and instead you want to do it all by separating it.

Btw, the scissors cut in all planes at once by default, so the first [example](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884/6) was deleting in the other planes too with the one swipe.

However, there is also a negative (or positive) mode, which allows to cut only above/below a specific slice. Doing that is similar to the one-slice-separation/island-removal strategy.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/d/1d9ecfc2cf6f66684f76f8cc5a2b86263690701f.png)

![3](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/7/37a7e10fdb10137ed02aa31f0aa0c132e6465041.gif)

---

<div class="post-metadata">

**Author:** ![ljod](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ljod/32/652_2.png) [@ljod](https://discourse.slicer.org/u/ljod)\
**Post date:** [August 26, 2018, 1:53am UTC](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884/10 "2018-08-26T01:53:28Z")

</div>

This looks like the perfect way to do this. Thanks Isaiah.

---

<div class="post-metadata">

**Author:** ![Saba\_Shahab](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Saba\_Shahab](https://discourse.slicer.org/u/Saba_Shahab)\
**Post date:** [August 27, 2018, 6:02pm UTC](https://discourse.slicer.org/t/spinal-cord-not-being-masked-out/3884/11 "2018-08-27T18:02:01Z")

</div>

Thank you, Isaiah and Lauren. The solution works!
