Select visibility of specific vtkMRMLScalarVolumeNode

Operating system: MacOS 12.6
Slicer version:5.0.3

When I load DICOM to the Subject hierarchy scene, there are multiple vtkMRMLScalarVolumeNodes and all are invisible. I need to select one specific one of them here, and then in the Master volume select the same volume. (The name of the volume changes every time I load the DICOM to the scene with the same code). I see previous posts referring to qSlicerSubjectHierarchyVolumesPlugin.cxx. Is there any python code that works in Python interactor?

For changing the visibility of a vtkMRMLScalarVolumeNode called volume_node from python:

shNode = slicer.mrmlScene.GetSubjectHierarchyNode()
itemID = shNode.GetItemByDataNode(volume_node)
slicer.qSlicerSubjectHierarchyVolumesPlugin().setDisplayVisibility(itemID, 0) # 0 or 1 for visibility
2 Likes