Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

fMRI Prep, XCP-D, MRIQC, and Resting State fMRI

Authors
Affiliations
Georgia Center for Developmental Science
University of Georgia

fmriprep

fMRIPrep_workflow

Esteban, O., Ciric, R., Finc, K. et al. Analysis of task-based functional MRI data preprocessed with fMRIPrep. Nat Protoc 15, 2186–2202 (2020). Esteban et al. (2020)

Notes:

#!/bin/bash

# Name of the job
#SBATCH --job-name=branch_w1_rs_fmriprep

# Partition on GACRC to run job
#SBATCH --partition=batch 

# Number of tasks
#SBATCH --ntasks=1

# Number of compute nodes
#SBATCH --nodes=1

# Number of CPUs per task
#SBATCH --cpus-per-task=16

# Request memory
#SBATCH --mem=64G

# save logs 
#SBATCH --output=/scratch/%u/workDir/RS_BIDS/log/fmriprep/fmriprep_log_array_%A-%a.out
#SBATCH --error=/scratch/%u/workDir/RS_BIDS/log/fmriprep/fmriprep_error_array_%A-%a.err

# Walltime (job duration)
#SBATCH --time=12:00:00

# Array jobs (* change the range according to # of subject; % = number of active job array tasks)
#SBATCH --array=1-2%20

participants=(116 121)
PARTICIPANT_LABEL=${participants[(${SLURM_ARRAY_TASK_ID} - 1)]}

BIDS_DIR=/scratch/$USER/workDir/RS_BIDS/
OUTPUT_DIR=/scratch/$USER/workDir/RS_BIDS/derivatives/
WORK_DIR=/scratch/$USER/workDir/work/fmriprep/sub-${PARTICIPANT_LABEL}/
FMRIPREP_RESOURCES_PATH=/work/PATH/containers/

echo "array id: " ${SLURM_ARRAY_TASK_ID}, "subject id: " ${PARTICIPANT_LABEL}

mkdir -p ${WORK_DIR}
mkdir -p ${OUTPUT_DIR}

singularity run \
                --cleanenv \
                -B ${FMRIPREP_RESOURCES_PATH}:/resources \
                -B ${BIDS_DIR}:/data \
                -B ${WORK_DIR}:/work \
                -B ${OUTPUT_DIR}:/output \
        ${FMRIPREP_RESOURCES_PATH}/fmriprep-23.2.1.sif /data /output \
        participant --participant_label $PARTICIPANT_LABEL \
        -w /work \
        --nthreads 16 \
        --fs-license-file /resources/.licenses/freesurfer/license.txt \
        --skip_bids_validation \
        --dummy-scans 6 \
        --use-syn-sdc warn \
        --force-syn \
        --write-graph \
        --debug all \
        -vv \
        --cifti-output 91k \
        --output-spaces T1w MNI152NLin2009cAsym

Troubleshooting:

rs1

Custom standard spaces

Convert AFNI file to nii.gz format, and create a mask.

3dAFNItoNIFTI -prefix /home/qy49547/.cache/templateflow/tpl-HaskinsPeds/tpl-HaskinsPeds_res-1_T1w.nii.gz HaskinsPeds_NL_template1.0+tlrc
fslmaths /home/qy49547/.cache/templateflow/tpl-HaskinsPeds/tpl-HaskinsPeds_res-1_T1w.nii.gz -thr 0.5 -bin /home/qy49547/.cache/templateflow/tpl-HaskinsPeds/tpl-HaskinsPeds_res-1_desc-brain_mask.nii.gz

3dAFNItoNIFTI -prefix tpl-HaskinsPeds_atlas.nii HaskinsPeds_NL_atlas1.01+tlrc
qy49547@ra6-14 tpl-HaskinsPeds$ fslinfo tpl-HaskinsPeds_res-1_desc-brain_mask.nii.gz
qy49547@c1-5 tpl-HaskinsPeds$ fslinfo tpl-HaskinsPeds_res-1_T1w.nii.gz
data_type	UINT8
dim1		179
dim2		218
dim3		182
dim4		1
datatype	2
pixdim1		1.000000
pixdim2		1.000000
pixdim3		1.000000
pixdim4		0.000000
cal_max		0.000000
cal_min		0.000000
file_type	NIFTI-1+

