# Modify segment directly using Python

**URL:** <https://discourse.slicer.org/t/modify-segment-directly-using-python/7856>\
**Category:** Development\
**Created:** [August 3, 2019, 12:49am UTC](https://discourse.slicer.org/t/modify-segment-directly-using-python/7856 "2019-08-03T00:49:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [August 3, 2019, 12:49am UTC](https://discourse.slicer.org/t/modify-segment-directly-using-python/7856/1 "2019-08-03T00:49:38Z")

</div>

I’ve seen a lot of python scripts that use existing segment editor effects, but is there a way to directly access segment data and volume data from python to implement prototype segmentation algorithms? Or is that something that’s better done via C++?

I’m positive there are probably pointers to how to do this in the docs…

Thanks!

-Hollister

---

<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:** [August 3, 2019, 2:17am UTC](https://discourse.slicer.org/t/modify-segment-directly-using-python/7856/2 "2019-08-03T02:17:26Z")

</div>

Contribution of new Segment Editor effects would be very welcome! You can implement Segment Editor effects either in C++ or Python. There is a template for Python-scripted segment editor effect in the Extension wizard and you can use all the current Segment Editor effects as examples of how to implement your own effect - see in [Slicer core](https://github.com/Slicer/Slicer/tree/master/Modules/Loadable/Segmentations/EditorEffects) and in [SegmentEditorExtraEffects extension](https://github.com/lassoan/SlicerSegmentEditorExtraEffects).
