**************************************************************************************************************
**************************************************************************************************************
	Brief Implicit Attitude Test (IAT) as described by Sriram & Greenwald (2009)
**************************************************************************************************************
**************************************************************************************************************
	Last Modified:	01-26-2011 at 09:00 AM (PST)
**************************************************************************************************************
**************************************************************************************************************
	Main Inquisit programming: 
	Sean Draine (seandr@millisecond.com)
	
	This script requires Inquisit 3.0.3.2 or greater.
	Script Copyright (c) by Millisecond Software, LLC.
	http://www.millisecond.com/
	Task Copyright (c) by Project Implicit.
	http://www.projectimplicit.org/
**************************************************************************************************************
**************************************************************************************************************
The University of Washington has applied for patent on the BIAT method. The patent 
is managed by Project Implicit. Both the University of Washington and Project Implicit 
authorize free use of the BIAT method and published stimuli for scholarly research, 
provided that reports of the research clearly identify any modifications made to the 
BIAT and appropriately cite the present article. Please contact Project Implicit 
(E-mail: feedback@projectimplicit.net) to request a license for commercial or other 
nonscholarly use of the BIAT.

**************************************************************************************************************
**************************************************************************************************************
	Adjustable Task Parameters:

	The "skipsummary" variable in the values tag can be set to true to skip the final
     summary page or false to display the page.

	The "extended" variable in the values tag can be set to true to run a total of four 
     test blocks, or false to run only 2 test blocks. 

**************************************************************************************************************
**************************************************************************************************************
     Stimulus Items:

     The following section defines the labels and stimulus items for attributes and 
     categories. By default, attributes are GOOD and BD words, and categories are
     FLOWERS and INSECTS.  The IAT can be adapted to other domains by simply 
     modifying these stimuli.

**************************************************************************************************************
**************************************************************************************************************

<item attributeAlabel>
/1 = "GOOD"
</item>

<item attributeA>
/1 = "Wonderful"
/2 = "Best"
/3 = "Superb"
/4 = "Excellent"
</item>

<item attributeBlabel>
/1 = "BAD"
</item>

<item attributeB>
/1 = "Terrible"
/2 = "Awful"
/3 = "Worst"
/4 = "Horrible"
</item>

<item targetALabel>
/1 = "FLOWERS"
</item>

<item targetA>
/1 = "Orchid"
/2 = "Lily"
/3 = "Violet"
/4 = "Daisy"
</item>

<item targetBLabel>
/1 = "INSECTS"
</item>

<item targetB>
/1 = "Ant"
/2 = "Locust"
/3 = "Bee"
/4 = "Wasp"
</item>

**************************************************************************************************************
**************************************************************************************************************
     Task Instructions:

     The following section defines the task instructions. 

**************************************************************************************************************
**************************************************************************************************************

<item introinstructions>
/ 1 = "In this task, you will be instructed to press the ~"I~" key for '<%item.attributeALabel.item.1%>' words and items from one specific category, either <%item.targetALabel.1%> or <%item.targetBLabel.1%>. The ~"E~" key is used for '<%item.attributeBLabel.item.1%>' words and items from the other of those categories. The first couple of blocks help you get used to the task format. Classify items as quickly as you can while making as few mistakes as possible. Going too slow or making too many mistakes will result in an uninterpretable score. It is OK to make an occasional mistake. If you press an incorrect key you will see a red ~"X~". Rapidly correct the error by pressing the other key.~n~nPress the space bar to continue."
/ 2 = "Press the I key for <%item.attributeALabel.item.1%>~nPress the E key for anything else~n~n~nGo as fast as you can~n~nPress the space bar to begin."
</item>

<item testinstructions>
/ 1 = "Press the I key for <%item.attributeALabel.item.1%> or <%values.currentTarget%>~nPress the E key for anything else~n~n~nGo as fast as you can~n~nPress the space bar to begin."
</item>

<text testInstructions>
/ items = testInstructions
/ size = (90%, 50%)
/ position = (50%, 50%)
/ valign = top
/ hjustify = center
/ vjustify = top
</text>

<text introinstructions>
/ items = introinstructions
/ size = (90%, 50%)
/ position = (50%, 40%)
/ select = sequence
/ resetinterval = 20
/ valign = top
/ hjustify = center
/ vjustify = top
</text>

<trial testinstructions>
/ stimulustimes = [1=testinstructions, topFocusInstruct, orInstruct, bottomFocusInstruct, progress]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

<trial introinstructions>
/ ontrialbegin = [if ( script.currentblock == "attributes" ) {text.bottomFocusInstruct.1 = item.attributeAFocusInstruct.1; values.currentTarget = item.attributeAlabel.1;} ]
/ stimulustimes = [1=introinstructions, bottomFocusInstruct, progress]
/ correctresponse = (" ")
/ errormessage = false
/ recorddata = false
</trial>

