If I have a bunch of annotation ruler node objects saved to disk as .acsv files, what is the correct way to load these into Slicer as Markups Line node objects? I would like to use the improved display node capabilities of the Markups Line node.
Using the Add Data dialog, I changed the description from “Annotation” to “Markups”, but then I just get an error on load.
[ERROR][VTK] 12.01.2022 15:48:44 [vtkSlicerMarkupsLogic (000002B87EDA8550)] (D:\D\P\Slicer-0\Modules\Loadable\Markups\Logic\vtkSlicerMarkupsLogic.cxx:875) - vtkSlicerMarkupsLogic::LoadMarkups failed: unrecognized file extension in C:/Users/JamesButler/Downloads/C_1.acsv
Through python code I’ll load the Annotation Ruler, get the positions of the 2 points, remove the Annotation Ruler, add a Markups Line, add 2 points with the same positions as the old object.
ruler_path = r"C:\Users\JamesButler\Downloads\C_1.acsv"
old_ruler_node = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLAnnotationRulerNode')
storage_node = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLAnnotationRulerStorageNode')
storage_node.SetFileName(ruler_path)
success = storage_node.ReadData(old_ruler_node)
pos1 = [0, 0, 0]
pos2 = [0, 0, 0]
old_ruler_node.GetPosition1(pos1)
old_ruler_node.GetPosition2(pos2)
slicer.mrmlScene.RemoveNode(old_ruler_node)
ruler_node = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLMarkupsLineNode')
ruler_node.AddControlPoint(vtk.vtkVector3d(pos1))
ruler_node.AddControlPoint(vtk.vtkVector3d(pos2))
1 Like