# Segment Editor: Threshold with masking

**URL:** <https://discourse.slicer.org/t/segment-editor-threshold-with-masking/5042>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [December 11, 2018, 3:21pm UTC](https://discourse.slicer.org/t/segment-editor-threshold-with-masking/5042 "2018-12-11T15:21:07Z")\
**Posts on this page:** 6\
**Page:** 1

<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:** [December 11, 2018, 3:21pm UTC](https://discourse.slicer.org/t/segment-editor-threshold-with-masking/5042/1 "2018-12-11T15:21:07Z")

</div>

I am trying to use the Segment Editor Threshold tool with a mask. I select a subregion, the segment named `mask` in yellow, and set that segment as the `Editable Area`. Then I add a second segment, and select an intensity range with the Threshold tool. The preview extends outside the mask, but that’s ok. The view is [1] below. Next I select a range and hit `Apply`, which results in a subtraction from the `mask` segment, rather than Segment\_2 containing only the thresholded region inside `mask`. Is this expected, a bug, or user error?

(I’ve also managed several times to get in a state in which none of the tools are responsive until I delete all segments, but I don’t have a reproduction workflow yet)

# 1

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/3/23dc2a021a46ce3f416294ce6b9ac49ef763b3ab.png)

# 2

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

---

<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:** [December 11, 2018, 3:34pm UTC](https://discourse.slicer.org/t/segment-editor-threshold-with-masking/5042/2 "2018-12-11T15:34:50Z")

</div>

This is Slicer 4.10.0 on macOS 10.13 by the way.

---

<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:** [December 11, 2018, 3:50pm UTC](https://discourse.slicer.org/t/segment-editor-threshold-with-masking/5042/3 "2018-12-11T15:50:55Z")

</div>

What you describe seems to be the expected behavior: if in masking section “Overwrite other segments” is left at default value of “All segments” then you overwrite the mask segment when you draw in another segment.

For masking with a segment, I usually hide the mask segment and set “Overwrite other segments” to “Visible segments”.

---

<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:** [December 11, 2018, 4:41pm UTC](https://discourse.slicer.org/t/segment-editor-threshold-with-masking/5042/4 "2018-12-11T16:41:57Z")

</div>

Ok, that works. Thanks! I had tried setting “Overwrite other segments” to “None”, but that didn’t seem to work.

One minor thing I noticed, not sure if it is worth a bug report: switching the selected segment while the Threshold tool is active removes the content of the previously-selected segment. ([screencap](https://www.dropbox.com/s/v9h0qynbreokpi0/thr-screencap.gif?dl=0))

---

<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:** [December 11, 2018, 9:57pm UTC](https://discourse.slicer.org/t/segment-editor-threshold-with-masking/5042/5 "2018-12-11T21:57:03Z")

</div>

Thanks for reporting. Opacity of the segment is set to 0 and not reverted if we switch to another segment (you can restore it in Segmentations module / Display / Advanced). I’ll fix this.

---

<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:** [December 12, 2018, 2:56pm UTC](https://discourse.slicer.org/t/segment-editor-threshold-with-masking/5042/6 "2018-12-12T14:56:35Z")

</div>

> [@ihnorton](#):
>
> One minor thing I noticed, not sure if it is worth a bug report: switching the selected segment while the Threshold tool is active removes the content of the previously-selected segment.

This has been fixed now (in r27625).
