Adding drop down menu

I’m currently developing a Python scripted module. Shortly after the module starts running, it pauses to allow the user to select a region of interest from an image by adjusting a vtkMRMLAnnotationROINode. I would like to add a dropdown menu that appears only during this paused for ROI selection stage so that the user can choose which image they want to display during ROI selection. I know how to load an image from a numpy array into a vtkMRMLScalarVolumeNode and then display that node. What I don’t know is:

-How to choose your own names for each vtkMRMLScalarVolumeNode
-Python code to create a dropdown menu and how to make each selection from dropdown menu prompt display of a different image in Slicer window

Any help with syntax for this would be greatly appreciated.
Thanks,
Rohan

I would not recommend to block the user and force him to do something, as it can easily get really frustrating for the user. Instead, you could follow the usual approach of Slicer modules: select inputs (using node selectors, sliders, etc.) and then click a button to process the inputs.

You can select nodes using vtkMRMLNodeComboBox. See programming tutorial.

You can add a vtkMRMLNodeComboBox to select a volume and connect to its currentNodeChanged signal to a method in your class that changes what volume is displayed in slice views using slicer.util.setSliceViewerLayers.

1 Like