Return to the Number Letter Task page
___________________________________________________________________________________________________________________	

							NUMBER-LETTER TASK: category switch task with alternating runs
___________________________________________________________________________________________________________________	

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

Script Copyright © 03-13-2020 Millisecond Software

___________________________________________________________________________________________________________________
BACKGROUND INFO 	
___________________________________________________________________________________________________________________
This script implements the Number-Letter task (category switch task), an executive function task.

The implemented procedure is based on:

Miyake, A., Friedman, N. P., Emerson, M. J., Witzki, A. H., Howerter, A.,
& Wager, T. D. (2000). The unity and diversity of executive functions
and their contributions to complex “frontal lobe” tasks: A latent variable
analysis. Cognitive Psychology, 41, 49–100.


The Letter-Number Task is a simplified version of the alternating runs switch task by:

Rogers, R. D., & Monsell, S. (1995). The costs of a predictable switch
between simple cognitive tasks. Journal of Experimental Psychology:
General, 124, 207–231.

___________________________________________________________________________________________________________________
TASK DESCRIPTION	
___________________________________________________________________________________________________________________
This task switching task uses two simple categorization tasks and predictably alternates btw.
the two by using a clockwise rotation of stimulus presentation in a 2x2 matrix as the predictable location cues:									  

A 2 x 2 matrix is presented on screen. A pair of characters (e.g. '2F') appears in one of the matrix fields.
For each new trial, the presented pair of characters moves in clockwise fashion to the next box,
so that it is always predictable where the next character pair will appear.
The task that needs to be performed depends on the box the character pair appears in (= location cue).

Two tasks:

Task A: letter task: "If one of the characters is a consonant press, key E. 
If one of the characters is a consonant, press key I"

Task B: digit task: "If one of the characters is an even digit press, key E. 
If one of the characters is an odd digit, press key I"

Each character pair consists of of a target character (depends on the target task) and a distractor character. 
The distractor character  always comes from the opposite task.

Example:
Participant has to perform the letter task every time the character pair appears in the top quadrants of the matrix
and has to perform the digit task every time the character pair appears in the bottom quadrants of the matrix 
(this quadrant-task assignment
can be set by experimenter).
Letter Task: the character pair consists of of a target letter (e.g. 'G') and a distractor digit (e.g. '2')
Digit Task: the character pair consists of of a target digit (e.g. '3') and a distractor letter (e.g. 'A')

Because the presentation of the character pairs moves predictably in a clockwise fashion, 
every odd trial during the combined block is a 'switch task' trial and every even trial is a 'nonswitch task' trial.

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

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

(1) Raw data file: 'numberlettertask_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. 
																			
									
values.countCombinedPracticeBlocks:	counts the number of combined practice blocks run

parameters.quadrantTaskAssignment:								
									1 = top quadrants: letter task; bottom quadrants: digit task
									symbols appearing in quadrant 1 (top, left) and quadrant 2 (top, right) =>  do letter task,
									symbols appearing in quadrant 3 (bottom, right) and quadrant 4 (bottom, left) =>  do digit task
								
									2 = top quadrants: digit task; bottom quadrants: letter task
									symbols appearing in quadrant 1 (top, left) and quadrant 2 (top, right) =>  do digit task,
									symbols appearing in quadrant 3 (bottom, right) and quadrant 4 (bottom, left) =>  do letter task						
						
									3 = left quadrants: letter task; right quadrants: digit task
									symbols appearing in quadrant 1 (top, left) and quadrant 4 (bottom, left) =>  do letter task
									symbols appearing in quadrant 2 (top, left) and quadrant 3 (bottom, left) =>  do digit task
						
									4 = left quadrants: digit task; right quadrants: letter task
									symbols appearing in quadrant 1 (top, left) and quadrant 4 (bottom, left) =>  do digit task
									symbols appearing in quadrant 2 (top, left) and quadrant 3 (bottom, left) =>  do letter task										
									
									
values.congruentTasks:				stores the currently congruent tasks (based on key assignment)
									"consonant-even; vowel-odd" vs. "consonant-odd; vowel-even";									

values.switch:						0 = non-switch trial (even trials); (relevant for combined trials only)
									1 = switch trials (odd trials)
								
values.quadrant:					1 = top, left; 
									2 = top, right; 
									3 = bottom, right; 
									4 = bottom, left (clockwise)	
								
values.targetTask:					stores the task to be performed:  "letter task" vs. "digit task"
values.targetCategory:				"CONSONANT" vs. "VOWEL" vs. "ODD" vs. "EVEN"								

values.targetSymbol:				stores the current target symbol (either the target consonant, target vowel, target even number, target odd number)
values.distractorSymbol:			stores the current distractor symbol
values.targetPair:					stores the currently presented combined pair of target symbol and distractor symbol

values.congruence: 					1 = target symbol and distractor symbol share the same key
									2 = target symbol and distractor symbol require opposite keys

stimulusitem:						the presented stimuli in order of trial presentation
response:							the participant's response (scancode of response button: 18 = E; 23 = I)
correct:							accuracy of response: 1 = correct response; 0 = otherwise
latency: 							the response latency (in ms); measured from: onset of symbol pair


