This repository contains analysis code and selected derivative outputs for the manuscript:
Linking dACC Responses to Unreciprocated Trust to Brain and Behavior in the Ultimatum Game
The hypotheses and analysis plans were pre-registered on the Open Science Framework.
The purpose of this repository is to support transparency and reproducibility. With access to the required raw behavioral files, preprocessed neuroimaging derivatives, templates, masks, and covariate files, users should be able to reproduce the primary behavioral and fMRI analyses reported in the manuscript.
Repository status: this is not a complete standalone data release. Raw imaging data, large intermediate files, and some locally stored inputs are not tracked in git. Several scripts currently contain project-specific paths and should be reviewed before running on a new system.
The repository supports analyses for two fMRI tasks:
- Trust Game (
trust): model01 - Ultimatum Game (
ugr): model3, the updated model using the revised trial timing / decision-phase specification
The main analysis workflow is:
- Identify participants with usable Trust Game and Ultimatum Game behavioral and neuroimaging data.
- Convert raw task logs to BIDS-style
events.tsvfiles. - Convert BIDS events into FSL-compatible three-column EV files.
- Run behavioral, EV-file, and MRIQC-based exclusions.
- Generate the final subject list used for fMRI analyses.
- Run first-level, second-level, and third-level FSL analyses.
- Run behavioral analyses in the associated R Markdown file.
Expected repository structure:
.
├── README.md
├── bids/ # Generated BIDS-style events files; not necessarily complete/tracked
├── code/ # Analysis and pipeline scripts
├── derivatives/
│ └── fsl/ # FSL EV files and selected FEAT outputs
├── masks/ # Seed/ROI masks used for PPI or ROI analyses
└── templates/ # FSL .fsf templates for L1/L2/L3 models
Important notes:
- The repository does not include a complete BIDS dataset.
- Large files and raw imaging data are intentionally not tracked in git.
- Some derivative files may be tracked for transparency, but larger outputs can be regenerated if the required inputs are available.
- Several scripts infer the project root from the location of the
code/directory, but others still use hard-coded local paths.
Users are expected to be comfortable working in a Linux command-line environment.
Required software:
- Linux / Unix-like shell environment
- Bash
- FSL, including
feat,fslnvols, andfslmeants - MATLAB, for converting raw behavioral logs to BIDS events
- R, for behavioral QC and subject-list generation
Required R packages:
library(dplyr)
library(readr)
library(stringr)
library(tidyr)Additional environment assumptions:
FSLDIRmust be defined.- The helper command
zeropadis used in several scripts and must be available on the system path. - The fMRI scripts assume fMRIPrep 24 derivatives and TedanaPlusConfounds files are available outside this repository.
- FSL
.fsftemplates must be present intemplates/. - Seed masks for PPI analyses must be present in
masks/using the naming conventionseed-<seedname>.nii.gz.
To reproduce the analyses, users need access to the following files or directories.
The Level 1 scripts expect fMRIPrep outputs in the following form:
/ZPOOL/data/projects/rf1-sra-linux2/derivatives/fmriprep-24/sub-<sub>/ses-01/func/
sub-<sub>_ses-01_task-<trust|ugr>_run-<run>_part-mag_space-MNI152NLin6Asym_desc-preproc_bold.nii.gz
The Level 1 scripts expect TedanaPlusConfounds files in the following form:
/ZPOOL/data/projects/rf1-sra-linux2/derivatives/fsl/confounds_tedana-24/sub-<sub>/
sub-<sub>_ses-01_task-<trust|ugr>_run-<run>_desc-TedanaPlusConfounds.tsv
If these confounds are missing, the Level 1 scripts exit before running FEAT.
The conversion scripts expect raw task logs from the original RF1 project directories.
Trust Game logs:
/ZPOOL/data/projects/rf1-sra/stimuli/Scan-Investment_Game/logs/
Ultimatum Game logs:
/ZPOOL/data/projects/rf1-sra/stimuli/Scan-Lets_Make_A_Deal/logs/
get_master_sublist.R requires:
Age.csv
AQ Data.csv
mriqc-metrics_allTasks_n299_ses-01.csv
behavioral_qc_dualtask.csv
ev_qc_dualtask.csv
subject_list_n225.txt
The script writes the final analysis subject list to:
sublist_n132.txt
| Script | Purpose | Main output |
|---|---|---|
get_n225_sublist.sh |
Finds participants with both Trust and UGR preprocessed BOLD files and behavioral logs, then keeps the first 225 valid subjects. | subject_list_all.txt, subject_list_n225.txt, exclusion_log.tsv, qc_table.tsv |
check_EVfiles.sh |
Checks whether expected Trust and UGR EV files exist and are non-empty for each subject/run. | ev_qc_dualtask.csv |
check_dualtask_validtrials.R |
Applies the preregistered behavioral missing-trial exclusion. Trust requires at least 32/42 valid trials; UGR requires at least 36/48 valid trials. | behavioral_qc_dualtask.csv |
get_master_sublist.R |
Combines behavioral QC, EV QC, age exclusion, AQ availability, and MRIQC run-level exclusions into a final run-aligned analysis sample. | master_subject_table_full.csv, sublist_n132.txt |
| Script | Purpose | Main output |
|---|---|---|
convertTrust_BIDS.m |
Converts raw Trust Game logs to BIDS-style events files. | bids/sub-*/func/sub-*_task-trust_run-*_events.tsv |
run_BIDSto3colTRUST.sh |
Loops over Trust Game BIDS event files and calls BIDSto3colTRUST.sh to generate FSL EV files. |
derivatives/fsl/EVfiles/sub-*/trust/ |
convertUGR_BIDS.m |
Converts raw Ultimatum Game logs to BIDS-style events files. | bids/sub-*/func/sub-*_task-ugr_run-*_events.tsv |
run_gen3colfilesUGR.sh |
Loops over subjects and calls gen3colfilesUGR.sh to generate UGR FSL EV files. |
derivatives/fsl/EVfiles/sub-*/ugr/model-3/ |
| Script | Purpose | Main output |
|---|---|---|
L1stats-trust.sh |
Runs Trust Game subject/run-level FEAT models. Supports activation and seed-based PPI modes. | derivatives/fsl/sub-*/ses-01/*.feat |
L1stats-ugr.sh |
Runs UGR subject/run-level FEAT models. Supports activation and seed-based PPI modes. | derivatives/fsl/sub-*/ses-01/*.feat |
run_L1stats-trust.sh |
Wrapper for Trust Game Level 1 models. | Multiple .feat directories |
run_L1stats-ugr.sh |
Wrapper for UGR Level 1 models. Currently configured for the pTPJ PPI seed. |
Multiple .feat directories |
L2stats-trust.sh |
Combines Trust Game runs within subject. | derivatives/fsl/sub-*/ses-01/*.gfeat |
L2stats-ugr.sh |
Combines UGR runs within subject. | derivatives/fsl/sub-*/ses-01/*.gfeat |
run_L2stats-trust.sh |
Wrapper for Trust Game Level 2 models. | Multiple .gfeat directories |
run_L2stats-ugr.sh |
Wrapper for UGR Level 2 models. Currently configured for ppi_seed-pTPJ. |
Multiple .gfeat directories |
L3stats-trust.sh |
Runs Trust Game group-level FEAT analyses. | Group-level .gfeat directories |
L3stats-ugr.sh |
Runs UGR group-level FEAT analyses. | Group-level .gfeat directories |
run_L3stats-trust.sh |
Wrapper for selected Trust Game Level 3 contrasts. Currently configured for cope 10, rec-def. |
Group-level Trust output |
The scripts are intended to be run from the code/ directory unless otherwise noted.
cd codebash get_n225_sublist.shThis creates:
subject_list_all.txt
subject_list_n225.txt
exclusion_log.tsv
qc_table.tsv
subject_list_n225.txt is used as an input to later QC and event-conversion steps.
matlab -batch "run('convertTrust_BIDS.m')"
bash run_BIDSto3colTRUST.shconvertTrust_BIDS.m writes BIDS-style events.tsv files. run_BIDSto3colTRUST.sh then converts those event files into FSL-compatible three-column EV files.
matlab -batch "run('convertUGR_BIDS.m')"
bash run_gen3colfilesUGR.shconvertUGR_BIDS.m writes BIDS-style events.tsv files. run_gen3colfilesUGR.sh then converts those event files into FSL-compatible EV files for UGR model 3.
bash check_EVfiles.shThis writes:
ev_qc_dualtask.csv
The EV QC file records whether expected Trust and UGR run-level EV files are present and non-empty.
Rscript check_dualtask_validtrials.RThis writes:
behavioral_qc_dualtask.csv
The behavioral QC script applies the preregistered threshold requiring no more than 25% missing trials:
- Trust Game: at least 32 valid trials out of 42
- UGR: at least 36 valid trials out of 48
A subject is marked task-valid if at least one run passes the threshold for that task.
Rscript get_master_sublist.RThis script combines:
- the initial
subject_list_n225.txtlist, - behavioral valid-trial QC,
- EV-file QC,
- age exclusion (
sub_age < 55), - AQ data availability,
- run-level MRIQC exclusions based on FD and tSNR outlier thresholds,
- run-aligned task validity.
It writes:
master_subject_table_full.csv
sublist_n132.txt
If the subject list has Windows line endings, clean it before using it in Bash wrappers:
sed -i 's/\r$//' sublist_n132.txtBefore running these wrappers, confirm that each wrapper uses the intended subject list and analysis type. Some wrappers currently point to older subject lists or specific PPI models.
Trust Game:
bash run_L1stats-trust.shUGR:
bash run_L1stats-ugr.shThe Level 1 scripts:
- read fMRIPrep preprocessed BOLD files,
- read TedanaPlusConfounds files,
- generate subject/run-specific
.fsffiles from templates, - run FSL FEAT,
- apply identity registration matrices for pre-normalized fMRIPrep data,
- delete selected large intermediate files after successful model estimation.
Trust Game:
bash run_L2stats-trust.shUGR:
bash run_L2stats-ugr.shThe Level 2 scripts combine run-level outputs within subject. Activation models expect 17 copes. PPI models add one contrast for the physiological regressor, producing 18 copes.
Trust Game:
bash run_L3stats-trust.shUGR group-level models can be run by calling L3stats-ugr.sh directly or by adding a corresponding run_L3stats-ugr.sh wrapper.
Example direct call:
bash L3stats-ugr.sh <cope_number> <cope_name> <analysis_type>The Level 3 scripts are currently configured for:
- final sample size:
N=132 - covariate model:
full - FSL group model:
flame1
Behavioral analyses are run from the associated R Markdown file:
UG-Trust Behavioral Analyses.Rmd
Open or render this file in RStudio or from the command line after verifying that the input paths match the local repository structure.
This repository is intended to reproduce the reported analyses when paired with the required external data. It is not yet fully portable. In particular:
- Several scripts use hard-coded paths from the original analysis environment.
- Some wrapper scripts are configured for specific analysis types, seeds, contrasts, or subject lists.
- Helper scripts called by the wrappers must be present in
code/. - The
.fsftemplates intemplates/must match the model names, contrast numbers, and placeholder names expected by the Bash scripts. - The final subject list is generated by combining behavioral QC, EV QC, MRIQC, age, AQ availability, and run-alignment checks.
Before using this repository outside the original analysis environment, review all paths and wrapper settings carefully.
Questions about this repository or the associated analyses can be directed to the manuscript authors.