# How do I programmatically allow segment volumes from different segmentations to be shown in one table in the segment statistics module?

**URL:** <https://discourse.slicer.org/t/how-do-i-programmatically-allow-segment-volumes-from-different-segmentations-to-be-shown-in-one-table-in-the-segment-statistics-module/19725>\
**Category:** Development\
**Tags:** segmentation, python, segment-statistics\
**Created:** [September 17, 2021, 1:38pm UTC](https://discourse.slicer.org/t/how-do-i-programmatically-allow-segment-volumes-from-different-segmentations-to-be-shown-in-one-table-in-the-segment-statistics-module/19725 "2021-09-17T13:38:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![akshay\_pillai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akshay_pillai/32/8301_2.png) [@akshay\_pillai](https://discourse.slicer.org/u/akshay_pillai)\
**Post date:** [September 17, 2021, 1:38pm UTC](https://discourse.slicer.org/t/how-do-i-programmatically-allow-segment-volumes-from-different-segmentations-to-be-shown-in-one-table-in-the-segment-statistics-module/19725/1 "2021-09-17T13:38:30Z")

</div>

I know that we can use the segment statistics, module to get the volume of individual segments inside a segmentation in a table. How do I programmatically make it add volumes of segments in different segmentations? I would want the segment volume from a second or third segmentation to be added to the segment statistics table. So just one table for comparing volumes across segmentations. Is this possible? Any help is appreciated thanks.

---

<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:** [September 17, 2021, 2:15pm UTC](https://discourse.slicer.org/t/how-do-i-programmatically-allow-segment-volumes-from-different-segmentations-to-be-shown-in-one-table-in-the-segment-statistics-module/19725/2 "2021-09-17T14:15:56Z")

</div>

It should be no problem at all. You can create a summary table (with an extra column to identify the segmentation node) and copy each cell of the segment statistics output table to this summary table using [vtkMRMLTableNode](http://apidocs.slicer.org/master/classvtkMRMLTableNode.html) methods (`GetCellText`, `AddEmptyRow`, `SetCellText`, etc.).

---

<div class="post-metadata">

**Author:** ![akshay\_pillai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akshay_pillai/32/8301_2.png) [@akshay\_pillai](https://discourse.slicer.org/u/akshay_pillai)\
**Post date:** [September 21, 2021, 4:18pm UTC](https://discourse.slicer.org/t/how-do-i-programmatically-allow-segment-volumes-from-different-segmentations-to-be-shown-in-one-table-in-the-segment-statistics-module/19725/3 "2021-09-21T16:18:15Z")

</div>

Hey, I still haven’t been able to implement this. Is there an example code so I can see it and understand or implement it?

---

<div class="post-metadata">

**Author:** ![akshay\_pillai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akshay_pillai/32/8301_2.png) [@akshay\_pillai](https://discourse.slicer.org/u/akshay_pillai)\
**Post date:** [September 21, 2021, 4:21pm UTC](https://discourse.slicer.org/t/how-do-i-programmatically-allow-segment-volumes-from-different-segmentations-to-be-shown-in-one-table-in-the-segment-statistics-module/19725/4 "2021-09-21T16:21:58Z")

</div>

> [@lassoan](#):
>
> m at all. You can create a summary table (with an extra column to identify the segmentation node) and copy each cell of the segment statistics output table to this summary table using [vtkMRMLTableNode](http://apidocs.slicer.org/master/classvtkMRMLTableNode.html) methods ( `GetCellText` ,

Also, I want 2 segments from different segmentations to be added into one column without creating another table. For example, just selecting volume and segment and clicking add consecutively one after the other adding onto the same table. I think I could implement it if I look at some example code with table creation and manipulation.

---

<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:** [September 21, 2021, 5:46pm UTC](https://discourse.slicer.org/t/how-do-i-programmatically-allow-segment-volumes-from-different-segmentations-to-be-shown-in-one-table-in-the-segment-statistics-module/19725/5 "2021-09-21T17:46:51Z")

</div>

These examples should help:

- [Slicer/TablesSelfTest.py at master · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Tables/Testing/Python/TablesSelfTest.py)
- [Script repository — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#measure-distance-of-points-from-surface)
- [Slicer/util.py at master · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/util.py#L2012-L2112)
