Disable the display of a segmentation in a specific view programmatically.


In the UI of the Segmentations module it is possible to configure per-view visibility of a segmentation.
(Segmentations / Advanced / Views → uncheck view of interest ).

I am interested in doing the same thing programmatically.

I could not find out the class/attribute that contains the method to enable/disable the display of segmentation in a specific view.

Thanks !

Hi, display nodes usually have this function called SetViewNodeIDs(…), which expects a list of view IDs where the visibility will apply.

E.g., if you make a segmentation with the default name “Segmentation” then this is how you would make sure the segmentation is only visible in the green 2D view, but not in the red or yellow:

displayNode = slicer.util.getNode("Segmentation").GetDisplayNode()