# How to store a 3d deformation field array into an mhd image

**URL:** https://discourse.itk.org/t/how-to-store-a-3d-deformation-field-array-into-an-mhd-image/4761
**Category:** Uncategorized
**Created:** [January 28, 2022, 3:31am UTC](https://discourse.itk.org/t/how-to-store-a-3d-deformation-field-array-into-an-mhd-image/4761 "2022-01-28T03:31:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Hongying\_Feng](https://discourse.itk.org/user_avatar/discourse.itk.org/hongying_feng/32/1984_2.png) [@Hongying\_Feng](https://discourse.itk.org/u/Hongying_Feng)
#### Post date: [January 28, 2022, 3:31am UTC](https://discourse.itk.org/t/how-to-store-a-3d-deformation-field-array-into-an-mhd-image/4761/1 "2022-01-28T03:31:06Z")

</div>

I have a numpy array of size (160,512,512,3), standing for a 3D deformation field.  
I am trying to save this array to an image (desired type is itk.Image[itk.Vector[itk.F,3],3]) by using itk.GetImageFromArray.  
The code can run without errors. But after I checked the image that I got. I found the size was (512,512,3,3) even though the image took the correct amount of memery (about three times of the corresponding image with type itk.Image[[itk.F,3],3] ).  
Can anyone help me to figure this out?  
I am using itk 5.2.1

---

<div class="post-metadata">

### Author: ![Hongying\_Feng](https://discourse.itk.org/user_avatar/discourse.itk.org/hongying_feng/32/1984_2.png) [@Hongying\_Feng](https://discourse.itk.org/u/Hongying_Feng)
#### Post date: [January 28, 2022, 4:28am UTC](https://discourse.itk.org/t/how-to-store-a-3d-deformation-field-array-into-an-mhd-image/4761/2 "2022-01-28T04:28:05Z")

</div>

Sorry to bother, the problem has been solved by using itk.image\_from\_array with ttype specified.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [January 28, 2022, 2:38pm UTC](https://discourse.itk.org/t/how-to-store-a-3d-deformation-field-array-into-an-mhd-image/4761/3 "2022-01-28T14:38:33Z")

</div>

You might want to share your code in case someone runs across this thread in the future.
