Fmriprep parameter --output-spaces dwi

Summary of what happened:

Dear fmriprep experts,

I am trying to register the function data in the DWI space (This is another post I am trying to solve this question Register function data (preprocessed by fmriprep) to DWI space). I found the fmriprep has the options parameter –output-spaces dwi. I would like to know What is the workflow of this parameter? What data do I need to prepare if I want to use this parameter? As far as I know, I haven’t found anything so far about explaining the use of the dwi parameter here. I would greatly appreciate any kind of guidance that you could provide me in this regard. Thank you! Looking forward to your reply.

Command used (and if a helper script was used, a link to the helper script or the command generated):

ingularity run --cleanenv -B /globalscratch/ucl/irsp/yufenghe:/scratch_dir -B /home/ucl/irsp/yufenghe/VAT_predict/raw_data:/bids_dir -B /globalscratch/ucl/irsp/yufenghe/fmriprep_11_Feb:/output -B /home/ucl/irsp/yufenghe/tools:/freesurfer_license /home/ucl/irsp/yufenghe/tools/containers/images/bids/bids-fmriprep--24.1.0.sing /bids_dir /output participant --participant-label sub-EB01 --work-dir /globalscratch/ucl/irsp/yufenghe/work-fmriprep_11_Feb/sub-EB01 --fs-license-file /freesurfer_license/license.txt --output-spaces MNI152NLin2009cAsym T1w boldref fsnative --dummy-scans 0 --notrack --skip_bids_validation --stop-on-first-crash

Version: fmriprep–24.1.0

Environment (Docker, Singularity / Apptainer, custom installation):Singularity

Relevant log outputs (up to 20 lines):

ValueError: space identifier "boldref" is invalid.
Valid identifiers are: Fischer344, MNI152Lin, MNI152NLin2009aAsym, MNI152NLin2009aSym, MNI152NLin2009bAsym, MNI152NLin2009bSym, MNI152NLin2009cAsym, MNI152NLin2009cSym, MNI152NLin6Asym, MNI152NLin6Sym, MNI305, MNIColin27, MNIInfant, MNIPediatricAsym, MouseIn, NKI, NMT31Sym, OASIS30ANTs, PNC, RESILIENT, UNCInfant, VALiDATe29, WHS, dhcpAsym, dhcpSym, dhcpVol, fsLR, fsaverage, onavg, T1w, T2w, anat, fsnative, func, run, sbref, session, individual, dwi, asl

Screenshots / relevant information:

Valid identifiers are: Fischer344, MNI152Lin, MNI152NLin2009aAsym, MNI152NLin2009aSym, MNI152NLin2009bAsym, MNI152NLin2009bSym, MNI152NLin2009cAsym, MNI152NLin2009cSym, MNI152NLin6Asym, MNI152NLin6Sym, MNI305, MNIColin27, MNIInfant, MNIPediatricAsym, MouseIn, NKI, NMT31Sym, OASIS30ANTs, PNC, RESILIENT, UNCInfant, VALiDATe29, WHS, dhcpAsym, dhcpSym, dhcpVol, fsLR, fsaverage, onavg, T1w, T2w, anat, fsnative, func, run, sbref, session, individual, dwi, asl


dwi and asl are there for the sake of dMRIPrep and ASLPrep. They cannot be used in fMRIPrep. If they could be used, they would mean the same as “func”, which just keeps each BOLD image in its original space instead of resampling it to align with anatomical or other images.

Thanks for your reply. I see, so it is impossible to achieve the function data register to dwi space by fmriprep. I have a few more questions about how to achieve register function data to dwi space. Thanks so much for any insights you have on my question!

I plan to use my fmriprep preprocessed data and apply the transform data that combine the orig :arrow_right: boldref, boldref :arrow_right: T1 and T1 :arrow_right: b0_ref. (The first two transform matrices acquired by fmriprep).Is this a good way, and are there other better ways to register from function data to dwi space?

Meanwhile, in continuing the above description, I found the data below path seems to be reasonable when running the above transformations. But I am not sure whether I am right.

Looking forward to your reply.

/work_fmriprep/sub*/fmriprep_24_1_wf/sub_wf/bold_ses_01_task_Catgs_run_wf/bold_native_wf/bold_stc_wf/copy_xform/*_bold_tshift_xform.nii.gz

Yes, this is reasonable.

This is the slice-timing-corrected time series. This is a reasonable source image to apply the transforms to, to get the target image.

The simplest thing to do without digging into the scratch directory would be to target func and then you can use antsApplyTransforms to apply the bold-T1 and T1-dwi transforms. If you want to do it in a single shot, you’re going to need to use GitHub - nipy/nitransforms: a standalone fork of nipy/nibabel#656. See fmriprep/fmriprep/interfaces/resampling.py at f53185e284115854c5428531a69920ee158525a4 · nipreps/fmriprep · GitHub (and the functions it calls) for example code that applies multiple transforms and SDC in a single shot.

1 Like

Thank you very much for your insight.
If I understand right the ‘target func’ means the functional data that have finished time-sliced correction, motion correction, and SDC. In other words, it is the result of --output-spaces func.

As I understood the ’ target func’ above, the code should probably look like this (a simple example):

antsApplyTransforms \
  -d 3 \
  -i func_finished_motion.nii.gz \
  -r b0_ref.nii.gz \
  -t T1_to_b0_ref.mat \
  -t bold_ref_to_T1.mat \
  -o func_inDWI.nii.gz

Thanks again. This is exactly what I was looking for: to do motion transformation and registration in different spaces in one shot!

Yes, this looks right.