Use of inverse warp file created with ANTs within MRtrix3

I used the ANTs tools to normalize my T1 image (previously registered to my DWI image) to MNI152 space. Now I would like to use the inverse warp file created by ANTs (called glanatInverseComposite.nii) to register my .tck file to MNI152 space. MRtrix3 does not seem to accept the inverse warp file created by ANTs. Could you tell me how I can modify the ANTs inverse warp file so that MRtrix3 can read it?
Thank you for your help,

1 Like

Hello Franziska

This post may help you: Registration: using transformations generated from other packages

It details how to use an ANTs warp with mrtransform



1 Like

Hi Fiona,

Thank you for your help.
I followed the instructions in the link, however, when applying the transformations to the identity warp of my reference image (MNI152 template) with

antsApplyTransforms -d 3 -e 0 -i inv_identity_warp.nii -o inv_mrtrix_warp.nii -r T1.nii -t antsInverseWarp.nii.gz --default-value 2147483647

I receive a 3D image as output, but the next step “fix warp” (warpcorrect inv_mrtrix_warp.nii inv_mrtrix_warp_corrected.mif -marker 2147483647) seems to require a 4D image, as I receive the error message “[ERROR] input warp is not a 4D image”.

Do you have an idea what is going wrong here?

Thank you,

Hi Fanziska

This is not my field of expertise, but the registration instructions state:

warpinit input.mif identity_warp[].nii

for i in {0..2}; do
    antsApplyTransforms -d 3 -e 0 -i identity_warp${i}.nii -o mrtrix_warp${i}.nii -r reference.nii -t ants1Warp.nii.gz -t ants0GenericAffine.mat --default-value 2147483647

warpcorrect mrtrix_warp[].nii mrtrix_warp_corrected.mif -marker 2147483647

beware of using the "[]"and the loop 



Hi William,
Great - thank you for your help! It worked now!

Just to make sure that I understood things right:

  1. First, I perform my non-linear registration using ANTs SyN to register my T1 to MNI152 space
  2. Then, I initialize the warp of the MNI152 template
  3. To apply the transformation to my initialized MNI152 warp, with my T1 image as reference image, I use the inverse warp file (previously received as ANTs output in step 1) as my transformation input file
  4. I then fix the warp with warpcorrect
  5. I can then use this MRtrix compatible inverse warp file to transform my .tck file to MNI152 space using tcktransform

As a last note: I only entered the inverse warp file as transformation file, but left the .mat file out, as I did not receive that as ANTs output. Is that fine or does that lead to different results?

Thank you very much for your help,

Hi Franziska,

Again, I am not an expert :slight_smile: Nevertheless, your strategy seems fine. The only thing missing seems to be the inverse warp/transformation from T1 to DWI space, assuming you did the tracking in DWI space (use transformcompose to combine transforms/warps). If you transformed and resampled DWI into T1 space and thus did the tracking in “T1” space, you are fine. You probably already did, but visually check how well the warped tracks fit MNI space.

Depending on your goal and sample characteristics, you could optimize the warping of tracks into MNI space a bit. You could compute FA images and warp those to FA MNI space. It is not trivial what template to pick though. I just noticed that templates such as FSL_HCP1065_FA_1mm.nii.gz, FMRIB58_FA_1mm.nii.gz, and ENIGMA_DTI_FA.nii.gz differ from each other in subtle but potentially significant ways. For example, the JHU-ICBM-labels-1mm.nii.gz wm ROI atlas often used in automated TBSS analysis fits the ENIGMA template nicely but not so the FSL MNI FA templates. The motto here is always visually to check your separate processing steps :slight_smile:
Another possibility is partially using the population template approach in the fixel-based analyses. For example, you could use the individual warps from individual wmfod to template wmfod space, to warp FA images into wmfod template space, create an average FA image in wmfod template space, and use the latter to derive a warp to MNI space.

There are also some multimodal approaches that might give even better results (e.g., )

Anyway, it all depends on what you want to achieve…sometimes it is best to keep things simple :wink:

Almost forgot … concerning, the “missing” affine ANTs transformation, it might be that this is embedded in the warp field. You have to check the ANTs documentation if this is the case


1 Like

Hi William,

Thanks a lot for your detailed answer and helpful advice! :slight_smile:

Regarding the missing inverse warp from T1 to DWI: I first registered T1 to DWI space by using the inverse warp of DWI to T1. I then used the T1 registered to DWI space for registration to MNI space.

The affine ANTs transformation indeed turned out to be already embedded in the warp field.

Thanks again a lot for your help,