View Issue Details

IDProjectCategoryView StatusLast Update
0004306Slicer4Module Markupspublic2017-06-13 17:54
Reporterfepegar Assigned Tonicole  
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionwon't fix 
Product VersionSlicer 4.6.1 
Target VersionFixed in Version 
Summary0004306: Markups are slow
Description

I'm working on characterization of geometric distortion in MRI, with a stereotactic phantom containing around 2000 points. It would be convenient to represent and modify these points using markups, but Slicer is not happy when there are "many" markups in the scene.

I don't know whether there are any tricks or advice for me or I just should use simpler classes.

Steps To Reproduce

import numpy as np

mn = slicer.vtkMRMLMarkupsFiducialNode()
mn.SetLocked(True) # Trying to make it faster...

LEKSELL_XMIN, LEKSELL_XMAX = 100-50, 100+50
LEKSELL_YMIN, LEKSELL_YMAX = 100-60, 100+60
LEKSELL_ZMIN, LEKSELL_ZMAX = 100-70, 100+60
grid = np.mgrid[LEKSELL_XMIN:LEKSELL_XMAX+1:10, LEKSELL_YMIN:LEKSELL_YMAX+1:10, LEKSELL_ZMIN:LEKSELL_ZMAX+1:10]
points = grid.reshape(3, -1).T # 2002 points

The loop takes some time...

for point in points:
mn.AddFiducialFromArray(point, '')

slicer.mrmlScene.AddNode(mn)

Once the fiducials are in the scene, I tried to lock them using the GUI of Markups module (to see it it goes faster) and Slicer hangs forever.

TagsNo tags attached.

Relationships

related to 0004239 closednicole Slicer crashes when trying to delete many fiducial markups 
related to 0001714 closednicole Serious annotation fiducial performance problems. 
related to 0001091 closednicole AnnotationFiducial: performance issues 

Activities

nicole

nicole

2016-11-21 19:10

administrator   ~0014254

The code as written goes through the loop really fast (< 2s on my machine, release build on Linux) because the node isn't in the scene yet, the slow part comes with adding the node at the end
loop time = 1.152904 , scene add time = 17.388191

There have been various speed ups incorporated in the code, but this is a case I haven't tested before. There are various commands that you can try to let the program know that you're batch processing, this is with assuming you move the adding of the node to the scene right after you create it (with no modify flag setting, I killed the add loop since it was super slow):

flag = mn.StartModify()
for point in points:
mn.AddFiducialFromArray(point, '')
mn.EndModify(flag)

This results in:
loop time = 1.154206 , modify end time = 36.331662
So, still slower but a big speed up from not using it when the node is in the scene.

The lock works more for interactive mode, stopping the constant intersection checks with each fiducial.

If you don't need the text to display you can add:
mn = slicer.vtkMRMLMarkupsFiducialNode()
slicer.mrmlScene.AddNode(mn)
dispNode = mn.GetDisplayNode()
dispNode.SetTextScale(0.0)

and that will result in a speed up in interacting with the fiducials, but not in adding them to the scene originally.

The other thing you can do is to make sure that you do the lock/visibility etc settings on the list as a whole, rather than iterating through each fiducial, which is what you're doing in python, but in the GUI, you need to use the toggles right beside the list name drop down, rather than the multi drop downs right above the table. That will cause any checks to hit the list status first rather than having to go down into the individual fiducial level to check.

If you're still finding the GUI too slow for you, consider using a different data structure and the glyph mapper that's used for displaying transforms. I'm not as familiar with that but could dig up some pointers.

lassoan

lassoan

2017-06-09 21:07

developer   ~0014700

Markups is intended to be used for manual marking/editing of point positions. There is no specific limit for number of points that can be added to a list, but performance is optimal if there are less than 100 points. For visualizing more points, it is recommended to use a vtkMRMLModelNode, which contains vtkPolyData generated by a vtkGlyph3D filter.

(this not is also added to markups node documentation)

fepegar

fepegar

2017-06-13 17:47

reporter   ~0014829

I ended up using a vtkGlyph for this project. Thanks for having looked into this.

Issue History

Date Modified Username Field Change
2016-11-18 13:03 fepegar New Issue
2016-11-18 13:03 fepegar Status new => assigned
2016-11-18 13:03 fepegar Assigned To => nicole
2016-11-18 13:03 fepegar Relationship added related to 0004239
2016-11-18 13:03 fepegar Relationship added related to 0001714
2016-11-18 13:04 fepegar Relationship added related to 0001091
2016-11-21 19:10 nicole Note Added: 0014254
2017-06-09 21:07 lassoan Status assigned => resolved
2017-06-09 21:07 lassoan Resolution open => won't fix
2017-06-09 21:07 lassoan Note Added: 0014700
2017-06-13 17:47 fepegar Note Added: 0014829
2017-06-13 17:54 lassoan Status resolved => closed