select segmentations in 3D view

Is there a way to quickly select segmentations and make them invisible in the 3D view.

Namely, problem I encounter is that my boss asks me to show him a certain structure and I have to often remove 1 or 2 other segmentations to see it clearly.

I end up hovering my mouse over the segmentation i want to remove while holding the shift.

Next I look at the red slices and then I hover in them as well.
Then it shows me the name of the segment and segmentation.
Then I have to go to search it with filter through data
After that I have to click right click and disable 3D view.

As you can see, it takes quite a lot of steps to remove just 1 structure.

Is there some plugin or something that can help me easily remove them?

Thank you

Wait… you can just select them in data module and just right click and uncheck visibility.

I am not sure I understand what you are asking for

There is no such built-in feature yet, but you can put together a Python script that does what you need. For example, you can set the crosshair in any views using Shift+MouseMove then run the following script to hide the segments at that position:

segmentationNode = getNode('Segmentation')
segmentationDisplayNode = segmentationNode.GetDisplayNode()

sliceViewWidget = slicer.app.layoutManager().sliceWidget('Red')
displayableManager2D = sliceViewWidget.sliceView().displayableManagerByClassName('vtkMRMLSegmentationsDisplayableManager2D')
crosshairNode=slicer.util.getNode('Crosshair')
crosshairNode.GetCrosshairRAS()
crosshairPosition = crosshairNode.GetCrosshairRAS()
# Look around crosshair position in all directions for a segment
# (necessary because picked position is at the segmentation boundary so it may be just outside the segment)
for attempts in range(16):
    crosshairPositionAdjusted = [crosshairPosition[0]-0.5+1.0*(attempts%2), crosshairPosition[1]-0.5+1.0*((attempts/2)%2), crosshairPosition[2]-0.5+1.0*((attempts/4)%8)]
    segmentIDs = vtk.vtkStringArray()
    segmentValues = vtk.vtkDoubleArray()
    displayableManager2D.GetVisibleSegmentsForPosition(crosshairPositionAdjusted, segmentationDisplayNode, segmentIDs, segmentValues)
    if segmentIDs.GetNumberOfValues() == 0:
        continue
    for i in range(segmentIDs.GetNumberOfValues()):
        segmentID = segmentIDs.GetValue(i)
        segmentationDisplayNode.SetSegmentVisibility(segmentID, False)
    break
1 Like

I am sorry but I tried however I don’t know how to run this script…
Like how does one run a script in Slicer?

You can open the Python console (Ctrl-3) and copy-paste the code there.