Return to the Cognitive Effort Discounting Task page
___________________________________________________________________________________________________________________	

						Cognitive Effort Discounting Task (with n-back task)
___________________________________________________________________________________________________________________

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software LLC
last updated:  03-06-2020 by K. Borchert (katjab@millisecond.com) for Millisecond Software, LLC

Script Copyright © 03-06-2020 Millisecond Software

___________________________________________________________________________________________________________________
BACKGROUND INFO 	
___________________________________________________________________________________________________________________	
This script implements a Cognitive Effort Discounting Procedure to establish
indifference points (minimum price points) at which people start to discount ("devalue") monetary rewards
paid for higher effort tasks in favor of less paid lower effort tasks.

The implemented procedure is based on:											
											
Westbrook A, Kester D, Braver TS (2013). What Is the Subjective Cost of Cognitive Effort? Load,
Trait, and Aging Effects Revealed by Economic Preference. 
Pessiglione M, ed. PLoS One 981 8:e68210.		

Adjustments to reported z-scores of extreme hit and false alarm rates as described by:
Gregg, A. & Sedikides, C. (2010). Narcissistic Fragility:
Rethinking Its Links to Explicit and Implicit Self-esteem, Self and Identity, 9:2, 142-161 (p.148)								
											
											
___________________________________________________________________________________________________________________
TASK DESCRIPTION	
___________________________________________________________________________________________________________________
Participants are repeatedly asked to choose between a more difficult cognitive task with
a higher earning potential or an easier cognitive task with less earning potential.
Through a series of questions the participants' cognitive effort indifference point for the pair
of tasks is determined (aka the price point at which participants start to devalue the potential
higher pay for a challenging cognitive task in favor of less pay for a less challenging one).
		
In this script, the cognitive task chosen is the n-back working memory task.
6 levels of n-back tasks are used in this task (editable) with the 1-back being the designated 'easy' task.

The procedure is divided into 3 phases:

1. Participants get familiar with the n-back procedure and work through several rounds of n-back tasks for the 
different levels of N.

2. Participants work through the indifference point estimation procedure (without actually performing the n-back tasks)
for the 5 higher levels of N (1 vs.2; 1 vs. 3; 1 vs. 4; 1 vs. 5; 1 vs. 6)

3. One of the participant's choices is randomly selected, the participant works through 10 (default) more rounds
of n-backs with the selected N and promised reward.
Note: in this script, d' is used as a rough performance/effort measure to decide actual payment.
This differs from the Westbrook et al (2013) procedure in which payment was not based on performance but rather on some
'behavioral cue' monitoring for effort.
											
											
									*N-back Task (with letter stimuli)*
The n-back task is a go/nogo task in which participants have to press one key for targets (go) and
don't respond for non-targets. Which stimuli are targets depends on the level of N:										
										