(2) Summary data file: 'numberlettertask_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)

							
parameters.quadrantTaskAssignment:								
									1 = top quadrants: letter task; bottom quadrants: digit task
										symbols appearing in quadrant 1 (top, left) and quadrant 2 (top, right) =>  do letter task,
										symbols appearing in quadrant 3 (bottom, right) and quadrant 4 (bottom, left) =>  do digit task
								
									2 = top quadrants: digit task; bottom quadrants: letter task
										symbols appearing in quadrant 1 (top, left) and quadrant 2 (top, right) =>  do digit task,
										symbols appearing in quadrant 3 (bottom, right) and quadrant 4 (bottom, left) =>  do letter task						
						
									3 = left quadrants: letter task; right quadrants: digit task
										symbols appearing in quadrant 1 (top, left) and quadrant 4 (bottom, left) =>  do letter task
										symbols appearing in quadrant 2 (top, left) and quadrant 3 (bottom, left) =>  do digit task
						
									4 = left quadrants: digit task; right quadrants: letter task
										symbols appearing in quadrant 1 (top, left) and quadrant 4 (bottom, left) =>  do digit task
										symbols appearing in quadrant 2 (top, left) and quadrant 3 (bottom, left) =>  do letter task									
									
									
values.congruentTasks:				stores the currently congruent tasks (based on key assignment)
									"consonant-even; vowel-odd" vs. "consonant-odd; vowel-even";	

values.prematureEnd:				1 = last combined practice performance was too low and script aborted prematurely
									0 = last combined practice performance >= parameters.minCombinedPracticeACC
									
values.countCombinedPracticeBlocks:	number of combined practice blocks of 16 trials run until performace >= parameters.minCombinedPracticeACC
									OR max number of practice blocks was run
									
expressions.ACC_combinedPractice:	proportion correct during last combined practice blocks run									

																		
Note: trials with latencies < 100ms are excluded from summary variables

expressions.count_switch:			number of switch trial responses qualified for summary variables
expressions.propCorrect_switch:		proportion of correct switch trials
expressions.count_nonswitch:		number of nonswitch trial responses qualified for summary variables
expressions.propCorrect_nonswitch:	proportion of correct nonswitch trials

expressions.ACC_SwitchCost:	accuracy switchcosts
									(difference btw. proportion correct of switch trials and nonswitch trials)
										=> negative value: participants were less accurate on switch trials 
										(there was an accuracy cost to switching )

expressions.meanRT_switch:			mean latency of correctly responding to a switch trial
expressions.meanRT_nonswitch:		mean latency of correctly responding to a nonswitch trial

expressions.RT_SwitchCost:		latency switchcosts
									(difference btw. mean correct latency of switch trials and nonswitch trials)
										=> positive value: participants were slower on switch trials 
										(there was a latency cost to switching)

expressions.propExcluded:		proportion excluded (from summary variables) trials across all combined trials 
									(excluded because of no responses or because latency < 100ms)


* separate data files: to change to one data file for all participants (on Inquisit Lab only), go to section
"DATA" and follow further instructions

___________________________________________________________________________________________________________________	
EXPERIMENTAL SET-UP 
___________________________________________________________________________________________________________________	

(1) Practice: individual task practice
* 1 block of Letter Task, 1 block of Number Task (order is randomized)
* Letter Task (32 trials):
	* 16 Consonant trials (consonants are selected randomly with replacement. Constraint: no immediate re-use of the same consonant)
		* half the consonants are paired with odd numbers, half are paired with even numbers
	* 16 Vowel trials (vowels are selected randomly with replacement. Constraint: no immediate re-use of the same vowel)
		* half the vowels are paired with odd numbers, half are paired with even numbers

* Number Task (32 trials):
	* 16 Odd trials (odd numbers are selected randomly with replacement. Constraint: no immediate re-use of the same odd number)
		* half the odd numbers are paired with consonants, half are paired with vowels
	* 16 Even trials (even numbers are selected randomly with replacement. Constraint: no immediate re-use of the same even number)
		* half the even numbers are paired with consonants, half are paired with vowels

* Key-Reminder are on screen for the first 8 trials of each practice block

(2) Test: combined task

(A) Combined Practice: 16 trials (if more or fewer practice trials should be run, change block.combinedTaskPractice)
* if proportion correct during the practice block < parameters.minCombinedPractice ACC (default = 0.8),
then the practice blocks gets repeated. Once paramaters.maxCombinedPracticeBlocks (default: 10) have run
with proportion correct during the practice block < parameters.minCombinedPractice ACC, the script aborts prematurely.
* trial set up is similar to test trials with the following differences:
	- if a mistake is made during the combined practice trials, a task and key reminder is presented and
	participants have to correct their incorrect response to move along
	- targetCategory as well as congruence is sampled randomly
	
