Python call for segmentation node selector in the view controller

Hi everybody,

I am working with multiple segmentations. When entering:
sliceController = slicer.app.layoutManager().sliceWidget(“Red”).sliceController()
sliceController.toggleSegmentationOutlineFill()
I am able to toggle through the fill states of the segmentation selected in the segmentation node selector. But I struggle to find a python call to switch to another segmentation - I have to select it manually out of the dropdown menu in the slice viewer window.
So my Question is: Is there any way I can specify in the Python Interactor which segmentation the .toggleSegmentationOutlineFill() Method refers to?

Thanks!

Screenshot 2022-10-04 214919

Operating system: WIn11
Slicer version: 5.0.3

In case anybody is interested, another approach works using the display node of the segmentation node in question, for example to enable 2D FIll and Outline:

segmentationNode.GetDisplayNode().SetVisibility2DFill(True)
segmentationNode.GetDisplayNode().SetVisibility2DOutline(True)

1 Like

Node selector in that widget is not exposed via MRML, so you need to drill down in the GUI to get to the segmentation node selector widget in the slice view controller. There are examples in the script repository and there have been similar questions on this forum that should get you there, but if you get stuck then let us know how far you got and we’ll help you with the rest.