Orienting views with respect to a selected markup

Hello,

For sake of reference, are there any particular Slicer modules that implement functionality to orient views with respect to a markup selected in the Markups module? For example, selecting a Plane reformats the views such that one is coplanar with the Plane and the others are mutually orthogonal.

I did notice that basic centering functionality is available, e.g. when clicking a point in a Point List or the origin of a Plane. The use cases of interest here are somewhat beyond this and perhaps more application-specific.

Thanks for the guidance!

Karl

You can use Volume reslice driver module in SlicerIGT extension to “drive” (position and orient) a slice view by plan eor line markup. You can also use Path Explorer for reslicing along and around markup line nodes.

You can also create any customized behavior using a few lines of Python script (add an observer to a markup node and modify slice position and orientation whenever the markup is changed. You can find examples in the script repository.

1 Like

Hi @lassoan, a follow-up question: the relevant examples in the script repository observe markup modification, but I would like to trigger view reformatting when a markup is selected. What is the proper way to observe changes in markup selection, specifically in the list shown in the markups module? Do I assume correctly that selection is different from modification?

Thanks!

Observing the vtkMRMLSelectionNode might accomplish the desired end. Unsure if this is an intended use case, though.

Crudely:

last_id = None

def reformat_if_selection_changed(active_id):
    if active_id!= last_id:
        ...reformat views...
        last_id = active_id

sn = slicer.app.applicationLogic().GetSelectionNode()
sn.AddObserver(
    slicer.vtkMRMLSelectionNode.ActivePlaceNodeIDChangedEvent, 
    lambda c, e: reformat_if_selection_changed(c.GetActivePlaceNodeID())
)