I'm looking for help with simpleITK, I'm working with NII files in order to calculate the deformation field. I use Python and simpleITK (simpleitk 1.2.0rc2.dev1167+gd4cf2). I can easily register my images or volumes but I cannot get the deformation field!
When I print it in the console simpleITK tells me that the vector is an image as predicted but when I try to save it with "WriteImage" which is a sitk member function, the written image is full of null values
the code used to do that:
def RegistrationGel(pathImage1,pathImage2):
elastixImageFilter = sitk.ElastixImageFilter()
elastixImageFilter.SetFixedImage(sitk.ReadImage(pathImage1))
elastixImageFilter.SetMovingImage(sitk.ReadImage(pathImage2))
parameterMapVector = sitk.VectorOfParameterMap()
parameterMapVector.append(sitk.GetDefaultParameterMap("affine"))
#parameterMapVector.append(sitk.GetDefaultParameterMap("bspline"))
elastixImageFilter.SetParameterMap(parameterMapVector)
elastixImageFilter.Execute()
sitk.WriteImage(elastixImageFilter.GetResultImage(),"C:/Users/Armand/Desktop/RecalageGel/Output/resultImageGel.nii")
transformixImageFilter = sitk.TransformixImageFilter()
transformixImageFilter.SetMovingImage(sitk.ReadImage(pathImage2))
transformixImageFilter.ComputeDeformationFieldOn()
#transformixImageFilter.SetOutputDirectory("C:/Users/Armand/Desktop/RecalageGel/Output/DeformationFIELD.nii")
transformixImageFilter.SetTransformParameterMap(elastixImageFilter.GetTransformParameterMap())
transformixImageFilter.Execute()
sitk.WriteImage(transformixImageFilter.GetDeformationField(),"C:/Users/Armand/Desktop/RecalageGel/Output/OutputDef.nii")
I also tried to set the output directory of transformixImageFilter but without success too. I really do not understand what's happening here... Does anyone have a solution or the same issue? I have read some related topics but without any success
I had the same problem but strangely now it seemed to worked.. here is my code:
the output in the terminal for the transformix part looked like this: