# How to save the deformation field ?

**URL:** https://discourse.itk.org/t/how-to-save-the-deformation-field/1910
**Category:** Beginner Questions
**Tags:** registration
**Created:** [May 24, 2019, 9:21am UTC](https://discourse.itk.org/t/how-to-save-the-deformation-field/1910 "2019-05-24T09:21:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![EE18D504\_SINDHURA\_C](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/b3f665/32.png) [@EE18D504\_SINDHURA\_C](https://discourse.itk.org/u/EE18D504_SINDHURA_C)
#### Post date: [May 24, 2019, 9:21am UTC](https://discourse.itk.org/t/how-to-save-the-deformation-field/1910/1 "2019-05-24T09:21:10Z")

</div>

I am executing deformableregistration15.cxx  
I wonder how to save the deformation field? In which format should I save it?  
It didn’t happen with both mhd and mha formats.

---

<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: [May 24, 2019, 1:06pm UTC](https://discourse.itk.org/t/how-to-save-the-deformation-field/1910/2 "2019-05-24T13:06:08Z")

</div>

Deformation field is an image of vectors, and can be written to disk just like any other image. That example already has the code for writing. But that only happens if you supply all the command line parameters (filenames). What is the exact problem you are running into?

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [May 24, 2019, 9:51pm UTC](https://discourse.itk.org/t/how-to-save-the-deformation-field/1910/3 "2019-05-24T21:51:34Z")

</div>

It is also possible to use the [TransformFileWriter](https://itk.org/Doxygen/html/classitk_1_1TransformFileWriterTemplate.html) to write the transformation to an HDF5 file.

---

<div class="post-metadata">

### Author: ![EE18D504\_SINDHURA\_C](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/b3f665/32.png) [@EE18D504\_SINDHURA\_C](https://discourse.itk.org/u/EE18D504_SINDHURA_C)
#### Post date: [May 25, 2019, 8:16am UTC](https://discourse.itk.org/t/how-to-save-the-deformation-field/1910/4 "2019-05-25T08:16:50Z")

</div>

Thanks @matt.mccormick I stored it in .tfm format. How to read it? how to visualize it?

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [May 25, 2019, 11:47am UTC](https://discourse.itk.org/t/how-to-save-the-deformation-field/1910/5 "2019-05-25T11:47:26Z")

</div>

`.h5` is recommended. You can [visualize it with the 3D Slicer Transform Visualizer](https://www.slicer.org/wiki/Documentation/Nightly/Modules/TransformVisualizer).
