How to use

This is the main source code for the experiment. If you want to use it, you should copy the actual zip file to your own PsyToolkit account, because often there are other files included for stimuli.

The source code for iat2

options
  background color 200 200 200
  scale
  set &MyMaxRT 10000

bitmaps
  title
  i1
  i2
  i3
  i4

fonts
  big   arial 24
  small arial 14

table pleasant_unpleasant
  include pleasant.txt
  include unpleasant.txt

table black_white
  include black_males.txt
  include white_males.txt

table combined
  include pleasant.txt
  include unpleasant.txt
  include black_males.txt
  include white_males.txt

######################################################################################
## parts of code being used in different tasks
######################################################################################

part determine_black_white_stimulus_position
  if &BlackIsPleasant == 1
    set &blackpos -300
    set &whitepos  300
    else
    set &blackpos  300
    set &whitepos -300
  fi

part determine_correct_key ## only for combined and black_white tasks
  if @3 == 2 ## this means unpleasant/pleasant classification
    set $correctKey @2
    else
    if &BlackIsPleasant == 1 ## black is left on screen
      set $correctKey @2
      else
      if @2 == 1 ## the name is black (and "black" is on right side)
        set $correctKey 2
        else       ## the name is white (and "black" is on right side)
        set $correctKey 1
      fi
    fi
  fi

## stimulustype : 1) pleasant word 2) unpleasant word 3) black name 4) white name

part determine_stimulustype
  ## stimulustype :
  if @3 == 2 ## words
    if @2 == 1 ## pleasant word
      set &stimulustype 3
    fi
    if @2 == 2 ## unpleasant word
      set &stimulustype 4
    fi
  fi
  if @3 == 1 ## names
    if @2 == 1 ## black name
      set &stimulustype 3
    fi
    if @2 == 2 ## white name
      set &stimulustype 4
    fi
  fi

part task_feedback_and_save
  if STATUS == WRONG
    show text "Wrong key (use A or L)" 0 0 black
    delay 300
    clear -1
  fi
  if STATUS == TIMEOUT
    show text "Too slow" 0 0 black
    delay 300
    clear -1
  fi
  delay 250
  ## we need to know percentage of trials lower than 300 for the new IAT scoring method
  if RT < 300
    set &lower300trials increase
  fi
  set &totalN increase
  save BLOCKNUMBER BLOCKNAME &inBlockCounter TABLEROW @1 @2 @3 &compatibility &stimulustype &BlackIsPleasant RT STATUS
  set &inBlockCounter increase

## stimulustype : 1) pleasant word 2) unpleasant word 3) black name 4) white name
## compatibility: 0) single block 1) compatible block 2) incompatible block

part myfeedback
  feedback
    text color black
    set &MyAverage mean c11  ; select c12 == 1 && c1 == BLOCKNUMBER
    set &MyErrorRate perc 50 ; select c12 != 1 && c1 == BLOCKNUMBER
    text 0 -50 "Some feedback about your performance:"
    text 0 0  &MyAverage ; prefix "Average response time " ; postfix " ms"
    text 0 150 &MyErrorRate ; prefix "Error percentage " ; postfix " %"
    text 0 200 "Press spacebar to continue"
  end

######################################################################################
## tasks
######################################################################################

task pleasant_unpleasant
  table pleasant_unpleasant
  if @2 == 1
    set &stimulustype 1 ## pleasant word
    else
    set &stimulustype 2 ## unpleasant word
  fi
  keys a l
  font big
  show text "pleasant"   -300  200  black
  show text "unpleasant"  300  200  black
  show text @1 0 0 black
  readkey @2 &MyMaxRT
  clear -1
  part task_feedback_and_save

task black_white
  table black_white
  if @2 == 1
    set &stimulustype 3 ## black name
    else
    set &stimulustype 4 ## white name
  fi
  keys a l
  part determine_black_white_stimulus_position
  part determine_correct_key
  part determine_stimulustype
  font big
  show text "BLACK" &blackpos -200  black
  show text "WHITE" &whitepos -200  black
  show text @1 0 0 black
  readkey $correctKey &MyMaxRT
  clear -1
  part task_feedback_and_save

