Millisecond Forums

Extending categories in AAT-Task- Creating a Sequence

https://forums.millisecond.com/Topic12826.aspx

By robwel - 3/28/2014

Hi, 

i'm new to Inquisit and first I'd like to thank Milisecond for providing us with such a usefull Tool for research.

i'm having a hard time extending the AAT-Task from the Task Library. This Task can be found here: http://www.millisecond.com/download/library/AAT/
The only change to the Design of Wiers et al is, that we want to use 6 categories with each 8 Stimuli (instead of 4 categories with 10 Stimuli).  I was able to change the Stimuli and categories. I did alter total trials, create new branches, new trials, Stimcats..... My Problem is now that i can't figure out how to alter the sequence generator to work with the 6 categories.I'm thankful for any suggestions.

[/quote]values>
/ratioA = 0.5
/ratioB = 0.5
/MinHeight = 0.1
/intertrialinterval = 300
/pixeltolerance = 5
</values>      

***************************************************************************************
*********************************************
Editable Stimuli
*********************************************
***************************************************************************************
TThe list item.targets is organized in the following way:
main category 1 (here: IAPS) brown (1): indices 1-8
main category 1 (here: IAPS) grey (2): indices 9-16
main category 2 (here: Chessboard) brown (3): indices 17-24
main category 2 (here: CHessboard) grey (4): indices 25-32
main category 3 (here: female children) brown (5): indices 33-40
main category 3 (here: female children) brown (6): indices 41-48
main category 4 (here: male children) brown (7): indices 49-56
main category 4 (here: male children) grey (8): indices 57-64
main category 5 (here: female adults) brown (9): indices 65-72
main category 5 (here: female adults) grey (10): indices 73-80
main category 6 (here: male adults) brown (11): indices 81-88
main category 6 (here: male adults) grey (12): indices 89-96
 
<item targets>
/1 = "IAPS1_braun_g.jpg"
/2 = "IAPS2_braun_g.jpg"
/3 = "IAPS3_braun_g.jpg"
/4 = "IAPS4_braun_g.jpg"
/5 = "IAPS5_braun_g.jpg"
/6 = "IAPS6_braun_g.jpg"
/7 = "IAPS7_braun_g.jpg"
/8 = "IAPS8_braun_g.jpg"

/9 = "IAPS1_grau_g.jpg"
/10 = "IAPS2_grau_g.jpg"
/11 = "IAPS3_grau_g.jpg"
/12 = "IAPS4_grau_g.jpg"
/13 = "IAPS5_grau_g.jpg"
/14 = "IAPS6_grau_g.jpg"
/15 = "IAPS7_grau_g.jpg"
/16 = "IAPS8_grau_g.jpg"

/17 = "Kontroll1_braun_g.jpg"
/18 = "Kontroll1_braun_g 2.jpg"
/19 = "Kontroll1_braun_g 3.jpg"
/20 = "Kontroll1_braun_g 4.jpg"
/21 = "Kontroll1_braun_g 5.jpg"
/22 = "Kontroll1_braun_g 6.jpg"
/23 = "Kontroll1_braun_g 7.jpg"
/24 = "Kontroll1_braun_g 8.jpg"

/25 = "Kontroll1_grau_g.jpg"
/26 = "Kontroll1_grau_g 2.jpg"
/27 = "Kontroll1_grau_g 3.jpg"
/28 = "Kontroll1_grau_g 4.jpg"
/29 = "Kontroll1_grau_g 5.jpg"
/30 = "Kontroll1_grau_g 6.jpg"
/31 = "Kontroll1_grau_g 7.jpg"
/32 = "Kontroll1_grau_g 8.jpg"

/33 = "FT1-1_braun_g.jpg"
/34 = "FT1-3_braun_g.jpg"
/35 = "FT1-6_braun_g.jpg"
/36 = "FT1-7_braun_g.jpg"
/37 = "FT2-1_braun_g.jpg"
/38 = "FT2-2_braun_g.jpg"
/39 = "FT2-4_braun_g.jpg"
/40 = "FT2-8_braun_g.jpg"

/41 = "FT1-1_grau_g.jpg"
/42 = "FT1-3_grau_g.jpg"
/43 = "FT1-6_grau_g.jpg"
/44 = "FT1-7_grau_g.jpg"
/45 = "FT2-1_grau_g.jpg"
/46 = "FT2-2_grau_g.jpg"
/47 = "FT2-4_grau_g.jpg"
/48 = "FT2-8_grau_g.jpg"

/49 = "MT1-2_braun_g.jpg"
/50 = "MT1-4_braun_g.jpg"
/51 = "MT1-7_braun_g.jpg"
/52 = "MT1-8_braun_g.jpg"
/53 = "MT2-1_braun_g.jpg"
/54 = "MT2-4_braun_g.jpg"
/55 = "MT2-6_braun_g.jpg"
/56 = "MT2-8_braun_g.jpg"

/57 = "MT1-2_grau_g.jpg"
/58 = "MT1-4_grau_g.jpg"
/59 = "MT1-7_grau_g.jpg"
/60 = "MT1-8_grau_g.jpg"
/61 = "MT2-1_grau_g.jpg"
/62 = "MT2-4_grau_g.jpg"
/63 = "MT2-6_grau_g.jpg"
/64 = "MT2-8_grau_g.jpg"

/65 = "FT4-1_braun_g.jpg"
/66 = "FT4-2_braun_g.jpg"
/67 = "FT4-5_braun_g.jpg"
/68 = "FT4-6_braun_g.jpg"
/69 = "FT5-1_braun_g.jpg"
/70 = "FT5-3_braun_g.jpg"
/71 = "FT5-5_braun_g.jpg"
/72 = "FT5-7_braun_g.jpg"

/73 = "FT4-1_grau_g.jpg"
/74 = "FT4-2_grau_g.jpg"
/75 = "FT4-5_grau_g.jpg"
/76 = "FT4-6_grau_g.jpg"
/77 = "FT5-1_grau_g.jpg"
/78 = "FT5-3_grau_g.jpg"
/79 = "FT5-5_grau_g.jpg"
/80 = "FT5-7_grau_g.jpg"

/81 = "MT4-1_braun_g.jpg"
/82 = "MT4-4_braun_g.jpg"
/83 = "MT4-5_braun_g.jpg"
/84 = "MT4-7_braun_g.jpg"
/85 = "MT5-4_braun_g.jpg"
/86 = "MT5-6_braun_g.jpg"
/87 = "MT5-7_braun_g.jpg"
/88 = "MT5-8_braun_g.jpg"

/89 = "MT4-1_grau_g.jpg"
/90 = "MT4-4_grau_g.jpg"
/91 = "MT4-5_grau_g.jpg"
/92 = "MT4-7_grau_g.jpg"
/93 = "MT5-4_grau_g.jpg"
/94 = "MT5-6_grau_g.jpg"
/95 = "MT5-7_grau_g.jpg"
/96 = "MT5-8_grau_g.jpg"
</item>


NOTE: 
organization of practice stimuli
1: stimulus of format A (here: braun)
2: stimulus of format B (here: braun)

<item practicestimuli>
/1 = "IMG_1749.jpg"
/2 = "IMG_1749 2.jpg"
</item>

***************************************************************************************
*********************************************
Editable Instructions
*********************************************
***************************************************************************************
<instruct >
/ windowsize = (90%, 90%)
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 0)
/inputdevice = mouse
/finishlabel = "Hier Klicken um fortzufahren"
/nextlabel = "Hier Klicken um fortzufahren"
/prevlabel = "Zurück"
</instruct>

