O-key shortcut in "Segment Editor" module

Operating system: Windows10 64bit
Slicer version:4.10.2
Expected behavior: O-key shortcut
Actual behavior:


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)

Thank you,

I’ve asked bing chat this question:

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.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.

1 Like

Thank you. Is there any way to use the O-key shortcut while I am segmenting in the 3D Slicer?

Yes, the shortcut works while you are segmenting.

1 Like