**********************************************************************************************************************************************
**********************************************************************************************************************************************
Parameters:
    skipsummary - set to true to skip the summary page, false to show it.
    extended - set to true to run 4 test blocks, or false to run only 2 test blocks.
**********************************************************************************************************************************************
**********************************************************************************************************************************************

***********************************************************************
Performance summary
***********************************************************************

<trial summary>
/ ontrialbegin = [values.magnitude = "little to no"]
/ ontrialbegin = [if( abs(expressions.d) > 0.15 ) values.magnitude = "a slight"]
/ ontrialbegin = [if( abs(expressions.d) > 0.35 ) values.magnitude = "a moderate"]
/ ontrialbegin = [if( abs(expressions.d) >= 0.65 ) values.magnitude = "a strong"]
/ ontrialbegin = [if (expressions.d >= 0.0) expressions.preferred = item.targetALabel.1]
/ ontrialbegin = [if (expressions.d < 0.0) expressions.preferred = item.targetBLabel.1]
/ ontrialbegin = [if (expressions.d < 0.0) expressions.notpreferred= item.targetALabel.1]
/ ontrialbegin = [if (expressions.d >= 0.0) expressions.notpreferred= item.targetBLabel.1]
/ stimulustimes = [0=summary]
/ validresponse = (" ")
/ recorddata = false
/ skip = [values.skipsummary]
</trial>

<text summary>
/ items = ("Your IAT score (D) was <% expressions.d %>, which suggests <% values.magnitude %> automatic preference for <% expressions.preferred %> compared to <% expressions.notpreferred %>.~n~n~nPress the spacebar to complete this session.")  
/ size = (60%, 80%)
/ hjustify = left
 </text>

***********************************************************************
Key assignment labels
***********************************************************************

<text attributeAFocusLabel>
/ items = attributeALabel
/ valign = top
/ halign = center
/ position = (50%, 5%)
/ txcolor = yellow
/ fontstyle = ("Arial", 4%)
/ erase = false
</text>

<text targetFocusLabel>
/ items = ("<%values.currentTarget%>")
/ valign = top
/ halign = center
/ position = (50%, 5%)
/ txcolor = aqua
/ fontstyle = ("Arial", 4%)
/ erase = false
</text>

<text orLabel>
/ items = ("or")
/ valign = top
/ halign = center
/ position = (50%, 10%)
/ txcolor = white
/ fontstyle = ("Arial", 3%)
/ erase = false
</text>

<text orAttributeAFocusLabel>
/ items = attributeALabel
/ valign = top
/ halign = center
/ position = (50%, 15%)
/ txcolor = yellow
/ fontstyle = ("Arial", 4%)
/ erase = false
</text>

<shape eraseLabels>
/ color = black
/ shape = rectangle
/ size = (50%, 20%)
/ position = (50%,  10%)
</shape>

<text topFocusInstruct>
/ items = ("")
/ valign = bottom
/ halign = center
/ position = (50%, 15%)
/ size = (100%, 12%)
/ txcolor = aqua
/ fontstyle = ("Arial", 5%)
</text>

<text orInstruct>
/ items = ("or")
/ valign = center
/ halign = center
/ position = (50%, 17.5%)
/ txcolor = white
/ fontstyle = ("Arial", 3%)
</text>

<text bottomFocusInstruct>
/ items = attributeAFocusInstruct
/ valign = top
/ halign = center
/ position = (50%, 20%)
/ size = (100%, 12%)
/ txcolor = yellow
/ fontstyle = ("Arial", 5%)
</text>

<item attributeAFocusInstruct>
/ 1 = "<%item.attributeALabel.1%>~n<%item.attributeA.1%> <%item.attributeA.2%> <%item.attributeA.3%> <%item.attributeA.4%>"
</item>

<item targetAFocusInstruct>
/ 1 = "<%item.targetALabel.1%>~n<%item.targetA.1%> <%item.targetA.2%> <%item.targetA.3%> <%item.targetA.4%>"
</item>

<item targetBFocusInstruct>
/ 1 = "<%item.targetBLabel.1%>~n<%item.targetB.1%> <%item.targetB.2%> <%item.targetB.3%> <%item.targetB.4%>"
</item>

<trial showAttributeLabel>
/ stimulusframes = [1=attributeAFocusLabel]
/ response = noresponse
/ recorddata = false
</trial>

<trial showLabels>
/ stimulusframes = [1=targetFocusLabel, orLabel, orAttributeAFocusLabel]
/ response = noresponse
/ recorddata = false
</trial>

<trial eraseLabels>
/ stimulusframes = [1=eraseLabels]
/ response = noresponse
/ recorddata = false
</trial>

***********************************************************************
Experimental Stimuli
***********************************************************************

