Different color in slices and 3D view

Hi all,

Is it posible to use different colors for the same segment (one for the slices and one for the 3D view)?

Thanks,

There are several ways to achieve showing the same segmentation with different colors in different views.

  • Option A: If you don’t want to do any Python scripting then you need to clone the segmentation, drag-and-drop a different node in the slice and the 3D view and change the color of one of the nodes.
  • Option B: Create a new segmentation display node, add it as a display node to the segmentation node (the segmentation will have two display nodes), set the override color for the segment, and set the view node ID of the 3D view (to make this secondary display node only show the segmentation in the 3D view).
1 Like

I tryied the first option. I can see the segmentations in different colors but I cannot edit both at the same time. That is, I change the segmentation in slice view but the change is not in 3D view. I thought that the cloned segmentation would be modified aswell.

Am I doing something wrong or it is not possible to edit the cloned segmentation at the same time?

Thanks

Option A is simple but changes are not automatically applied. You need Option B if you keep changing the segmentation.

1 Like

Now it works!
The code i have used is:

# Create a new segmentation display node
slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationDisplayNode")

# Add it as a display node to the segmentation node
segmentationNode.AddAndObserveDisplayNodeID(displayNode_copy.GetID())

# Set the override color for the segment
segmentID = segmentationNode.GetSegmentation().GetSegmentIdBySegmentName("coronary")
displayNode_copy.SetSegmentOverrideColor(segmentID, 1, 0.7, 0)
displayNode_copy.SetVisibility2D(0)

# Set the view node ID of the 3D view
viewNode_new = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLViewNode")
displayNode_copy.SetViewNodeIDs(viewNode_new)
slicer.app.layoutManager().threeDWidget(0).setMRMLViewNode(viewNode_new)

2 Likes