问题
i'am looking for help with simpleITK, I'am 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" wich is a sitk member function, the writtent 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 realted topics but without any success Thank you in advance :)
来源:https://stackoverflow.com/questions/60854606/simple-itk-problem-when-saving-deformation-field-the-deformation-field-is-empt