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

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

        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 ?

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:

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 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.

1 Like

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

        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

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).

1 Like

Yes it was It - thank You !!

1 Like