ANTsX / ANTs

Advanced Normalization Tools (ANTs)
Apache License 2.0
1.16k stars 375 forks source link

Combine 2 transform0GenericAffine.mat files into 1 #602

Closed javierjuan closed 4 years ago

javierjuan commented 6 years ago

Hi, is there any tool in ANTs to combine 2 transform0GenericAffine.mat files (obtained with antsRegistration) into a single one (Not a composite transform)? I know I can concatenate transformations with antsApplyTransforms to perform the registration but I want the "final" affine transformation matrix.

Thank you very much

ntustison commented 6 years ago
$ antsApplyTransforms --help 

...

     -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 

...
javierjuan commented 6 years ago

Thanks for the quick answer!

Yes, I saw that option and I tried it before posting the comment but sure I am not writing correctly the command because antsApplyTransform crashes

The command I tried was:

antsApplyTransforms -o Linear[outputTransform.mat] -t t10GenericAffine.mat t20GenericAffine.mat

I don't want to apply it to any input file so I didn't specify the "-i" flag nor "-r". Which is the correct syntax?

Thanks again

ntustison commented 6 years ago

You neglected to include the 2nd -t. Also, I can't remember if you have to specify the -r option. You might want to try that.

javierjuan commented 6 years ago

Hi Nick,

I've tried to add the second -t flag and the -r option but none of them works. I always get a segmentation fault. I've also tried other options and combinations wihout success. Do you have any idea about what might be missing?

Thank you very much

ntustison commented 6 years ago

test2DTranslation.txt

antsApplyTransforms -d 2 -i r16slice.nii.gz -r r16slice.nii.gz -o Linear[composeTranslation.mat,0] -v 1 -t test2DTranslation.txt -t test2DTranslation.txt