Troubleshooting:

Resources

Molfese, P. J., Glen, D., Mesite, L., Cox, R. W., Hoeft, F., Frost, S. J., Mencl, W. E., Pugh, K. R., & Bandettini, P. A. (2020). The Haskins pediatric atlas: A magnetic-resonance-imaging-based pediatric template and atlas. Pediatric Radiology51(4), 628. Molfese et al. (2020)

https://brainybehavior.com/neuroimaging/2015/02/brain-template-creation-with-ants/

https://www.youtube.com/playlist?list=PL_CD549H9kgqsb1Core6DhdCIw9vhQhQP

Quality Control for Resting State fMRI with fMRIPrep and MRIQC

MRIQC

MRIQC provides fast data quality checks before preprocessing with fMRIprep. We can use array jobs for individual-level processing, and then use group-level processing after all participants have been processed. After group-level processing, you can click on the interactive image to jump to the individual-level results.

Individual Level

#!/bin/bash

# Name of the job
#SBATCH --job-name=MRIQC

# Partition on GACRC to run job
#SBATCH --partition=batch 

# Number of tasks
#SBATCH --ntasks=1

# Number of compute nodes
#SBATCH --nodes=1

# Number of CPUs per task
#SBATCH --cpus-per-task=16

# Request memory
#SBATCH --mem=64G

# save logs 
#SBATCH --output=/scratch/%u/workDir/log/MRIQC/MRIQC_log_array_%A-%a.out
#SBATCH --error=/scratch/%u/workDir/log/MRIQC/MRIQC_error_array_%A-%a.err

# Walltime (job duration)
#SBATCH --time=4:00:00

# Array jobs (* change the range according to # of subject; % = number of active job array tasks)
#SBATCH --array=1-2%20

participants=(090 100)
PARTICIPANT_LABEL=${participants[(${SLURM_ARRAY_TASK_ID} - 1)]}

# The outputdir of group analysis should be same same of individual level

BIDS_DIR=/PATH/BIDS
OUTPUT_DIR=CHANGE_HERE
WORK_DIR=CHANGE_HERE/sub-${PARTICIPANT_LABEL}
CONTAINER=/work/PATH/containers/

echo "array id: " ${SLURM_ARRAY_TASK_ID}, "subject id: " ${PARTICIPANT_LABEL}

mkdir -p ${WORK_DIR}
mkdir -p ${OUTPUT_DIR}

singularity run \
                --cleanenv \
                -B ${CONTAINER}:/resources \
                -B ${BIDS_DIR}:/data \
                -B ${WORK_DIR}:/work \
                -B ${OUTPUT_DIR}:/output \
        ${CONTAINER}/mriqc_24.0.2.sif /data /output \
        participant --participant_label $PARTICIPANT_LABEL \
        -w /work \
        --no-sub \
        --nprocs 16 \
        --verbose-reports \
        --notrack \
        --session-id 01 \
        --omp-nthreads 4 \
        --write-graph \
        -vv

Group

Change work_dir and output_dir (use the individual MRIQC output directory as the group output directory). Changes to other paths and parameters are consistent at the individual level.

#!/bin/bash

# Name of the job
#SBATCH --job-name=branch_w1_rs_MRIQC

# Partition on GACRC to run job
#SBATCH --partition=batch 

# Number of tasks
#SBATCH --ntasks=1

# Number of compute nodes
#SBATCH --nodes=1

# Number of CPUs per task
#SBATCH --cpus-per-task=16

# Request memory
#SBATCH --mem=64G

# save logs 
#SBATCH --output=/scratch/%u/workDir/log/MRIQC/MRIQC_log_array_%A-%a.out
#SBATCH --error=/scratch/%u/workDir/log/MRIQC/MRIQC_error_array_%A-%a.err

# Walltime (job duration)
#SBATCH --time=1:00:00

BIDS_DIR=/PATH/BIDS
OUTPUT_DIR=CHANGE_HERE
WORK_DIR=CHANGE_HERE
CONTAINER=/work/cglab/containers/

mkdir -p ${WORK_DIR}
mkdir -p ${OUTPUT_DIR}

