I’m not really sure what happened… my code was working well yesterday and this morning I can’t figure out what changed.
My goal is to iterate through all the segmentation files in a directory and use the Segment Statistics module to get the segment volumes for each one. All my segmentation files are saved as “study_id_number_segmentations.seg.nrrd” and the corresponding volumes are saved as “study_id_number_MRI.nii”, where each study_id_number refers to a particular patient. So far I have:
Setup imports
import os
import glob
from path lib import Path
import SegmentStatistics
Load a specific segmentation and corresponding Node
segmentation_file = “path/to/study_id_1_segmentations.seg.nrrd”
segmentationNode = getNode(“study_id_1_segmentations”)
Compute segment statistics for that segmentation
segStatLogic = SegmentStatistics.SegmentStatisticsLogic()
segStatLogic.getParameterNode().SetParameter(“study_id_1_segmentations”, segmentationNode.GetID())
segStatLogic.computeStatistics()
stats = segStatLogic.getStatistics()
I’m (seemingly) able to load the volume and the node, but when I try to compute segment statistics I get the error: ‘NoneType’ object has no attribute ‘GetParentTransformNode’. Am I missing something here?