# InPlace and Order of the Operations in Transform

Dear All,

By the manual I do not understand the difference between InPlace True and False. Could you please explain? What it is adequate.

##Don’t optimize in-place, we would possibly like to run this cell multiple times.
registration_method.SetInitialTransform(initial_transform, inPlace=False)

And please confirm. The resulting transform of a registration must be applied to the moving image, first the rotation and the then translation.

Thanks,

Luis Gonçalves

Hello @Luis_Carlos_Carneiro,

`inPlace=True` means that `initial_transform` is modified by the registration, if it is `False` then the transform isn’t modified. Please see the documentation for details.

The resulting transform maps points from the fixed image to the moving image. Please read the Registration Overview and the Fundamental Concepts pages to gain better understanding of how transforms are applied.

Thanks for the confirmation (again). There was a contradiction at a newer post.

But which the advantages of inPlace=True and of inPlace=False? In which situations one gives better than the other?

In sitk.Euler3DTransform() parameters output:

#Insight Transform File V1.0
#Transform 0
Transform: CompositeTransform_double_3_3
#Transform 1
Transform: Euler3DTransform_double_3_3
Parameters: 0.0011635719083707028 -0.05268331433173672 0.0395152745443439 1.3770413687711978 3.3794554573645668 3.4098819618569753
FixedParameters: 54.6 54.15 33.9 0

I must apply the rotation first to the fixed image then the translation (divided by the dimensions to give voxels). This to match the moving image.

Sorry, I hope to not annoy all you.

I saw in the link you presented the following text:

### Features of Interest

#### Transforms and image spaces

While the goal of registration, as defined above, refers to a single transformation and two images, the ITKv4 registration and the SimpleITK ImageRegistrationMethod provide additional flexibility in registration configuration.

From a coordinate system standpoint ITKv4 introduced the virtual image domain , making registration a symmetric process so that both images are treated similarly. As a consequence the ImageRegistrationMethod has methods for setting three transformations :

1. SetInitialTransform ToTo - composed with the moving initial transform, maps points from the virtual image domain to the moving image domain, modified during optimization.

2. SetFixedInitialTransform TfTf - maps points from the virtual image domain to the fixed image domain, never modified.

3. SetMovingInitialTransform TmTm- maps points from the virtual image domain to the moving image domain, never modified.

The transformation that maps points from the fixed to moving image domains is thus:

pmoving=To(Tm(T^{−1}_f(pfixed)))

*******************************************************************************************+

In example

http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/Python_html/60_Registration_Introduction.html

which is To,Tm,Tf?

Problem solved. Sorry.

Describing what the problem was, and how you solved it will be helpful if someone in the future comes across this thread.

I was doing the rotation Z->Y->X instead of X->Y->Z. But there space for better results. All cases improved a lot but not yet perfect.

Some cases are good enough but others are not the best fit despite a close fit. I do not know yet if a mine problem or a convergence problem because of the images or algorithm.

1 Like

In the above formula the transform is inverse. Seems that to convert the fixed image in the moving image it is needed the inverse transform. And seems the transform is from the moving to the fixed.