Get/Set GUI data from Python

Hi everyone,

I am trying write a Python script that accesses the “volume” node and “ROI” nodes that the user has manually selected in the “Volume Rendering” module.

Does anyone have any clues on how to access this information from Python?

Thank you in advance :slight_smile:

This should help:

volRenLogic = slicer.modules.volumerendering.logic()
displayNode = volRenLogic.GetFirstVolumeRenderingDisplayNode(volumeNode)
roiNode = displayNode.GetROINode()
1 Like

Thank for the answer, but what is “volumeNode” in your example? An empty “vtkMRMLScalarVolumeNode”?

volumeNode = getNode("nodeNameInTheDataModule")

1 Like

The problem is that I don’t know the name of the volumeNode in advance, or it’s ID.

I ended up figuring out how to access the GUI element that holds the list of volumes. Maybe it helps someone else in the future :slight_smile:

vol_node = slicer.modules.volumerendering.widgetRepresentation().findChild(slicer.qMRMLNodeComboBox(), "VolumeNodeComboBox").currentNode();