I have a dataset of thousands of scans that have already been landmarked. I now want to use a subset of existing landmarks to define new curves. This is quite straightforward to do manually by adding curves with the markups toolbox but I am stuck trying to script the same process (necessary because of the size of the dataset). It is possibly straightforward but I am a Slicer and Python novice. Below is a brief script of where I have got to so far. I can read the scan in and read in a csv containing coordinates for two control points defining the ends points of the curve. I can define the curve type (here, arbitrarily using a Kochanek spline). Next, I want to:
- include code to implement “Constrain to Model” from Curve Settings menu and constrain to the input model (shoebillNode)
- Resample the curve to e.g. 10 resampled points and set the output node to markupsNode1 from the script below.
- Output to file the resampled curve
I hope that makes sense. I would greatly appreciate suggestions on how to script this. At this point I am not even sure which functions I need.
# Read obj model shoebillNode = slicer.util.loadModel('Balaeniceps_rex_2.obj') # Read markups with two points markupsNode1 = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsCurveNode") slicer.modules.markups.logic().ImportControlPointsFromCSV(markupsNode1, 'Table1.csv') # Input control points (not sure if this is necessary - does it do anything different to the previous two lines?) slicer.vtkProjectMarkupsCurvePointsFilter().SetInputCurveNode(markupsNode1) # Kochanek spline slicer.vtkMRMLMarkupsCurveNode.SetCurveTypeToKochanekSpline(markupsNode1)