Introduction

A broad introduction to task switching can be read in the other task switching library entry. Click here to go there.

There are two types of task-switching paradigms:

Paradigm type Description

Alternate runs paradigm

Participant needs to know when to switch. For example, the switching rule can be to switch every two trials . The other lesson has a demo of this.

Cued taskswitching paradigm

A cue stimulus tells the participant which task to do on every trial. Used in this library experiment.

There are also some paradigms which are a bit inbetween. A good example is the one in which the cue is implicit, as you can see in the multitasking paradigm on this website. Click here to the multitasking experiment.

A good example of a paper about cued task switching is Meiran’s 1996 study (see references).

About this implementation

In this paradigm, we have a shape and a color task. The cue for the color task is the word "color" and the cue for the shape task is the word shape. In the shape task, you need to respond to circles and shapes while ignoring the color; in the color task you need to respond to the color while ignoring the shape.

You can change the duration of the cue presentation, the delay between cue and imperative stimulus, the between trial interval. All these variables will influence the task switch costs. At the end of the trial, you will get feedback about your performance, task-switch cost, etc.

We can calculate a task switch and a task interference or task congruence cost.

Run the demo

In this experiment, you respond with the keys b and n to circles and squares (in the shape task) and the color purple and yellow (in the color task). The instructions are all on screen and require some concentrated reading.

Data output file

In PsyToolkit, the data output file is simply a textfile. The save line of the PsyToolkit experiment script determines what is being saved in the data output file. Typically, for each experimental trial, you would have exactly one line in your text file, and each number/word on that line gives you the information you need for your data analysis, such as the condition, response speed, and whether an error was made.

Meaning of the columns in the output datafile. You need this information for your data analysis.

Colum Meaning

1

Blockname

2

Task-type

3

Congruent or incongruent (as word)

4

Congruent or incongruent (as number 1 or 2)

5

Required button press (left = b-key, right = n-key)

6

Response time in milleseconds

7

Status (1=correct, 2=wrong, 3=timeout)

8

Taskswitching (1=repeat, 2=switch)

PsyToolkit code

Click to expand the PsyToolkit script code (part of zip file below)
options
  bitmapdir stimuli
  set &CurrentTask 0
  set &previousTask 0
  set &cue_display_time 350
  set &cue_delay 750
  set &intertrialinterval 1000

fonts
  arial 18
  
bitmaps
  ready
  fixpoint
  thankyou
  info1
  instruction1
  instruction2
  instruction3
  instruction4
  wrong_key
  too_slow
  circle_blue
  circle_yellow  
  rectangle_blue
  rectangle_yellow  
  colorcue
  shapecue

######################################################################
# task switching conditions
######################################################################

table colortasktable
  "color congruent   1 left " circle_yellow     1
  "color incongruent 2 left " rectangle_yellow  1
  "color incongruent 2 right" circle_blue       2
  "color congruent   1 right" rectangle_blue    2

table shapetasktable
  "shape congruent   1 left " circle_yellow     1
  "shape incongruent 2 right" rectangle_yellow  2
  "shape incongruent 2 left " circle_blue       1
  "shape congruent   1 right" rectangle_blue    2

######################################################################
# task switching tasks
######################################################################

task color
  table colortasktable
  keys b n
  # -- for later data analysis --------
  set &CurrentTask 1
  if &CurrentTask == &previousTask
    set $taskSwitch 1
  fi
  if &CurrentTask != &previousTask
    set $taskSwitch 2
  fi
  set &previousTask &CurrentTask
  #------------------------------------
  show bitmap fixpoint
  delay 150
  clear -1
  delay 500
  show bitmap colorcue
  delay &cue_display_time
  clear -1
  delay &cue_delay
  show bitmap @2      
  readkey @3 2000 ## respond withint 2s
  clear -1
  if STATUS == WRONG
    show bitmap wrong_key
    delay 500
    clear -1
  fi
  if STATUS == TIMEOUT
    show bitmap too_slow    
    delay 500
    clear -1
  fi
  delay &intertrialinterval
  save BLOCKNAME @1 RT STATUS $taskSwitch

task shape
  table shapetasktable
  keys b n
  # -- for later data analysis --------
  set &CurrentTask 2
  if &CurrentTask == &previousTask
    set $taskSwitch 1
  fi
  if &CurrentTask != &previousTask
    set $taskSwitch 2
  fi
  set &previousTask &CurrentTask
  #------------------------------------
  show bitmap fixpoint
  delay 150
  clear -1
  delay 500
  show bitmap shapecue
  delay &cue_display_time
  clear -1
  delay &cue_delay
  show bitmap @2      
  readkey @3 2000 ## responde withint 2s
  clear -1
  if STATUS == WRONG
    show bitmap wrong_key   
    delay 500
    clear -1
  fi
  if STATUS == TIMEOUT
    show bitmap too_slow    
    delay 500
    clear -1
  fi
  delay &intertrialinterval
  save BLOCKNAME @1 RT STATUS $taskSwitch

# -------------------------------------------------------
#      B L O C K S
# -------------------------------------------------------

######################################################################
#                            B L O C K S
######################################################################

block trainingblock
  pager info1 instruction1 instruction2 instruction3 instruction4
  tasklist
    color 5
    shape 5
  end

block realblock
  message ready
  tasklist
    color 25
    shape 25
  end
  feedback
    set &overall      mean c6 ; select c7 == 1
    set &RepeatTrials mean c6 ; select c7 == 1 && c8 == 1
    set &SwitchTrials mean c6 ; select c7 == 1 && c8 == 2
    set &Congruent    mean c6 ; select c7 == 1 && c4 == 1
    set &Incongruent  mean c6 ; select c7 == 1 && c4 == 2
    set &SwitchCost expression &SwitchTrials - &RepeatTrials
    set &TaskInterference expression &Incongruent - &Congruent
    text 0 -200 &overall ; prefix "Average RT in all correct trials:" ; postfix "ms"
    text 0 -150 &RepeatTrials ; prefix "RT in task-repeat trials:" ; postfix "ms"
    text 0 -100 &SwitchTrials ; prefix "RT in task-switching trials:" ; postfix "ms"
    text 0  -50 &SwitchCost ; prefix "Task-switch cost:" ; postfix "ms"
    text 0    0 &Congruent ; prefix "RT in task-congruent trials:" ; postfix "ms"
    text 0   50 &Incongruent ; prefix "RT in task-incongruent trials:" ; postfix "ms"
    text 0  100 &TaskInterference ; prefix "Task-interference:" ; postfix "ms"
    text 0  250 "Press space bar"
  end
  
##########################

message thankyou

Download

If you have a PsyToolkit account, you can upload the zipfile directly to your PsyToolkit account. Watch a video on how to do that. If you want to upload the zipfile into your PsyToolkit account, make sure the file is not automatically uncompressed (some browsers, especially Mac Safari, by default uncompress zip files). Read here how to easily deal with this.

Further reading

  • Meiran, N. (1996). Reconfiguration of Processing Mode Prior to Task Performance. Journal of Experimental Psychology. Learning, Memory, and Cognition, 22, 1423-1442.