singularity run \
                --cleanenv \
                -B ${CONTAINER}:/resources \
                -B ${BIDS_DIR}:/data \
                -B ${WORK_DIR}:/work \
                -B ${OUTPUT_DIR}:/output \
        ${CONTAINER}/mriqc_24.0.2.sif /data /output \
        group \
        -w /work \
        --no-sub \
        --nprocs 16 \
        --notrack \
        --session-id 01 \
        --omp-nthreads 4 \
        --verbose-reports \
        --write-graph \
        -vv

Exclusion Criteria

After processed by MRIQC in group level, it will generates some tsv files that contain quantitative indicators. The generated HTML file content is similar to that of fMRIPrep and provides a simple interface for researchers to perform scoring. The following documentation also provides detailed exclusion criteria:

fMRIPrep generates multiple visual HTML reports.

fMRIPrep_QC1fMRIPrep_QC2fMRIPrep_QC3

fMRIPrep_QC4 fMRIPrep_QC5

fMRIPrep_QC6fMRIPrep_QC7fMRIPrep_QC8fMRIPrep_QC9

Post-analysis (functional connectivity): XCP-D

#!/bin/bash

# Name of the job
#SBATCH --job-name=dorry_w2_rs_xcpd

# Partition on GACRC to run job
#SBATCH --partition=batch 

# Number of tasks
#SBATCH --ntasks=1

# Number of compute nodes
#SBATCH --nodes=1

# Number of CPUs per task
#SBATCH --cpus-per-task=16

# Request memory
#SBATCH --mem=64G

# save logs 
#SBATCH --output=/PATH/xcpd_log_array_%A-%a.out
#SBATCH --error=/PATH/xcpd_error_array_%A-%a.err

# Walltime (job duration)
#SBATCH --time=24:00:00

# Array jobs (* change the range according to # of subject; % = number of active job array tasks)
#SBATCH --array=1-2%20

participants=(1003 1004)

PARTICIPANT_LABEL=${participants[(${SLURM_ARRAY_TASK_ID} - 1)]}
BIDS_DIR=/PATH/fMRIPrep_derivatives/
OUTPUT_DIR=/PATH/derivatives_xcpd/
WORK_DIR=/PATH/sub-${PARTICIPANT_LABEL}/
CONTAINER=/PATH/containers/

echo "array id: " ${SLURM_ARRAY_TASK_ID}, "subject id: " ${PARTICIPANT_LABEL}

mkdir -p ${WORK_DIR}
mkdir -p ${OUTPUT_DIR}

singularity run \
                --cleanenv \
                -B $HOME:/home/xcp \
                --home /home/xcp \
                -B ${CONTAINER}:/resources \
                -B ${BIDS_DIR}:/data \
                -B ${WORK_DIR}:/work \
                -B ${OUTPUT_DIR}:/output \
        ${CONTAINER}/xcp_d-0.11.0rc1.sif /data /output \
        participant --participant_label $PARTICIPANT_LABEL \
        -w /work \
        --mode abcd \
        --dummy-scans 6 \
        --motion-filter-type notch \
        --band-stop-min 15 \
        --band-stop-max 25 \
        --nuisance-regressors 36P \
        --create-matrices all \
        --nprocs 4 \
        --omp-nthreads 4 \
        --write-graph \
        --fs-license-file /resources/.licenses/freesurfer/license.txt

Resource and Reference

Lepping, R. J., Yeh, H., McPherson, B. C., Brucks, M. G., Sabati, M., Karcher, R. T., Brooks, W. M., Habiger, J. D., Papa, V. B., & Martin, L. E. (2023). Quality control in resting-state fMRI: The benefits of visual inspection. Frontiers in Neuroscience, 17, 1076824. Lepping et al. (2023)

Birn, R. M. (2023). Quality control procedures and metrics for resting-state functional MRI. Frontiers in Neuroimaging, 2, 1072927. Birn (2023)

Provins, C., MacNicol, E., Seeley, S. H., Hagmann, P., & Esteban, O. (2023). Quality control in functional MRI studies with MRIQC and fMRIPrep. Frontiers in Neuroimaging, 1, 1073734. Provins et al. (2023)

Esteban, O., Ciric, R., Finc, K., Blair, R. W., Markiewicz, C. J., Moodie, C. A., Kent, J. D., Goncalves, M., DuPre, E., Gomez, D. E., Ye, Z., Salo, T., Valabregue, R., Amlien, I. K., Liem, F., Jacoby, N., Stojić, H., Cieslak, M., Urchs, S., . . . Gorgolewski, K. J. (2020). Analysis of task-based functional MRI data preprocessed with fMRIPrep. Nature Protocols, 15(7), 2186-2202. Esteban et al. (2020)

