Registration A->B & B->C, thus Transformation A->C using InitialTransform?

268 views
Skip to first unread message

Ricardo A Corredor J

unread,
Apr 15, 2021, 7:24:55 AM4/15/21
to elastix-imageregistration
Hi everyone,

I have a question that is partially related to this previous post, but I have troubles to see a clear answer to this.

As indicated in the subject, there is a basic affine registration to go from image A to B, and another one to go from image B to C. Images A, B and C have different dimensions! 

If I have a mask to be transformed from A to C, I could:
  1. Apply transformix twice which gives correct results
  2. Apply transformix once, using the TransformParameters.txt file of A->B and set the path of the TransformParameters.txt of B->C to the InitialTransformParametersFileName. This one is generating a result in the correct orientation but cropped!

Questions:
  - For option 2, it is really the case that I need to use the parameters file of the first transformation and set as InitialTransform the one of the second transformation or is it the opposite?
 - The fact that the images have different dimensions has an effect on the composition of transformations? 

Thanks in advance! 

RaC

Soren Christensen

unread,
Apr 15, 2021, 3:59:29 PM4/15/21
to elastix-imag...@googlegroups.com
Hi,
  - For option 2, it is really the case that I need to use the parameters file of the first transformation and set as InitialTransform the one of the second transformation or is it the opposite?

Yes, that is correct. The transforms specify the mapping from the fixed image coordinate system to that of the moving. So if you want to specify how to transform A to C [moving to fixed], then that would be the mapping C to A you are after. That can be constructed from the mappings C to B followed by B to A (which is the B-C followed by A->B you mention, in that order). Think of it as a coordinate in C that you look up first in B (using C to B mapping) and then in A using B 2 A mapping. Now in order to get the target sampling grid to match that of C, you need to make sure the last transformation in your chain contains the size, direction and spacing of C. You can manually edit it to do so. 
 - The fact that the images have different dimensions has an effect on the composition of transformations? 
No. It's useful to separate the concepts of transformation of coordinates and then regridding. Transformation allows you to "hop" between points in images (homologous points in your transform is good). Regridding determines where in the fixed image you start your "hops" from. So if you start from your C grid center locations then your resampled image will match the spacing, size and direction of C - which is typically what you want. 

Soren

--
You received this message because you are subscribed to the Google Groups "elastix-imageregistration" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elastix-imageregis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elastix-imageregistration/e4a025d5-811a-40be-abca-1ac38a35733dn%40googlegroups.com.

Ricardo A Corredor J

unread,
Apr 16, 2021, 10:29:02 AM4/16/21
to elastix-imageregistration
Thanks Soren for your reply.

Seems clear to me. I tried, as you suggested, to launch transformix using the transformation from the TransformParameters.txt file of A->B, set the path of the TransformParameters.txt of B->C to the InitialTransformParametersFileName, AND set the dimensions and image properties of C. This works, but I still cannot understand something.

In another application, I use elastix to perform a affine + bspline registration between image D and E (to continue with letters :P). In this situation, I run elastix with two parameters files and I call it like:
    elastix -moving D -fixed E -p AfffineParameters.txt -p BSplineParamenters -out out_dir

The registration process generates the two files:
  - TransformParameters.0.txt, containing the affine transformation
  - TransformParameters.1.txt, containing the parameters of the BSpline to apply the deformation

If we follow the logic we discussed in the first example, the TransformParameters.0.txt would had as InitialTransformation the TransformParameters.1.txt (as the affine is applied first). However, this is not the case ... The InitialTransformation of TransformParameters.1.txt points to the TransformParameters.0.txt, so like the one pointed in the InitialTransformation need to be applied first ... This seems to me the opposite of what you described. I really don't get that .... 

Maybe you have some hints to understand that better ? 

Thanks a lot!

RaC

Soren Christensen

unread,
Apr 16, 2021, 3:52:11 PM4/16/21
to elastix-imag...@googlegroups.com
I think the difference between the two situations is this:
"elastix -moving D -fixed E -p AfffineParameters.txt -p BSplineParamenters -out out_dir" 
asks for an affine transform that followed by a b-spline transform best maps from fixed to moving. There's no middle step as in an image transformed by the affine transform. So the order of the transforms is by way of the command line call affine followed by b-spline and this seems consistent with what you see "The InitialTransformation of TransformParameters.1.txt points to the TransformParameters.0.txt".
In your example you had 2 separate registrations that needed to be concatenated and we concatenated them by mapping in the order of coordinate transformation from fixed to moving instead of the order of the image operations, transforming the moving image two times. In the command line call it is specified by the argument order that the coordinate transformation is an affine followed by a b-spline transform.
If you did two command line calls, affine, then b-spline, you would have an intermediary image and you would be back to your original situation. The transform would be b-spline followed by affine to map from fixed to moving.
I hope that helps (and that it is correct)!
Soren


Ricardo A Corredor J

unread,
Apr 19, 2021, 4:06:00 PM4/19/21
to elastix-imageregistration
Thanks so much for providing some hints. However, I must admit that I'm still a bit lost.

If I understand well, you are telling me that doing two sequential registration gives different transformation parameters (files at least) that if I do it directly in one shot using the capabilities of elastix executable to provide two parameters files. Is that correct? Also, I understood that this is because elastix does not need to generate an intermediate image that would be the result of the affine registration, to then apply the bspline. 

However, I'm afraid it actually generates that intermediate image even internally ... maybe I'm wrong. At least, I see from the output files that all the results of the first registration process (the affine) are stored with the suffix 0.txt and the next ones (the bspline) with the 1.txt, including the intermediate image of "each" step:

elastix_affine_and_bspline.jpg

Then, if this is the case, it keeps being weird to me that in the second example (the affine + bspline) elastix produces and uses the transformation parameters file of the bspline and set InitialTransformation the affine, whilst for the first example I need to use the transf. params. file of the first registration (A->B) and set as InitialTransformation the second one (B->C) ... 

It is a bit weird, isn't it? Maybe it's just the phrasing of the parameter, but still ... I find that it's similar situations, but different setup... 

RaC
Reply all
Reply to author
Forward
0 new messages