Changes to the Markups Module

I also can reproduce the crash @ezgimercan describes. I am running 4.13.0-2021-09-26 on Windows. On opening Slicer with an empty scene, the following leads to a crash:

F = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLMarkupsFiducialNode')
F.logic.Ad

Pressing the tab key after typing F.logic.Ad pops up a list of functions, and if I click one of them, Slicer crashes. I did notice that Slicer will not auto-complete ‘logic’, after typing F.lo, perhaps that indicates that F.logic isn’t supposed to be accessed in this way??

Probably. It doesn’t make sense to access the logic of a markups node - but you can :smiley:
It wasn’t something I wanted to, it just happened when I was browsing through functions to find “unset” function. It seemed weird because it lists the functions but crashes when you try to autocomplete.

I’ve fixed the crash, the returning incorrect list of autocompletions for non-existing members (F.logic does not exist), and the problem of the interpreter getting stuck in an error state after invalid autocomplete (or other errors).

I’ve also improved ordering of autocompletions: the list starts with methods&attributes, followed by constants, and ends private Python members.

2 Likes

Having used it a little bit more, I have a couple ‘very-specific-to-my-use-case’ suggestions, more like discussion points. I would love to have your opinion on them since I cannot decide how to improve/fix them.

Skipping a landmark / Selected or highlighted control point

My main use case is to load a fiducial template (usually 50-70 points) and mark the control points one by one on 3D rendering (sometimes on 2D slice views). There is usually a few control points missing in each scan, so I need to use “skip” button once or twice in each scan. Currently, it sets the state of highlighted control point as “skipped” but the highlight or selection stays on the last marked control point (unless you are in the persistent mode).

  • If you are not using persistent mode, you either need to go into place mode, then click on the “skip” button; or select the next control point from the list (simply go to the list and click or if the next point is out of the screen, scroll down and then click to select) and click on “skip”. If you go into the place mode, even if you click “skip”, you stay in the place mode.

  • The workaround is to use the persistent mode, the selection auto-advances and you can simply click “skip” when you don’t want to mark that point. But then you need to go into and out of placement mode a lot if you are also interacting with the rendering (rotate, translate etc).

I think the behavior is that the selection (highlighted control point) advances to the next “empty” control point when you go into the “place” mode - and only when you are in Markups module, it doesn’t advance or change when you are in another module and keep marking points. I wonder what could go wrong if the selection advances to the next “empty” point when a point is marked? You probably need an exception when there is no more “empty” points in the list.

I understand the idea of marking a point “missing” (skip it) when you ‘attempt’ to mark it by going into place mode (hence advancing the selection) but my thinking is usually like this: “look at the list to see which point I need to mark next, then adjust the 3D view or slice views to find it, then go into place mode and place it”. Not “first go into place mode, cannot find the point, click skip”.

Auto-scroll control point list

In the same scenario of marking points one by one from the list, my fist action is to look at the list to see which points are coming. Currently, if I marked the last visible point from the list, I need to scroll down to see the next point - or again, go into the place mode so the selection advances and control point list automatically scrolls down. As I said, I don’t like to go into the place mode or use persistent mode as I adjust 3D view and slice views a lot when I am marking points. I think it would be nice to auto-scroll the list so that the selected point is not the last one, maybe 2nd or 3rd one from the visible portion of the list.

Keyboard shortcut for skip button

I also LOVE the ‘p’ keyboard shortcut that comes with SlicerMorph startup script for “dropping” a control point where the mouse is. I like to keep mouse actions for interaction - it is easy to move the mouse cursor unintentionally when clicking to mark a point. It’s much better to position your mouse, and press a key from your keyboard.

This is something @smrolfe and I discuss a lot, the shortcuts for going into the placement mode and persistent mode are too complex. Once reprogrammed, they could be a workaround for the highlight auto-advance + skip issue. I would love to be able to program another keyboard shortcut for “skip” button (if possible, “skip the next empty point”, not “skip the selected point”). If there was a shortcut even for only the current functionality (skip the selected point), you could mark a temporary point with “p” shortcut and make it “unset” or “skipped” by this new shortcut. Let me know if this is possible to program.

FCSV export

I know we are transitioning from fcsv to JSON, but since Slicer still supports fcsv exports, I wanted to note that currently the column headings for the last few fields are not written. When you want to read them as csv files into R, for example, R complains about the mismatch between columns and column headings.


Again, although these are minor improvements in larger Slicer-verse, they will have huge returns for my research team since most of what our students do is marking anatomical landmarks on hundreds of CTs.

There is currently quite a bit of problem with right-click context menus (e.g., MarkupEditor plugin doesn’t work yet with the new markups changes), and we will eventually provide keyboard shortcuts for these actions in SlicerMorph. Shortcuts in core is a bit more problematic as it is really to hard to come by with keyboard shortcuts that (1) everyone agrees on how it works, (2) not assigned to something else before, (3) and it doesn’t require you use four of your fingers to create the shortcut (alt+ctrl+shift+P).

Yeah, that’s exactly the problem of fcsv format. it is not possible to grow it with new features. So with the new stable release I think we (as in SlicerMorph) will probably expect everyone to switch to Json. There is a json parser in SlicerMorphR package (GitHub - SlicerMorph/SlicerMorphR: R convenience functions for importing SlicerMorph dataset), but I have not had time to try with the updates to markups. If you can try and let us know, it will be great.

Just being able to program shortcuts for certain functions is enough for me. I couldn’t find how to access skip button functionality from Python yet, or more specifically the index of highlighted control point, but if it’s something that could be exposed, I can add it to my startup script.

I will test the JSON parser from SlicerMorphR. I had my own little dummy one but it only reads coordinates and the coordinate system. I agree JSON is better and generalizable.

Callbacks for three new shortcuts can be accessed in the Markups toolbar:

  • slicer.modules.markups.toolBar().onPlacePointShortcut(): initiates placement mode in the current node
  • slicer.modules.markups.toolBar().onCreateNodeShortcut(): Continues point placement of the current markup class in a new node
  • slicer.modules.markups.toolBar().onTogglePersistenceShortcut(): toggles the persistence

The current shortcuts are not very convenient, but you can customize them using the method here.

Adding a shortcut for “skip the current point” would be easy. Another option might be “advance to the next point” which would skip the current point if unplaced.

At one point we discussed adding tooltips with the new shortcuts to the toolbar, but at that time the toolbar actions were not parallel to the keyboard actions. In the final version, this is no longer true, so it would be good to add these tooltips now.

1 Like

Sara,
that’s a very helpful tutorial. The logic of how the Markups module was intended to be used is much clearer to me now than it was from either just opening Slicer† or reading the documentation at https://www.slicer.org/wiki/Documentation/4.10/Modules/Markups . It would therefore be good to link to the tutorial(s) from the documentation page.
The latest documentation page at Markups — 3D Slicer documentation currently does not have such a link. It is a bit improved on the 4.10 documentation, but is still not making the conceptual hierarchy of objects (nor sequence of actions) quite as clear as your video. Maybe some definitions there would help? (To me “node” sounded like a point in 3D space, rather than a collection of mark-ups, and “control point” sounded like either a guide for a spline or a handle on a graphics object.)

—DIV

† It could perhaps have been a bit more intuitive if the Control Points panel were open by default when a Node is created. Having it closed by default made me think it was something that didn’t often need to be interacted with by the user.

Thanks @DIV for this feedback. The documentation for the Markups will be updated sometime soon, probably in the next few weeks, so it helps to hear what might be useful.

1 Like