# Error With Converting RAS to IJK coordinates

**URL:** <https://discourse.slicer.org/t/error-with-converting-ras-to-ijk-coordinates/1319>\
**Category:** Support\
**Created:** [October 30, 2017, 1:47pm UTC](https://discourse.slicer.org/t/error-with-converting-ras-to-ijk-coordinates/1319 "2017-10-30T13:47:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lpott005](https://avatars.discourse-cdn.com/v4/letter/l/ea5d25/32.png) [@lpott005](https://discourse.slicer.org/u/lpott005)\
**Post date:** [October 30, 2017, 1:47pm UTC](https://discourse.slicer.org/t/error-with-converting-ras-to-ijk-coordinates/1319/1 "2017-10-30T13:47:36Z")

</div>

Hello Slicer Community,

I was using this older post as a guide to convert RAS to IJK coordinates: [http://slicer-devel-archive.65872.n3.nabble.com/Get-coordinates-from-Fiducials-td4034132.html](http://slicer-devel-archive.65872.n3.nabble.com/Get-coordinates-from-Fiducials-td4034132.html)

But when I use “volumeNode.GetRASToIJKMatrix(rasToIJK)” I get an “AttributeError: ‘NoneType’ object has no attribute ‘GetRASToIJKMatrix’” Error call.

I’m using the Python interactor in 4.7.0, if that helps.

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [October 30, 2017, 1:48pm UTC](https://discourse.slicer.org/t/error-with-converting-ras-to-ijk-coordinates/1319/2 "2017-10-30T13:48:58Z")

</div>

It means that `volumeNode` is not pointing to a node – probably the call to `getNode(name)` or a similar call failed. You can check this in the python interactor:

```auto
>>> n = getNode("foo")
>>> print(n)
None

```

---

<div class="post-metadata">

**Author:** ![lpott005](https://avatars.discourse-cdn.com/v4/letter/l/ea5d25/32.png) [@lpott005](https://discourse.slicer.org/u/lpott005)\
**Post date:** [October 30, 2017, 2:17pm UTC](https://discourse.slicer.org/t/error-with-converting-ras-to-ijk-coordinates/1319/3 "2017-10-30T14:17:26Z")

</div>

Good call- I added print statements for everything up to that and I notice two things.

After `print(volumeNode)`, the interactor just returns an empty line. And after `print(volumeNode)`, the interactor returns “None”. Any pointers for how to fix that?

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [October 30, 2017, 2:34pm UTC](https://discourse.slicer.org/t/error-with-converting-ras-to-ijk-coordinates/1319/4 "2017-10-30T14:34:20Z")

</div>

`volumeNode` is still not set to a MRML node… Whatever call you are making to assign `volumeNode` is failing (e.g.: `volumeNode = ...`), so you need to start there and figure out why.

There’s not much more we can say without some code demonstrating the problem. Please post a short example of what you are doing using data from the [Sample Data](https://www.slicer.org/wiki/SampleData).

---

<div class="post-metadata">

**Author:** ![lpott005](https://avatars.discourse-cdn.com/v4/letter/l/ea5d25/32.png) [@lpott005](https://discourse.slicer.org/u/lpott005)\
**Post date:** [October 31, 2017, 12:58pm UTC](https://discourse.slicer.org/t/error-with-converting-ras-to-ijk-coordinates/1319/5 "2017-10-31T12:58:47Z")

</div>

I just want to get the transformation for RAS to IJK- I’m working with an older library that needs the voxel coordinates, not the mm coordinates.

I downloaded the sample data “MR-Head”, and placed a fiducial at (0,0,0) and used the same code- I gave me the same error though.

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [October 31, 2017, 1:29pm UTC](https://discourse.slicer.org/t/error-with-converting-ras-to-ijk-coordinates/1319/6 "2017-10-31T13:29:16Z")

</div>

```auto
volumeNode = slicer.util.getNode("FOO")
print volumeNode

```

> None

```auto
import SampleData
sampleDataLogic = SampleData.SampleDataLogic()
sampleDataLogic.downloadMRHead()

volumeNode = slicer.util.getNode("MRHead")
print volumeNode

```

> vtkMRMLScalarVolumeNode (0x7fe62896cff0)  
> ID: vtkMRMLScalarVolumeNode2  
> Class: vtkMRMLScalarVolumeNode  
> …

```auto
mat = vtk.vtkMatrix4x4()
volumeNode.GetRASToIJKMatrix(mat)
print mat

```

> vtkMatrix4x4 (0x7fe628ecd4b0)  
> Debug: Off  
> Modified Time: 9287983  
> Reference Count: 1  
> Registered Events: (none)  
> Elements:  
> 0 -1 0 133.929  
> -0 0 -1 116.786  
> 0.769233 0 0 66.6502  
> -0 0 -0 1

---

<div class="post-metadata">

**Author:** ![lpott005](https://avatars.discourse-cdn.com/v4/letter/l/ea5d25/32.png) [@lpott005](https://discourse.slicer.org/u/lpott005)\
**Post date:** [October 31, 2017, 1:56pm UTC](https://discourse.slicer.org/t/error-with-converting-ras-to-ijk-coordinates/1319/7 "2017-10-31T13:56:44Z")

</div>

Wonderful, thanks so much!
