# Set visibility of fiducials inside an ROI?

**URL:** <https://discourse.slicer.org/t/set-visibility-of-fiducials-inside-an-roi/16300>\
**Category:** Development\
**Created:** [March 2, 2021, 1:31am UTC](https://discourse.slicer.org/t/set-visibility-of-fiducials-inside-an-roi/16300 "2021-03-02T01:31:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [March 2, 2021, 1:31am UTC](https://discourse.slicer.org/t/set-visibility-of-fiducials-inside-an-roi/16300/1 "2021-03-02T01:31:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [March 2, 2021, 1:38am UTC](https://discourse.slicer.org/t/set-visibility-of-fiducials-inside-an-roi/16300/2 "2021-03-02T01:38:16Z")

</div>

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](https://github.com/SlicerMorph/SlicerMorph/tree/master/Docs/MarkupEditor)

---

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [March 2, 2021, 2:29am UTC](https://discourse.slicer.org/t/set-visibility-of-fiducials-inside-an-roi/16300/3 "2021-03-02T02:29:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [March 3, 2021, 1:28pm UTC](https://discourse.slicer.org/t/set-visibility-of-fiducials-inside-an-roi/16300/4 "2021-03-03T13:28:26Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 3, 2021, 1:41pm UTC](https://discourse.slicer.org/t/set-visibility-of-fiducials-inside-an-roi/16300/5 "2021-03-03T13:41:44Z")

</div>

> [@hherhold](#):
>
> `n.GetNthFiducialSelected()`

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.

---

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [March 3, 2021, 1:47pm UTC](https://discourse.slicer.org/t/set-visibility-of-fiducials-inside-an-roi/16300/6 "2021-03-03T13:47:06Z")

</div>

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