<page intro>
In the following task, you will be presented images either in landscape or portrait format.
^^Ihre Aufgabe ist es die Maus
^* zu sich zu zu zihen, wenn das Bild <%values.format1%> erscheint
^                                        (aka move the mouse cursor DOWN)
^*  von sich weg zu drücken, wenn das Bild <%values.format2%> erscheint 
^                                        (aka move the mouse cursor UP)
^^=> Wenn Sie die Maus von sich weg bewegen wird das Bild verkleinert.
^=> Wenn Sie die Maus zu sich hin zihen wird das Bild größer.
^^^Sie müssen die Maus immer bis zum Bildschirmrand bewegen. 
^^Anschließend werden sie aufgefordert die Maus wieder zur BIldschormmitte auszurichten und auf das X zu klicken.
^^Nachdem SIe auf das X geklick haben erscheint ein neues Bild
^^Drücken Sie auf das Feld um den Testdurchlauf zu starten.
</page>

<page practice>
^^Ihre Aufgabe ist es die Maus
^* zu sich zu zu zihen, wenn das Bild <%values.format1%> erscheint
^                                        (aka move the mouse cursor DOWN)
^*  von sich weg zu drücken, wenn das Bild <%values.format2%> erscheint 
^                                        (aka move the mouse cursor UP)
^^=> Wenn Sie die Maus von sich weg bewegen wird das Bild verkleinert.
^=> Wenn Sie die Maus zu sich hin zihen wird das Bild größer.
^^^Sie müssen die Maus immer bis zum Bildschirmrand bewegen. 
^^Anschließend werden sie aufgefordert die Maus wieder zur BIldschormmitte auszurichten und auf das X zu klicken.
^^Nachdem SIe auf das X geklick haben erscheint ein neues Bild
^^ Seien Sie so schnell wie möglich
^^Drücken Sie auf das Feld um den Testdurchlauf zu starten.
</page>

<page taskinstructions>
Dies ist die Testung
In the following task, you will be presented images either in landscape or portrait format.
^^Ihre Aufgabe ist es die Maus
^* zu sich zu zu zihen, wenn das Bild <%values.format1%> erscheint
^                                        (aka move the mouse cursor DOWN)
^*  von sich weg zu drücken, wenn das Bild <%values.format2%> erscheint 
^                                        (aka move the mouse cursor UP)
^^=> Wenn Sie die Maus von sich weg bewegen wird das Bild verkleinert.
^=> Wenn Sie die Maus zu sich hin zihen wird das Bild größer.
^^^Sie müssen die Maus immer bis zum Bildschirmrand bewegen. 
^^Anschließend werden sie aufgefordert die Maus wieder zur BIldschormmitte auszurichten und auf das X zu klicken.
^^Nachdem SIe auf das X geklick haben erscheint ein neues Bild
^^ Seien Sie so schnell wie möglich
^^Drücken Sie auf das Feld um den Test zu starten.
</page>

<page End>
^^Sie haben es geschafft!
^^Vielen Dank für Ihre Teilnahme
</page>

<item trialstartinstructions>
/1 = "Drücken SIe auf die Mitte des 'X'"
</item>

***************************************************************************************
*********************************************
Editable Lists
*********************************************
***************************************************************************************
AAT lists contain the indices of the target stimuli for each category
(see item.targets above)

!!! NOTE: if the number of stimuli per category changes, change the appropriate
list accordingly otherwise you can leave these lists as they are

<list category1>
/ items = (1, 2, 3, 4, 5, 6, 7, 8)
/ replace = false
</list>

<list category2>
/ items = (9, 10, 11, 12, 13, 14, 15, 16)
/ replace = false
</list>

<list category3>
/ items = (17. 18, 19, 20, 21, 22, 23, 24)
/ replace = false
</list>

<list category4>
/ items = (25, 26, 27, 28, 29, 30, 31, 32)
/ replace = false
</list>

<list category5>
/ items = (33, 34, 35, 36, 37, 38, 39, 40)
/ replace = false
</list>

<list category6>
/ items = (41, 42, 43, 44, 45, 46, 47, 48)
/ replace = false
</list>

<list category7>
/ items = (49, 50, 51, 52, 53, 54, 55, 56)
/ replace = false
</list>

<list category8>
/ items = (57, 58, 59, 60, 61, 62, 63, 64)
/ replace = false
</list>

<list category9>
/ items = (65, 66, 67, 68, 69, 70, 71, 72)
/ replace = false
</list>

<list category10>
/ items = (73, 74, 75, 76, 77, 78, 79, 80)
/ replace = false
</list>

<list category11>
/ items = (81, 82, 83, 84, 85, 86, 87, 88)
/ replace = false
</list>

<list category12>
/ items = (89, 90, 91, 92, 93, 94, 95, 96)
/ replace = false
</list>


**************************************************************************************************************
**************************************************************************************************************
DEFAULT SCREEN SETTING
**************************************************************************************************************
**************************************************************************************************************
requires Inquisit 4.0.2.0 or higher

<defaults >
/canvasaspectratio = (4,3)
/minimumversion = "4.0.2.0"
/ inputdevice = mouse
</defaults>

**************************************************************************************************************
**************************************************************************************************************
VALUES
**************************************************************************************************************
**************************************************************************************************************
            
*****************************
automatically updated at runtime
****************************
                        Stimulus sequence generation 
/runcount_1 ...runcount_4:               counts how many consecutive stimuli of the same category
/runcount_A / runcount_B = 0:            counts how many consecutive stimuli of the same format
/newnumber :                              the next potential stimulus digit (1-8) for the sequence 
/count_comparecat:                     helper variable: stores the count of the consecutive stimulus category 
                                          relevant for the selected newnumber
/count_compareformat :                  helper variable: stores the count of the consecutive stimulus format
                                          relevant for the selected newnumber
/sequence:                           the stimulus generation sequence
/index:                              current position in a string variable, helper variable to get individual items
                                 out of a string of items

                                     AAT code:
/totaltrialcount:                     the number of experimental trials (here 80)
/nextstimulus :                        the number of the next targetstimulus to be presented
/selectstimulus:                     the index of targetstimulus (in item )
/targetcategory:                     the targetcategory of the targetstimulus, 1 - 4
/targetformat :                        the targetformat of the targetstimulus (l = landscape; p = portrait)
/sumRTcorrect_1- sumRTcorrect_8 :         the sum of latencies for stimuli of (e.g.) category 1 - only for correct responses               
/sumRT_1 - sumRT_8:                     the sum of latencies for stimuli of (e.g.) category 1 - regardless of accuracy
/repeat:                           helper variable: counts how often a change trial has run itself
/selectpracticepicture:                  helper variable: dictates which rectangle (landscape/portrait) to select for practice
/starttime:                           determines the starttime of a trial (measured at beginning of a picture trial)
/endtime:                           determines the endtime of a zooming (measured at end of zoom trials)
/expcondition:                        used for counterbalancing experimental conditions
/format1/forma2:                     helper variables for instruction purposes; set in expt
/startheight_A/startheight_B:            sets the default height of the A(landscape)/B (portrait) picture
/maxheight:                           maximum height for pictures (display.height)
/mouse_y:                           helper variable to track the y-position of the cursor                  
/completeRT:                        stores how long it takes until the cursor hits the screen top or bottom
/changedirection:                     stores whether and how often participant changed direction during zooming
                                 (0 = no change)
/mouse_change:                         stores the absolute change in cursor y-positions from one zoom trial to the next
/trialcode:                           stores the trialcode of the trial
/RT:                              stores the latency of the initial response
/correct:                           stores the correctness of the initial response
/stimulus:                           stores the stimulus 
/initialresponse:                     stores the initial response 
/finalresponse:                        stores the final response (at time mouse cursor hits top or bottom of screen)
/response:                           1 = push (cursor UP), 0 = pull (cursor DOWN)


<values >
/totaltrialcount = 96
/runcount_1 = 0
/runcount_2 = 0
/runcount_3 = 0
/runcount_4  = 0
/runcount_5 = 0
/runcount_6 = 0
/runcount_A = 0
/runcount_B = 0
/newnumber = 0
/count_comparecat = 0
/count_compareformat = 0
/sequence = ""
/index = 0

