A short tutorial for lifespan social neuroscience. You will ask whether younger and older adults respond differently to social partners in economic games: friends, strangers, and computer partners. The tutorial starts with a runnable teaching demo, then shows how to apply the same workflow to the OpenNeuro social reward dataset, including one optional first-level fMRI GLM.
Time: ~2 hours for the behavioral workflow; ~3-4 hours if you download imaging data and run the GLM. Coding level: beginner/intermediate Python.
What you'll learn
- How to frame aging as a social-neuroscience question rather than only a
cognitive-decline question.
- How to quantify a partner effect in trust-game behavior: friend,
stranger, and computer.
- How to test an age-group-by-partner interaction with a transparent linear
model.
- How BIDS events become regressors in a first-level fMRI GLM.
- How to build one social contrast: friend > stranger during trust
decisions.
Runnable code is in `code/`:
| File | What it does | Needs |
|---|---|---|
| `code/social_reward_trust.py` | Simulated teaching demo, real-event summaries, and optional first-level GLM | numpy, pandas, scipy, matplotlib; + nilearn for GLM |
Dataset
The main dataset is Social Reward Processing & Decision Making Across the Lifespan (OpenNeuro ds005123). It includes 114 adults ages 21-80 completing social and nonsocial reward tasks in the scanner. The trust task is especially tutorial-friendly because partner type is explicit: friend, stranger, and computer.
For broader aging context, compare it with HCP-Aging / AABC, a large registered- access lifespan connectome resource for healthy brain aging.
Setup
From the repository root:
python3 -m venv venv && source venv/bin/activate
pip install -r tutorials/social-reward-aging/requirements.txtPart 1 runs with no downloads.
python tutorials/social-reward-aging/code/social_reward_trust.pyExpected output:
Simulated trust-game demo (50 participants, 3 partner types)
Mean amount shared by group and partner:
...
Saved .../results/social_reward_trust_demo.pngThe demo is simulated on purpose: it lets you understand the model and plot before waiting for a neuroimaging download. The real-data workflow below uses the same column-normalization and model code when OpenNeuro files are present.
Part 1 — Behavioral question
The trust task asks participants to make decisions involving different partners. A social reward question can be stated compactly:
Do people share or invest more with friends than with strangers or computers, and does that partner effect differ between younger and older adults?
In the teaching demo, each participant has repeated trials for three partners. We fit a linear model:
amount_shared ~ age_group + partner + age_group:partnerThe interaction terms are the lifespan-social-neuroscience part. They test whether the social context effect differs between age groups.
Part 2 — Real OpenNeuro events
Download the dataset or a subset from OpenNeuro. Event files are small, while raw multi-echo imaging files are much larger.
pip install openneuro-py
python3 -m openneuro download --dataset ds005123 --target-dir ds005123For a small local smoke test, you can download only metadata, two event files, and one raw trust-task BOLD run:
python3 -m openneuro download --dataset ds005123 --target-dir ds005123 \
--include CHANGES --include README \
--include dataset_description.json --include participants.tsv --include participants.json \
--include 'sub-10317/func/sub-10317_task-trust_run-1_events.*' \
--include 'sub-10369/func/sub-10369_task-trust_run-1_events.*' \
--include 'sub-10369/func/sub-10369_task-trust_run-1_echo-1_part-mag_bold.*'Then run the real-event summary:
SOCIAL_REWARD_DIR=ds005123 python tutorials/social-reward-aging/code/social_reward_trust.py --realThe script searches for trust-task events.tsv files, infers partner labels from columns such as partner, condition, or trial_type, and looks for a numeric choice/investment column such as trust_value. BIDS event files differ across studies, so if the script cannot infer the relevant columns it prints the discovered columns and you can map them explicitly in the code.
Part 3 — One first-level GLM
The GLM asks where one participant's brain response is stronger for trust decisions involving a friend than a stranger.
SOCIAL_REWARD_DIR=ds005123 python tutorials/social-reward-aging/code/social_reward_trust.py --glm --subject sub-10369The script:
- Finds a trust-task event file and either a preprocessed BOLD run or a raw
single-echo magnitude BOLD run.
- Converts partner labels into BIDS
trial_typeregressors:
friend, stranger, and computer.
- Fits a first-level GLM with nilearn.
- Saves a
friend_minus_strangerz-map and PNG figure.
The contrast is deliberately simple:
friend - strangerFor a real paper, you would preprocess the raw multi-echo data carefully, repeat this across all usable runs and participants, then run a second-level model testing group and age effects. Here the goal is to show how social task structure enters a reproducible neuroimaging model.
Caveats
- Age-group differences in social reward are subtle and task-dependent. Treat
the teaching demo as a scaffold, not a scientific result.
- A single-subject GLM is a tutorial artifact. Do not interpret it as evidence
for age effects.
- Registered-access aging resources such as HCP-Aging/AABC are excellent for
lifespan neuroscience, but they are less directly social than this economic- games dataset.
Where to go next
- Add subject-level random effects or mixed models.
- Replace
amount_sharedwith reaction time, acceptance, or model-derived
utility if those columns are available in the real events.
- Run the
friend > strangerGLM for all subjects, then compare younger and
older groups at the second level.
- Pair this with social-network aging data such as NSHAP for a behavioral
tutorial on social connectedness and health.
Putting it together
You framed aging as a *social* question, quantified a partner effect with a transparent linear model, tested whether that effect shifts across the lifespan, and saw how the same task structure (friend, stranger, computer) becomes regressors in a first-level fMRI GLM. That arc — a behavioral model first, then the same structure in the brain — is the connective tissue across all three tutorials in this series.
References
- Smith DV, Sharp CJ, Dachs A, et al. (2024). *Social Reward and Nonsocial Reward
Processing Across the Adult Lifespan: An Interim Multi-echo fMRI and Diffusion Dataset.* Data in Brief, 110810. <https://openneuro.org/datasets/ds005123>
- Berg J, Dickhaut J, McCabe K (1995). *Trust, Reciprocity, and Social History.*
Games and Economic Behavior, 10(1), 122–142.
- Fareri DS, Delgado MR (2014). *Social rewards and social networks in the human
brain.* The Neuroscientist, 20(4), 387–402.
- Mather M (2016). *The affective neuroscience of aging.* Annual Review of
Psychology, 67, 213–238.
- nilearn — *Machine learning for neuroimaging in Python.* <https://nilearn.github.io/>
*Part of Social Neuroscience DataFinder. Found an error or have an improvement? Contributions welcome.*