task combined
  set $my_trial &&alltrials remove random
  tablerow $my_trial
  table combined
  keys a l
  part determine_black_white_stimulus_position
  part determine_correct_key
  font big
  show text "pleasant"        -300  200  black
  show text "unpleasant"       300  200  black
  show text "BLACK"      &blackpos -200  black
  show text "WHITE"      &whitepos -200  black
  show text @1 0 0 black
  readkey $correctKey &MyMaxRT
  clear -1
  part task_feedback_and_save
  ##
  ## now append RTs for correct (STATUS==1) trials, but not first 2 trials (&FirstInBlock==0)
  ## FOR method 1 (Greenwald 1998 paper) and method 2 (Greenwald 2003)
  if &inBlockCounter > 2 and STATUS == 1 and RT >= 300 and RT <= 3000
    if &BlackIsPleasant == 1 ## black + pleasant / white + unpleasant = incompatible
      if @2 == 1 ## blacks
        set &&rtBlackPleasant append RT
      fi
      if @2 == 2 ## whites
        set &&rtWhiteUnpleasant append RT
      fi
    fi
    if &BlackIsPleasant == 2 ## black + unpleasant / white + pleasant = compatible
      if @2 == 1 ## blacks
        set &&rtBlackUnpleasant append RT
      fi
      if @2 == 2 ## whites
        set &&rtWhitePleasant append RT
      fi
    fi
  fi
  ### NOW FOR METHOD 2 (GREENWALD 2003), WHICH INCLUDES DIFFERENT TRIALS AND SO ON
  ###
  if STATUS == 1 and RT <= 10000
    if &practice == 1 and &BlackIsPleasant == 1 ## incompatible
      set &&method2incPractice append RT
    fi
    if &practice == 2 and &BlackIsPleasant == 1 ## incompatible
      set &&method2incReal append RT
    fi
    if &practice == 1 and &BlackIsPleasant == 2 ## compatible
      set &&method2comPractice append RT
    fi
    if &practice == 2 and &BlackIsPleasant == 2 ## compatible
      set &&method2comReal append RT
    fi
  fi
  ###

## the last task calc_and_show does the relatively complex score
## calculation and gives detailed feedback.

task calc_and_show
  keys space
  text align left
  ### FIRST THE CONVENTIONAL METHOD AS IN GREENWALD ET AL 1998
  set $compatibleB   &&rtBlackUnpleasant roundmean
  set $incompatibleB &&rtBlackPleasant roundmean
  set $compatibleW   &&rtWhitePleasant roundmean
  set $incompatibleW &&rtWhiteUnpleasant roundmean
  set $iat_overall_rt expression ( $incompatibleB + $incompatibleW ) / 2 - ( $compatibleB + $compatibleW ) / 2
  #
  # SECOND THE 2003 METHOD AS IN GREENWALD ET AL 2003 and LANE ET AL (Bookchapter)
  # this result is saved but not reported based on Lane table 3.3
  #
  # 3. Compute the “inclusive” standard deviation for all trials in
  #  Stages 3 and 6 and likewise for all trials in Stages 4 and 7
  set &&stages_3_6 append &&method2comPractice
  set &&stages_3_6 append &&method2incPractice
  set &practiceSD &&stages_3_6 sd1 ## with Bessel's correction n-1
  set &&stages_4_7 append &&method2comReal
  set &&stages_4_7 append &&method2incReal
  set &realSD &&stages_4_7 sd1 ## with Bessel's correction n-1
  # Compute the mean latency for responses for each of Stages 3, 4, 6,
  #  and 7
  set &meanStage3 &&method2comPractice mean
  set &meanStage4 &&method2comReal mean
  set &meanStage6 &&method2incPractice mean
  set &meanStage7 &&method2incReal mean
  # Compute the two mean differences (MeanStage 6 – MeanStage 3) and
  # (MeanStage 7 – MeanStage 4)
  set &iatDiffPractice expression &meanStage6 - &meanStage3
  set &iatDiffReal     expression &meanStage7 - &meanStage4
  # 6 Divide each difference score by its associated “inclusive”
  # standard deviation
  set &iatDiffPracticeRatio expression &iatDiffPractice / &practiceSD
  set &iatDiffRealRatio     expression &iatDiffReal     / &realSD
  # 7 D = the equal-weight average of the two resulting ratios
  set &iatDscore expression ( &iatDiffPractice + &iatDiffReal ) / 2
  set $percentageBelow300 expression ( &lower300trials / &totalN ) * 100
  save $iat_overall_rt &iatDscore $percentageBelow300
  #
  # now prepare the output for the participant
  #
  set %my_score "Your overall Implicit Association Task score is: " $iat_overall_rt
  set %my_score_black_pleasant   "RT for BLACK names for BLACK and PLEASANT on same side " $incompatibleB " ms"
  set %my_score_black_unpleasant "RT for BLACK names for BLACK and UNPLEASANT on same side " $compatibleB " ms"
  set %my_score_white_pleasant   "RT for WHITE names for WHITE and PLEASANT on same side " $compatibleW " ms"
  set %my_score_white_unpleasant "RT for WHITE names for WHITE and UNPLEASANT on same side " $incompatibleW " ms"
  #
  # Now show results
  #
  font small
  show text %my_score -390 -250 black
  show text %my_score_black_pleasant   -390 -200 black
  show text %my_score_black_unpleasant -390 -150 black
  show text %my_score_white_pleasant   -390 -100 black
  show text %my_score_white_unpleasant -390 -50 black
  #
  if $iat_overall_rt > -50 and $iat_overall_rt < 50
    show text "Your score is relatively close to 0" -390 0 black
    show text "This suggest you are not very racially biased" -390 100 black
  fi
  if $iat_overall_rt < -50
    show text "Your score is relatively low" -390 0 black
    show text "If the IAT theory is correct (big if)," -390 100 black
    show text "this suggest you are racially biased against whites and for blacks" -390 150 black
  fi
  if $iat_overall_rt > 50
    show text "Your score is relatively high" -390 0 black
    show text "If the IAT theory is correct (big if)," -390 100 black
    show text "this suggest you are racially biased against blacks and for whites" -390 150 black
  fi
  #
  readkey 1 99999
  clear screen
  #
  text align center
  show text "The IAT score is based on a controversial theory." 0 -250 black
  show text "You do not need to be concerned about your own score."  0 -200 black
  show text "But this theory is widely used."  0 -150 black
  show text "Learn more via www.psytoolkit.org" 0 -50 black
  show text "Press space bar to continue" 0 100 black
  readkey 1 99999
  clear screen

