I bumped into an issue I can’t seem to find a solution for. I have a large number (>400) of segments for each I want to measure the intensity (essentially the anatomical location off an atlas) from the centroid voxel. I used Segment Statistics to export the Centroid coordinates and I can import those into a fiducial list.
I’m wondering what would be the best way to get the intensity data from the centroids?
A) I could import the coordinates into a fiducial list, but is there a way to get values from the fiducial’s coordinates?
B) Can I shrink the segments to a single central voxel? (this would be the simplest)
C) DO i have to generate 400+ transforms with the coordinates and use a single central voxel to get the data?
- I used LabelmapSegmentStatistics to pull the centroid for each segment in the Segmentation
- Then I used the centroid coordinates to generate new spherical segments with a 1mm diameter (or radius?)
- These can be used with Segment statistics to query core lesion locations based on anatomical atlases
# Pull Centroids and generate 1mm spheric lesions in centroid for anatomical assessment
# Adjust name for "Segmentation" and "Volume" as needed
import numpy as np
segmentationNode = slicer.util.getNode("Segmentation")
volume_node = slicer.util.getNode("Volume")
segmentation = segmentationNode.GetSegmentation()
segnum = segmentation.GetNumberOfSegments()
for i in range(segnum):
segment = segmentation.GetNthSegment(i)
segmentId = segmentationNode.GetSegmentation().GetSegmentIdBySegment(segment)
segmentName = segment.GetName()
segStatLogic = SegmentStatistics.SegmentStatisticsLogic()
stats = segStatLogic.getStatistics()
centroid_ras = stats[segmentId,"LabelmapSegmentStatisticsPlugin.centroid_ras"]
tumorCentroid = vtk.vtkSphereSource()
CentroidSegmentName = segmentName + "-centroid"
segmentId = segmentationNode.AddSegmentFromClosedSurfaceRepresentation(tumorCentroid.GetOutput(), CentroidSegmentName, [1.0,0.0,0.0])