Morfini, F. (2023). Functional connectivity MRI quality control procedures in CONN. Frontiers in Neuroscience, 17, 1092125. Morfini et al. (2023)

Behzadi, Y., Restom, K., Liau, J., & Liu, T. T. (2007). A component based noise correction method (CompCor) for BOLD and perfusion based fMRI. NeuroImage, 37(1), 90-101. Behzadi et al. (2007)

https://drive.google.com/file/d/1TMg9MRvBwZO8HB1UJmH0gm4tYaBVnvcQ/view

https://www.axonlab.org/hcph-sops/processing/qaqc-criteria-preprocessed/

https://andysbrainbook.readthedocs.io/en/latest/OpenScience/OS/fMRIPrep_Demo_3_ExaminingPreprocData.html

https://fmriprep.org/en/20.2.3/outputs.html

https://sites.brown.edu/cnrc-core/resources-and-help/

https://www.axonlab.org/frontiers-qc-sops/exclusion_criteria/

https://github.com/transatlantic-comppsych/fmriprep_qa_guide?tab=readme-ov-file

References
  1. Esteban, O., Ciric, R., Finc, K., Blair, R. W., Markiewicz, C. J., Moodie, C. A., Kent, J. D., Goncalves, M., DuPre, E., Gomez, D. E. P., Ye, Z., Salo, T., Valabregue, R., Amlien, I. K., Liem, F., Jacoby, N., Stojić, H., Cieslak, M., Urchs, S., … Gorgolewski, K. J. (2020). Analysis of task-based functional MRI data preprocessed with fMRIPrep. Nature Protocols, 15(7), 2186–2202. 10.1038/s41596-020-0327-3
  2. Molfese, P. J., Glen, D., Mesite, L., Cox, R. W., Hoeft, F., Frost, S. J., Mencl, W. E., Pugh, K. R., & Bandettini, P. A. (2020). The Haskins pediatric atlas: a magnetic-resonance-imaging-based pediatric template and atlas. Pediatric Radiology, 51(4), 628–639. 10.1007/s00247-020-04875-y
  3. Hagen, M. P., Provins, C., MacNicol, E., Li, J., Gomez, T., Garcia, M., Seeley, S., Haitz Legarreta, J., Norgaard, M., Bissett, P., Poldrack, R. A., Rokem, A. G., & Esteban, O. (2024). Quality assessment and control of unprocessed anatomical, functional, and diffusion MRI of the human brain using MRIQC. 10.1101/2024.10.21.619532
  4. Provins, C., MacNicol, E., Seeley, S. H., Hagmann, P., & Esteban, O. (2023). Quality control in functional MRI studies with MRIQC and fMRIPrep. Frontiers in Neuroimaging, 1. 10.3389/fnimg.2022.1073734
  5. Power, J. D. (2017). A simple but useful way to assess fMRI scan qualities. NeuroImage, 154, 150–158. 10.1016/j.neuroimage.2016.08.009
  6. Lepping, R. J., Yeh, H.-W., McPherson, B. C., Brucks, M. G., Sabati, M., Karcher, R. T., Brooks, W. M., Habiger, J. D., Papa, V. B., & Martin, L. E. (2023). Quality control in resting-state fMRI: the benefits of visual inspection. Frontiers in Neuroscience, 17. 10.3389/fnins.2023.1076824
  7. Birn, R. M. (2023). Quality control procedures and metrics for resting-state functional MRI. Frontiers in Neuroimaging, 2. 10.3389/fnimg.2023.1072927
  8. Morfini, F., Whitfield-Gabrieli, S., & Nieto-Castañón, A. (2023). Functional connectivity MRI quality control procedures in CONN. Frontiers in Neuroscience, 17. 10.3389/fnins.2023.1092125
  9. Behzadi, Y., Restom, K., Liau, J., & Liu, T. T. (2007). A component based noise correction method (CompCor) for BOLD and perfusion based fMRI. NeuroImage, 37(1), 90–101. 10.1016/j.neuroimage.2007.04.042