Test-Retest Reliability of fMRI measures in Dual Mechanisms of Cognitive Control dataset. This code is capable of reproducing all results and figures within Freund, Chen, Chen, and Braver (2024; DOI: 10.1101/2024.04.24.591032). For questions or concerns please contact Mike Freund.
To reproduce the results and figures in the paper, you will need to:
- Clone this repository.
- Download the data derivatives from https://doi.org/10.5281/zenodo.14043318.
- Unpack the zipped file of data derivatives into the
outdirectory of this repository. - Skip down to the
Running Analysessection of this README -- in particular, work through theGeneral Pipelinesubsection.
NB: fMRI data derivatives includes the output of our:
- timeseries models (vertex by trial matrices of activation estimates per subject and session)
- spatial models (a long-form table of trial-level univariate and multivariate contrasts for each region, session, and subject)
- reliability models (RDS files containing hierarchical model estimates)
The raw or minimally preprocessed fMRI timeseries data (i.e., inputs to timeseries models) will soon be made available on OpenNeuro, organized as a subcomponent of a larger release of the Dual Mechanisms of Cognitive Control dataset. If you would like these data before the OpenNeuro release, please contact us and we will fulfill your request directly.
- all analysis scripts in
code/ - scripts in
coderead and write toout/ in/contains behavioral data files, subject lists- files in
in/are not modified by any scripts
- trialtype: "high demand" (difficult trials), "low demand" (easy trials)
- run: run1, run2
- task: Axcpt, Cuedts, Stern, Stroop
- session: baseline, proactive, reactive
- wave: wave1, wave2 (wave1 = test, wave2 = retest)
Run code/timeseries/null_2rpm/run_deconvolve.sh to detrend the timeseries.
- Reads: the subject list in
in/ - Writes: the detrended timeseries to
out/timeseries/
Run code/timeseries/selav/selav_single_trials.R to get the trial-level statistics (selective averaging).
- reads: the
.giifiles in the GLM output folders inout/timeseries/- e.g.,
out/timeseries/130518/RESULTS/Stroop/baseline_null_2rpm_wave1/errts_L.gii(along witherrts_R.gii)
- e.g.,
- writes: the results in
errts_trials_target_epoch.RDSunder the same folder as the input
Run code/behav/write_behav_subjs.R to generate trial-level behavioral data
- reads:
in/behav/orig/to CSV files - writes: behavioral data csvs to
in/behav, e.g.,behavior-and-events_wave13_Stroop.csv.
Run code/spatial/multivariate_projections_within-task_cv-sessions.R to generate univariate and multivariate statistics for reliability analysis
- reads: the behavior CSVs
- writes: to a csv like
out/spatial/projections__stroop__rda__n_resamples100__demean_run__cv_allsess_wave12.csv
Run code/spatial/gather_csvs.R to recode "wave2/3" and "wave1/3" to "wave1/2" and gather all three CSVs into one
- reads: the behavior CSVs
- writes: into
out/spatial/projections_*contains trial-level scalar contrast values per univariate and multivariate modelweights_*contains vertex-level weights for multivariate decodernoise_projs_*contains noise PCs (vertex-level weights that account for trial-level variability)
Run code/inferential/estimate_reliability.R to fit the reliability models.
- reads:
projections_* - writes: the fitted models to
out/inferential/schaefer2018_17_400_fsaverage5/NAMES_OF_ROI/ - Warning: fitting the bayesian model is VERY SLOW and usually some jobs fail at the first run!
- Each model is about 36M and requires about an hour to train (with 4 chains on 4 cores) without further parallelization.
- With
mclapply()over the ROIs we can fit 32 models in about 15 hours. - Currently, we only focus on "baseline" session.
Run code/inferential/summarize_model_output.R to extract the fitted parameters of all models
- reads: the fitted models from step 3.
- writes: to
out/inferential, the RDS filesposterior_*and CSV filessummarystat_*
Run code/inferential/plot_manuscript_figures.R to plot all figures
- reads: from
out/inferential, the RDS filesposterior_*and CSV filessummarystat_* - writes: to
figs
- test-retest subject list and QC grades
- first-pass reliability analyses
- minimally preprocessed BOLD timeseries (TR by vertex)
- wave 1: /data/nil-bluearc/ccp-hcp/DMCC_ALL_BACKUPS/HCP_SUBJECTS_BACKUPS/fMRIPrep_AFNI_ANALYSIS
- wave 2: /data/nil-bluearc/ccp-hcp/DMCC_ALL_BACKUPS/DMCC_Phase3/fMRIPrep_AFNI_ANALYSIS
- trial onset times
- /data/nil-bluearc/ccp-hcp/DMCC_ALL_BACKUPS/EVTS