# Inquiry Spatial Coordinates

**URL:** https://discourse.slicer.org/t/inquiry-spatial-coordinates/41874
**Category:** Support
**Created:** [February 25, 2025, 5:21pm UTC](https://discourse.slicer.org/t/inquiry-spatial-coordinates/41874 "2025-02-25T17:21:25Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![MPARHAM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mparham/32/70304_2.png) [@MPARHAM](https://discourse.slicer.org/u/MPARHAM)
#### Post date: [February 25, 2025, 5:21pm UTC](https://discourse.slicer.org/t/inquiry-spatial-coordinates/41874/1 "2025-02-25T17:21:25Z")

</div>

Hi everyone,

Glad to be back on the forum and hope everyone had a great start to this year.

I had a question about exporting files and coordinate systems in 3D Slicer. My objective is to recreate the segmentation used in 3D slicer in MATLAB. Which I am able to do as seen below.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/8/08371824bf00572518666a175dc56dfe14f75265.jpeg)

I understand that for Slicer the coordinate system is in RAS, but when exported in NRRD it is transformed to the LPS System as this coordinate system is more recognizable with other software. I wanted to check if the transformation from both coordinate system were accurate and analyze in MATLAB.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/8/88d5db0358c4eacd4c01652fabdd1ffce7f18803.jpeg)

In my methodology, I was able to bring the points in the nrrd file and graph them to replicate Slicer’s visual display. However, one issue I am having is that the points are off by 1 pixels usually in the x, in the y or both.

For example, in the picture above I placed my cursor at both identical points in slicer and in my code and although they are similar, the MATLAB algorithm is 1 point off. In Slicer the coordinates for that corner are 118, 135, 61.

For my algorithm it read 119, 136, and 62. Luckily, for the middle value all of the other coordinates for this segmentation is reading the same layer and I am still able to duplicate the segmentation.

I cannot think of anyone why this is happening, but if anyone else had a thought it would be greatly appreciated.

Thank you,  
Melton Parham

---

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [February 25, 2025, 5:32pm UTC](https://discourse.slicer.org/t/inquiry-spatial-coordinates/41874/2 "2025-02-25T17:32:34Z")

</div>

> [@MPARHAM](#):
>
> I cannot think of anyone why this is happening, but if anyone else had a thought it would be greatly appreciated.

Rounding error? In slicer coordinates are continuous, there is no guarantee that you place the point in exactly on a specific IJK coordinate in image grid. Maybe try turning off the interpolation in Slicer and see if helps.

---

<div class="post-metadata">

### Author: ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)
#### Post date: [February 25, 2025, 5:36pm UTC](https://discourse.slicer.org/t/inquiry-spatial-coordinates/41874/3 "2025-02-25T17:36:05Z")

</div>

Is this a Matlab 1 indexing method compared against 0 indexing method?

---

<div class="post-metadata">

### Author: ![MPARHAM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mparham/32/70304_2.png) [@MPARHAM](https://discourse.slicer.org/u/MPARHAM)
#### Post date: [February 25, 2025, 5:50pm UTC](https://discourse.slicer.org/t/inquiry-spatial-coordinates/41874/4 "2025-02-25T17:50:27Z")

</div>

Hi, that’s a great point! Thank you for clarifying that the points I’m selecting may not be exact. I went to Volumes \> Display and turned off interpolation to ensure the pixel I’m on matches the expected position. I believe this is part of the issue, so I really appreciate your help!

---

<div class="post-metadata">

### Author: ![MPARHAM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mparham/32/70304_2.png) [@MPARHAM](https://discourse.slicer.org/u/MPARHAM)
#### Post date: [February 25, 2025, 5:52pm UTC](https://discourse.slicer.org/t/inquiry-spatial-coordinates/41874/5 "2025-02-25T17:52:01Z")

</div>

> [@jamesobutler](#):
>
> Is this a Matlab 1 indexing method compared against 0 indexing method?

Hi James, to ensure clarity 3D slicer is 0 indexing method? If so that also explains the 1 point off. MATLAB indexing does begin at 1 and that would explain why each point is slightly off but still similar.

---

<div class="post-metadata">

### Author: ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)
#### Post date: [February 25, 2025, 9:07pm UTC](https://discourse.slicer.org/t/inquiry-spatial-coordinates/41874/6 "2025-02-25T21:07:49Z")

</div>

Python and C++ (Which is what Slicer uses) is using 0 indexing. You can confirm that your dataset also has a 0,0,0 location. As you can see in my image below I was able to find the 0 index of IJK using the Data Probe and the MRHead sample dataset.

 ![{B10FC4B6-9738-471A-A873-4383920AACA3}](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/a/4a8a7e11142518b3bab8ba0494e9fb21ae7637a2.png)

---

<div class="post-metadata">

### Author: ![MPARHAM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mparham/32/70304_2.png) [@MPARHAM](https://discourse.slicer.org/u/MPARHAM)
#### Post date: [February 25, 2025, 9:16pm UTC](https://discourse.slicer.org/t/inquiry-spatial-coordinates/41874/7 "2025-02-25T21:16:16Z")

</div>

You are correct. Indexing is 0,0,0 and MATLAB’s indexing begins at 1.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/d/5d3e06e261355f3b2ac587f48cc30526f7187591.png)

Also I would like to say that 3D slicer’s community is very responsive and helpful. Thank you both @jamesobutler & @muratmaga for you insights. They were both very helpful.
