Hello,
I am trying to run groupwise registrations in SimpleITK and ITKElastix, but with either the resulting images just seem to be flipped vertically. My original images are .tifs; I converted them to grayscale and then combined them into a .nii file before reading in. I am using code from tutorials for SimpleElastix in SimpleITK (Groupwise Registration — SimpleElastix 0.1 documentation) and for ITKElastix ( ITKElastix/examples/ITK_Example06_GroupwiseRegistration.ipynb at main · InsightSoftwareConsortium/ITKElastix · GitHub ). I have not altered the ITKElastix code; I only altered the SimpleITK code to read in a single .nii file rather than read in a folder and join the images together:
SimpleITK:
import SimpleITK as sitk
population = sitk.ReadImage("syngcleansizedgrey.nii")
vectorOfImages = sitk.VectorOfImage()
#for filename in population:
#vectorOfImages.push_back(sitk.ReadImage(filename))
image = vectorOfImages
# Register
elastixImageFilter = sitk.ElastixImageFilter()
elastixImageFilter.SetFixedImage(population)
elastixImageFilter.SetMovingImage(population)
elastixImageFilter.SetParameterMap(sitk.GetDefaultParameterMap('groupwise'))
elastixImageFilter.Execute()
sitk.WriteImage(population, 'groupwise.tif')
ITKElastix:
import itk
# Load folder containing images.
images = itk.imread("syngcleansizedgrey.nii", itk.F) #", itk.F" loads images as floats
# Call registration function
# both fixed and moving image should be set with the vector_itk to prevent elastix from throwing errors
result_image, result_transform_parameters = itk.elastix_registration_method(
images, images, parameter_object=parameter_object, log_to_console=True
)
# Call registration function
# both fixed and moving image should be set with the vector_itk to prevent elastix from throwing errors
result_image, result_transform_parameters = itk.elastix_registration_method(
images, images, parameter_object=parameter_object, log_to_console=True
)
# Save image with itk
itk.imwrite(result_image, "exampleoutput/groupwise.tif")
With either, when I compare the output file to the original image, each image is simply vertically flipped. I would be very grateful for any insight on what I am doing wrong!
Thank you,
Rock