InsightSoftwareConsortium / ITKElastix

An ITK Python interface to elastix, a toolbox for rigid and nonrigid registration of images
Apache License 2.0
213 stars 23 forks source link

Applying series of registrations to moving image label map #277

Closed tenres closed 6 months ago

tenres commented 7 months ago

Hello, this is more of a question than a problem. I chained 3 registrations in series (affine, BSpline1, Bspline2) by initializing each registration with the transform obtained from the previous one (i.e., setting the "InitialTransformParameterFileName" of the current registration to the previous registration output parameter file). The registrations completed successfully and the result looks good. I then transform a label map (segmentation) from the moving image through the 3 registrations into the fixed image space using transformix. Few questions here:

  1. For transforming the moving image label (segmentation), I set the transformix SetTransformParameterObject to only the final BSpline2 output parameter file and update. Just wanted to confirm this is the correct way and it is not required to read the other transforms (affine and Bspline1) and perform the 3 transformations explicitly. The Bspline2 parameter already has the path to BSpline1 parameter file in its InitialTransformParameterFileName, which in turn has the path to the affine parameter file in its InitialTransformParameterFileName and transformix will account for this.
  2. Doing it the above way (set the transformix SetTransformParameterObject to only the final BSpline2 output parameter file and update), is it correct assume that the resampling happens only at the end after transformix applies the chained transformations affine, Bspline1 and Bspline2? Or does it happen after each of the 3 transforms?
  3. I also set the "ResampleInterpolator" to "FinalNearestNeighborInterpolator" since I am transforming a binary segmentation label map. This I do only for the last transform Bspline2, assuming the interpolation happens only at the end. But does it have to be set for all the 3 transforms? Thanks!
dzenanz commented 7 months ago

Everything sounds right to me. @N-Dekker or @ViktorvdValk might also pitch in.

tenres commented 7 months ago

Thanks for confirming @dzenanz. @N-Dekker, @ViktorvdValk, just checking in if you have other comments. Thanks!

N-Dekker commented 7 months ago

Your approach sounds right to me as well. Indeed, it is sufficient to just specify the final transform parameter file to transformix (Bspline2, in your case), it will then find the previous two transforms (affine, BSpline1) by "InitialTransformParameterFileName".

"ResampleInterpolator" only needs to be set in the final transform parameter file (BSpline2). The resampling only happens at the end.

Hope that helps!

tenres commented 6 months ago

Thanks for the confirmation. Closing this issue.