/nextstimulus = 0
/selectstimulus = 0
/targetcategory = 0
/targetformat = ""
/sumRTcorrect_1 = 0
/sumRT_1 = 0
/sumRTcorrect_2 = 0
/sumRT_2 = 0
/sumRTcorrect_3 = 0
/sumRT_3 = 0
/sumRTcorrect_4 = 0
/sumRT_4 = 0
/sumRTcorrect_5 = 0
/sumRT_5 = 0
/sumRTcorrect_6 = 0
/sumRT_6 = 0
/sumRTcorrect_7 = 0
/sumRT_7 = 0
/sumRTcorrect_8 = 0
/sumRT_8 = 0
/sumRTcorrect_9 = 0
/sumRT_9 = 0
/sumRTcorrect_10 = 0
/sumRT_10 = 0
/sumRTcorrect_11 = 0
/sumRT_11 = 0
/sumRTcorrect_12 = 0
/sumRT_12 = 0
/repeat = 0
/selectpracticepicture = 0
/starttime = 0
/endtime = 0
/expcondition = 0
/format1 = 0
/format2 = 0
/startheight_A = 0
/startheight_B = 0
/Maxheight = display.height
/mouse_y = 0
/completeRT = 0
/changedirection = 0
/mouse_change = 0
/trialcode = 0
/RT = 0
/correct = 0
/stimulus = 0
/initialresponse = ""
/finalresponse = ""
/response = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************
uncorrecte AAT Difference Scores for each of the 4 main categories, 
Diff Scores = median latency for Push trials - median latency for Pull trials
!!! NOTE: NOT corrected for accuracy, latency only for original response (not until cursor hits top or bottom of screen)

/ratio_mousechangePerAssignedpixel: cursor change per max pixel assigned for picture change 

<expressions >
/ AAT_Diffscore_Cat1 = if (values.expcondition == 1) trial.AAT_1.medianlatency - trial.AAT_2.medianlatency else
                           trial.AAT_2.medianlatency - trial.AAT_1.medianlatency
/ AAT_Diffscore_Cat2 = if (values.expcondition == 1) trial.AAT_3.medianlatency - trial.AAT_4.medianlatency else
                           trial.AAT_4.medianlatency - trial.AAT_3.medianlatency
/ AAT_Diffscore_Cat3 = if (values.expcondition == 1) trial.AAT_5.medianlatency - trial.AAT_6.medianlatency else
                           trial.AAT_6.medianlatency - trial.AAT_5.medianlatency
/ AAT_Diffscore_Cat4 = if (values.expcondition == 1) trial.AAT_7.medianlatency - trial.AAT_8.medianlatency else
                           trial.AAT_8.medianlatency - trial.AAT_7.medianlatency
/ AAT_Diffscore_Cat5 = if (values.expcondition == 1) trial.AAT_9.medianlatency - trial.AAT_10.medianlatency else
                           trial.AAT_10.medianlatency - trial.AAT_9.medianlatency
/ AAT_Diffscore_Cat6 = if (values.expcondition == 1) trial.AAT_11.medianlatency - trial.AAT_12.medianlatency else
                           trial.AAT_12.medianlatency - trial.AAT_11.medianlatency
/ratio_mousechangePerAssignedpixel = 500/((values.ratioA - values.MinHeight) * values.Maxheight)
</expressions>


**************************************************************************************************************
**************************************************************************************************************
DATA
**************************************************************************************************************
**************************************************************************************************************
Note:
"latency" values.RT stores the reaction time that it took a participant to make the decision to push or pull.
"values.completeRT" during trial.InterTrialInterval stores the time that it took a participant 
to bring mouse cursor to top or bottom of screen
*values.changedirection stores whether and how often the participant changed the cursor direction during zooming
*values.initialresponse stores the original response to the stimulus
*values.finalresponse stores the response when cursor hits screen top or bottom

*****************
raw data
*****************
<data >
/file = "AATmouseinput_raw.iqdat"
/ separatefiles = true
/ columns = [date, time, subject, values.expcondition, blockcode, trialcode, values.trialcode, values.stimulus,values.mouse_y,
         values.initialresponse, values.correct, values.finalresponse, values.changedirection,
         values.RT, values.completeRT]
</data>


*****************
summary data
*****************

<summarydata >
/file = "ATTmouseinput_summary.iqdat"
/columns = [script.startdate, script.starttime, script.subjectid, values.expcondition, 
expressions.aat_diffscore_cat1, expressions.aat_diffscore_cat2,
expressions.aat_diffscore_cat3, expressions.aat_diffscore_cat4, expressions.aat_diffscore_cat5,expressions.aat_diffscore_cat6, values.sequence]
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
 AAT STIMULI
**************************************************************************************************************
**************************************************************************************************************
<picture targetstimulus>
/ items = targets
/ select = values.selectstimulus
/ position = (50%, 50%)
/ size = (100%, 100%)
/ erase = false
</picture>

***helper stimulus
<shape eraser>
/ shape = rectangle
/ color = white
/ size = (100%, 100%)
/ erase = false
</shape>

<text instructtext>
/items = trialstartinstructions
/select = 1 
/position = (50%, 40%)
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
</text>

<text center>
/items = ("X")
/position = (50%, 50%)
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 1)
/ txcolor = (red)
</text>
**************************************************************************************************************
**************************************************************************************************************
AAT LISTS
**************************************************************************************************************
**************************************************************************************************************

**************************************************************************************************************
**************************************************************************************************************
AAT PRACTICE 
**************************************************************************************************************
**************************************************************************************************************

*************************
Practice Stimuli
*************************
<text error>
/ items = ("ERROR")
/ position = (50%, 50%)
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 0)
/ txcolor = (white)
/txbgcolor = (red)
</text>


*************************
Practice Stimuli
*************************

NOTE:
 picture.practicetarget selects the target via
values.selectpracticepicture (this value is set in the
practice trials, see below)

<picture practicetarget>
/ items = practicestimuli
/ select = values.selectpracticepicture
/ position = (50%, 50%)
/ size = (100%, 100%)
/ erase = false
</picture>
*************************
Practice Trials
*************************
NOTE: practice trials report error feedback to participant.


Note: trial.practicestarta/trial.practicestartb
* makes sure the mouse cursor is in the middle of the screen by asking participants 
to click on a center stimulus (here:X)
<trial practicestartA>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.practicestartA.responsey]
/recorddata = false
/branch = [trial.practicetrial_a]
</trial>

<trial practicestartB>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.practicestartB.responsey]
/recorddata = false
/branch = [trial.practicetrial_b]
</trial>

NOTE: 
*trial.practicetrial_A displays the stimulus of format A (here: landscape) by setting
values.selectpracticepicture = 1
*if a push movement is detected (=mouse is pushed away from body)-> decrease picture
*if a pull movement is detected (=mouse is pulled towards body)-> increase picture
<trial practicetrial_A>
/inputdevice = mouse
/ontrialbegin = [values.trialcode = "practicetrial_A"]
/ontrialbegin = [values.targetformat = "braun"]
/ ontrialbegin = [values.selectpracticepicture = 1]
/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [picture.practicetarget.height = values.startheight_A]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = practicetarget]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.practicetrial_a.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.practicetrial_a.responsey < (values.mouse_y - values.pixeltolerance)) ]

/ iscorrectresponse = [(values.expcondition == 1 && trial.practicetrial_a.responsey < values.mouse_y) ||
                  (values.expcondition == 2 && trial.practicetrial_a.responsey > values.mouse_y)]
/ errormessage = true(error,0)

/ontrialend = [if (trial.practicetrial_a.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.practicetrial_a.responsey)]
/ ontrialend = [values.mouse_y = trial.practicetrial_a.responsey]

