Convert a displacement filed nifty image to SITK transform type

Hello everyone,

I have a displacement field Nifti format (field.nii.gz). How can I convert it to sitk.transform type (field.tfm) so that I can use it as transformation in SITK?

I really appreciate any help you can provide,
Vahdaneh

Hello @VHK,

This is easily done:

import SimpleITK as sitk

transform = sitk.DisplacementFieldTransform(sitk.ReadImage('field.nii.gz', sitk.sitkVectorFloat64))

For full details I recommend going through the toolkit’s Jupyter notebook repository and specifically the transformations notebook.

1 Like