# perpendicular cross sectional area along centerline

**URL:** <https://discourse.slicer.org/t/perpendicular-cross-sectional-area-along-centerline/15556>\
**Category:** Support\
**Tags:** segmentation, centerlines\
**Created:** [January 16, 2021, 3:20pm UTC](https://discourse.slicer.org/t/perpendicular-cross-sectional-area-along-centerline/15556 "2021-01-16T15:20:07Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [November 30, 2022, 6:52pm UTC](https://discourse.slicer.org/t/perpendicular-cross-sectional-area-along-centerline/15556/22 "2022-11-30T18:52:32Z")

</div>

> [@Tom](#):
>
> is it possible to extract the data for all voxels comprising a given cross-section

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

```auto
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])

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 30, 2022, 8:48pm UTC](https://discourse.slicer.org/t/perpendicular-cross-sectional-area-along-centerline/15556/23 "2022-11-30T20:48:23Z")

</div>

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.

[Previous page](https://discourse.slicer.org/t/perpendicular-cross-sectional-area-along-centerline/15556.md?page=1)