<text attributeA>
/ items = attributeA
/ fontstyle = ("Arial", 10%)
/ txcolor = yellow
</text>

<text attributeB>
/ items = attributeB
/ fontstyle = ("Arial", 10%)
/ txcolor = yellow
</text>

<text targetA>
/ items = targetA
/ fontstyle = ("Arial", 10%)
/ txcolor = aqua
</text>

<text targetB>
/ items = targetB
/ fontstyle = ("Arial", 10%)
/ txcolor = aqua
</text>

<text error>
/ position = (50%, 75%)
/ items = ("X")
/ color = red
/ fontstyle = ("Arial", 5%)
</text>

<text progress>
/ position = (50%, 95%)
/ items = ("(Block <%expressions.currentblocknumber%> of <%expressions.totalblockcount %>)")
/ color = white
/ fontstyle = ("Arial", 2%)
</text>

***********************************************************************
Trials
***********************************************************************

<trial attributeA>
/ validresponse = ("E", "I")
/ correctresponse = ("I")
/ stimulusframes = [1 = attributeA]
/ posttrialpause = 250
</trial>

<trial attributeB>
/ validresponse = ("E", "I")
/ correctresponse = ("E")
/ stimulusframes = [1 = attributeB]
/ posttrialpause = 250
</trial>

<trial targetALeft>
/ validresponse = ("E", "I")
/ correctresponse = ("E")
/ stimulusframes = [1 = targetA]
/ posttrialpause = 250
</trial>

<trial targetARight>
/ validresponse = ("E", "I")
/ correctresponse = ("I")
/ stimulusframes = [1 = targetA]
/ posttrialpause = 250
</trial>

<trial targetBLeft>
/ validresponse = ("E", "I")
/ correctresponse = ("E")
/ stimulusframes = [1 = targetB]
/ posttrialpause = 250
</trial>

<trial targetBRight>
/ validresponse = ("E", "I")
/ correctresponse = ("I")
/ stimulusframes = [1 = targetB]
/ posttrialpause = 250
</trial>


***********************************************************************
Blocks
***********************************************************************

<block attributes>
/ trials = [1-2=introinstructions; 3=showAttributeLabel;  4-23 = noreplace(attributeA, attributeB)]
/ errormessage = true(error,200)
/ responsemode = correct
</block>

<block A>
/ skip = [values.extended == false && block.A.totalcount >=1]
/ onblockbegin = [values.currentTarget = item.targetALabel.1; text.topFocusInstruct.1 = item.targetAFocusInstruct.1]
/ trials = [1=testInstructions; 2=showLabels;
  3-6 = noreplace(targetARight, targetBLeft);
  8,10,12,14,16,18,20,22 = noreplace(targetARight, targetBLeft);
  7,9,11,13,15,17,19,21 = noreplace(attributeA, attributeB)]
/ errormessage = true(error,200)
/ responsemode = correct
/ ontrialend = [if (block.A.totalcount == 0 && block.A.latency  <= 10000 && block.A.currenttrialnumber >= 3 ) values.A1sum =  values.A1sum + block.A.latency]
/ ontrialend = [if (block.A.totalcount == 0 && block.A.latency  <= 10000 && block.A.currenttrialnumber >= 3 ) values.A1n=  values.A1n+ 1]
/ ontrialend = [if (block.A.totalcount == 0 && block.A.latency  <= 10000 && block.A.currenttrialnumber >= 3 ) values.A1ss =  values.A1ss  + (block.A.latency * block.A.latency)]
/ ontrialend = [if (block.A.totalcount == 1 && block.A.latency  <= 10000 && block.A.currenttrialnumber >= 3 ) values.A2sum =  values.A2sum + block.A.latency]
/ ontrialend = [if (block.A.totalcount == 1 && block.A.latency  <= 10000 && block.A.currenttrialnumber >= 3 ) values.A2n=  values.A2n+ 1]
/ ontrialend = [if (block.A.totalcount == 1 && block.A.latency  <= 10000 && block.A.currenttrialnumber >= 3 ) values.A2ss =  values.A2ss  + (block.A.latency * block.A.latency)]
</block>


<block B>
/ skip = [values.extended == false && block.B.totalcount >=1]
/ onblockbegin = [values.currentTarget = item.targetBLabel.1; text.topFocusInstruct.1 = item.targetBFocusInstruct.1]
/ trials = [1=testInstructions;2=showLabels;
  3-6 = noreplace(targetBRight, targetALeft);
  8,10,12,14,16,18,20,22= noreplace(targetBRight, targetALeft);
  7,9,11,13,15,17,19,21= noreplace(attributeA, attributeB)]
