Question on Transfroming Tedana's output to MNI space

Hi,

I am working with multi-echo fMRI data and I have preprocessed the images with fMRIPrep (version 22.0.0) and tedana (v 0.0.12) afterwards. I am now transforming tedana’s output (optcomDenoised_bold.nii.gz) to the MNI space using antsApplyTransforms with the transformations created by fMRIPrep and using the follwoing commands (on singularity).

antsApplyTransforms --dimensionality 3 \
 --input-image-type 3 \
 --input /project/ctb-villens/javan/multi_prep/test/tedana/sub-MTL0002_ses-FU84/sub-sub-MTL0002_ses-FU84_task-sharedreward_space-Native_desc-optcomDenoised_bold.nii.gz \
 --reference-image /home/javan/scratch/multi_prep/test/derive_v22_24h/sub-MTL0002/ses-FU84/anat/sub-MTL0002_ses-FU84_acq-MPRAGE_desc-preproc_T1w.nii.gz \
 --output /home/javan/scratch/multi_prep/test/tedana/registration/sub-MTL0002_ses-FU84_task-sharedreward_space-T1w_desc-optcomDenoised_bold.nii.gz \
 --interpolation LanczosWindowedSinc \
 --transform /project/ctb-villens/javan/multi_prep/test/derive_v22_24h/sub-MTL0002/ses-FU84/func/sub-MTL0002_ses-FU84_task-rest_run-01_from-scanner_to-T1w_mode-image_xfm.txt \
 --default-value 0 \
 --float 1 \
 --verbose 1

I am first applying the fMRIPrep created transform (scanner_to-T1w_mode-image_xfm.txt ) on tedana’s output to transorm it from T1w to native space. Next, I intend to apply the T1w_to-MNI152NLin2009cAsym_mode-image_xfm.h5 to transorm the output of the previous transormation into the MNI space.
I was wondering first, whether my approach does make sense and if yes, am I using the right parameters for the transformations? Second, what reference images should I use for these transformations, is it correct to use acq-MPRAGE_desc-preproc_T1w.nii.gz for native2T1w transformation?
Also for the T1w2MNI transormation, does using acq-MPRAGE_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz make sense as a reference image or I need to use the MNI152NLin2009cAsym template itself?
During applying the native2T1w transfrom, I am receiving the follwoing error although I have dedicated 80G of memory to the task:

terminate called after throwing an instance of 'itk::MemoryAllocationError'
  what():  /tmp/ebuser/avx512/ANTs/2.3.5/GCC-9.3.0/easybuild_obj/staging/include/ITK-5.2/itkImportImageContainer.hxx:192:
Failed to allocate memory for image.

I highly appreciate your guidance,
Regards,
Ali

Hi,

