ANTsX / ANTs

Advanced Normalization Tools (ANTs)
Apache License 2.0
1.19k stars 380 forks source link

how to get the affine flow!!!! #1796

Closed anamazingclown closed 5 days ago

anamazingclown commented 5 days ago

Thank you very much for your work. I have a question and hope you can answer it? I want to obtain the displacement field from an affine transformation. How can I get a 2D flow from mmtf['fwdtransforms'] so that I can use it as a input to a Spatial Transformer, such as the one in VoxelMorph? image

I am looking forward to receiving your answer,Thanks!

ntustison commented 5 days ago

In ANTs, you can use antsApplyTransforms. Look at the second option

     -o, --output warpedOutputFileName
                  [warpedOutputFileName or compositeDisplacementField,<printOutCompositeWarpFile=0>]
                  Linear[genericAffineTransformFile,<calculateInverse=0>]
          One can either output the warped image or, if the boolean is set, one can print 
          out the displacement field based on the composite transform and the reference 
          image. A third option is to compose all affine transforms and (if boolean is 
          set) calculate its inverse which is then written to an ITK file. 
anamazingclown commented 5 days ago

Thank you for your response. However, if I am using warped_img = ants.apply_transforms(fixed=f_img, moving=m_img, transformlist=mmtf['fwdtransforms'], interpolator="linear"), how can I get the affine matrix?

ntustison commented 5 days ago

This is an ANTsPy question. Please close this issue here and open one over at that repo with your question.

anamazingclown commented 5 days ago

ok Thank you very much for your help. I apologize for bothering you again