# 'NoneType' Object has no attribute 'GetParentTransformNode'?

**URL:** <https://discourse.slicer.org/t/nonetype-object-has-no-attribute-getparenttransformnode/19089>\
**Category:** Development\
**Tags:** segmentation, python\
**Created:** [August 5, 2021, 7:35pm UTC](https://discourse.slicer.org/t/nonetype-object-has-no-attribute-getparenttransformnode/19089 "2021-08-05T19:35:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![J1234](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@J1234](https://discourse.slicer.org/u/J1234)\
**Post date:** [August 5, 2021, 7:35pm UTC](https://discourse.slicer.org/t/nonetype-object-has-no-attribute-getparenttransformnode/19089/1 "2021-08-05T19:35:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Juicy](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Juicy](https://discourse.slicer.org/u/Juicy)\
**Post date:** [August 5, 2021, 10:38pm UTC](https://discourse.slicer.org/t/nonetype-object-has-no-attribute-getparenttransformnode/19089/2 "2021-08-05T22:38:56Z")

</div>

Just a very quick observation: The line:

```auto
segStatLogic.getParameterNode().SetParameter(“study_id_1_segmentations”, segmentationNode.GetID())

```

Looks a bit wrong. I think it should be:

```auto
segStatLogic.getParameterNode().SetParameter("Segmentation", segmentationNode.GetID())

```

Also if you want statistics like mean pixel values etc which come from the volume, you should also point segment statistics toward the correct volume:

```auto
segStatLogic.getParameterNode().SetParameter("ScalarVolume", volumeNode.GetID())

```

You would first need to load the volume though and assign it to the variable ‘volumeNode’

---

<div class="post-metadata">

**Author:** ![J1234](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@J1234](https://discourse.slicer.org/u/J1234)\
**Post date:** [August 6, 2021, 4:05am UTC](https://discourse.slicer.org/t/nonetype-object-has-no-attribute-getparenttransformnode/19089/3 "2021-08-06T04:05:10Z")

</div>

That works, thanks for the correction!
