# Color changed in a display but not in data box while loaded by Python script

**URL:** <https://discourse.slicer.org/t/color-changed-in-a-display-but-not-in-data-box-while-loaded-by-python-script/26459>\
**Category:** Development\
**Tags:** segmentation\
**Created:** [November 27, 2022, 2:40pm UTC](https://discourse.slicer.org/t/color-changed-in-a-display-but-not-in-data-box-while-loaded-by-python-script/26459 "2022-11-27T14:40:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jakub\_Mitura](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jakub_mitura/32/8858_2.png) [@Jakub\_Mitura](https://discourse.slicer.org/u/Jakub_Mitura)\
**Post date:** [November 27, 2022, 2:40pm UTC](https://discourse.slicer.org/t/color-changed-in-a-display-but-not-in-data-box-while-loaded-by-python-script/26459/1 "2022-11-27T14:40:19Z")

</div>

I am loading set of the labels from paths like in code below

```auto
        label= slicer.util.loadSegmentation(labPath.as_posix(),labPath.name) 
        idss=label[1].GetDisplayNode().GetVisibleSegmentIDs()
        colorr= listOfColors[index]
        label[1].GetDisplayNode().SetSegmentOverrideColor(idss[0],*colorr)

```

As one can see below this manages to set the color in the display but the color in the data menu on the left is default green - So i o not know which label is related to which color while displaying - what am I doing wrong ?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/9/996498e0dd48c0c3134473dc92bd3b1e46a18024.jpeg)

---

<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:** [November 27, 2022, 3:58pm UTC](https://discourse.slicer.org/t/color-changed-in-a-display-but-not-in-data-box-while-loaded-by-python-script/26459/2 "2022-11-27T15:58:06Z")

</div>

`SetSegmentOverrideColor` method is provided for special cases: when you want to display a segment in a particular view with a different color than the segment’s color specified in

```
segmentationNode.GetSegmentation().GetSegment(segmentID).SetColor(r,g,b)

```

See [`SetSegmentOverrideColor` method documentation](https://apidocs.slicer.org/master/classvtkMRMLSegmentationDisplayNode.html#af59758179523133bbc04156bd4bb2f34):

> Set segment override color by segment ID Override color is used for specifying custom color for a segment in selected views. By default, segment color is invalid (-1,-1,-1), which means that the color stored in [vtkSegment](https://apidocs.slicer.org/master/classvtkSegment.html) object will be used. If a valid override color is specified then in the views corresponding to this display node, segment will be colored using the override color.

---

<div class="post-metadata">

**Author:** ![Jakub\_Mitura](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jakub_mitura/32/8858_2.png) [@Jakub\_Mitura](https://discourse.slicer.org/u/Jakub_Mitura)\
**Post date:** [November 27, 2022, 4:05pm UTC](https://discourse.slicer.org/t/color-changed-in-a-display-but-not-in-data-box-while-loaded-by-python-script/26459/3 "2022-11-27T16:05:24Z")

</div>

Thanks Hovewer for reply Now when I use code as below I get blank indicators in data tab

```auto
        label[1].GetSegmentation().GetSegment(idss[0]).SetColor(colorr[0],colorr[1],colorr[2])

```

I am using Slicer in browser using unmodified slicer jupyter docker container

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/0/b0e9c44e449594b527bf51281430db1daa4d2205.png)

---

<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:** [November 27, 2022, 4:10pm UTC](https://discourse.slicer.org/t/color-changed-in-a-display-but-not-in-data-box-while-loaded-by-python-script/26459/4 "2022-11-27T16:10:25Z")

</div>

You specified white color for the segment (all RGB values were set to values \>= 1.0). RGB color in VTK are defined by numbers between 0.0 … 1.0 (not 0 … 255).

If you previously set SegmentOverrideColor, don’t forget to reset it by setting it to (-1,-1,-1).

---

<div class="post-metadata">

**Author:** ![Jakub\_Mitura](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jakub_mitura/32/8858_2.png) [@Jakub\_Mitura](https://discourse.slicer.org/u/Jakub_Mitura)\
**Post date:** [November 27, 2022, 4:11pm UTC](https://discourse.slicer.org/t/color-changed-in-a-display-but-not-in-data-box-while-loaded-by-python-script/26459/5 "2022-11-27T16:11:43Z")

</div>

Yes it was It - thank You !!
