# Building the ijk to RAS transform from a nrrd file

**URL:** <https://discourse.slicer.org/t/building-the-ijk-to-ras-transform-from-a-nrrd-file/1513>\
**Category:** Support\
**Tags:** nrrd\
**Created:** [November 23, 2017, 11:58pm UTC](https://discourse.slicer.org/t/building-the-ijk-to-ras-transform-from-a-nrrd-file/1513 "2017-11-23T23:58:04Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 24, 2017, 1:05am UTC](https://discourse.slicer.org/t/building-the-ijk-to-ras-transform-from-a-nrrd-file/1513/2 "2017-11-24T01:05:47Z")

</div>

Almost correct. IJKToRAS is a homogeneous transformation matrix, which contains axis directions in the top-left 3x3 sub-matrix, origin in the first 3 values of 4th column, and [0,0,0,1] in the 4th row (so you don’t “add” the translation component but concatenate). In Matlab syntax:

```
ijk_to_lps = [[space_directions, space_origin]; [0 0 0 1]]
lps_to_ras = diag([-1 -1 1 1])
ijk_to_ras = lps_to_ras * ijk_to_lps
```

---

_[View the full topic](https://discourse.slicer.org/t/building-the-ijk-to-ras-transform-from-a-nrrd-file/1513)._
