Set visibility of fiducials inside an ROI?

I’d like to be able to make an ROI and hide all the markup fiducials inside of it. Is there a way to get the RAS bounds of an ROI? GetRASBounds() is returning [1e+299, -1e+299, 1e+299, -1e+299, 1e+299, -1e+299], but GetBoundsROI() returns reasonable-looking values (but not in RAS coordinates). Do I need to do something to it to get it to set the RAS bounds? And do I need RAS coordinates to then loop through the MarkupsFiducialNode, setting visibility?

(Does this make sense?)

Thanks!!!

-Hollister

FYI If you don’t need to do this programmatically, SlicerMorph’s MarkupEditor does something similar (at least lets you select points within a curve) via MarkupEditor

2 Likes

Oh, that’s most excellent! That’s actually a lot easier than making an ROI (for my workflow).

Thanks, Murat! Hope you’re doing well.

-Hollister

1 Like

Hmm, I’m a little confused by what “selected” means and how that is set in code and in the control points list. Here’s my code to toggle visibility for selected control points:

def hh_toggle_visibility_selected_fiducials():
    mod = slicer.util.getModule("Markups")
    ml = mod.logic()
    n = slicer.util.getNode(ml.GetActiveListID())
    num_control_points = n.GetNumberOfControlPoints()
    for i in range(num_control_points):
      visible = n.GetNthFiducialVisibility(i)
      selected = n.GetNthFiducialSelected()
      if selected:
        n.SetNthFiducialVisibility(i, not visible)

If I use the button in the control points to select all, then run my code, it toggles the visibility just fine. But if I pick a few points by hand, using the check boxes, or use the select points by curve, as @muratmaga mentioned, the above code has no effect. I’ve compared what I’m doing to the C++ in vtkSlicerMarkupsLogic and I can’t see any meaningful differences… Is there something obvious I’m missing?

Thanks!

This is a syntax error. The code will have no effect because it just stops.

Have you connected using PyCharm debugger? Recent versions are quote buggy and may cause you not to see error messages in the Slicer console in certain circumstances.

1 Like

GAAAH that’s totally embarrassing. Works perfectly now.

I do not use PyCharm - I either use VS Code when working inside the Slicer codebase or just Emacs when tweaking my .slicerrc.py file, where this function is. (My Emacs setup has no checking or code completion. Maybe it’s time to rethink that…)

THANKS!!