21 """ A SimpleITK example demonstrating image registration using optimizer
25 import SimpleITK
as sitk
31 "<fixedImageFile> <movingImageFile>",
32 "<outputTransformFile>",
44 sitk.CenteredTransformInitializerFilter.GEOMETRY,
48 registration_method.SetMetricAsCorrelation()
49 registration_method.SetMetricSamplingStrategy(registration_method.NONE)
50 registration_method.SetInterpolator(sitk.sitkLinear)
51 registration_method.SetOptimizerAsGradientDescent(
53 numberOfIterations=300,
54 convergenceMinimumValue=1e-6,
55 convergenceWindowSize=10,
57 registration_method.SetOptimizerScalesFromPhysicalShift()
58 registration_method.SetInitialTransform(transform, inPlace=
True)
59 registration_method.SetOptimizerWeights([0, 0, 1, 1, 1, 1])
60 registration_method.Execute(fixed_image, moving_image)
63 print(f
"Final transform parameters: {transform.GetParameters()}")
65 "Optimizer stop condition: "
66 + f
"{registration_method.GetOptimizerStopConditionDescription()}"
68 print(f
"Iteration: {registration_method.GetOptimizerIteration()}")
69 print(f
"Metric value: {registration_method.GetMetricValue()}")