# Convert between RAS and numpy array indices

**URL:** https://discourse.slicer.org/t/convert-between-ras-and-numpy-array-indices/19408
**Category:** Development
**Created:** [August 30, 2021, 12:05am UTC](https://discourse.slicer.org/t/convert-between-ras-and-numpy-array-indices/19408 "2021-08-30T00:05:46Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![ungi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ungi/32/78573_2.png) [@ungi](https://discourse.slicer.org/u/ungi)
#### Post date: [August 31, 2021, 8:04pm UTC](https://discourse.slicer.org/t/convert-between-ras-and-numpy-array-indices/19408/2 "2021-08-31T20:04:39Z")

</div>

First, download MRHead data from Sample Data module

```auto
import numpy as np
volumeArray = slicer.util.array("MRHead") # Get the image data in numpy array format
volumeArray[60, 127, 150] = 0 # Make one voxel black, numpy array is in KJI, not IJK.
volumeNode = slicer.mrmlScene.GetFirstNodeByName("MRHead")
volumeNode.Modified() # I think this is needed to let Slicer know the image was modified.
ijkToRasMatrix = vtk.vtkMatrix4x4()
volumeNode.GetIJKToRASMatrix(ijkToRasMatrix)
ijkPoint = np.array([150, 127, 60]) # This is IJK, opposite order compared to KJI.
rasPoint = ijkToRasMatrix.MultiplyFloatPoint(np.append(ijkPoint, 1))
print(rasPoint)

```

If you hover your mouse over the new black point in the image, Data Probe should show the same coordinates that were printed at the end of this script.

---

_[View the full topic](https://discourse.slicer.org/t/convert-between-ras-and-numpy-array-indices/19408)._
