Inquiry Spatial Coordinates

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.

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.

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

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.

1 Like

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

1 Like

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!

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.

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.

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

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.

1 Like