/ontrialend = [values.RT = trial.practicetrial_A.latency]
/ontrialend = [values.correct = trial.practicetrial_A.correct]
/ontrialend = [values.stimulus = picture.practicetarget.currentitem]
/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "ziehen"]

/ branch = [if (values.response == 1) trial.practicedecrease else trial.practiceincrease]
/ recorddata = false
</trial>

*trial.practicetrial_B displays the stimulus of format B (here: portrait) by setting
values.selectpracticepicture = 2
*if a push movement is detected (=mouse is pushed away from body)-> decrease picture
*if a pull movement is detected (=mouse is pulled towards body)-> increase picture
<trial practicetrial_B>
/inputdevice = mouse
/ontrialend = [values.trialcode = "practicetrial_B"]
/ontrialbegin = [values.targetformat = "grau"]
/ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.repeat = 0]
/ ontrialbegin = [values.selectpracticepicture = 2]
/ ontrialbegin = [picture.practicetarget.height = values.startheight_B]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = practicetarget]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.practicetrial_b.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.practicetrial_b.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.practicetrial_b.responsey > values.mouse_y) ||
                  (values.expcondition == 2 && trial.practicetrial_b.responsey < values.mouse_y)]
/ errormessage = true(error,0)

/ontrialend = [if (trial.practicetrial_b.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.practicetrial_b.responsey)]
/ ontrialend = [values.mouse_y = trial.practicetrial_b.responsey]

/ontrialend = [values.RT = trial.practicetrial_b.latency]
/ontrialend = [values.correct = trial.practicetrial_b.correct]
/ontrialend = [values.stimulus = picture.practicetarget.currentitem]
/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "ziehen"]

/ branch = [if (values.response == 1) trial.practicedecrease else trial.practiceincrease]
/ recorddata = false
</trial>

*********ZOOM FEATURE: trial  increase/decrease the size of the rectangles depending on participant's response*********

<trial practicedecrease>
/inputdevice = mouse
/ontrialbegin = [if (values.expcondition == 1 && values.targetformat == "grau") trial.practicedecrease.insertstimulustime(text.error, 0)]
/ontrialbegin = [if (values.expcondition == 2 && values.targetformat == "braun") trial.practicedecrease.insertstimulustime(text.error, 0)]

/ ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height - values.mouse_change/expressions.ratio_mousechangePerAssignedpixel]
/ stimulusframes = [1 = eraser, practicetarget]
/validresponse = (mousemove)

/ontrialend = [values.mouse_change = abs(values.mouse_y - trial.practicedecrease.responsey)]

/ontrialend = [trial.practicedecrease.resetstimulusframes()]


/branch = [if (script.subjectid == "monkey") {values.endtime = script.elapsedtime; values.finalresponse = "drücken"; trial.intertrialinterval}]

/branch = [if (trial.practicedecrease.responsey <= 0) 
            {values.mouse_y = trial.practicedecrease.responsey; values.endtime = script.elapsedtime; values.finalresponse = "ziehen"; trial.enddecrease_practice}]
/branch = [if (trial.practicedecrease.responsey <= values.mouse_y) 
            {values.mouse_y = trial.practicedecrease.responsey; trial.practicedecrease}]
/branch = [if (trial.practicedecrease.responsey > values.mouse_y) 
            {values.mouse_y = trial.practicedecrease.responsey; values.changedirection += 1; trial.practiceincrease}]

/ recorddata = false
</trial>

<trial practiceincrease>
/inputdevice = mouse
/ontrialbegin = [if (values.expcondition == 1 && values.targetformat == "braun") trial.practiceincrease.insertstimulustime(text.error, 0)]
/ontrialbegin = [if (values.expcondition == 2 && values.targetformat == "grau") trial.practiceincrease.insertstimulustime(text.error, 0)]

/ ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height + values.mouse_change/expressions.ratio_mousechangePerAssignedpixel]
/ stimulusframes = [1 =  practicetarget]
/validresponse = (mousemove)
/ontrialend = [values.mouse_change = abs(values.mouse_y - trial.practiceincrease.responsey)]

/ontrialend = [trial.practiceincrease.resetstimulusframes()]

/branch = [if (script.subjectid == "monkey") {values.endtime = script.elapsedtime; values.finalresponse = "ziehen"; trial.intertrialinterval}]
/branch = [if (trial.practiceincrease.responsey >= display.height-1) 
            {values.mouse_y = trial.practiceincrease.responsey; values.endtime = script.elapsedtime; values.finalresponse = "drücken"; trial.endincrease_practice}]
/branch = [if (trial.practiceincrease.responsey >= values.mouse_y) 
            {values.mouse_y = trial.practiceincrease.responsey; trial.practiceincrease}]
/branch = [if (trial.practiceincrease.responsey < values.mouse_y) 
            {values.mouse_y = trial.practiceincrease.responsey; values.changedirection += 1; trial.practicedecrease}]
/recorddata = false
</trial>


Note: trials show the last size of the picture
<trial endincrease_practice>
/ ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height + values.mouse_change/expressions.ratio_mousechangePerAssignedpixel]
/stimulusframes = [1 = practicetarget]
/timeout = 0
/branch = [trial.intertrialinterval]
/recorddata = false
</trial>

<trial enddecrease_practice>
/ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height - values.mouse_change/expressions.ratio_mousechangePerAssignedpixel]
/stimulusframes = [1 = eraser, practicetarget]
/timeout = 0
/branch = [trial.intertrialinterval]
/recorddata = false
</trial>
*************************
Practice Block
*************************
NOTE:
block.practice_AAT presents 10 practice trials randomly (without replacement) selecting
from format A (landscape) (N=5) and format B (portrait) stimuli (N=5)
<block practice_AAT>
/preinstructions = (intro, practice)
/ trials = [1-20 = noreplace(practicestartA, practicestartB)]
</block>

**************************************************************************************************************
**************************************************************************************************************
AAT EXPERIMENTAL TRIALS
**************************************************************************************************************
**************************************************************************************************************
Trial Sequence for each targetstimulus:
trial.AAT_start -> (e.g.) trial.AAT_1 -> (e.g. depending on response) trial.decrease ->....-> trial.decrease (until a set amount of trial.decrease have run)
                                                               
**********************************************************************
trial that selects the next targetstimulus category (1-8)
**********************************************************************
Debug:
<text nextstimulus>
/ items = ("<%values.nextstimulus%>")
/ position = (50%, 60%)
/ fontstyle = ("Arial", 2.33%, false, false, false, false, 5, 0)
</text>


NOTE:
trial.AAT_start is only necessary if a preestablished sequence of target categories is used
(either generated at the beginning of the experiment or by selecting from a 
pool of pregenerated sequences). The trial determines the next target
category via values.nextstimulus and calls the corresponding trial for that category (e.g. trial.AAT_1).

<trial AAT_start>
/ ontrialbegin = [values.nextstimulus = substring(values.sequence, values.index, 1); 
                  values.index += 1]
/ ontrialbegin = [values.repeat = 0]
/ timeout = 0
/ branch = [if (values.nextstimulus == 1) trial.AAT_1_start]
/ branch = [if (values.nextstimulus == 2) trial.AAT_2_start]
/ branch = [if (values.nextstimulus == 3) trial.AAT_3_start]
/ branch = [if (values.nextstimulus == 4) trial.AAT_4_start]
/ branch = [if (values.nextstimulus == 5) trial.AAT_5_start]
/ branch = [if (values.nextstimulus == 6) trial.AAT_6_start]
/ branch = [if (values.nextstimulus == 7) trial.AAT_7_start]
/ branch = [if (values.nextstimulus == 8) trial.AAT_8_start]
/ branch = [if (values.nextstimulus == 9) trial.AAT_9_start]
/ branch = [if (values.nextstimulus == 10) trial.AAT_10_start]
/ branch = [if (values.nextstimulus == 11) trial.AAT_11_start]
/ branch = [if (values.nextstimulus == 12) trial.AAT_12_start]
/ recorddata = false
</trial>

