# Paint Segment Using Data Points in Python

**URL:** <https://discourse.slicer.org/t/paint-segment-using-data-points-in-python/18537>\
**Category:** Development\
**Tags:** segmentation, python\
**Created:** [July 6, 2021, 5:31pm UTC](https://discourse.slicer.org/t/paint-segment-using-data-points-in-python/18537 "2021-07-06T17:31:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpereira](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@tpereira](https://discourse.slicer.org/u/tpereira)\
**Post date:** [July 6, 2021, 5:31pm UTC](https://discourse.slicer.org/t/paint-segment-using-data-points-in-python/18537/1 "2021-07-06T17:31:24Z")

</div>

Hi, so I have a series of (x,y,z) data points. I want to create a segmentation that will use paint to set the location and paint a sphere with a diameter of 3 at that location using code. I would be adding this to an existing segmentation of the spine. The circle location does not have to be super exact so I could round to the nearest existing pixel in the image. Would appreciate any guidance I am very new at this. Thank you!

---

<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:** [July 9, 2021, 5:17am UTC](https://discourse.slicer.org/t/paint-segment-using-data-points-in-python/18537/2 "2021-07-09T05:17:44Z")

</div>

You can create spheres and import them into the segmentation. See complete example [here](https://gist.github.com/lassoan/2d5a5b73645f65a5eb6f8d5f97abf31b#file-segmentgrowcutsimple-py-L10-L34). You can find many more examples in the [script repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#segmentations).
