I’m curious if there is a way to show particular segmentation nodes on each of four different views in a two over two layout programmatically. An example of doing this for background volumes would be as follows:
volumes_of_interest = [pre_T1, pre_ADC, post_T1, post_ADC]
viewNodes = slicer.mrmlScene.getNodesByClass('vtkMRMLSliceCompositeNode')
for i,viewNode in enumerate(viewNodes):
viewNode.SetBackgroundVolumeID(self.volumesLoad[i].GetID())
In our use case we make unique segmentations on two different MRI sequences before and after an intervention. Being able to view and touch-up all four segmentations would be helpful.
I understand that Segmentations play by different rules. I tried exploring SetDisplayVisibility, but it seems to only act globally on all views.
Create one using slicer.mrmlScene.AddNewNodeByClass and add it to the segmentation node using its AddAndObserveDisplayNodeID method.
These are display node methods.
Example:
# Get segmentation node, for the rest, we assume that there are 3 segments, with default names/ids
segmentationNode=getNode('Segmentation')
# Get display node that is used by default for all views
segmentationDisplayNode1=segmentationNode.GetDisplayNode()
# Add one more display node
segmentationDisplayNode2=slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationDisplayNode')
segmentationNode.AddAndObserveDisplayNodeID(segmentationDisplayNode2.GetID())
# Display node 1: show only in Red slice view, show only segment 3
segmentationDisplayNode1.SetViewNodeIDs(['vtkMRMLSliceNodeRed'])
segmentationDisplayNode1.SetSegmentVisibility('Segment_1',False)
segmentationDisplayNode1.SetSegmentVisibility('Segment_2',False)
# Display node 2: show only in Yellow nad Green slice views, show only segment 1
segmentationDisplayNode2.SetViewNodeIDs(['vtkMRMLSliceNodeYellow', 'vtkMRMLSliceNodeGreen'])
segmentationDisplayNode2.SetSegmentVisibility('Segment_2',False)
segmentationDisplayNode2.SetSegmentVisibility('Segment_3',False)