I can convert a cross section and convert to a segmentation and then convert it back to a model; then go to the next cross section by browsing in the cross sectional analysis module. Finally, I can save them to STL. This is tedious. Is there is way to export multiple cross sections at a time? Say, I want to resample the centerline to have 20 control points, then export all the cross sections at these control points.
Also, how to get the center (coordinates) of a cross section?
If I have fully understood your requirements, this step can be done through scripting. A good start is as follows:
import CrossSectionAnalysis
logic = CrossSectionAnalysis.CrossSectionAnalysisLogic()
centerline = getNode("Centerline curve (0)")
segmentation = getNode("Segmentation")
logic.setInputCenterlineNode(centerline)
logic.setLumenSurface(segmentation, "Segment_1")
logic.run()
for i in range(20):
crossSectionPolyData = logic.computeCrossSectionPolydata(i)
# Add your export code to STL here
You must add more code to export the crossSectionPolyData to STL.
For me, ‘centre’ refers to a regular geometry, like circle, rectangle, cube… Do you mean the control point coordinates of your resampled curve? They are available in the ‘Markups’ module.
@chir.set, thank you so much! Your method seems promising. I’m not familiar with script, but I get your code run in the python console and it seems working. Can you tell me how to export crossSectionPolyData to STL, how to convert them to models so that I can view them in Slicer?
For the second question about the center, if the sections are exactly extracted at the centerline control points, then I can get the coordinates from the centerline table.
Cool. I got 20 cross sections in a second. Unfortunately, they are not at the control points. Did I miss something with my centerline curve? I just resampled it to have 20 control points.