Hi all,
Is it posible to use different colors for the same segment (one for the slices and one for the 3D view)?
Thanks,
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.
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.
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)
Hi Iassoan,
Could you please help me check the code below? I want to show the data in both Red and Green view, with different displaynode, such that I can change the display seperately. But it does not work.
import numpy as np
x = np.random.randn(512, 512)
volumeNode = slicer.mrmlScene.AddNewNodeByClassWithID("vtkMRMLScalarVolumeNode", "ScanData", "vtkMRMLScalarVolumeNodeScanData")
slicer.util.updateVolumeFromArray(volumeNode, x)
d1 = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLScalarVolumeDisplayNode")
d2 = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLScalarVolumeDisplayNode")
volumeNode.AddAndObserveDisplayNodeID(d1.GetID())
volumeNode.AddAndObserveDisplayNodeID(d2.GetID())
v1 = slicer.util.getNode("Red Display")
v2 = slicer.util.getNode("Green Display")
d1.SetViewNodeIDs(v1)
d2.SetViewNodeIDs(v2)