for N=1 trials (1-back):
- is the letter the same as the one that preceded it? If so (it's a target), and press "A". If not, don't respond.

for N=2 trials (2-back):
- is the letter the same as the one presented two trials before? If so (it's a target), and press "A". If not, don't respond.

for N=3 trials (3-back):
- is the letter the same as the one presented three trials before? If so (it's a target), and press "A". If not, don't respond.

etc.

___________________________________________________________________________________________________________________	
DURATION 
___________________________________________________________________________________________________________________	
the default set-up of the script takes appr. 20 minutes to complete

___________________________________________________________________________________________________________________	
DATA FILE INFORMATION 
___________________________________________________________________________________________________________________
The default data stored in the data files are:

(1) Raw data file: 'cognitiveeffortdiscountingtask_raw.iqdat' (a separate file for each participant)

build:								The specific Inquisit version used (the 'build') that was run
computer.platform:					the platform the script was run on (win/mac/ios/android)
date, time, 						date and time script was run 
subject, group, 					with the current subject/groupnumber
script.sessionid:					with the current session id

blockcode, blocknum:				the name and number of the current block (built-in Inquisit variable)
trialcode, trialnum: 				the name and number of the currently recorded trial (built-in Inquisit variable)
										Note: trialnum is a built-in Inquisit variable; it counts all trials run; even those
										that do not store data to the data file such as feedback trials. Thus, trialnum 
										may not reflect the number of main trials run per block. 

phase1BlockCount:					the total number of n-back practice blocks run (phase 1)
phase3BlockCount:					the total number of phase 3 n-back blocks run

phase:								1 = n-back practice
									2 = indifference point assessment
									3 = final n-back runs to earn money
								
N:									the level of N tested								

stimulusitem.1:						phase1/phase3: n-back trials: the letter presented
									phase2: the current amount offered for the 1-back 
								
								
values.phase1BlockCount, values.phase3BlockCount,
values.phase, values.N, , , stimulusitem, 
values.currenttarget, response, values.respCategory, correct, latency,	values.level1Reward, values.levelXReward, values.adjust,	
expressions.hitrate, expressions.FArate, expressions.z_hits, expressions.z_FA, expressions.dprime, values.								
								
								
stimulusnumber.1: 					n-back trials: the item number of the presented letter

stimulusitem.2:						phase1/phase3: empty
									phase2: the amount offered for the current higher N-back 

currenttarget:						n-back trials: the item number of the current target

response:							the response of the participant (scancode of response button)
									31 = A
									16 = Q
									25 = P
									57 = spacebar
									
respCategory:						Phase 1/Phase 3: n-back => Hit, Miss, FA (false alarm), CorrReject 	
									Phase 2: 1-back, 2-back, 3-back, 4-back, 5-back, 6-back (the selected n-back)
																		
correct:							the correctness of the response (1 = correct; 0 = otherwise)
									Note: has no meaning for phase 2 trials
									
latency:							how fast a participant responded within the given timeframe (in ms)
									Phase1/Phase3: n-back trials => latencies of 1500ms (stimulus presentation time) are no responses
									
level1Reward:						Phase 2: the currently offered reward for choosing the 1-back task									
levelNReward:						Phase 2: the currently offered reward for choosing the higher level N-back task							
adjust:								Phase 2: the adjusted amount for level1Reward for that trial

the following variables have only meaning for phase1/phase3										
hitrate:							calculates the hit rate for the current level of N 
FArate:								calculate the False Alarm rate for the current level of N (resets after each level)	
z_hits:								converts the current hit rate into a z-value (resets after each level)
z_FA:								converts the current False Alarm rate into a z-value (resets after each level)
dprime:								calculates d' for the current level of N (resets after each level)
									=> the higher d' the better targets were distinguished from nontargets (and the correct responses were made)
									=> d' = 0, random performance OR not responding at all OR always responding
									=> negative d': essentially targets are more treated as non-targets and non-targets as targets

the following variables have only meaning for phase3:
RoundWinAmount: 					Phase 3: the amount won after the current phase 3 round
TotalWinAmount:						Phase 3: the total amount won during phase 3
								
								
(2) Summary data file: 'cognitiveeffortdiscountingtask_summary*.iqdat' (a separate file for each participant)

computer.platform:					the platform the script was run on (win/mac/ios/android)
script.startdate:					date script was run
script.starttime:					time script was started
script.subjectid:					assigned subject id number
script.groupid:						assigned group id number
script.sessionid:					assigned session id number
script.elapsedtime:					time it took to run script (in ms); measured from onset to offset of script
script.completed:					0 = script was not completed (prematurely aborted); 
									1 = script was completed (all conditions run)

IP12-IP16:							indifference points 
									(here: values.level1Reward after the 6th choice for the currently tested level of N)
								
TotalWinAmount:						the total win amount from phase 3								

Adjustments to reported z-scores of extreme hit and false alarm rates as described by:
Gregg, A. & Sedikides, C. (2010). Narcissistic Fragility:
Rethinking Its Links to Explicit and Implicit Self-esteem, Self and Identity, 9:2, 142-161 (p.148)	
																
hitrate_N1-
hitrate_N6:							store the hitrates for N levels 1-6 during phase 1 (across all rounds for each N-level)
FArate_N1-
FArate_N6:							store the false alarm rate for N levels 1-6 during phase 1 (across all rounds for each N-level)			 	
zh_N2-
zh_N4:								store the z-values of the hit rate for N levels 1-6 during phase 1
zFA_N2-
zFA_N4:								store the z-values of the false alarm rate for N levels 1-6 during phase 1
dprime_N2-
dprime_N4:							store d' for N levels 1-6 during phase 1
									=> the higher d' the better targets were distinguished from nontargets (and the correct responses were made)
									=> d' = 0, random performance OR not responding at all OR always responding
									=> negative d': essentially targets are more treated as non-targets and non-targets as targets
								

___________________________________________________________________________________________________________________	
EXPERIMENTAL SET-UP 
___________________________________________________________________________________________________________________	

3 phases:

(1) Phase 1: n-back Practice

- by default, this script runs through 1 run of N-levels 1-6 (see section Editable Parameters to select N-levels and/or change number
of rounds) => 6 blocks of n-backs

- each n-back block runs for 20 trials (see section Editable Parameters to change the number of trials; the start trials that
cannot be target yet are not counted towards the trialcount)
Note: Westbrook et al (2013) ran 64 trials per block.

- each block runs 25% targets (here: 5 target trials) (see section Editable Parameters to change the proportion)
!!!This script does not run target-lure trials (see Westbrook et al, 2013, p.2)
- the order of targets and nontargets is randomly determined

- each level of N is assigend a particular letter color (see section Editable Parameters)

- at the end of each block, participants receive feedback

Trial Sequence:
Letter (1500ms = response timeout) -> Fixation Cross (2000ms) -> Letter.....

Responses are only registered during letter presentations. Responses do not interrupt letter presentations. 


(2) Phase 2: Indifference Point Estimations
- each higher level of N (2-6) is compared to level N=1 in 6 consecutive trials
Note: levels of N are referred to by Number and respective Color as opposed to Westbrook et al (2013)
who only refer to the levels by their respective colors

- the order of the 5 tested N-levels is randomized

Indifference Point Algorithm:
- the harder level N always offers a higher (fixed) reward (see section Editable Parameters),
- the possible reward for the easier 1-back starts at 1 but gets adjusted according to the choices made:
	- if the harder choice was previously selected; the reward goes up (by half the previous adjustment)
	- if the easier choice was previously selected; the reward goes down (by half the previous adjustment)
- Indifference Points: the adjusted reward for level 1 after the last choice (aka: the reward offered for level 1 on the 
7th round)


(3) Phase 3: Actual Money Earning Phase with Effort Monitoring (can be skipped; see parameters.phase3Runs for more info)
- one of the 5 (level of N: 2-6) * 6 (trials per level of N) = 30 choice trials from Phase 2 is randomly 
selected by the computer
- the chosen N during that trial as well as the promised reward is used for another 5 (editable)
rounds of n-backs

!!!NOTE: in this script, d' is used as a rough performance measure to decide actual payment.
This differs from the Westbrook et al (2013) procedure in which payment was not based on performance but rather on some
'behavioral cue' monitoring for effort.

___________________________________________________________________________________________________________________	
STIMULI
___________________________________________________________________________________________________________________
* the n-back task runs with consonants (see section Editable Stimuli)
* the size of the letters can be adjusted under section Editable Parameters

___________________________________________________________________________________________________________________	
INSTRUCTIONS 
___________________________________________________________________________________________________________________	
provided by Millisecond Software as *.htm files.
To change instructions, edit the htm files directly (e.g. in TextEdit for Macs or Notepad for Windows).
These are not the original Westbrook et al (2013) instructions.

___________________________________________________________________________________________________________________	
EDITABLE CODE 
___________________________________________________________________________________________________________________	
check below for (relatively) easily editable parameters, stimuli, instructions etc. 
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code 
to further customize your experiment.

The parameters you can change are:

Experimental Settings:
/runN2:								true(default) vs. false: if true, the 2-back task is run
/runN3:								true(default) vs. false: if true, the 3-back task is run
/runN4:								true(default) vs. false: if true, the 4-back task is run
/runN5:								true(default) vs. false: if true, the 5-back task is run
/runN6:								true(default) vs. false: if true, the 6-back task is run
									!!!Note: by setting one of these variables to false, the respective n-back is 
									removed from the experimental procedure. HOWEVER: instruction files need to be manually 
									updated to reflect the changes.
										-> cog_ed_nbackintro7.htm
										-> cog_ed_nbackintro8.htm
										-> cog_ed_choice1.htm

/trials_per_nback:						number of trials per block of n-back tasks (default: 20, Westbrook et al, 2013, ran 64 trials)

/propTargets:							the proportion of target trials (default: 0.25 => 5 target trials per block)
										Note: the proportion should result in an integer number of target trials
										given parameters.trials_per_nback 
										
/practiceRuns:						number of blocks a particular n-back level is repeated during practice
									(e.g. by default, 1 block per n-back level are run, Westbrook et al, 2013, ran 3 runs of each level)
									
/phase3Runs:						number of times, the randomly selected n-back procedure from phase 2 
									is run (default: 5, Westbrook et al, 2013, ran 10 blocks)
									Note: by setting this parameter = 0; phase 3 can be skipped altogether.
									
									
/level1_reward:						the initial reward offered for 1-back tasks during the choice phase (default: $1)
/level2_reward:						the initial reward offered for 2-back tasks during the choice phase (default: $2)
/level3_reward:						the initial reward offered for 3-back tasks during the choice phase (default: $2)
/level4_reward:						the initial reward offered for 4-back tasks during the choice phase (default: $2)
/level5_reward:						the initial reward offered for 5-back tasks during the choice phase (default: $2)
/level6_reward:						the initial reward offered for 6-back tasks during the choice phase (default: $2)									
																		

Trial Timings;

/startFixationDuration:				the duration (in ms) of the first fixation cross (and key reminder) at the beginning of each 
										n-back block (default: 3000ms)
									
/SOA: 								the stimulus onset asynchrony (time in ms between onset of one letter and onset of the next)
										(default: 3500ms)
									
/stimulusPresentationtime:			the duration (in ms) of each letter (default: 1500)
										Note: this duration equals the response timeout
									
										!!!Note: if durations are changed, image "intro6_image.png"
										needs to be updated manually.
																		
User Interface:
									
/letterSize:						the height of the letters in proportion to canvas height (default: 20%)
/fixationCrossSize:					the height of the fixation cross in proportion to canvas height (default: 10%)

Colors: 							the colors used for the 6 different n-back levels

Note: The default colors are the ones used by Westbrook et al (2013)									
									
/colorN1 = "black"
/colorN2 = "red"
/colorN3 = "blue"
/colorN4 = "purple"
/colorN5 = "green"
/colorN6 = "brown"


/debugmode = 0						debugmode = 1: targetalerts are shown on screen, 
									debugmode = 0, no targetalerts are shown (default)