# RGY views from numpy array

**URL:** <https://discourse.slicer.org/t/rgy-views-from-numpy-array/19141>\
**Category:** Development\
**Created:** [August 10, 2021, 1:50pm UTC](https://discourse.slicer.org/t/rgy-views-from-numpy-array/19141 "2021-08-10T13:50:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shatz](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@shatz](https://discourse.slicer.org/u/shatz)\
**Post date:** [August 10, 2021, 1:50pm UTC](https://discourse.slicer.org/t/rgy-views-from-numpy-array/19141/1 "2021-08-10T13:50:56Z")

</div>

When I first import my imaging file, it looks like this:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/f/2f2b4c2570e29c0aef334261baf6d9a781c4611e.jpeg)

If I then get it as a numpy array through `arr = array("imaging")` and write it as a new volume by doing `addVolumeFromArray(arr, name="newarray")`, it looks like this:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/1/31ff248d58dd66b949654cb8c3c48b95f654eeb6.jpeg)

I would like for the views to correspond to eachother. So for example, the red “R” view would be a top-down view of the patient in the new volume as well.

Is there any way to keep all the formatting of the volume it came from?

---

<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:** [August 10, 2021, 2:04pm UTC](https://discourse.slicer.org/t/rgy-views-from-numpy-array/19141/2 "2021-08-10T14:04:17Z")

</div>

A simple numpy array cannot store the image geometry (image origin, spacing, and axis directions = IJK to RAS matrix). You need to copy the IJKToRASMatrix from the original volume to the new volume.

```python
ijkToRas = vtk.vtkMatrix4x4()
originalVolumeNode.GetIJKToRASMatrix(ijkToRas)
newVolumeNode.SetIJKToRASMatrix(ijkToRas)

```
