Dear community,
I’m building a code, which relies on cross-section analysis. The output I’m interested in is the standard output as in GUI: table and plot of diameters. I’m struggling to achieve the same via CLI.
# Step 4: Cross-Sectional Analysis
def cross_sectional_analysis(centerline_model_node, segmentation_node):
# Initialize the CrossSectionAnalysis logic
logic = CrossSectionAnalysis.CrossSectionAnalysisLogic()
# Set the inputs for the CrossSectionAnalysis logic
logic.setInputCenterlineNode(centerline_model_node)
logic.setLumenSurface(segmentation_node, 'Segment_1')
# Run the cross-sectional analysis
logic.run()
# Create and set the output table node if it does not exist
if not logic.outputTableNode:
output_table_node = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLTableNode")
logic.setOutputTableNode(output_table_node)
print("Created and set new output table node.")
# Create and set the output plot series node if it does not exist
if not logic.outputPlotSeriesNode:
output_plot_series_node = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLPlotSeriesNode")
logic.setOutputPlotSeriesNode(output_plot_series_node)
print("Created and set new output plot series node.")
# Determine the number of control points
if centerline_model_node.IsTypeOf("vtkMRMLModelNode"):
number_of_points = centerline_model_node.GetPolyData().GetNumberOfPoints()
elif centerline_model_node.IsTypeOf("vtkMRMLMarkupsShapeNode"):
trimmed_spline = vtk.vtkPolyData()
if not centerline_model_node.GetTrimmedSplineWorld(trimmed_spline):
number_of_points = centerline_model_node.GetSplineWorld().GetNumberOfPoints()
else:
number_of_points = trimmed_spline.GetNumberOfPoints()
else:
number_of_points = centerline_model_node.GetCurvePointsWorld().GetNumberOfPoints()
print(f"Number of control points: {number_of_points}")
#GetArray?
#UpdateTable?
Thank you in advance!
Bohdan