# How to split one segment into three equal parts via script?

**URL:** <https://discourse.slicer.org/t/how-to-split-one-segment-into-three-equal-parts-via-script/11287>\
**Category:** Support\
**Tags:** segmentation, python\
**Created:** [April 24, 2020, 12:23pm UTC](https://discourse.slicer.org/t/how-to-split-one-segment-into-three-equal-parts-via-script/11287 "2020-04-24T12:23:57Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [April 24, 2020, 4:05pm UTC](https://discourse.slicer.org/t/how-to-split-one-segment-into-three-equal-parts-via-script/11287/2 "2020-04-24T16:05:19Z")

</div>

If you want to split to three equal volumes then you can use the new [Segment cross-section area extension](https://discourse.slicer.org/t/new-module-for-measuring-cross-section-area-of-segments/11293) to compute cross-sections along slices. You can get the positions as a table and get physical position of 0, 1/3, 2/3, full volume like this:

```python
crossSectionsTable = getNode('Segment cross-section area table')
positions = slicer.util.arrayFromTableColumn(crossSectionsTable, 'Position')
areas = slicer.util.arrayFromTableColumn(crossSectionsTable, 'Segment_1')

import numpy as np
volumeRatio = np.cumsum(areas)/np.sum(areas)
slicePositions = np.interp([0.0, 1.0/3.0, 2.0/3.0, 1.0], volumeRatio, positions[:,3])
print("Slice position along IS axis for zero, 1/3, 2/3, and full volumes: "+str(slicePositions))

```

---

_[View the full topic](https://discourse.slicer.org/t/how-to-split-one-segment-into-three-equal-parts-via-script/11287)._
