the pyramid. The 0-th level corresponds to the finest resolution.
opt_iter = [5, 10, 10]
registration_optimizer = SymmetricDiffeomorphicRegistration(metric, opt_iter)
Execute the optimization, which returns a DiffeomorphicMap object,
that can be used to register images back and forth between the static and moving
domains
mapping = registration_optimizer.optimize(static, moving,
static_affine, moving_affine, pre_align)
Now let"s warp the moving image and see if it gets similar to the static image
warped_moving = mapping.transform(moving)
To visually check the overlap of the static image with the transformed moving
image, we can plot them on top of each other with different channels to see
where the differences are located
overlay_middle_slices_coronal(static, warped_moving, "Static", "Warped moving", "warped_moving.png")
.. figure:: warped_moving.png
:align: center
**Moving image transformed under the (direct) transformation in green
on top of the static image (in red)**.
And we can also apply the inverse mapping to verify that the warped static image
is similar to the moving image
warped_static = mapping.transform_inverse(static)
overlay_middle_slices_coronal(warped_static, moving, "Warped static", "Moving", "warped_static.png")