************************************************
Start trials:

* make sure the mouse cursor is in the middle of the screen by asking participants 
to click on a center stimulus (here:X)
************************************************
<trial AAT_1_start>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.AAT_1_start.responsey]
/recorddata = false
/branch = [trial.AAT_1]
</trial>

<trial AAT_2_start>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.AAT_2_start.responsey]
/recorddata = false
/branch = [trial.AAT_2]
</trial>

<trial AAT_3_start>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.AAT_3_start.responsey]
/recorddata = false
/branch = [trial.AAT_3]
</trial>

<trial AAT_4_start>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.AAT_4_start.responsey]
/recorddata = false
/branch = [trial.AAT_4]
</trial>

<trial AAT_5_start>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.AAT_5_start.responsey]
/recorddata = false
/branch = [trial.AAT_5]
</trial>

<trial AAT_6_start>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.AAT_6_start.responsey]
/recorddata = false
/branch = [trial.AAT_6]
</trial>

<trial AAT_7_start>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.AAT_7_start.responsey]
/recorddata = false
/branch = [trial.AAT_7]
</trial>

<trial AAT_8_start>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.AAT_8_start.responsey]
/recorddata = false
/branch = [trial.AAT_8]
</trial>

<trial AAT_9_start>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.AAT_9_start.responsey]
/recorddata = false
/branch = [trial.AAT_9]
</trial>

<trial AAT_10_start>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.AAT_10_start.responsey]
/recorddata = false
/branch = [trial.AAT_10]
</trial>

<trial AAT_11_start>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.AAT_11_start.responsey]
/recorddata = false
/branch = [trial.AAT_11]
</trial>

<trial AAT_12_start>
/inputdevice = mouse
/stimulusframes = [1 = instructtext, center]
/validresponse = (center)
/ontrialend = [values.mouse_y = trial.AAT_12_start.responsey]
/recorddata = false
/branch = [trial.AAT_12]
</trial>
**********************************************************************
trials that select targetstimuli via list.categoryX 
and take in initial response (move mouse away vs. mouse mouse closer)

Note: if error feedback should be given, include
/ errormessage = true(error,0) in each of the following trials
**********************************************************************

<trial AAT_1>
/inputdevice = mouse
/ ontrialbegin = [values.trialcode = "AAT_1"]
/ ontrialbegin = [values.selectstimulus = list.category1.nextvalue]
/ ontrialbegin = [values.targetcategory = 1; values.targetformat = "braun"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_A]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_1.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.AAT_1.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_1.responsey < values.mouse_y) ||
                  (values.expcondition == 2 && trial.AAT_1.responsey > values.mouse_y)]

/ ontrialend = [if (trial.AAT_1.correct) values.sumRTcorrect_1 += trial.AAT_1.latency]
/ ontrialend = [values.sumRT_1 += trial.AAT_1.latency]

/ontrialend = [if (trial.AAT_1.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_1.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_1.responsey]

/ ontrialend = [values.RT = trial.AAT_1.latency]
/ ontrialend = [values.correct = trial.AAT_1.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "Ziehen"]
/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>


<trial AAT_2>
/inputdevice = mouse
/ ontrialbegin = [values.selectstimulus = list.category2.nextvalue]
/ ontrialbegin = [values.targetcategory = 1; values.targetformat = "grau"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_B]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_2.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.AAT_2.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_2.responsey > values.mouse_y) ||
                  (values.expcondition == 2 && trial.AAT_2.responsey < values.mouse_y)]

/ontrialend = [if (trial.AAT_2.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_2.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_2.responsey]

/ ontrialend = [if (trial.AAT_2.correct) values.sumRTcorrect_2 += trial.AAT_2.latency]
/ ontrialend = [values.sumRT_2 += trial.AAT_2.latency]

/ ontrialend = [values.trialcode = "AAT_2"]
/ ontrialend = [values.RT = trial.AAT_2.latency]
/ ontrialend = [values.correct = trial.AAT_2.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "Drücken"
                  else values.initialresponse = "ziehen"]

/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>


<trial AAT_3>
/inputdevice = mouse
/ ontrialbegin = [values.trialcode = "AAT_3"]
/ ontrialbegin = [values.selectstimulus = list.category3.nextvalue]
/ ontrialbegin = [values.targetcategory = 2; values.targetformat = "braun"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_A]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_3.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.AAT_3.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_3.responsey < values.mouse_y) ||
                  (values.expcondition == 2 && trial.AAT_3.responsey > values.mouse_y)]

/ ontrialend = [if (trial.AAT_3.correct) values.sumRTcorrect_3 += trial.AAT_3.latency]
/ ontrialend = [values.sumRT_3 += trial.AAT_3.latency]

/ontrialend = [if (trial.AAT_3.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_3.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_3.responsey]

/ ontrialend = [values.RT = trial.AAT_3.latency]
/ ontrialend = [values.correct = trial.AAT_3.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "ziehen"]
/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>


<trial AAT_4>
/inputdevice = mouse
/ ontrialbegin = [values.selectstimulus = list.category4.nextvalue]
/ ontrialbegin = [values.targetcategory = 2; values.targetformat = "grau"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_B]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_4.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.AAT_4.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_4.responsey > values.mouse_y) ||
                  (values.expcondition == 2 && trial.AAT_4.responsey < values.mouse_y)]

/ontrialend = [if (trial.AAT_4.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_4.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_4.responsey]

/ ontrialend = [if (trial.AAT_4.correct) values.sumRTcorrect_4 += trial.AAT_4.latency]
/ ontrialend = [values.sumRT_4 += trial.AAT_4.latency]

/ ontrialend = [values.trialcode = "AAT_4"]
/ ontrialend = [values.RT = trial.AAT_4.latency]
/ ontrialend = [values.correct = trial.AAT_4.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "ziehen"]

/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>


<trial AAT_5>
/inputdevice = mouse
/ ontrialbegin = [values.trialcode = "AAT_5"]
/ ontrialbegin = [values.selectstimulus = list.category5.nextvalue]
/ ontrialbegin = [values.targetcategory = 3; values.targetformat = "grau"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_A]
/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_5.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.AAT_5.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_5.responsey < values.mouse_y) ||
                  (values.expcondition == 2 && trial.AAT_5.responsey > values.mouse_y)]

/ ontrialend = [if (trial.AAT_5.correct) values.sumRTcorrect_5 += trial.AAT_5.latency]
/ ontrialend = [values.sumRT_5 += trial.AAT_5.latency]

/ontrialend = [if (trial.AAT_5.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_5.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_5.responsey]

/ ontrialend = [values.RT = trial.AAT_5.latency]
/ ontrialend = [values.correct = trial.AAT_5.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "ziehen"]
/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>


<trial AAT_6>
/inputdevice = mouse
/ ontrialbegin = [values.selectstimulus = list.category6.nextvalue]
/ ontrialbegin = [values.targetcategory = 3; values.targetformat = "grau"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_B]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_6.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.AAT_6.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_6.responsey > values.mouse_y) ||
                  (values.expcondition == 2 && trial.AAT_6.responsey < values.mouse_y)]

/ontrialend = [if (trial.AAT_6.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_6.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_6.responsey]

/ ontrialend = [if (trial.AAT_6.correct) values.sumRTcorrect_6 += trial.AAT_6.latency]
/ ontrialend = [values.sumRT_6 += trial.AAT_6.latency]

/ ontrialend = [values.trialcode = "AAT_6"]
/ ontrialend = [values.RT = trial.AAT_6.latency]
/ ontrialend = [values.correct = trial.AAT_6.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "ziehen"]

/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>


<trial AAT_7>
/inputdevice = mouse
/ ontrialbegin = [values.trialcode = "AAT_7"]
/ ontrialbegin = [values.selectstimulus = list.category7.nextvalue]
/ ontrialbegin = [values.targetcategory = 4; values.targetformat = "braun"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_A]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_7.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.AAT_7.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_7.responsey < values.mouse_y) ||
                  (values.expcondition == 2 && trial.AAT_7.responsey > values.mouse_y)]