###############################################
## the blocks
###############################################

block instructions
  message i1
  message i2
  message i3

block feedback
  tasklist
    calc_and_show 1
  end

block bw ## black/white
  set &inBlockCounter 1
  set &BlackIsPleasant 1
  set &compatibility 0
  message "Ready for a block? Press space to start"
  delay 1500
  tasklist
    black_white 50
  end
  part myfeedback

block pu ## pleasant/unpleasant
  set &inBlockCounter 1
  set &compatibility 0
  message "Ready for a block? Press space to start"
  delay 1500
  tasklist
    pleasant_unpleasant 50
  end
  part myfeedback

block wb ## white/black
  set &inBlockCounter 1
  set &BlackIsPleasant 2 ## black now on right
  set &compatibility 0
  message "Ready for a block? Press space to start"
  delay 1500
  tasklist
    black_white 50
  end
  part myfeedback

block combined1 ## black is on left
  set &practice 1 ## for the D score
  set &inBlockCounter 1
  set &&alltrials range 1 100
  set &compatibility 2 ## black=pleasant, therefor incompatible (see article)
  set &BlackIsPleasant 1 ## black now on left
  message "Ready for a block? Press space to start"
  delay 1500
  tasklist
    combined 50
  end
  part myfeedback

block combined1b
  set &practice 2 ## for the D score
  set &inBlockCounter 1
  set &BlackIsPleasant 1 ## black now on left
  set &compatibility 2 ## black=pleasant, therefor incompatible (see article)
  message "Ready for a block? Press space to start"
  delay 1500
  tasklist
    combined 50
  end
  part myfeedback

block combined2
  set &practice 1 ## for the D score
  set &inBlockCounter 1
  message "Ready for a block? Press space to start"
  set &&alltrials range 1 100
  set &BlackIsPleasant 2 ## black now on right
  set &compatibility 1 ## black=unpleasant, therefor compatible (see article)
  delay 1500
  tasklist
    combined 50
  end
  part myfeedback

block combined2b
  set &practice 2 ## for the D score
  set &inBlockCounter 1
  set &BlackIsPleasant 2 ## black now on right
  set &compatibility 1 ## black=unpleasant, therefor compatible (see article)
  message "Ready for a block? Press space to start"
  delay 1500
  tasklist
    combined 50
  end
  part myfeedback

#########################

blockorder
  instructions
  bw
  pu
  combined1
  combined1b
  wb
  combined2
  combined2b
  wb
  combined2
  combined2b
  bw
  combined1
  combined1b
  feedback

blockorder
  instructions
  wb
  pu
  combined2
  combined2b
  bw
  combined1
  combined1b
  bw
  combined1
  combined1b
  wb
  combined2
  combined2b
  feedback