Error With Converting RAS to IJK coordinates

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

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.

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:

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

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?

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.

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.

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

None

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

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

vtkMRMLScalarVolumeNode (0x7fe62896cff0)
ID: vtkMRMLScalarVolumeNode2
Class: vtkMRMLScalarVolumeNode

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

Wonderful, thanks so much!

1 Like