# How to select segment

**URL:** <https://discourse.slicer.org/t/how-to-select-segment/4120>\
**Category:** Development\
**Created:** [September 14, 2018, 4:00pm UTC](https://discourse.slicer.org/t/how-to-select-segment/4120 "2018-09-14T16:00:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [September 14, 2018, 4:00pm UTC](https://discourse.slicer.org/t/how-to-select-segment/4120/1 "2018-09-14T16:00:27Z")

</div>

I have two segment “skin1” and “skin2”. And when I apply threshold with CLI, I donot know how to select the second one. I don’t know how to set parameters for skin2  
 ![360%E6%88%AA%E5%9B%BE-406308453](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/c/3c3f5fbd95bf06ae8d4cd0bdfcf7fe54a2dd3d51.jpeg)

```
# Thresholding
segmentEditorWidget.setActiveEffectByName("Threshold")
effect = segmentEditorWidget.activeEffect()
effect.setParameter("MinimumThreshold","54")  
effect.setParameter("MaximumThreshold","78")
effect.self().onApply()

```

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 14, 2018, 4:20pm UTC](https://discourse.slicer.org/t/how-to-select-segment/4120/2 "2018-09-14T16:20:10Z")

</div>

This should do the trick

> <https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Segmentations/Widgets/qMRMLSegmentEditorWidget.h#L212>

---

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [September 14, 2018, 4:47pm UTC](https://discourse.slicer.org/t/how-to-select-segment/4120/3 "2018-09-14T16:47:23Z")

</div>

OK, Csaba Pinter, thank you very much.  
Another problem, can I define the color of a segment  
`addedSegmentID = segmentationNode.GetSegmentation().AddEmptySegment("skin11",*red*)`

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 14, 2018, 5:25pm UTC](https://discourse.slicer.org/t/how-to-select-segment/4120/4 "2018-09-14T17:25:48Z")

</div>

To change the primary color of the segment (that is also saved to disk etc.)

```
s=getNode('vtkMRMLSegmentationNode1')
se=s.GetSegmentation()
seg=se.GetSegment('Segment_1')
seg.SetColor(1,0,0)

```

To change the override color (only for display)

```
d=s.GetDisplayNode()
d.SetSegmentOverrideColor('Segment_1', 0,1,0)
```

---

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [September 15, 2018, 8:51am UTC](https://discourse.slicer.org/t/how-to-select-segment/4120/5 "2018-09-15T08:51:45Z")

</div>

Thank you very much.
