A MATLAB/PsychToolbox implementation of a Pavlovian-Instrumental Transfer task. Participants complete instrumental training (approach or withdrawal) and Pavlovian conditioning before performing PIT trials in which Pavlovian background stimuli are presented alongside instrumental stimuli.
Huys, Q.J.M., et al. (2011).
Geurts, D.E.M., et al. (2022).
Original task code by Q.J.M. Huys. Modified and extended by Elizabeth Endecott.
- MATLAB (R2019b or later recommended)
- Psychtoolbox-3
- Clone or download the repository
- Open MATLAB and navigate to the task folder
- Ensure the following folder structure exists:
task/
├── data/
│ └── backup/
├── shrooms/
│ ├── 1/ (12 mushroom images: shroom_1.jpg ... shroom_12.jpg)
│ └── 2/ (12 mushroom images: shroom_1.jpg ... shroom_12.jpg)
└── stimuli/
├── 1/ (5 fractal images: fractal1.jpg ... fractal5.jpg)
└── 2/ (5 fractal images: fractal1.jpg ... fractal5.jpg)
- Edit
modifyme.mto set your experimental parameters (see below) - Run
runexpin the MATLAB command window to start the experiment
modifyme.m is the only file that may need editing between sessions. Key settings:
| Parameter | Description |
|---|---|
name |
Project name, used in saved filename |
english / dutch |
Set language (1 = active, 0 = inactive) |
cb_method |
Counterbalancing method (see below) |
dosave |
Set to 1 to save data (always 1 during experiments) |
doinstr |
Set to 0 to skip instructions during debugging |
payment |
Set to 0 for patients not receiving payment |
txtsize |
Text size in pixels (40 for 1024x768, up to 65 for larger screens) |
| Option | Description |
|---|---|
1 |
Running log file (recommended). Tracks assignments in data/counterbalance_log.mat and assigns whichever condition has fewer participants. Works with any subject numbering. |
2 |
Modulo. Even subject numbers start with approach, odd with withdrawal. Guarantees alternation but not randomization. |
3 |
Random. No guarantee of balance across participants. |
Initial VAS ratings
│
├── Block 1
│ ├── Instrumental training (approach or withdrawal)
│ ├── Pavlovian training
│ └── PIT session
│
├── Break (2 minutes)
│
├── Block 2 (opposite condition)
│ ├── Instrumental training
│ ├── Pavlovian training (short)
│ └── PIT session
│
├── Final VAS ratings
│
└── Debriefing (Day 2 only)
| File | Description |
|---|---|
runexp.m |
Master file. Run this to start the experiment. Calls all other scripts. |
modifyme.m |
The only file that may need editing between sessions. |
| File | Description |
|---|---|
preps.m |
Sets up all stimulus sequences and counterbalancing before the experiment starts. |
setup.m |
Opens the PsychToolbox display window and preloads all stimulus images. |
pittraining.m |
Runs a single instrumental training trial with feedback. |
pavlov.m |
Runs a single Pavlovian conditioning trial. |
pavquery.m |
Runs a single Pavlovian comparison (query) trial, interleaved with Pavlovian training. |
pit.m |
Runs a single PIT trial (no feedback). |
| File | Description |
|---|---|
pitinstr_approach.m |
Instructions for the approach instrumental training block. |
pitinstr_avoid.m |
Instructions for the withdrawal instrumental training block. |
pitinstr_start.m |
Instructions shown at the start of each PIT session. |
pavinstr.m |
Full instructions for the first Pavlovian training block. |
pavinstr_short.m |
Abbreviated refresher instructions for the second Pavlovian block. |
| File | Description |
|---|---|
VASpics.m |
VAS ratings of Pavlovian fractal stimuli (run pre and post conditioning). |
debrief.m |
Post-experiment debriefing questions (Day 2 only). |
| File | Description |
|---|---|
centermouseclick.m |
Displays a central orange square and waits for the participant to click it to initiate each trial. |
checkabort.m |
Checks for Escape key press and aborts the experiment gracefully. |
displaytext.m |
Displays centered text on screen. Used throughout for instructions and feedback. |
givebreak.m |
Displays a countdown break screen between blocks. |
mygetclicks.m |
Waits for a mouse button press and release. |
Data is saved as .mat files in data/ with a backup copy in data/backup/. Files are named:
[name]_[type]_[subjn]_[day]_[datetime].mat
For example: GADA_C_1001_1_250115_1430.mat
If the experiment crashes, a .crashed.mat file is saved. If aborted via Escape, a .aborted.mat file is saved.
Trial indices
| Variable | Description |
|---|---|
nt |
Instrumental trial number |
np |
Pavlovian trial number |
npit |
PIT trial number |
Reaction times
| Variable | Description |
|---|---|
treact |
Instrumental trial RTs |
pavreact |
Pavlovian query trial RTs |
pitreact |
PIT trial RTs |
Instrumental training
| Variable | Description |
|---|---|
ainst |
Correct response per trial (1=Go, 2=NoGo) |
mprest |
Mushroom stimulus presented per trial |
lrt |
Stimulus position (1=left, 3=right) |
crtfb |
Whether accurate (1) or erroneous (0) feedback was given |
crt |
Correctness of participant's choice (1=correct, 0=incorrect) |
cht |
Participant's choice (0=NoGo, 1=left, 3=right, NaN=invalid) |
r |
Reward outcome (1=reward, -1=punishment) |
Pavlovian training
| Variable | Description |
|---|---|
pavpres |
Pavlovian stimulus presented per trial |
posp |
Stimulus position (1=left, 3=right) |
cppres |
Stimulus pair presented at each query trial |
chq |
Participant's choice at query trials |
crm |
Whether correct (higher value) stimulus was chosen |
PIT
| Variable | Description |
|---|---|
ains |
Correct response per trial (1=Go, 2=NoGo) |
mpres |
Mushroom stimulus presented per trial |
mpresp |
Pavlovian background stimulus per trial |
lr |
Stimulus position (1=left, 3=right) |
ch |
Participant's choice (0=NoGo, 1=left, 3=right, NaN=invalid) |
cr |
Correctness of participant's choice (1=correct, 0=incorrect) |
VAS and debriefing
| Variable | Description |
|---|---|
OVaspic |
VAS ratings matrix (session x stimulus), stored as proportion of scale (0=left, 1=right) |
ODebr |
Debriefing ratings matrix (session x question), stored as proportion of scale |
Notes
- To check whether a participant started with the approach block, see
Z.approachstartin the saved data (1 = started with approach). - If
Z.approachstart = 1, the first 60 instrumental trials and first 100 PIT trials are approach. - Stimulus position (lr/lrt/posp) uses values 1 and 3 based on the
drmcoordinate array insetup.m.
Sound is disabled by default. To re-enable it, uncomment the PsychPortAudio sections in setup.m, pavlov.m, and pit.m simultaneously. See the header in setup.m for full instructions.
To abort the experiment mid-session, press the Escape key. The experiment will close gracefully and save a .aborted.mat file with all data collected up to that point.