I am using the rigid registration module to compute a registratration between two Ct scans. The compute function returns a transformation3d object. How do I apply this transformation? Do I translate the origin by the translation returned by get translate?
TL;DR how do I apply the computed translation?
Hi Ben W,
To apply the computed transformation3D :
First, use your transformation3D (transform) object directly with the deformImage method
deformedImage = transform.deformImage(moving)
Then: use the resampler with the deformed image to align the two grids
resampledOnFixedGrid = resampleImage3DOnImage3D(deformedImage, fixedImage=fixed, fillValue=-1000)
You can check out our example on our website : Rigid registration | OpenTPS
Regards,
Eliot
Hi Ben,
did it work? I have done a similar thing in the past (i.e. reading a DICOM reg file) but I used a different function (i.e. transform3D.deformData) to perform the transform:
# Perform registration
transform3D = Transform3D()
transform3D.setCenter('dicomOrigin') # other option is 'imgCenter' but in this case we should use dicomOrigin
transform3D.setMatrix4x4(tformMatrix_1)
mr_reg = transform3D.deformData(mr, outputBox='keepAll')
# resample to CT grid
mr_reg.resample(ct.spacing, ct.gridSize, ct.origin)
Hey Ana,
Sorry for the late reply took me a while to figure out the best way to test the outputs. The above method given by Eliot does work. Is there a difference with what you have done or should it give the same output?
After looking at our source code, the two methods are pretty similar.
In @Ana_Barragan_Montero code, a Transform3D object is initialized and then the transformation matrix is set. In the example version, the Transform3D object is initialized and computed by the the RigidRegistration.compute() method.
As for the difference between deformImage and deformData, deformData is a more flexible implementation for deforming the moving image i.e. you can choose the interpolation order and if the computed angles (of the Tranform3D) are all 0° are simple translation will be applied while with the deformImage method, the interpolation order is always 1 (linear) and there is no case check for 0° angles (but this should not change that much the output).
Hope this clarifies things for you.