Fmriprep: applying transforms (from-orig_to-T1w_mode-image query)

Hello everyone,

I wish to use the transforms generated by fmriprep to normalise some other images (e.g. PET and ASL)

In the dataset each subject has two sessions. For e.g. session 1 my plan was to:

  1. Get session 1 PET image coregistered to session 1 anatomical image
  2. Then use _from-orig_to-T1w_mode-image_xfm.txt to get the PET image aligned with the averaged anatomical image
  3. Then use _from-T1w_to-MNI152NLin2009cAsym_mode-image_xfm.h5 to move the PET image to MNI space

This is the same as suggested here:
https://neurostars.org/t/looking-for-affine-transform-mat-file-for-t1-to-epi/4261

After doing step 1 I would then do:

antsApplyTransforms
-i </path/to/pet.nii.gz>
-o </path/to/pet_space-MNI152NLin2009cAsym.nii.gz>
-r </path/to/reference_MNI_template.nii.gz>
-n NearestNeighbor
-t _from-T1w_to-MNI152NLin2009cAsym_mode-image_xfm.h5
-t _from-orig_to-T1w_mode-image_xfm.txt

However this does not seem to be working well, and on further investigation it seems to me as though ‘_from-orig_to-T1w_mode-image_xfm.txt’ is in fact the transform for the averaged_anatomical ->session specific image rather than session specific image ->averaged anatomical?

If this is correct, is there a straighforward way to calculate the inverse transform?

Thanks!

Rob

You’re right, I encountered the same problem and solved it by inverting the _xfm.txt transfomation using the invert transform flag inputs in the ApplyTransforms function.

Using python, this is the code that yielded good results:

at = ApplyTransforms()
at.inputs.input_image = ‘/path/to/ROI_1.nii.gz’
at.inputs.reference_image = ‘/path/to/example_func_in_MNI_space.nii.gz’
at.inputs.transforms = [’/path/to/sub*_from-T1w_to-MNI152NLin2009cAsym_mode-image_xfm.h5’,’//path/to/sub-_ses-_from-orig_to-T1w_mode-image_xfm.txt’]
at.inputs.invert_transform_flags = [False, True]
at.inputs.output_image =’/path/to/ROI_1_func_MNI.nii.gz’
res = at.run()

1 Like