# The shape will be changed when I turn an array to volume

**URL:** <https://discourse.slicer.org/t/the-shape-will-be-changed-when-i-turn-an-array-to-volume/29920>\
**Category:** Community\
**Tags:** python\
**Created:** [June 8, 2023, 3:31pm UTC](https://discourse.slicer.org/t/the-shape-will-be-changed-when-i-turn-an-array-to-volume/29920 "2023-06-08T15:31:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![slicer365](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/slicer365/32/67549_2.png) [@slicer365](https://discourse.slicer.org/u/slicer365)\
**Post date:** [June 8, 2023, 3:31pm UTC](https://discourse.slicer.org/t/the-shape-will-be-changed-when-i-turn-an-array-to-volume/29920/1 "2023-06-08T15:31:43Z")

</div>

I use the script slicer.util.arrayFromVolume(volumeNode) get an array.

Then I use the script slicer.util.addVolumeFromArray(array), the volume’s shape is changed as is shown in the picture.

Why? How can I get the original volume from the array.

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

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [June 8, 2023, 3:47pm UTC](https://discourse.slicer.org/t/the-shape-will-be-changed-when-i-turn-an-array-to-volume/29920/2 "2023-06-08T15:47:59Z")

</div>

You can specify the ijkToRAS transform from the source volume, something like this:

```auto
ijkToRAS = vtk.vtkMatrix4x4()
volumeNode.GetIJKToRASMatrix(ijkToRAS)
segArray = numpy.stack(segmentationArrays)
segNode = slicer.util.addVolumeFromArray(segArray, ijkToRAS=ijkToRAS, name="Segmentation")

```
