Hi! I tried to register two images, using the following code:
Registration framework setup.
registration_method = sitk.ImageRegistrationMethod()
#Set Interpolator
registration_method.SetInterpolator(sitk.sitkLinear)
#Set Metric as Mutual Information
#registration_method.SetMetricAsANTSNeighborhoodCorrelation(radius=100)
registration_method.SetMetricAsMattesMutualInformation(numberOfHistogramBins=50)
registration_method.SetMetricSamplingStrategy(registration_method.RANDOM)
registration_method.SetMetricSamplingPercentage(0.01)
#Set Optimizer
registration_method.SetOptimizerAsGradientDescent(learningRate=0.1, numberOfIterations=1000, convergenceMinimumValue=1e-6, convergenceWindowSize=10)
registration_method.SetOptimizerScalesFromPhysicalShift()
#Set initial transform
registration_method.SetInitialTransform(initial_transform, inPlace=True)
# Setup for the multi-resolution framework
registration_method.SetShrinkFactorsPerLevel(shrinkFactors = [4,2,1])
registration_method.SetSmoothingSigmasPerLevel(smoothingSigmas = [2,1,0])
registration_method.SmoothingSigmasAreSpecifiedInPhysicalUnitsOn()
#Show the graph of Mi against iterations
#registration_method.AddCommand(sitk.sitkStartEvent, metric_start_plot)
#registration_method.AddCommand(sitk.sitkEndEvent, metric_end_plot)
#registration_method.AddCommand(sitk.sitkMultiResolutionIterationEvent, metric_update_multires_iterations)
#registration_method.AddCommand(sitk.sitkIterationEvent, lambda: metric_plot_values(registration_method))
#Execute the registration
final_transform = registration_method.Execute(fixed_image, moving_image)
#Print results
print('Final metric value: {0}'.format(registration_method.GetMetricValue()))
print('Optimizer\'s stopping condition, {0}'.format(registration_method.GetOptimizerStopConditionDescription()))
print(final_transform)
However, every time I run the code with the exact same two images, the offset (from the final transform), metric value, changes. Is there a reason why it changes?