GetMatrix from SimpleITK ImageRegistrationMethod.Execute transform result

Is there a way to GetMatrix from the base transform returned from ImageRegistrationMethod.Execute(…)?
final_transform = registration_method.Execute(fixed_image, moving_image)
Final_transform doesn’t have access to GetMatrix even though
str(final_matrix) shows the Matrix in string form.

Matrix: \n       0.969854 0.227518 -0.0872828 \n       -0.225962 0.97375 0.0274403 \n       0.0912348 -0.00689049 0.995806 \n

The descended class Euler3DTransform has GetMatrix but casting failed.

SimpleITK::ERROR: Transform is not of type Euler3DTransform!

The final_transform is a generic wrapper around a CompositeTransform, so if you only have one transformation inside you can get the specific transform this way:

euler3d_transform = sitk.CompositeTransform(final_transform).GetBackTransform()

There is an issue discussing if the return type should be changed here:

If you pass inPlace=True to SetInitialTransform then the same transform object provided in the argument is updated. This may be preferred to the additional conversions in the code @zivy provided.