Return to the Category Switch Task page
___________________________________________________________________________________________________________________	

								Category Switch Task: random task switches
___________________________________________________________________________________________________________________

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 12-04-2017
last updated:  01-07-2020 by K. Borchert (katjab@millisecond.com) for Millisecond Software, LLC

Script Copyright © 01-07-2020 Millisecond Software

___________________________________________________________________________________________________________________
BACKGROUND INFO 	
___________________________________________________________________________________________________________________
This script implements a Category Switch Task, an executive function test, similarly to the one outlined by:

Friedman, N.P., Miyake, A., Young, S.E., DeFries, J.C., Corley, R.P., & Hewitt, J.K. (2008).
Individual Differences in Executive Functions Are Almost Entirely Genetic
in Origin. Journal of Experimental Psychology: General, 137, 201-225.

The Friedman et al (2008) task is in turn based on:
Mayr, U., & Kliegl, R. (2000). Task-set switching and long-term memory
retrieval. Journal of Experimental Psychology: Learning, Memory, and
Cognition, 26, 1124–1140.

The task switching implemented in this script is random and thus, not predictable.

___________________________________________________________________________________________________________________
TASK DESCRIPTION	
___________________________________________________________________________________________________________________
Participants are given a word and have to perform one of two simple categorization tasks
depending on the cue that appears with the word:
1. 'Living' Task: If the cue is a heart -> Participants are asked to categorize the word via key press 
based on whether it represents a LIVING vs. a NON-LIVING object.
2. 'Size' Task: If the cue is an arrowcross -> Participants are asked to categorize the word via key press 
based on whether it represents an object that is BIGGER or SMALLER than a basketball.

The cue selection for each new trial is randomized.
Half the test trials in this script are switch trials, half of the test trials are non-switch trials.
Half the switch (non-switch) trials are congruent in the key presses for either task,
half are incongruent.

(Congruent: the 'living' and the 'size' task require the same key press for a correct response
Incongruent: the 'living' and the 'size' task require opposite key presses for a correct response)

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

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

(1) Raw data file: 'categoryswitchtask_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

keyAssignmentGroup:			KeyAssignment group 1: runs "living/big (left) vs. non-living/small (right)"
								KeyAssignment group 2: runs "living/small (left) vs. non-living/big (right)"
								KeyAssignment group 3: runs "living/big (right) vs. non-living/small (left)"
								KeyAssignment group 4: runs "living/small (right) vs. non-living/big (left)" 
								
blockcode, blocknum:			the name and number of the current block (built-in Inquisit variable)

countCombinedPracticeBlocks:	Practice Block Counter

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. 

congruentKeys:					stores the congruent keys 'living-big vs. nonliving-small' VS 'living-small vs. nonliving-big'									
switch:							1 = current trial requires a task switch; 0 = current trial presents the same task as the previous one
cueCondition:						1 = heart -> living Task; 2 = arrowcross -> size Task 

congruence:						Congruence: the 'living' and the 'size' task require the same key press for a correct response
									1 = congruent; 0 = incongruent	
								
target:							stores the current target word
targetIndex:						stores the current target Itemnumber
stimulusitem:						the presented stimuli in order of trial presentation

correctResponseCat:			living task: 1 = living; 0 = non-living; 
									size task: 1 = bigger; 0 = smaller
								
response:							the participant's response: scancode of last response button pressed 
									Note: for corrected responses (here: all practice trials), 
									'correct' stores the accuracy of the FIRST response but 'response' will store the LAST response 
								
responseKeyInterpret: 			the interpretation of the response key press depending on task required									
correct:							accuracy of (initial) response: 1 = correct response; 0 = otherwise
latency: 							the response latency (in ms); measured from: onset of target word
list.ACC_block.mean:				stores the proportion correct of the current block trials


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

keyAssignmentGroup:				KeyAssignment group 1: runs "living/big (left) vs. non-living/small (right)"
									KeyAssignment group 2: runs "living/small (left) vs. non-living/big (right)"
									KeyAssignment group 3: runs "living/big (right) vs. non-living/small (left)"
									KeyAssignment group 4: runs "living/small (right) vs. non-living/big (left)" 

