# How to programmatically convert some of my segments into models and then get and store information from these models?

**URL:** https://discourse.slicer.org/t/how-to-programmatically-convert-some-of-my-segments-into-models-and-then-get-and-store-information-from-these-models/17195
**Category:** Development
**Tags:** segmentation, python
**Created:** [April 20, 2021, 6:02am UTC](https://discourse.slicer.org/t/how-to-programmatically-convert-some-of-my-segments-into-models-and-then-get-and-store-information-from-these-models/17195 "2021-04-20T06:02:47Z")
**Posts on this page:** 3
**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 20, 2021, 6:02am UTC](https://discourse.slicer.org/t/how-to-programmatically-convert-some-of-my-segments-into-models-and-then-get-and-store-information-from-these-models/17195/1 "2021-04-20T06:02:47Z")

</div>

Operating system: Windows 10  
Slicer version: 4.11

I want to (i)programmatically convert some of my segments into models and then (ii)get and store information from these models. Information like surface area, volume, etc. How can I do this programmatically? I would like to convert all the segments into models and store this information as an excel sheet or as data or graph. Is there any way to do this?

---

<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: [April 20, 2021, 11:09am UTC](https://discourse.slicer.org/t/how-to-programmatically-convert-some-of-my-segments-into-models-and-then-get-and-store-information-from-these-models/17195/2 "2021-04-20T11:09:38Z")

</div>

For the first question see solution in the script repository:  
[https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Export\_model\_nodes\_from\_segmentation\_node](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Export_model_nodes_from_segmentation_node)

However, for your second question there is no need for such conversion, because the Segment Statistics module can do it for you from the surface models representation within the segmentations (see explanation of the representations [here](https://slicer.readthedocs.io/en/latest/user_guide/image_segmentation.html)). To programmatically drive a module you need to see [its source code](https://github.com/Slicer/Slicer/blob/master/Modules/Scripted/SegmentStatistics/SegmentStatistics.py), then simply set the proper inputs and call the necessary functions.

---

<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 27, 2021, 3:29pm UTC](https://discourse.slicer.org/t/how-to-programmatically-convert-some-of-my-segments-into-models-and-then-get-and-store-information-from-these-models/17195/3 "2021-04-27T15:29:52Z")

</div>

Thanks , Segment Statistics was perfect.
