# How to programmatically export data from segment statistics?

**URL:** <https://discourse.slicer.org/t/how-to-programmatically-export-data-from-segment-statistics/17390>\
**Category:** Development\
**Tags:** python\
**Created:** [April 30, 2021, 7:02am UTC](https://discourse.slicer.org/t/how-to-programmatically-export-data-from-segment-statistics/17390 "2021-04-30T07:02:44Z")\
**Posts on this page:** 4\
**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:** [April 30, 2021, 7:02am UTC](https://discourse.slicer.org/t/how-to-programmatically-export-data-from-segment-statistics/17390/1 "2021-04-30T07:02:44Z")

</div>

Operating system: Windows 10

I use segment statistics to generate a table of all the information I need.  
My question is how can I export the table of information from slicer programmatically after I use segment statistics. Ideally, I would run a command that would just export the table.  
Also, how can I generate a graph or histogram from segment statistics and export that as well(programmatically)

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [May 1, 2021, 11:17am UTC](https://discourse.slicer.org/t/how-to-programmatically-export-data-from-segment-statistics/17390/2 "2021-05-01T11:17:43Z")

</div>

You can use

```
slicer.util.saveNode(tablenode,filename)

```

A “test.csv” filename will export it in the CSV format.

---

<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:** [May 4, 2021, 5:59am UTC](https://discourse.slicer.org/t/how-to-programmatically-export-data-from-segment-statistics/17390/3 "2021-05-04T05:59:20Z")

</div>

Great, thanks. Also, do you know how I can generate a graph of all the segments and the info?

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [May 4, 2021, 8:05am UTC](https://discourse.slicer.org/t/how-to-programmatically-export-data-from-segment-statistics/17390/4 "2021-05-04T08:05:32Z")

</div>

The segment statistics module generates a result table (find it in the Data module).  
If you open this result table in the “Table” module, you can directly create a plot chart.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/c/1c4e255c45cf2bd40c95e1954e92700886c37065.jpeg)

More sophisticated plotting requires Python scripting:

[https://www.slicer.org/wiki/Documentation/Nightly/Developers/Plots](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Plots)
