In 3D Slicer version 4.10.2, when I use “Editor” module, I can use O-key shortcut to paint over the ROI in a way that it only shows the border of the area I have painted. But, when I use “Segment Editor” module, the O-key shortcut does not work. I would be thankful if you could help me with this issue. (I also tried this shortcut the latest version of 3D slicer, but it did not work)
create a python script that toggles segmentation filling in 3D Slicer when I press the “O” key
It generated an almost-perfect code that you can simply copy-paste into the Python console (or if you always want this shortcut then put it into your .slicerrc.py file). It makes O key toggle the filling of the first segmentation node in the scene:
# Define a function that toggles the segmentation filling
def toggleSegmentationFilling():
segmentationNode = slicer.mrmlScene.GetFirstNodeByClass("vtkMRMLSegmentationNode")
displayNode = segmentationNode.GetDisplayNode()
fillVisibility = displayNode.GetVisibility2DFill()
displayNode.SetVisibility2DFill(not fillVisibility)
# Create a shortcut for the "O" key
shortcut = qt.QShortcut(slicer.util.mainWindow())
shortcut.setKey(qt.QKeySequence("O"))
shortcut.connect("activated()", toggleSegmentationFilling)
You can ask bing chat to make further changes to the code. For example, if you want to toggle fill visibility in all the segmentations in the scene, not just the first one then you can ask:
Modify this code to change slice fill of all segmentation nodes in the scene:
and copy the full script from above. I’ve tried it and it worked perfectly.