Spiering et al., Nature Communications, 2025
Link to paper: https://www.nature.com/articles/s41467-025-67853-8
bioRxiv preprint available at: https://www.biorxiv.org/content/10.1101/2024.10.01.615833v1
This repository contains data, analysis script and plotting scripts for the above project. Please refer to above preprint for details on the project. Each script contains comments on how to use the script and which figures or analyses it produces. For any questions, please refer to above preprint or contact the authors.
The code was developed on macOS Sonoma 14.7.6, using R version 4.2.1 (2022-06-23), FSL (v. 6.00) and MATLAB (R2021a). A list of required R packages can be found in the R-packages.txt file
Please install these programs:
- R: https://www.r-project.org/
- FSL: https://fsl.fmrib.ox.ac.uk/fsl/docs/#/install/index
- MATLAB: https://uk.mathworks.com/help/install/ug/install-products-with-internet-connection.html
Then install the required R packages (see R-packages.txt) using the install.packages() function in R. This can take a few minutes.
analysis:
The analysis folder contains the scripts necessary to analyse the behavioura and neural data provided, and reproduce the plots of the study.
_functions: contains custom R functions used for the analysissetup_cc.R: setup the analysis environment, load the required packages and data. change the paths here to run the analyses and plotting scriptsfit_sub_behaviour.R: fit subject-wise regressions using brmsload_data4regs.R: load the preprocessed behavioural data to run regression analyses and for plottingload_learners.R: load the simulated data from the three Bayesian optimal observer models and aggregate with the behavioural dataload_tc2plot.R: load the time course data for plotting the fMRI time coursestransform_data_l1.R: transform the behavioural data in a long format for the fMRI time course analyses
behaviour: contains analysis and plotting script for the behavioural resultsBayesianModel_phase1.stanandBayesianModel_phase3.stan: the stan files that specify the Bayesian learner models (phase1 = Self-Other phase, phase3 = Control-Other phase).cc_beh01_fit_learners.Rmd: fits the Bayesian learner models to the behavioural datacc_beh02_overview_behaviour.Rmd: plotting script for various overview plots of the behavioural datacc_beh03_credit_assignment_social_PEs.Rmd: regression analysis and plotting script for how participants assign social PEs to themselves and others according to their perceived control (Figure 2e)cc_beh04_AD.Rmd: regression analysis and plotting script for how participants used AD (e.g. Figure 3)cc_beh05_regression_intercept_anovas.Rmd: analysis script to test the intercept effects of the resulting beta estimates from subject-wise regressions (e.g. Figure 2e)cc_beh06_AD_guided_control_learning.Rmd: regression analysis and plotting script for how participants used AD to guide their control learning (e.g. Figure 4)
fmri: contains analysis and plotting script for the fMRI results- subfolder
functionscontains the custom MATLAB functions supporting the scriptcc_roi02_run_timecourse.mlx cc_roi01_prep_behavioural_data.Rmd: prepares the behavioural data for the fMRI time course analysescc_roi02_run_timecourse.mlx: runs the fMRI time course analyses and performs LOO-procedurecc_roi03_plot.Rmd: plots the fMRI time courses (e.g. Figures 6 and 7)
- subfolder
data:
The behavioural data can be found in the folder behavioural-data and the fMRI data can be found in the folder mri-data.
behavioural-data:- The behavioural data for the respective behavioural analyses are found in the files
preprocessed_behaviour_mri.RData(mri sample),preprocessed_behaviour_online.RData(online sample), andpreprocessed_data_4regs.RData(both samples combined, for the regressions) - The regression fits are found in the subfolder
regression-fits. More information on which files are necessary for which analysis or plotting script can be found in the behavioural analysis scripts folder (analysis\behaviour)
- The behavioural data for the respective behavioural analyses are found in the files
mri-data:- The cluster-corrected whole-brain maps shown in Fig 5, showing the effects of uncertainty and AD at the time of action, can be found in the folder
whole-brain-mapsinmri-data. The cluster-corrected maps are denoted as*_thresh_act.nii.gzand_thresh_deact.nii.gz, and the uncorrected maps are denoted as*_unthresholded.nii.gz. These can be viewed using for example FSLeyes. They can also be found in this neurovault repo: https://identifiers.org/neurovault.collection:21965 - The ROI masks in MNI space used for the fMRI time-course analyses can be found in the folder
roi-masksinmri-data. - For the fMRI time-course analysis, the time-course data for each ROI can be found in the folder
roi-timecoursesinmri-data. The files are named according to to the script they were generated with, e.g.roi01_behdata_glm001.matcontains the behavioural regressor data for the ROI-GLMs defined in the scriptcc_roi01_prep_behavioural_data.Rmd.
- The cluster-corrected whole-brain maps shown in Fig 5, showing the effects of uncertainty and AD at the time of action, can be found in the folder
demo : The code can be used together with the data provided to reproduce various figures and analyses for the above project (see above).
Copyright, 2025, Lisa Spiering. All rights reserved