# Creating an array to use in: volumeNode.GetIJKToRASDirections (array)

**URL:** <https://discourse.slicer.org/t/creating-an-array-to-use-in-volumenode-getijktorasdirections-array/4276>\
**Category:** Development\
**Created:** [October 3, 2018, 6:54pm UTC](https://discourse.slicer.org/t/creating-an-array-to-use-in-volumenode-getijktorasdirections-array/4276 "2018-10-03T18:54:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nassir](https://avatars.discourse-cdn.com/v4/letter/n/9de053/32.png) [@Nassir](https://discourse.slicer.org/u/Nassir)\
**Post date:** [October 3, 2018, 6:54pm UTC](https://discourse.slicer.org/t/creating-an-array-to-use-in-volumenode-getijktorasdirections-array/4276/1 "2018-10-03T18:54:18Z")

</div>

Hello,

I’m trying to use the function GetIJKToRASDirections on a volume to get its IJK to RAS direction matrix. I previously transformed this image, and will now use the matrix to transform (using the set functions) another image that was acquired at about the same time. Unfortunately, I did not save the transform matrix.

The GetIJKToRASDirections function requires an output array with type ‘double’ and dimensions “dirs[3][3]” ([Slicer: vtkMRMLVolumeNode Class Reference](http://apidocs.slicer.org/master/classvtkMRMLVolumeNode.html#a486704c0cef8b42bf5505967669ab674)). I was not able to use normal python methods to create a 3 by 3 array. I also think there’s probably a simple way to do this Slicer, but I can’t find it on the script repositories.

TLDR: how do I create a 3 by 3 array of type ‘double’ to use in volumeNode.GetIJKToRASDirections (array).

Thank you for your help.

PS: I’m slicer Slicer 4.9

---

<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 3, 2018, 7:25pm UTC](https://discourse.slicer.org/t/creating-an-array-to-use-in-volumenode-getijktorasdirections-array/4276/2 "2018-10-03T19:25:19Z")

</div>

Here is a post with some example code that should help:

> [@ACPC transform question](https://discourse.slicer.org/t/acpc-transform-question/3525/2):
>
> Hi Alexis, You can try this code on the Python console: import numpy as np import SampleData def getSampleVolume(): # Download MRHead sampleDataLogic = SampleData.SampleDataLogic() volumeNode = sampleDataLogic.downloadMRHead() return volumeNode def getMatrixToACPC(ac, pc, ih): # Anteroposterior axis pcAc = ac - pc yAxis = pcAc / np.linalg.norm(pcAc) # Lateral axis acIhDir = ih - ac xAxis = np.cross(yAxis, acIhDir) xAxis /= np.linalg.norm(xAxis) …

---

<div class="post-metadata">

**Author:** ![Nassir](https://avatars.discourse-cdn.com/v4/letter/n/9de053/32.png) [@Nassir](https://discourse.slicer.org/u/Nassir)\
**Post date:** [October 4, 2018, 11:11pm UTC](https://discourse.slicer.org/t/creating-an-array-to-use-in-volumenode-getijktorasdirections-array/4276/3 "2018-10-04T23:11:56Z")

</div>

Did not answer the question directly but got me where I should have been looking.

Thanks!