/ ontrialend = [if (trial.AAT_7.correct) values.sumRTcorrect_7 += trial.AAT_7.latency]
/ ontrialend = [values.sumRT_7 += trial.AAT_7.latency]

/ontrialend = [if (trial.AAT_7.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_7.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_7.responsey]

/ ontrialend = [values.RT = trial.AAT_7.latency]
/ ontrialend = [values.correct = trial.AAT_7.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "ziehen"]
/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>


<trial AAT_8>
/ ontrialbegin = [values.selectstimulus = list.category8.nextvalue]
/ ontrialbegin = [values.targetcategory = 4; values.targetformat = "grau"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_B]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_8.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.AAT_8.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_8.responsey > values.mouse_y) ||
                  (values.expcondition == 2 && trial.AAT_8.responsey < values.mouse_y)]

/ontrialend = [if (trial.AAT_8.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_8.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_8.responsey]

/ ontrialend = [if (trial.AAT_8.correct) values.sumRTcorrect_8 += trial.AAT_8.latency]
/ ontrialend = [values.sumRT_8 += trial.AAT_8.latency]

/ ontrialend = [values.trialcode = "AAT_8"]
/ ontrialend = [values.RT = trial.AAT_8.latency]
/ ontrialend = [values.correct = trial.AAT_8.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "ziehen"]

/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>

<trial AAT_9>
/inputdevice = mouse
/ ontrialbegin = [values.trialcode = "AAT_9"]
/ ontrialbegin = [values.selectstimulus = list.category9.nextvalue]
/ ontrialbegin = [values.targetcategory = 5; values.targetformat = "braun"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_A]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_9.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.AAT_9.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_9.responsey < values.mouse_y) ||
                  (values.expcondition == 2 && trial.AAT_9.responsey > values.mouse_y)]

/ ontrialend = [if (trial.AAT_9.correct) values.sumRTcorrect_9 += trial.AAT_9.latency]
/ ontrialend = [values.sumRT_9 += trial.AAT_9.latency]

/ontrialend = [if (trial.AAT_9.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_9.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_9.responsey]

/ ontrialend = [values.RT = trial.AAT_9.latency]
/ ontrialend = [values.correct = trial.AAT_9.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "ziehen"]
/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>


<trial AAT_10>
/ ontrialbegin = [values.selectstimulus = list.category10.nextvalue]
/ ontrialbegin = [values.targetcategory = 5; values.targetformat = "grau"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_B]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_10.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.AAT_10.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_10.responsey > values.mouse_y) ||
                  (values.expcondition == 2 && trial.AAT_10.responsey < values.mouse_y)]

/ontrialend = [if (trial.AAT_10.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_10.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_10.responsey]

/ ontrialend = [if (trial.AAT_10.correct) values.sumRTcorrect_10 += trial.AAT_10.latency]
/ ontrialend = [values.sumRT_10 += trial.AAT_10.latency]

/ ontrialend = [values.trialcode = "AAT_10"]
/ ontrialend = [values.RT = trial.AAT_10.latency]
/ ontrialend = [values.correct = trial.AAT_10.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "ziehen"]

/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>

<trial AAT_11>
/inputdevice = mouse
/ ontrialbegin = [values.trialcode = "AAT_11"]
/ ontrialbegin = [values.selectstimulus = list.category11.nextvalue]
/ ontrialbegin = [values.targetcategory = 6; values.targetformat = "braun"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_A]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_11.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.AAT_11.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_11.responsey < values.mouse_y) ||
                  (values.expcondition == 2 && trial.AAT_11.responsey > values.mouse_y)]

/ ontrialend = [if (trial.AAT_11.correct) values.sumRTcorrect_11 += trial.AAT_11.latency]
/ ontrialend = [values.sumRT_11 += trial.AAT_11.latency]

/ontrialend = [if (trial.AAT_11.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_11.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_11.responsey]

/ ontrialend = [values.RT = trial.AAT_11.latency]
/ ontrialend = [values.correct = trial.AAT_11.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "ziehen"]
/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>


<trial AAT_12>
/ ontrialbegin = [values.selectstimulus = list.category12.nextvalue]
/ ontrialbegin = [values.targetcategory = 6; values.targetformat = "grau"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_B]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_12.responsey > (values.mouse_y + values.pixeltolerance)) ||
               (trial.AAT_12.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_12.responsey > values.mouse_y) ||
                  (values.expcondition == 2 && trial.AAT_12.responsey < values.mouse_y)]

/ontrialend = [if (trial.AAT_12.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_8.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_12.responsey]

/ ontrialend = [if (trial.AAT_12.correct) values.sumRTcorrect_12 += trial.AAT_12.latency]
/ ontrialend = [values.sumRT_12 += trial.AAT_12.latency]

/ ontrialend = [values.trialcode = "AAT_12"]
/ ontrialend = [values.RT = trial.AAT_12.latency]
/ ontrialend = [values.correct = trial.AAT_12.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "drücken"
                  else values.initialresponse = "ziehen"]

/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>

**********************************************************************
ZOOM trials that control the size changes of the target stimuli 
as dictated by response; zoom trials come to an end when the 
mouse cursor has reached either end of the monitor height
**********************************************************************

<trial decrease>
/inputdevice = mouse
/ ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.mouse_change/expressions.ratio_mousechangePerAssignedpixel]

/ stimulusframes = [1 = eraser, targetstimulus]
/validresponse = (mousemove)
/ontrialend = [values.mouse_change = abs(values.mouse_y - trial.decrease.responsey)]

/ontrialend = [trial.decrease.resetstimulusframes()]

/branch = [if (script.subjectid == "monkey") {values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.intertrialinterval}]

/branch = [if (trial.decrease.responsey <= 1) 
            {values.mouse_y = trial.decrease.responsey; values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.enddecrease}]
/branch = [if (trial.decrease.responsey <= values.mouse_y) 
            {values.mouse_y = trial.decrease.responsey; trial.decrease}]
/branch = [if (trial.decrease.responsey > values.mouse_y) 
            {values.mouse_y = trial.decrease.responsey; values.changedirection += 1; trial.increase}]

/ recorddata = false
</trial>


<trial increase>
/ ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height + values.mouse_change/expressions.ratio_mousechangePerAssignedpixel]
/ stimulusframes = [1 = targetstimulus]
/validresponse = (mousemove)
/ontrialend = [values.mouse_change = abs(values.mouse_y - trial.increase.responsey)]

/ontrialend = [trial.increase.resetstimulusframes()]

/branch = [if (script.subjectid == "monkey") {values.endtime = script.elapsedtime; values.finalresponse = "PULL"; trial.intertrialinterval}]

/branch = [if (trial.increase.responsey >= display.height-1) 
            {values.mouse_y = trial.increase.responsey; values.endtime = script.elapsedtime; values.finalresponse = "PULL"; trial.endincrease}]
/branch = [if (trial.increase.responsey >= values.mouse_y) 
            {values.mouse_y = trial.increase.responsey; trial.increase}]
/branch = [if (trial.increase.responsey < values.mouse_y) 
            {values.mouse_y = trial.increase.responsey; values.changedirection += 1; trial.decrease}]
/recorddata = false
</trial>

Note: trials show the last size of the picture
<trial endincrease>
/ ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height + values.mouse_change/expressions.ratio_mousechangePerAssignedpixel]
/stimulusframes = [1 = targetstimulus]
/timeout = 0
/branch = [trial.intertrialinterval]
/recorddata = false
</trial>

