I was just working with the “Markups To Model” extension for the first time and I saw that it only accepts markup fiducial lists as an input. Is there a reason why it does not take markup curves (open or closed) as input? I know how to convert a markups open curve into a markup fiducial list programmatically (via arrayFromMarkupsCurvePoints()), but the name “Markups to Model” implies that this is already supported anyway, directly from the UI.
A bit of context why I’m doing this: I’m currently trying to find an easy way to accurately segment bone fractures, specifically skull fractures. The way I do it right now works, but is a bit cumbersome, with roughly the following steps:
segment the skull via thresholding
erode that by 1mm and export that as a model
use “Probe Volume With Model” to get a textured mesh with ImageScalars (the fracture is nicely visible in these scalars)
place an open-curve-markup with a few control points on the mesh surface
constrain the curve path to lie on the skull surface model, and the path should follow a shortest-distance path on the model with an “Additive” cost function that is “distance + 10*ImageScalars” - Now, the open curve follows exactly the HU intensity dip along the fracture line.
Here is where the above part is a bit of an inconvenience… I wanna import this path into the segmentation node… to do this I have to i) resample the path with a large number of fiducials, ii) convert the curve to a fiducials list, iii) use “Markups to Model” to convert this into a model, and iv) import the model into the segmentation.
Especially point 6 would get a bit simpler, if it was possible to directly convert the open curve into a model (without resampling and/or converting to a fiducial list).
Maybe this way to segment a fracture is way too complex. If anyone has an idea how to do it better, I’d be greatful for suggestions. I can also open a new topic for this… This topic is mainly for the “Markups to Model” feature request to accept “Open Curve Markups” as well.
Thanks Andras… the reason I need to do steps 6.i/ii/iii are because I want to convert the open curve itself into a model (a tube of certain diameter), then import that tube into the segment editor. I don’t see a quicker way how to accomplish that right now.
The Dynamic Modeler module can clip a surface along an open curve - but it cannot convert the curve itself into a tube model, right?
You can draw tubes directly in Segment Editor using “Draw tube” effect (provided by SegmentEditorExtraEffects extension). Right now you cannot enable constraining of the curve in this effect (or selection of a curve node), but this would not be hard to add. The effect is just a short Python script that you can easily modify, so it would be great if you could give it a go and make the changes that you need (e.g., add an input curve node selector). If you find that these modifications are useful then we could merge those back to the official version.
For what I’ve read, it seems that you managed to convert an “Open Curve Markup” into a “Markup Fiducial List”, in order to use it in “Markups to Model”. Could you please share the code with me or give me some instructions about it? I would really appreciate it.
sure, no problem. Getting an array from the curve is easy, Slicer provides a function for this. Creating a fiducial markups node from this array needs to be coded. There may be a Slicer function for this too, but I’m not aware of any. I modified a function I created for this to fit your use case. Here’s the code, obviously you can modify the function to your needs (and obviously it’s not very clean, e.g. no asserts or anything) - hope it helps:
# Utility function to create a fiducial list from a Nx3 numpy array
def fiducialListFromArray(name_fidnode, arr, fidsPrefix=''):
# Check if a fiducial markups node with the name "name_fidnode" already exists, if not, create it and add it to the scene
n_fid = slicer.util.getNode(name_fidnode)
n_fid = slicer.vtkMRMLMarkupsFiducialNode()
nrfids = arr.shape
# if no fiducial names are given,
sep = ''
sep = '-'
listFidNames = ['%s%s%d'%(fidsPrefix,sep,i+1) for i in range(nrfids)]
for i in range(nrfids):
n_fid.AddFiducial(arr[i,0], arr[i,1], arr[i,2], listFidNames[i])
# n_curve is the node to the open curve markup
arr = arrayFromMarkupsControlPoints(n_curve)
# A node of name 'FiducialsFromCurve' is created if it doesn't exist already
# if it exists, the fiducials in arr are simply appended to the existing list
n_fid = fiducialListFromArray('FiducialsFromCurve', arr, fidsPrefix='F')