(B) Combined Test: (128 trials)
* Block Start: depending on values.quadrantTaskAssignment (1, 2, 3, 4) the first quadrant position is randomly determined (randomly WITH replacement)
(and with it the first task is randomly determined)

	Example: values.quadrantTaskAssignment = 1 (top quadrants = letter task; bottom quadrants = digit task)
		=> the first selected quadrant is randomly selected to be either 1 (top left), or 3 (bottom right)
			=> if start quadrant is 1: starting task is letter task
				=> task sequence: AABBAABBAABB...AABB
			=> if start quadrant is 3: starting task is digit task
				=> task sequence: BBAABBAABBAA...BBAA

* quadrant changes clockwise from one trial to the next: 1 = top left; 2 = top, right; 3 = bottom, right; 4 = bottom, left	
* the task to be performed (letter task vs. digit task) depends on the quadrant
	* if letter task: half the trials select consonants; half select vowels
	* if digit task: half the trials select even numbers; half select odd numbers
* consonants, vowels, even digits, odd digits, control symbols are selected randomly WITH replacement
(constraint: the same consonant (vowel, even digit, odd digit, control symbol) canNOT be selected during the next
drawing from the same list) 
* the placement in the pair presented ('7R' vs. 'R7') is randomly determined

* Trials: 64 switch trials, 64 non-switch trials
* 64 switch trials
	=> 32 switch trials for letter (number) task
		=> 16 consonant (vowel, even, odd) trials
			=>  8 congruent/ 8 incongruent consonant (vowel, even, odd) trials
			(congruent = response buttons are the same for the target and distractor letter)

Trial Information:
target pair presentation-> 
correct response/timeout: ITI of 150ms; incorrect response: ITI of 1500ms (with errorfeedback)

___________________________________________________________________________________________________________________
STIMULI
___________________________________________________________________________________________________________________
vowels: "A", "E", "I", "U" (see list.vowels under section Editable Stimuli)
consonants: "G", "K", "M", "R" (see list.consonants under section Editable Stimuli)
odd: "3", "5", "7", "9" (see list.odd under section Editable Stimuli)
even: "2", "4", "6", "8" (see list.even under section Editable Stimuli)

___________________________________________________________________________________________________________________	
INSTRUCTIONS 
___________________________________________________________________________________________________________________
provided by Millisecond Software - can be edited under section Editable 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:

/quadrantTaskAssignmnent:		
						1 = top quadrants:letter task; bottom quadrants: digit task
							symbols appearing in quadrant 1 (top, left) and quadrant 2 (top, right) =>  do letter task,
							symbols appearing in quadrant 3 (bottom, right) and quadrant 4 (bottom, left) =>  do digit task
							
						2 = top quadrants: digit task; bottom quadrants: letter task
							symbols appearing in quadrant 1 (top, left) and quadrant 2 (top, right) =>  do digit task,
							symbols appearing in quadrant 3 (bottom, right) and quadrant 4 (bottom, left) =>  do letter task						
						
						3 = left quadrants: letter task; right quadrants: digit task
							symbols appearing in quadrant 1 (top, left) and quadrant 4 (bottom, left) =>  do letter task
							symbols appearing in quadrant 2 (top, left) and quadrant 3 (bottom, left) =>  do digit task
						
						4 = left quadrants: digit task; right quadrants: letter task
							symbols appearing in quadrant 1 (top, left) and quadrant 4 (bottom, left) =>  do digit task
							symbols appearing in quadrant 2 (top, left) and quadrant 3 (bottom, left) =>  do letter task	
							
						
Key Assignments: the default assignments align consonants and even digits/vowels and odd digits

/leftKey:				the left response button (default: "E")
/rightKey:				the right response button (default: "I")

/consonantKey:			the key assigned for consonants (default: parameters.leftKey)
/vowelKey:				the key assigned for vowels (default: parameters.rightKey)

/evenKey:				the key assigned for even digits (default: parameters.leftKey)
/oddKey:				the key assigned for odd digits (default: parameters.rightKey)

Stimuli Sizing
/quadrantSize:			the size of one of the box quadrants proportional to canvas height (default: 25%)
/targetSize:			the height of the symbol pairs proportional to canvas height (default: 5%)

Timing Parameters:
/readyDuration:			the duration (in ms) of the 'get-ready' trial (default: 2000ms)
/correctITI:			the duration (in ms) of the intertrial interval if response was correct (default: 150ms)
/errorITI:				the duration (in ms) of the intertrial interval if response was incorrect (default: 1500ms)
/blockstartDuration:	the duration (in ms) of the highlighted box at the start of a new block (default: 2000ms)

For Summary Variables
/minRT:						trials in which participant respond with latency < minRT are excluded from summary variables (default: 100ms)						
							
/minCombinedPracticeACC:	minimum performance (proportion correct) during last combined practice block to move on to actual test.
							If performance during last combined practice block is lower than parameters.minCombinedPracticeACC, 
							combined practice block gets repeated (default: 0.8 => max. number of errors = 3 => 13correct trials/16 practice trials = 0.8125)
							
/maxCombinedPracticeBlocks:	maximum number of combined practice blocks run. If practice performance is still < minCombinedPracticeACC 
							after the last block, then script aborts prematurely (default: 10)