Denoising resting state fMRIPrep Data


I am running a resting state analysis. I preprocessed my fMRI and anatomical data using fMRIprep and now I am denoising the data in AFNI. For each model, I am including 24 head motion parameters, volumes identified as non-steady state by fMRIprep, cosine regressors generated by fMRIprep for high-pass filtering, and polort 2 to remove linear trends.

For each subject, I compiled a confound text file containing time series regressors (see attached). The first 24 columns are the 6 head motion parameters, their first temporal derivatives, and square terms. Columns 25-29 are the cosine regressions, and column 30 is a regressor indicating the volume identified as non-steady state. Is there any issue with the organization of the confound file?

Subsequently, I used 3dTproject to regress the nuisance confounds, as indicated below:

3dTproject -polort 2 -input ${sid}_${filename} -mask ${sid}_${maskname} -ort ${outdir}/RegMatrices/${pipe}/${sid}_${pipe}_confounds.txt -blur 6 -prefix errt_${sid}_${pipe}.nii.gz

Is this specification correct to perform nuisance regression?

Thank you!

Hi Jenna,

That seems fine from the view of projection. Blurring does not need to be done there, but it should be okay, too.
I gather you do not plan to do any censoring. That could be included if you wanted it.

It would also be reasonable to have do these things, which would allow for a quality control HTML report to be generated.

But for just doing a projection and blur, this seems okay.

  • rick

Hi Rick,

Thanks for your response! How would I implement the regression using


Hi Jenna,

The only special things to do for that are to pass the motion parameters via -regress_motion_file, and to pass any other (sets of?) regressors of no interest via -regress_extra_ortvec (and _labels). Beyond that, would you like to do blurring and/or scaling?

Just for a start, here is an example that processes like rest, but with no extra regressors of no interest for now.

It gives:

  • processing blocks (mask blur scale regress)
  • 3 sets of input files (EPI, anat, motion (task is ignored, but could be passed))
  • processing options (here, blur size, motion regressor types and censor limits)
  • if you want to do the high-pass filtering with sinusoids, this includes such options
  • then QC options (radial correlate, blur estimation and pythonic HTML)
# assuming shell-specific $ddir pointing to data: -subj_id Santa                                  \
   -blocks                   mask blur scale regress         \
   -dsets                    $ddir/pb02.FT.r0*.HEAD          \
   -copy_anat                $ddir/anat_final.FT+tlrc.HEAD   \
   -regress_motion_file      $ddir/dfile_rall.1D             \
   -blur_size                6                               \
   -regress_censor_outliers  0.05                            \
   -regress_motion_per_run                                   \
   -regress_apply_mot_types  demean deriv                    \
   -regress_censor_motion    0.2                             \
   -regress_bandpass         0.01 1                          \
   -regress_polort           2                               \
   -radial_correlate_blocks  tcat                            \
   -regress_est_blur_epits                                   \
   -regress_est_blur_errts                                   \
   -html_review_style        pythonic

If you would like this to be for task, add corresponding -regress_ options. I did not put any -regress_extra_ortvec options (e.g. squared motion terms and sinusoids, or other confounds if you want them), but they are simple to include. For example, you could pass that entire confounds file, but it might be better to separate at least the motion, so that can do censoring and report on it with the QC.

Pre-steady state volumes are better off being removed before the the analysis (-tcat_remove_first_trs, for which timing files or the fmriprep regressors might need altering). Including them in any temporal computations is not a good idea, including those done by fmriprep.

Please feel free to adjust for your experiment and let me know.

  • rick