<trial enddecrease>
/ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.mouse_change/expressions.ratio_mousechangePerAssignedpixel]
/stimulusframes = [1 = eraser, targetstimulus]
/timeout = 0
/branch = [trial.intertrialinterval]
/recorddata = false
</trial>
**********************************************************************
Helper Trials:
*trial. InterTrialInterval : sets a predetermined InterTrialInterval
(and stores all relevant data in the data file to have one complete dataline for each trial)
**********************************************************************

<trial InterTrialInterval>
/ontrialbegin = [values.completeRT= values.endtime - values.starttime]
/ stimulusframes = [1 = eraser]
/ timeout = values.intertrialinterval
/ recorddata = true
</trial>

**************************************************************************************************************
**************************************************************************************************************
AAT EXPERIMENTAL BLOCKS
**************************************************************************************************************
**************************************************************************************************************
<block AAT>
/preinstructions = (taskinstructions)
/ onblockbegin = [values.index = 0]
/ trials = [1-96 = AAT_start]
</block>

**************************************************************************************************************
**************************************************************************************************************
EXPERIMENT 
**************************************************************************************************************
**************************************************************************************************************
NOTE:
Experiment is counterbalanced by group number

<expt >
/ onexptbegin = [values.expcondition = 1]
/ onexptbegin = [values.format1 = "grau"; values.format2 = "braun"]
/ subjects = (1 of 2)
/groupassignment = groupnumber
/ onexptbegin = [values.startheight_A = values.ratioA*display.height]
/ onexptbegin = [values.startheight_B = values.ratioB* display.height]
/ blocks = [1 = SequenceGenerator; 2 = practice_AAT; 3 = AAT]
/ postinstructions = (End)
</expt>

<expt >
/ onexptbegin = [values.expcondition = 2]
/ onexptbegin = [values.format2 = "grau"; values.format1 = "braun"]
/ subjects = (2 of 2)
/groupassignment = groupnumber
/ onexptbegin = [values.startheight_A = values.ratioA*display.height]
/ onexptbegin = [values.startheight_B = values.ratioB*display.height]
/ blocks = [1 = SequenceGenerator; 2 = practice_AAT; 3 = AAT]
/ postinstructions = (End)
</expt>

**************************************************************************************************************
**************************************************************************************************************
TRIAL SEQUENCE GENERATION  CODE:
**************************************************************************************************************
**************************************************************************************************************
The trial sequence generation code generates a sequence of trials that fulfills the following
constraints:
1) 10 stimuli of category 1 in Format A (=1), 10 stimuli of category 1 in Format B (=2),
10 stimuli of category 2 in Format A (=3), 10 stimuli of category 1 in Format B (=4),
10 stimuli of category 3 in Format A (=5), 10 stimuli of category 1 in Format B (=6),
10 stimuli of category 4 in Format A (=7), 10 stimuli of category 1 in Format B (=8),
2) no more than three consecutive stimuli of the same category
3) no more than three consecutive stimuli of the same format

the sequences produced look something like this:
86854627681534427238341865316174854225166758252358517483251343227374137614617876

NOTE:
!!!! The time to generate the appropriate sequence will differ between participants.
Two alternatives are:
1) pregenerated sequences.
For example, you could generate 100 of these sequences (run this code in a separate script),
store the sequences in an item element and select randomly from these sequences for each
participant.
2) run the experiment with simple random sampling 
(without replacement) without paying attention to the added constraints 
regarding category/format repetitions.

This trialsequence algorithm is a simple, brute-force method that may 
reach its limits if more conditions/trials are added. In this case,
a new algorithm may have to be written or any of the two alternatives has
to be used.
*****************************************************************************
List Stimcats: contains all 96 possible stimuli
*****************************************************************************
<list stimcats>
/ items = (
1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,
4,4,4,4,4,4,4,4,
5,5,5,5,5,5,5,5,
6,6,6,6,6,6,6,6,
7,7,7,7,7,7,7,7,
8,8,8,8,8,8,8,8,
9,9,9,9,9,9,9,9,
10,10,10,10,10,10,10,10,
11,11,11,11,11,11,11,11,
12,12,12,12,12,12,12,12)
/ replace = false
</list>

*****************************************************************************
Trial Selectnumber: selects the newnumber and checks whether
all constraints are met
- if all constraints are met: adds new number to sequence
- constraints are not met: starts the sequence over
*****************************************************************************
<trial selectnumber>
/ ontrialbegin = [values.newnumber = list.stimcats.nextvalue]
/ ontrialbegin = [if (values.newnumber ==1) 
                  {values.runcount_1 += 1; 
                  values.runcount_A += 1;
                  values.count_comparecat = values.runcount_1;
                  values.count_compareformat = values.runcount_A}]
/ ontrialbegin = [if (values.newnumber ==2) 
                  {values.runcount_1 += 1; 
                  values.runcount_B += 1;
                  values.count_comparecat = values.runcount_1;
                  values.count_compareformat = values.runcount_B}]
/ ontrialbegin = [if (values.newnumber ==3) 
                  {values.runcount_2 += 1; 
                  values.runcount_A += 1;
                  values.count_comparecat = values.runcount_2;
                  values.count_compareformat = values.runcount_A}]
/ ontrialbegin = [if (values.newnumber ==4) 
                  {values.runcount_2 += 1; 
                  values.runcount_B += 1;
                  values.count_comparecat = values.runcount_2;
                  values.count_compareformat = values.runcount_B}]
/ ontrialbegin = [if (values.newnumber ==5) 
                  {values.runcount_3 += 1; 
                  values.runcount_A += 1;
                  values.count_comparecat = values.runcount_3;
                  values.count_compareformat = values.runcount_A}]
/ ontrialbegin = [if (values.newnumber ==6) 
                  {values.runcount_3 += 1; 
                  values.runcount_B += 1;
                  values.count_comparecat = values.runcount_3;
                  values.count_compareformat = values.runcount_B}]
/ ontrialbegin = [if (values.newnumber ==7) 
                  {values.runcount_4 += 1; 
                  values.runcount_A += 1;
                  values.count_comparecat = values.runcount_4;
                  values.count_compareformat = values.runcount_A}]
/ ontrialbegin = [if (values.newnumber ==8) 
                  {values.runcount_4 += 1; 
                  values.runcount_B += 1;
                  values.count_comparecat = values.runcount_4;
                  values.count_compareformat = values.runcount_B}]
/ ontrialbegin = [if (values.newnumber ==9) 
                  {values.runcount_5 += 1; 
                  values.runcount_A += 1;
                  values.count_comparecat = values.runcount_5;
                  values.count_compareformat = values.runcount_A}]
/ ontrialbegin = [if (values.newnumber ==10) 
                  {values.runcount_5 += 1; 
                  values.runcount_B += 1;
                  values.count_comparecat = values.runcount_5;
                  values.count_compareformat = values.runcount_B}]
/ ontrialbegin = [if (values.newnumber ==11) 
                  {values.runcount_6 += 1; 
                  values.runcount_A += 1;
                  values.count_comparecat = values.runcount_6;
                  values.count_compareformat = values.runcount_A}]
/ ontrialbegin = [if (values.newnumber ==12) 
                  {values.runcount_6 += 1; 
                  values.runcount_B += 1;
                  values.count_comparecat = values.runcount_6;
                  values.count_compareformat = values.runcount_B}]

/ ontrialbegin = [if (values.count_comparecat < 4 && values.count_compareformat < 4 && (values.newnumber == 1 || values.newnumber == 2))
                     { values.runcount_2 = 0; values.runcount_3 = 0; values.runcount_4 = 0}]
/ ontrialbegin = [if (values.count_comparecat < 4 && values.count_compareformat < 4 && (values.newnumber == 3 || values.newnumber == 4) )
                     { values.runcount_1 = 0; values.runcount_3 = 0; values.runcount_4 = 0}]
