# How to get the master volume of a segmentation with Python

**URL:** <https://discourse.slicer.org/t/how-to-get-the-master-volume-of-a-segmentation-with-python/15520>\
**Category:** Support\
**Tags:** segmentation, python\
**Created:** [January 14, 2021, 7:57am UTC](https://discourse.slicer.org/t/how-to-get-the-master-volume-of-a-segmentation-with-python/15520 "2021-01-14T07:57:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![samuelholly](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@samuelholly](https://discourse.slicer.org/u/samuelholly)\
**Post date:** [January 14, 2021, 7:57am UTC](https://discourse.slicer.org/t/how-to-get-the-master-volume-of-a-segmentation-with-python/15520/1 "2021-01-14T07:57:28Z")

</div>

Dear Slicer communnity,

sorry if this was already asked before. I would like to ask how can I get the master volume node from of a segmentation in the Python interactor.

Thank you very much in advance.

Samuel

---

<div class="post-metadata">

**Author:** ![samuelholly](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@samuelholly](https://discourse.slicer.org/u/samuelholly)\
**Post date:** [January 14, 2021, 1:23pm UTC](https://discourse.slicer.org/t/how-to-get-the-master-volume-of-a-segmentation-with-python/15520/2 "2021-01-14T13:23:56Z")

</div>

EDIT: I figured out. I used the following code:

```
segment_editor_node = getNode('SegmentEditor')

```

followed by

```
refvol = segment_editor_node.GetMasterVolumeNode()

```

Is this the proper to way to do it?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [January 15, 2021, 10:46am UTC](https://discourse.slicer.org/t/how-to-get-the-master-volume-of-a-segmentation-with-python/15520/3 "2021-01-15T10:46:56Z")

</div>

It can be if in your use case you only have one segmentation, however it can get you the wrong result if you are editing another segmentation than which you want to get the master volume of.

This is the way to get the volume which gave the geometry of the segmentation: [Slicer/SegmentStatisticsSubjectHierarchyPlugin.py at master · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/blob/master/Modules/Scripted/SegmentStatistics/SubjectHierarchyPlugins/SegmentStatisticsSubjectHierarchyPlugin.py#L93)