You should apply those two transformations in one step with antsApplyTransforms`, in that way you will interpolate your data only once, and thus limitate the smoothing inherent to this process.
It is exactly what FMRIPREP is doing: this is an example from my data where you can see that several transforms are applied at once:


antsApplyTransforms --default-value 0 --float 1  
--input /work/temp_data_BRAINT/fmriprep_22_1_wf/single_subject_pilote1_wf/func_preproc_ses_01_task_rest_wf/bold_split/vol0000.nii.gz
--interpolation LanczosWindowedSinc 
--output /work/temp_data_BRAINT/fmriprep_22_1_wf/single_subject_pilote1_wf/func_preproc_ses_01_task_rest_wf/bold_std_trans_wf/_std_target_MNI152NLin2009cAsym.resnative/bold_to_std_transform/vol0000_xform-00000.nii.gz
--reference-image /work/temp_data_BRAINT/fmriprep_22_1_wf/single_subject_pilote1_wf/func_preproc_ses_01_task_rest_wf/bold_std_trans_wf/_std_target_MNI152NLin2009cAsym.resnative/gen_ref/tpl-MNI152NLin2009cAsym_res-02_T1w_reference.nii.gz
--transform /work/temp_data_BRAINT/fmriprep_22_1_wf/single_subject_pilote1_wf/anat_preproc_wf/anat_norm_wf/_template_MNI152NLin2009cAsym/registration/ants_t1_to_mniComposite.h5
--transform /work/temp_data_BRAINT/fmriprep_22_1_wf/single_subject_pilote1_wf/func_preproc_ses_01_task_rest_wf/bold_reg_wf/bbreg_wf/concat_xfm/out_fwd.tfm
--transform /work/temp_data_BRAINT/fmriprep_22_1_wf/single_subject_pilote1_wf/func_preproc_ses_01_task_rest_wf/unwarp_wf/resample/vol0000_xfm.nii.gz
--transform /work/temp_data_BRAINT/fmriprep_22_1_wf/single_subject_pilote1_wf/func_preproc_ses_01_task_rest_wf/bold_std_trans_wf/_std_target_MNI152NLin2009cAsym.resnative/bold_to_std_transform/tmp-iwqis9z9/mat2itk_pos-003_xfm-00000.txt

Also, your command is putting your bold image to the resolution of you T1w image, this could explain why it is asking so much ressources to process it.

Anyone would work, the reference image gives only the bounding box and the resolution for the output image, and those two images have the same dimensions and same resolution.

I hope this helps,

Julien

Hello Julien,
Many thanks for your reply!!

Just to double check: adding the two transforms (scanner2T1w & T1w2MNI) at the same time with the right reference image (sub-MTL0002_ses-FU84_acq-MPRAGE_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.nii.gz) discards the issue of bold to T1w image issue?

I was also not sure of how ants handels the order of transforms inputted which I assume is first come first served order in the commands?

Accordingly, I modified my command to this and it has successfully completed the job, I highly appreciate it if you could please have a quick look at it:

antsApplyTransforms --dimensionality 3 \
 --input-image-type 3 \
 --input /project/ctb-villens/javan/multi_prep/test/tedana/sub-MTL0002_ses-FU84/sub-sub-MTL0002_ses-FU84_task-sharedreward_space-Native_desc-optcomDenoised_bold.nii.gz \
 --reference-image /home/javan/scratch/multi_prep/test/derive_v22_24h/sub-MTL0002/ses-FU84/anat/sub-MTL0002_ses-FU84_acq-MPRAGE_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.nii.gz \
 --output /home/javan/scratch/multi_prep/test/tedana/registration/sub-MTL0002_ses-FU84_task-sharedreward_space-MNI152NLin2009cAsym_desc-optcomDenoised_bold.nii.gz \
 --interpolation LanczosWindowedSinc \
 --transform /project/ctb-villens/javan/multi_prep/test/derive_v22_24h/sub-MTL0002/ses-FU84/func/sub-MTL0002_ses-FU84_task-rest_run-01_from-scanner_to-T1w_mode-image_xfm.txt \
 --transform /project/ctb-villens/javan/multi_prep/test/derive_v22_24h/sub-MTL0002/ses-FU84/anat/sub-MTL0002_ses-FU84_acq-MPRAGE_from-T1w_to-MNI152NLin2009cAsym_mode-image_xfm.h5 \
 --default-value 0 \
 --float 1 \
 --verbose 1

Thank you very much,
Ali

I think you should better use a boldref image computed by fmriprep in the space MNI152NLin2009cAsym. Which resolution did you get for those bold images in MNI space with FMRIPREP?
But perhaps the image sub-MTL0002_ses-FU84_acq-MPRAGE_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.nii.gz has the same resolution than you bold images in the MNI space and in that case you are fine.

Hi julien,

It was a 2mm resolution MNI152NLin2009cAsym. Just to make sure, I used the sub-MTL0002_ses-FU84_task-rest_run-01_space-MNI152NLin2009cAsym_res-2_boldref.nii.gz image as my reference image.
I visualzied the output with sub-MTL0002_ses-FU84_acq-MPRAGE_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.nii.gz and it was good too as you expected too.

Thank you very much for your time and guidance,
Ali

2 Likes