Add Segment to SegmentationNode uses invalid color values (scalar) and adds a new colortable node

baderstine
Mon, 15 Dec 2025 18:00:39 +0000
Support

Summary:

I am attempting to import/edit/export segmentations from numpy to slicer to numpy. I am using custom color tables but am getting invalid color IDs on export after a segment has been added.

For example, my color table file defines 118 colors from IDs 0 to 117. I load a segmentation, set the color node to my loaded color file, then when I add a new segment in Segment Editor to that segmentation node, I select the appropriate color for it from the loaded terminology. However, on export the newly added segment has segment ID 118, not the correct value that would be found on lookup in either the terminology JSON file or the color table node. I noticed that in the All nodes tab of slicer a new color table node now exists with name [segmentation node name]_ColorTable and that new colortablenode contains an extra segment with ID 118 and the name from the terminology file. So rather than using the color table node that I’ve defined it’s just making one up. I’m using the code found here - Script repository — 3D Slicer documentation - for importing/exporting but it doesn’t seem to be working as I would expect? Is there some extra python code that I need to include to ensure that segments added to an existing segmentationnode use that node’s assigned colortablenode for name/id lookups?

6 posts - 2 participants