/ ontrialbegin = [if (values.count_comparecat < 4 && values.count_compareformat < 4 && (values.newnumber == 5 || values.newnumber == 6) )
                     { values.runcount_1 = 0; values.runcount_2 = 0; values.runcount_4 = 0}]
/ ontrialbegin = [if (values.count_comparecat < 4 && values.count_compareformat < 4 && (values.newnumber == 7 || values.newnumber == 8) )
                     { values.runcount_1 = 0; values.runcount_2 = 0; values.runcount_3 = 0}]

/ ontrialbegin = [if (values.count_comparecat < 4 && values.count_compareformat < 4 && mod(values.newnumber,2) == 0)
                     { values.runcount_A = 0}]
/ ontrialbegin = [if (values.count_comparecat < 4 && values.count_compareformat < 4 && mod(values.newnumber,2) != 0)
                     { values.runcount_B = 0}]
/ timeout = 0
/ ontrialend = [if (values.count_comparecat < 4 && values.count_compareformat < 4)
                     {values.sequence = concat(values.sequence, values.newnumber);
                     values.index += 1}
               else
                     {values.sequence = "";
                     values.index = 0;
                     values.runcount_1 = 0; values.runcount_2 = 0; values.runcount_3 = 0; values.runcount_4 = 0;values.runcount_5 = 0;values.runcount_6 = 0;
                     values.runcount_A = 0; values.runcount_B = 0;
                     reset(list.stimcats)}]
/ branch = [if (values.index < values.totaltrialcount) trial.selectnumber ]
</trial>
Debug:
/ branch = [if (values.index < values.totaltrialcount) trial.selectnumber else trial.showsequence]
*****************************************************************************
Trial Showsequence: Debug Trial
*****************************************************************************
<text completesequence>
/ items = ("<%values.sequence%>")
</text>

<trial showsequence>
/ inputdevice = keyboard
/ stimulusframes = [1 = completesequence]
/ validresponse = (57)
</trial>

*****************************************************************************
Block SequenceGenerator: 
*****************************************************************************
<text wait>
/items = ("Please wait; we'll be ready shortly")
/ fontstyle = ("Arial", 3.00%, false, false, false, false, 5, 0)
</text>

<block SequenceGenerator>
/ bgstim = (wait)
/ trials = [1 = selectnumber]
/ recorddata = false
</block>

**************************************************************************************************************
                                                          END OF FILE
**************************************************************************************************************[quote]
 

Thanks for the Help
By robwel - 3/28/2014

the sequence generator doesnt seem to stop.
By Dave - 3/28/2014

Look at how a generated sequence as stored in values.sequence looks like. An example is right there in the script's comments:

"the sequences produced look something like this:
86854627681534427238341865316174854225166758252358517483251343227374137614617876"

trial.aat_start the pulls *a single digit* out of that long string and increases an index value by one:

<trial AAT_start>
/ ontrialbegin = [values.nextstimulus = substring(values.sequence, values.index, 1);
                        values.index += 1]
[...]
</trial>

Now, obviously, that'll work fine as long as you're in the single-digit range, i.e. there a no more than 9 categories / versions as in

<list stimcats>
/ items = (
1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,3,3,
4,4,4,4,4,4,4,4,4,4,
5,5,5,5,5,5,5,5,5,5,
6,6,6,6,6,6,6,6,6,6,
7,7,7,7,7,7,7,7,7,7,
8,8,8,8,8,8,8,8,8,8)
/ replace = false
</list>

You, however, break into the two-digit realm:

<list stimcats>
/ items = (
1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,
4,4,4,4,4,4,4,4,
5,5,5,5,5,5,5,5,
6,6,6,6,6,6,6,6,
7,7,7,7,7,7,7,7,
8,8,8,8,8,8,8,8,
9,9,9,9,9,9,9,9,
10,10,10,10,10,10,10,10,
11,11,11,11,11,11,11,11,
12,12,12,12,12,12,12,12)
/ replace = false
</list>

Now, suppose, one of the 12s is pulled from the list and added to values.sequence in the course of sequence generation. values.sequence will thus contain the following

"...12..."

To <trial AAT_start> this *does not* indicate "category 12". Instead it is interpreted as "category 1" followed by "category 2" as per the statement

/ ontrialbegin = [values.nextstimulus = substring(values.sequence, values.index, 1);
                        values.index += 1]

already discussed above. A further problem, of course, is posed by the 10s in your <list>, meaning "category 1" followed by "category 0". There is no "category 0", though.

So, what you ought to do, is (a) extend everything to two digits

<list stimcats>
/ items = (
01,01,01,01,01,01,01,01,
02,02,02,02,02,02,02,02,
...
11,11,11,11,11,11,11,11,
12,12,12,12,12,12,12,12)
/ replace = false
</list>

such that the resulting values.sequence e.g. reads

"...100302..."

meaning category 10, followed by category 3, followed by category 2 and (b) adjust the logic throughout the script accordingly

/ ontrialbegin = [values.nextstimulus = substring(values.sequence, values.index, 2);
                        values.index += 2]

etc.



By robwel - 3/28/2014

hi, 

thanks for such a quick and helpfull response. 

Great work:-)
By Dave - 3/28/2014

A personal request, if I may: Please do not paste lengthy syntax excerpts or full scripts into a post's body. It makes those posts extremely hard to follow throuh and work with. Please use the forum's file attachment facilities instead. Thank you.
By Dave - 3/28/2014

robwel (3/29/2014)
the sequence generator doesnt seem to stop.

The algorithm has its limits (as indicated in the script's comments):

"This trialsequence algorithm is a simple, brute-force method that may reach its limits if more conditions/trials are added."

Basically, if at a given point the generated sequence so far doesn't satisfy the various constraints imposed, the entire generation process will be restarted from scratch. The more complex things get (more categories, more constraints), the longer this process will take and the likelier it is to fail (i.e. to not converge on a valid result). Constrained randomization is a hard problem (c.f. https://www.millisecond.com/forums/Topic6419.aspx). In this case, you should consider the alternatives indicated in the comments:

"
NOTE:
!!!! The time to generate the appropriate sequence will differ between participants.
Two alternatives are:
1) pregenerated sequences.
For example, you could generate 100 of these sequences (run this code in a separate script),
store the sequences in an item element and select randomly from these sequences for each
participant.
2) run the experiment with simple random sampling 
(without replacement) without paying attention to the added constraints 
regarding category/format repetitions."

By robwel - 3/29/2014

Hi, 

it's running again thanks but now there are only about 10 testtrials. I'll atach the file. I havent programmed in 2 years and would appreciate any help. Thank you.

By Dave - 3/29/2014

#1:
<values>
/totaltrialcount = 80
[...]
</values>

#2:
<trial selectnumber>
[...]
/ branch = [if (values.index < values.totaltrialcount) trial.selectnumber ]
</trial>

You should also (a) enable the debug /branch included in the script's comments for the above <trial>

"Debug:
/ branch = [if (values.index < values.totaltrialcount) trial.selectnumber else trial.showsequence]"

to view the generated sequence and (b) use CTRL+D extensively to review the state of the various variables involved.


By robwel - 3/29/2014

hi,

looking at the sequence i can see that its still generated in the one digit format. This might be the problem. Where can i find the procedure that is causing the digitlength?

Thank you for the help... I hope i am not asking for too much help on here.
By Dave - 3/29/2014

There are various issues with your code (and I'm not sure I've caught them all; when in doubt, go back to the original script and study the code for <trial selectnumber> thoroughly until you fully understand how it works / what it does; only then start re-adding your modifications, i.e. the extension to additional categories). Anyway, review the attached file to which I've added a bunch of debug stuff allowing you to observe sequence generation as it happens. Note that you are going to run into issues re. format (A/B) runs due to the increased number of categories. You should consider increasing the cutoff value (currently < 4).

EDIT NOTE: Uploaded wrong attachment. Fixed now.