perpendicular cross sectional area along centerline

This code snippet should give you the HU values of the contour points of the cross-section. Is it what you expected ?

inputVolume = slicer.util.getNode("CTA-cardio")
inputVolumeArray = slicer.util.arrayFromVolume(inputVolume)
centerlineNode = slicer.util.getNode("vtkMRMLMarkupsCurveNode1")

import CrossSectionAnalysis
csaLogic = CrossSectionAnalysis.CrossSectionAnalysisLogic()
csaLogic.setInputCenterlineNode(centerlineNode)
csaLogic.setLumenSurface(segmentation, "Segment_F")
crossSectionContour = csaLogic.computeCrossSectionPolydata(100)
crossSectionPoints = crossSectionContour.GetPoints()

# From LineProfile.py (simplified)
rasToIJK = vtk.vtkMatrix4x4()
parentToIJK = vtk.vtkMatrix4x4()
rasToParent = vtk.vtkMatrix4x4()
inputVolume.GetRASToIJKMatrix(parentToIJK)
vtk.vtkMatrix4x4.Multiply4x4(parentToIJK, rasToParent, rasToIJK)

for i in range(crossSectionPoints.GetNumberOfPoints()):
    contourPoint = crossSectionPoints.GetPoint(i)
    point_RAS = (contourPoint[0], contourPoint[1], contourPoint[2], 1)
    point_IJK = [0,0,0,1]
    rasToIJK.MultiplyPoint(point_RAS, point_IJK)
    point_IJK_int = (int(point_IJK[0]), int(point_IJK[1]), int(point_IJK[2]))
    print(inputVolumeArray[point_IJK_int])
2 Likes

The original voxel array is not aligned with your spiral. If you need a voxel array then I would recommend to straighten the volume using Curved Planar Reformat module in Sandbox extension.

1 Like