/ errormessage = true(error,200)
/ responsemode = correct
/ ontrialend = [if (block.B.totalcount == 0 && block.B.latency  <= 10000 && block.B.currenttrialnumber >= 3 ) values.B1sum =  values.B1sum + block.B.latency]
/ ontrialend = [if (block.B.totalcount == 0 && block.B.latency  <= 10000 && block.B.currenttrialnumber >= 3 ) values.B1n=  values.B1n+ 1]
/ ontrialend = [if (block.B.totalcount == 0 && block.B.latency  <= 10000 && block.B.currenttrialnumber >= 3 ) values.B1ss =  values.B1ss  + (block.B.latency * block.B.latency)]
/ ontrialend = [if (block.B.totalcount == 1 && block.B.latency  <= 10000 && block.B.currenttrialnumber >= 3 ) values.B2sum =  values.B2sum + block.B.latency]
/ ontrialend = [if (block.B.totalcount == 1 && block.B.latency  <= 10000 && block.B.currenttrialnumber >= 3 ) values.B2n=  values.B2n+ 1]
/ ontrialend = [if (block.B.totalcount == 1 && block.B.latency  <= 10000 && block.B.currenttrialnumber >= 3 ) values.B2ss =  values.B2ss  + (block.B.latency * block.B.latency)]
</block>

<block summary>
/ trials = [1=summary]
/ recorddata = false
</block>

***********************************************************************
Experiment
***********************************************************************

<defaults>
/ fontstyle = ("Arial", 3.5%)
/ screencolor = black
/ txbgcolor = black
/ txcolor = white
/ minimumversion = "3.0.2.0"
</defaults>

<expt>
/ subjects = (1 of 2)
/ blocks = [1=attributes; 2=A; 3=B; 4=B; 5=A; 6=summary]
</expt>

<expt>
/ subjects = (2 of 2)
/ blocks = [1=attributes; 2=B; 3=A; 4=A; 5=B; 6=summary]
</expt>


***********************************************************************
Data Columns
***********************************************************************

<data>
/ columns = [date, time, subject, blockcode, blocknum, trialcode, trialnum, response, correct, latency, stimulusnumber, stimulusitem, expressions.d1, expressions.d2, expressions.d]
</data>

***********************************************************************
Test Monkey
***********************************************************************
<monkey>
/ latencydistribution = normal(500, 100)
/ percentcorrect = 90
</monkey>

***********************************************************************
Scoring
***********************************************************************

<values>
/ skipsummary = false
/ extended = true
/ A1sum = 0
/ A2sum = 0
/ B1sum = 0
/ B2sum = 0
/ A1n = 0
/ A2n = 0
/ B1n = 0
/ B2n = 0
/ A1ss = 0
/ A2ss = 0
/ B1ss = 0
/ B2ss = 0
/ magnitude = "unknown"
/ currentTarget = ""
</values>

<expressions>
/ A1m = values.A1sum / values.A1n
/ A2m = values.A2sum / values.A2n
/ B1m = values.B1sum / values.B1n
/ B2m = values.B2sum / values.B2n
/ A1sd = sqrt((values.A1ss - (values.A1n* (expressions.A1m * expressions.A1m))) / (values.A1n - 1))
/ A2sd = sqrt((values.A2ss - (values.A2n* (expressions.A2m * expressions.A2m))) / (values.A2n - 1))
/ B1sd = sqrt((values.B1ss - (values.B1n* (expressions.B1m * expressions.B1m))) / (values.B1n - 1))
/ B2sd = sqrt((values.B2ss - (values.B2n* (expressions.B2m * expressions.B2m))) / (values.B2n - 1))
/ sd1 = sqrt((((values.A1n - 1) * (expressions.A1sd * expressions.A1sd) + (values.B1n - 1) * (expressions.B1sd * expressions.B1sd)) + ((values.A1n + values.B1n) * ((expressions.A1m - expressions.B1m) * (expressions.A1m - expressions.B1m)) / 4) ) / (values.A1n + values.B1n - 1) )
/ sd2 = sqrt((((values.A2n - 1) * (expressions.A2sd * expressions.A2sd) + (values.B2n - 1) * (expressions.B2sd * expressions.B2sd)) + ((values.A2n + values.B2n) * ((expressions.A2m - expressions.B2m) * (expressions.A2m - expressions.B2m)) / 4) ) / (values.A2n + values.B2n - 1) )
/ d1 = (expressions.B1m - expressions.A1m) / expressions.sd1
/ d2 = (expressions.B2m - expressions.A2m) / expressions.sd2
/ d = if ( values.extended ) { (d1+d2) / 2 } else { d1 }
/ currentblocknumber = max(expt.1.currentblocknumber, expt.2.currentblocknumber)
/ preferred = "unknown"
/ notpreferred = "unknown"
/ totalblockcount = if (values.extended) {expt.1.blockcount} else {expt.1.blockcount-2}
</expressions>













 
