# Add segmentation with sphere brush from known coordinates via scripts

**URL:** <https://discourse.slicer.org/t/add-segmentation-with-sphere-brush-from-known-coordinates-via-scripts/29321>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [May 6, 2023, 7:34pm UTC](https://discourse.slicer.org/t/add-segmentation-with-sphere-brush-from-known-coordinates-via-scripts/29321 "2023-05-06T19:34:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hapkx](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hapkx/32/18609_2.png) [@hapkx](https://discourse.slicer.org/u/hapkx)\
**Post date:** [May 6, 2023, 7:34pm UTC](https://discourse.slicer.org/t/add-segmentation-with-sphere-brush-from-known-coordinates-via-scripts/29321/1 "2023-05-06T19:34:26Z")

</div>

This problem may be simple, but I can’t find the right solution for the moment.  
There are some coordinates, for example(10, 10, 10) and (20, 20, 20), and I want to add ‘paint’ (maybe with a sphere brush) at the corresponding position of each coordinate within one segmentation node, is it possible? What should I do?  
Thanks a lot inadvance!

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [May 7, 2023, 12:09pm UTC](https://discourse.slicer.org/t/add-segmentation-with-sphere-brush-from-known-coordinates-via-scripts/29321/2 "2023-05-07T12:09:05Z")

</div>

There are [examples in the Script Repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#use-segment-editor-effects-from-script-qmrmlsegmenteditorwidget) that should help. [This example](https://gist.github.com/lassoan/2d5a5b73645f65a5eb6f8d5f97abf31b) in particular is close to what you asked for.

---

<div class="post-metadata">

**Author:** ![hapkx](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hapkx/32/18609_2.png) [@hapkx](https://discourse.slicer.org/u/hapkx)\
**Post date:** [May 7, 2023, 3:23pm UTC](https://discourse.slicer.org/t/add-segmentation-with-sphere-brush-from-known-coordinates-via-scripts/29321/3 "2023-05-07T15:23:55Z")

</div>

Thanks alot. I tried this, but it looks like the overlap has become hollow. Is there a solution to this problem?  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/8/e86216ff78035073e4084eedd95fe5cd094cea8a.png)

---

<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:** [May 8, 2023, 5:14am UTC](https://discourse.slicer.org/t/add-segmentation-with-sphere-brush-from-known-coordinates-via-scripts/29321/4 "2023-05-08T05:14:36Z")

</div>

If you append overlapping meshes then intersecting regions will be considered as “outside” (this allows definition of shapes with holes in them). In your case you don’t want intersections to be hollow, so don’t append the meshes. Instead, you can add the meshes to the segmentation one by one and combine them as segments, using “Logical operations” effect.

---

<div class="post-metadata">

**Author:** ![hapkx](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hapkx/32/18609_2.png) [@hapkx](https://discourse.slicer.org/u/hapkx)\
**Post date:** [May 8, 2023, 12:55pm UTC](https://discourse.slicer.org/t/add-segmentation-with-sphere-brush-from-known-coordinates-via-scripts/29321/5 "2023-05-08T12:55:34Z")

</div>

That works. Thank you!