congruentKeys:					stores the congruent keys 'living-big vs. nonliving-small' VS 'living-small vs. nonliving-big'								
								
practiceFail:						1 = last combined practice performance was too low and script aborted prematurely (fail)
									0 = last combined practice performance >= parameters.minCombinedPracticeACC (pass)
								
countCombinedPracticeBlocks:	number of combined practice blocks of 16 trials run until performace >= parameters.minCombinedPracticeACC
									OR max number of practice blocks was run
								
ACC_CombinedPractice:			proportion correct during last combined practice blocks run	

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

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

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 )

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

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)

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 
___________________________________________________________________________________________________________________	

Key Assignments are counterbalanced by groupnumbers (1-4) in this script.
KeyAssignment group1: runs "living/big (left) vs. non-living/small (right)"
KeyAssignment group2: runs "living/small (left) vs. non-living/big (right)"
KeyAssignment group3: runs "living/big (right) vs. non-living/small (left)"
KeyAssignment group4: runs "living/small (right) vs. non-living/big (left)"

(1) Practice:
	(A) only living test: 32 trials (first 8 trials with key reminders)
		- errorfeedback
		- need to correct response to move along
	(B) size test: 32 trials (first 8 trials with key reminders)
		- errorfeedback
		- need to correct response to move along
		
	=> The order of living practice vs. size practice is randomized in this script
		
	(C) Combined tasks: 
		- 16 trials (change block.combinedPractice to increase number of trials)
		- 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 combined 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

(2) Test:		
	(A) Prefatory Block: 1 trial (data excluded from summary variables) 
		- randomly selects the cuecondition and the stimulus
		- the prefatory trial turns into test trials without further notice
	(B) Test Block: 32 trials (default number of test blocks run: 2 => Total of 64 trials)
		- order of switch and non-switch tasks is randomly determined (see list.switchOrder)
		- 16 switch tasks, 16 non-switch tasks
			- the 16 switch trials run all 16 items (8 are key congruent, 8 are key incongruent)
			- the 16 nonswitch trials run all 16 items (8 are key congruent, 8 are key incongruent)
			
	Error Feedback: presented for 500ms after an incorrect response

Note: this script focuses on the shifting btw. tasks and therefore keeps the number of switch 
and non-switch trials balanced while allowing the order of switch and non-switch trials to be random (see list.switchOrder). 
This can result in an inbalance of the number of Living vs. Size Tasks run.
If switch tasks are alternated (instead of randomized), then the number of Living vs. Size Tasks run will be the same.

___________________________________________________________________________________________________________________	
STIMULI
___________________________________________________________________________________________________________________
* 16 target words provided by Friedman et al (2008)/Mayr & Kliegl (2000);
font: Arial, Size: can be edited under section Editable Parameters
* cues provided by Millisecond Software, Size: can be edited under section Editable Parameters

___________________________________________________________________________________________________________________	
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:

/cueSize:					proportional (to canvas height) sizing of the cue (default: 10%)
/targetWordSize:				proportional (to canvas height) sizing of the target words (default: 10%)

/leftKey:						the scancode of the left response key (default: 18)
									Note: see Tools-> keyboard scancodes
									
/leftKey_Label:				the label of the left response key (default: 'E')
/rightKey:					the scancode of the left response key (default: 23)
/rightKey_Label:				the label of the left response key (default: 'I')

/numberOfTestblocks:			the number of test blocks run (default: 2 => each test blocks runs 32 trials)

/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)

/readyDuration:				duration (in ms) of the 'get ready' trials (default: 2000ms)
/cueTarget_SOA:				the stimulus onset asynchrony (SOA) btw. onset of cue and onset of target (default: 0ms)
/errorITI:						the duration (in ms) of the intertrial pause after an error (default: 1500ms)
/correctITI:					the duration (in ms) of the intertrial pause after a correct response (default: 500ms)

For Summary Variables
/minRT:						trials in which participant respond with latency < minRT are excluded from summary variables (default: 100ms)