# I want to obtain the x, y coordinates of the regions I have segmented

**URL:** <https://discourse.slicer.org/t/i-want-to-obtain-the-x-y-coordinates-of-the-regions-i-have-segmented/22873>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [April 8, 2022, 1:19pm UTC](https://discourse.slicer.org/t/i-want-to-obtain-the-x-y-coordinates-of-the-regions-i-have-segmented/22873 "2022-04-08T13:19:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aysegul\_sayin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aysegul_sayin/32/14944_2.png) [@aysegul\_sayin](https://discourse.slicer.org/u/aysegul_sayin)\
**Post date:** [April 8, 2022, 1:19pm UTC](https://discourse.slicer.org/t/i-want-to-obtain-the-x-y-coordinates-of-the-regions-i-have-segmented/22873/1 "2022-04-08T13:19:34Z")

</div>

![Screenshot_1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/4/049f59e064f528df429d4f08d32364fad07f6f1a.png)

I want to obtain the x, y coordinates of the regions I have segmented and the information on which section they are in. In what format should I save the segmentation and how can I get this coordinate information?

---

<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 9, 2022, 10:32am UTC](https://discourse.slicer.org/t/i-want-to-obtain-the-x-y-coordinates-of-the-regions-i-have-segmented/22873/2 "2022-04-09T10:32:53Z")

</div>

Storing a segmentation as a list of coordinates is an extremely inefficient representation. How would you use these coordinates?

---

<div class="post-metadata">

**Author:** ![DIV](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/div/32/12816_2.png) [@DIV](https://discourse.slicer.org/u/DIV)\
**Post date:** [April 10, 2022, 10:55pm UTC](https://discourse.slicer.org/t/i-want-to-obtain-the-x-y-coordinates-of-the-regions-i-have-segmented/22873/3 "2022-04-10T22:55:32Z")

</div>

> [@lassoan](#):
>
> Storing a segmentation as a list of coordinates is an extremely inefficient representation.

True, but it would be easier to understand if inspecting ‘manually’, and also easier to write code to process.  
—DIV

---

<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 11, 2022, 1:26am UTC](https://discourse.slicer.org/t/i-want-to-obtain-the-x-y-coordinates-of-the-regions-i-have-segmented/22873/4 "2022-04-11T01:26:35Z")

</div>

Indices are rarely useful for manual inspection, as even small structures consists of thousands of voxels (e.g., a tiny 10x10x10 structure = 1000 voxels), which is just too tedious to review manually. Image processing algorithms don’t operate on voxel indices representation, so I don’t see how it could help with any processing (unless you want to process your images with text processing algorithms?).

I did not want to tell @aysegul_sayin to just go and use `numpy.where` to get those indices, because most likely that would have lead to a dead end or suboptimal solution. Instead, I tried to understand what her overall goal was and find the best way to achieve that.

---

<div class="post-metadata">

**Author:** ![aysegul\_sayin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aysegul_sayin/32/14944_2.png) [@aysegul\_sayin](https://discourse.slicer.org/u/aysegul_sayin)\
**Post date:** [April 11, 2022, 8:19am UTC](https://discourse.slicer.org/t/i-want-to-obtain-the-x-y-coordinates-of-the-regions-i-have-segmented/22873/5 "2022-04-11T08:19:13Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/0/701df2d6b7a16f4c5a440c8764b5e5e152500def.png)

Hello, first of all thank you for your replies.  
Actually, my goal is to reach the coordinate information of a segmented structure, for example a tumor. I’ve read and tried before on the forum that we can do this with the following code block. (I’m a bit of a newbie at Slicer so sorry if I said anything wrong). The values I got as numpy format from here were the values corresponding to the field that says Red.What do the values in the place called Red mean here? However, what I want is the x,y,z, coordinate information in my own MR image.

---

<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 11, 2022, 3:17pm UTC](https://discourse.slicer.org/t/i-want-to-obtain-the-x-y-coordinates-of-the-regions-i-have-segmented/22873/6 "2022-04-11T15:17:16Z")

</div>

You can get voxels of a segmentation as a numpy array as shown in [examples in the script repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#read-and-write-a-segment-as-a-numpy-array).

“Red” means that the mouse pointer is over the “Red” view. You can ignore this information. Content displayed in the Data Probe is documented [here](https://slicer.readthedocs.io/en/latest/user_guide/user_interface.html#data-probe).

> [@aysegul\_sayin](#):
>
> my goal is to reach the coordinate information of a segmented structure, for example a tumor

What exactly do you need? Anatomical coordinates of the segmented tumor’s center?
