I’m trying to get the current volume rendered in the RYG views (from a Dicom).
On the screen, i have 2 volume:
For now, i already got all the vtkMRMLScalarVolumeNode in a VtkCollection, but i cannot find a way to get witch one is visible on the RYG.
Since we cannot set visible multiple volumes, i try a basic solution:
#currentNode is a vtkMRMLScalarVolumeNode
currentNode.GetScalarVolumeDisplayNode().GetDisplayableNode().GetDisplayVisibility()
I expected this to return “1” for the volume rendered in the scene, 0 for all others, but it always return 1.
Hi, you can use this to set a volume as background slicer.util.setSliceViewerLayers(background=currentNode)
Edit: i misread you want to get the displayed one
See this example in the script repository for how to get/set foreground and background volume node in each slice view (you just need to replace Set…Volume… by Get…Volume…):
layoutManager = slicer.app.layoutManager()
for sliceViewName in layoutManager.sliceViewNames():
compositeNode = layoutManager.sliceWidget(sliceViewName).sliceLogic().GetSliceCompositeNode()
volumeNodeID = compositeNode.GetBackgroundVolumeID()
print(sliceViewName + ": " +volumeNodeID)