Millisecond Forums

Random AAT HELP PLEASE

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

By poleraze - 2/13/2020

Hey there,

I want to program an AAT (approach avoidance task) were you have to pull non_alcoholic drinks towards you and push alcoholic drinks away from you.
Its connected with a sequence generator.
I have two groups. alcoholic and non-alcoholic pictures.
I want each item two be used 3 times that makes a total of 150. selection should be random.
below you see the sequence genarator script.
Thank you all

<values>
/count1 = 25
/count2 = 25
/totaltrialcount = 150

/runcount_1 = 0
/runcount_2 = 0

/newnumber = 0
/count_comparecat = 0

/sequence = ""
/index = 0
/reset = 1
</values>

**************************************************************************************************************
**************************************************************************************************************
    STIMULI
**************************************************************************************************************
**************************************************************************************************************

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


**************************************************************************************************************
**************************************************************************************************************
    LISTS
**************************************************************************************************************
**************************************************************************************************************

<list stimcats>
/ items = (
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2)
/ maxrunsize = 3
/ replace = false
</list>

**************************************************************************************************************
**************************************************************************************************************
    TRIALS
**************************************************************************************************************
**************************************************************************************************************

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: checks whether an alternative number is available that could meet constraint
                            => if yes: returns current number to list and tries again
                            => if no: starts the sequence over

<trial selectnumber>
/ ontrialbegin = [
    values.newnumber = list.stimcats.nextvalue;
    values.index += 1;
    values.sequence = concat(values.sequence, values.newnumber);
]
/branch = [if (values.index != values.totaltrialcount) trial.selectnumber else trial.checksequence]

/timeout = 0
/recorddata = false
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCK
**************************************************************************************************************
**************************************************************************************************************

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

<trial checksequence>
/ ontrialbegin = [
    if (contains(values.sequence, "1111") || contains(values.sequence, "2222")) {
        values.sequence = "";
        values.index = 0;
        values.reset = 1;
    } else values.reset = 0;
]
/timeout = 0
/recorddata = false
/ branch = [
    if(values.reset) trial.selectnumber;
]
</trial>


<text thesequence>
/ items = ("Length: <%length(values.sequence)%>
~nN(Cat1) = <%length(replaceall(values.sequence, ~"1~", ~"~"))%>
~nN(Cat2) = <%length(replaceall(values.sequence, ~"2~", ~"~"))%>
~nSequence:~n<%values.sequence%>")
/ size = (50%, 50%)
</text>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************



**************************************************************************************************************
                    END OF FILE
**************************************************************************************************************

**** Anpassen Sequenz
**** exp condition: alc ranziehen 1; neutral 2
By Dave - 2/13/2020

poleraze - 2/13/2020
Hey there,

I want to program an AAT (approach avoidance task) were you have to pull non_alcoholic drinks towards you and push alcoholic drinks away from you.
Its connected with a sequence generator.
I have two groups. alcoholic and non-alcoholic pictures.
I want each item two be used 3 times that makes a total of 150. selection should be random.
below you see the sequence genarator script.
Thank you all

<values>
/count1 = 25
/count2 = 25
/totaltrialcount = 150

/runcount_1 = 0
/runcount_2 = 0

/newnumber = 0
/count_comparecat = 0

/sequence = ""
/index = 0
/reset = 1
</values>

**************************************************************************************************************
**************************************************************************************************************
    STIMULI
**************************************************************************************************************
**************************************************************************************************************

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


**************************************************************************************************************
**************************************************************************************************************
    LISTS
**************************************************************************************************************
**************************************************************************************************************

<list stimcats>
/ items = (
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2)
/ maxrunsize = 3
/ replace = false
</list>

**************************************************************************************************************
**************************************************************************************************************
    TRIALS
**************************************************************************************************************
**************************************************************************************************************

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: checks whether an alternative number is available that could meet constraint
                            => if yes: returns current number to list and tries again
                            => if no: starts the sequence over

<trial selectnumber>
/ ontrialbegin = [
    values.newnumber = list.stimcats.nextvalue;
    values.index += 1;
    values.sequence = concat(values.sequence, values.newnumber);
]
/branch = [if (values.index != values.totaltrialcount) trial.selectnumber else trial.checksequence]

/timeout = 0
/recorddata = false
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCK
**************************************************************************************************************
**************************************************************************************************************

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

<trial checksequence>
/ ontrialbegin = [
    if (contains(values.sequence, "1111") || contains(values.sequence, "2222")) {
        values.sequence = "";
        values.index = 0;
        values.reset = 1;
    } else values.reset = 0;
]
/timeout = 0
/recorddata = false
/ branch = [
    if(values.reset) trial.selectnumber;
]
</trial>


<text thesequence>
/ items = ("Length: <%length(values.sequence)%>
~nN(Cat1) = <%length(replaceall(values.sequence, ~"1~", ~"~"))%>
~nN(Cat2) = <%length(replaceall(values.sequence, ~"2~", ~"~"))%>
~nSequence:~n<%values.sequence%>")
/ size = (50%, 50%)
</text>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************



**************************************************************************************************************
                    END OF FILE
**************************************************************************************************************

**** Anpassen Sequenz
**** exp condition: alc ranziehen 1; neutral 2

And what is your question?
By poleraze - 2/13/2020

Dave - 2/13/2020

And what is your question?

it always selects some items more than 3 times and i dont know why. does anyone (you) see the mistake i made ?
By Dave - 2/13/2020

poleraze - 2/13/2020
Dave - 2/13/2020

And what is your question?

it always selects some items more than 3 times and i dont know why. does anyone (you) see the mistake i made ?

But that has nothing to do with the sequence generator.
By Dave - 2/13/2020

Dave - 2/13/2020
poleraze - 2/13/2020
Dave - 2/13/2020

And what is your question?

it always selects some items more than 3 times and i dont know why. does anyone (you) see the mistake i made ?

But that has nothing to do with the sequence generator.

Look, the sequence generator generates a sequence of *trials* with certain constraints. In your case here, there's a total 150 trials, 75 of which are category 1 trials and 75 of which are category 2 trials. The constraint here is that no more than 3 trials of the same category occur back to back. And that's exactly what the generator puts out:
By poleraze - 2/13/2020

okey, so thats the other code. sorry for the long post but i thought its better when you see the whole thing.
its my first time using inquisit sorry.
**************************************************************************************************************
**************************************************************************************************************
                                            APPROACH-AVOIDANCE TASK (AAT)
**************************************************************************************************************
**************************************************************************************************************
                                                        SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software LLC
Date: 08-17-2012

last updated: 09-04-2014 by K. Borchert for Millisecond Software

Copyright © 09-04-2014 Millisecond Software
**************************************************************************************************************
**************************************************************************************************************
SCRIPT DESCRIPTION/BACKGROUND INFO
**************************************************************************************************************
**************************************************************************************************************
<include>
/ file = "aat_sequencegenerator.iqx"
</include>




*******************************************************************************************************************
*******************************************************************************************************************
    EDITABLE CODE: The code in this section can be easily altered (look for additional instructions were indicated)
*******************************************************************************************************************
*******************************************************************************************************************

***************************************************************************************
*********************************************
Editable Values
*********************************************
***************************************************************************************

<values>
/Startheight_ratioA = 0.5
/Startheight_ratioB = 0.5
/MinHeight_ratioA = 0.05
/MinHeight_ratioB = 0.05
/intertrialinterval = 300

</values>
    
***************************************************************************************
*********************************************
Editable Stimuli
*********************************************
***************************************************************************************
***************************************************************************************
item 1-25 are non-alc stimuli
item 25-50 are alc stimuli
**************************************************************************************

<item targets>

/1 = "HighPoly_0000_HP_64.png"
/2 = "HighPoly_0001_HP_63.png"
/3 = "HighPoly_0002_HP_62.png"
/4 = "HighPoly_0004_HP_59.png"
/5 = "HighPoly_0005_HP_58.png"
/6 = "HighPoly_0010_HP_53.png"
/7 = "HighPoly_0064_HP_01.png"
/8 = "HighPoly_0020_HP_43.png"
/9 = "HighPoly_0015_HP_48.png"
/10 = "HighPoly_0065_HP_01.png"
/11 = "HighPoly_0028_HP_35.png"
/12 = "HighPoly_0016_HP_47.png"
/13 = "HighPoly_0034_HP_29.png"
/14 = "HighPoly_0035_HP_28.png"
/15 = "HighPoly_0038_HP_25.png"
/16 = "HighPoly_0042_HP_21.png"
/17 = "HighPoly_0050_HP_13.png"
/18 = "HighPoly_0019_HP_44.png"
/19 = "HighPoly_0045_HP_18.png"
/20 = "HighPoly_0051_HP_12.png"
/21 = "HighPoly_0054_HP_09.png"
/22 = "HighPoly_0020_HP_43.png"
/23 = "HighPoly_0057_HP_06.png"
/24 = "HighPoly_0061_HP_02.png"
/25 = "HighPoly_0063_HP_01.png"

/26 = "HighPoly_0003_HP_60.png"
/27 = "HighPoly_0006_HP_57.png"
/28 = "HighPoly_0009_HP_54.png"
/29 = "HighPoly_0043_HP_20.png"
/30 = "HighPoly_0013_HP_50.png"
/31 = "HighPoly_0014_HP_49.png"
/32 = "HighPoly_0022_HP_41.png"
/33 = "HighPoly_0023_HP_40.png"
/34 = "HighPoly_0024_HP_39.png"
/35 = "HighPoly_0025_HP_38.png"
/36 = "HighPoly_0026_HP_37.png"
/37 = "HighPoly_0029_HP_34.png"
/38 = "HighPoly_0055_HP_08.png"
/39 = "HighPoly_0031_HP_32.png"
/40 = "HighPoly_0032_HP_31.png"
/41 = "HighPoly_0036_HP_27.png"
/42 = "HighPoly_0037_HP_26.png"
/43 = "HighPoly_0039_HP_24.png"
/44 = "HighPoly_0040_HP_23.png"
/45 = "HighPoly_0041_HP_22.png"
/46 = "HighPoly_0049_HP_14.png"
/47 = "HighPoly_0056_HP_07.png"
/48 = "HighPoly_0059_HP_04.png"
/49 = "HighPoly_0060_HP_03.png"
/50 = "HighPoly_0047_HP_16.png"

</item>



<item practicestimuli>
/1 = "Beer_Probe.png"
/2 = "Water_Probe.png"
</item>
***************************************************************************************
*********************************************
Editable Instructions
*********************************************
***************************************************************************************

<instruct >
/ windowsize = (80%, 60%)
/ fontstyle = ("Book Antique", 2.50%, false, false, false, false, 5, 0)
</instruct>

<item instructions>
/ 1 = "In the following task, you will be presented alcoholic or non-alcoholic images.
~n~nYour task is to:
~n* PULL the joystick towards you if you see a non-alcoholic image
* PUSH the joystick away from you if you see an alcoholic image
~nWhen you PUSH, the image will shrink.
When you PULL, the image will enlarge.
~nYou need to PUSH/PULL until the joystick is FULLY extended in that direction
(aka cannot go any further).
Afterwards you need to bring the joystick back into the rest position
and a new image will be presented.
~n~nMove the joystick to the left to start practice."
/ 2 = "This is practice.
~nYou will be you will be presented alcoholic or non-alcoholic images.
~n* PULL the joystick towards you if you see a non-alcoholic image
* PUSH the joystick away from you if you see an alcoholic image
~nRemember to PULL/PUSH until the joystick is fully extended and then
bring it back into the rest position to start the next trial.
~n~n~nBe as fast and accurate as you possibly can.
~n~nMove the joystick to the left to start the practice trials."
/ 3 = "This is the real task.
~nYou will be you will be presented alcoholic or non-alcoholic images.
~nJust like you did during practice,
~n* PULL the joystick towards you if you see a non-alcoholic image
* PUSH the joystick away from you if you see an alcoholic image
~n~nBe as fast and accurate as you possibly can. There will be 150 images total.
~nMove the joystick to the left to start."
</item>

<page End>
Thats the end of the task. Thank you for your participation.
</page>
***************************************************************************************
*********************************************
Editable Lists
*********************************************
***************************************************************************************
AAT lists contain the indices of the target stimuli for each category

********************************
category1 = alc
category2 = non-alc
********************************

<list category1>
/ items=(26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50)
/ replace = false
</list>

<list category2>
/ items=(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
/ replace = false
</list>


*******************************************************************************************************************
*******************************************************************************************************************
    DATA: this section contains data file information
*******************************************************************************************************************
*******************************************************************************************************************

*****************
raw data
*****************
date, time, subject:            date and time script was run with the current subjectnumber
/expcondition:                    used for counterbalancing experimental conditions
                                    1: push for landscape, pull for portrait
                                    2: pull for landscape, push for portrait

blockcode, blocknum:            the name and number of the current block
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data)
/stimulus:                        the presented stimulus
/targetcategory:                the targetcategory of the targetstimulus, 1 - 4
/targetformat :                    the targetformat of the targetstimulus (l = landscape; p = portrait)
/initialresponse:                stores the original response to the stimulus
/correct:                        stores the correctness of the initial response
/finalresponse:                    stores the final response (at time joystick is fully extended)
/changedirection:                stores whether and how often participant changed direction during zooming (0 = no change)
/RT:                            stores the latency of the initial response (in ms)
/completeRT:                    stores how long it takes until the joystick is fully extended in whatever direction (in ms)

<data >
/file = "AAT_raw.iqdat"
/ separatefiles = true
/ columns = [date, time, subject, group, values.expcondition, blockcode, blocknum, values.trialcode, trialnum, values.stimulus,
            values.targetcategory,values.targetformat,
            values.initialresponse, values.correct, values.finalresponse, values.changedirection,
            values.RT, values.completeRT, values.completeRTminusRT]
</data>


*****************
summary data
*****************
script.elapsedtime:                            time it took to run script (in ms)
completed:                                    0 = script was not completed; 1 = script was completed (all conditions run)

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 joystick is fully extended)

/sequence:     the experimental sequence generated for the participant


<summarydata >
/file = "ATT_summary.iqdat"
/columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, values.completed, values.expcondition,
expressions.aat_diffscore_cat1, expressions.AAT_Median_NTR, expressions.AAT_Median_ALK]
</summarydata>

*******************************************************************************************************************
*******************************************************************************************************************
                            REMAINING CODE: Customize after careful consideration only
*******************************************************************************************************************
*******************************************************************************************************************


**************************************************************************************************************
**************************************************************************************************************
DEFAULT SCREEN SETTING
**************************************************************************************************************
**************************************************************************************************************
requires Inquisit 4.0.4.0

<defaults >
/canvasaspectratio = (4,3)
/minimumversion = "4.0.4.0"
/ inputdevice = joystick
/joystickthreshold = 30
</defaults>

**************************************************************************************************************
**************************************************************************************************************
VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************


             AAT code:
/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_px:                                maximum height for pictures (display.canvasheight) in pixels
/joystick_y:                                helper variable to track the y-position of the joystick                            
/completeRT:                                stores how long it takes until the joystick is fully extended
/changedirection:                            stores whether and how often participant changed direction during zooming
                                            (0 = no change)
/joystickchange:                            stores the absolute change in joystick 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 joystick is fully extended)
completed:                                    0 = script was not completed; 1 = script was completed (all conditions run)


<values >
/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
/repeat = 0
/selectpracticepicture = 0
/starttime = 0
/endtime = 0
/expcondition = 0
/format1 = 0
/format2 = 0
/startheight_A = 0
/startheight_B = 0
/Maxheight_px = display.canvasheight
/joystick_y = 0
/completeRT = 0
/changedirection = 0
/joystick_change = 0
/trialcode = 0
/RT = 0
/correct = 0
/stimulus = 0
/initialresponse = ""
/finalresponse = ""
/completed = 0
/completeRTminusRT = 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 joystick is fully extended)

/maxheightchange_px: max pixel height change of picture

noch offen:
<expressions >
/ AAT_Diffscore_Cat1 = if (values.expcondition == 1) trial.ALK.medianlatency - trial.NTR.medianlatency else
                                    trial.ALK.medianlatency - trial.NTR.medianlatency
/ AAT_Median_NTR = trial.NTR.medianlatency
/ AAT_Median_ALK = trial.ALK.medianlatency
/maxheightchange_px = if (values.targetformat == "alk") {(values.Startheight_ratioA - values.MinHeight_ratioA) * values.Maxheight_px} else
                                        {(values.Startheight_ratioB - values.MinHeight_ratioB) * values.Maxheight_px}
</expressions>

**************************************************************************************************************
**************************************************************************************************************
INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************
<text instruction>
/items = instructions
/select = sequence
/position = (50%, 50%)
/ fontstyle = ("Book Antique", 3%, false, false, false, false, 5, 0)
/txcolor = black
/resetinterval = 3
/size = (80%, 80%)
</text>

<trial instructions>
/stimulusframes = [1 = instruction]
/validresponse = ("left")
/recorddata = false
/branch = [trial.instruct_joystickrest]
</trial>

Note: trial.instruct_joystickrest & trial.instruct_pause make sure that Joystick is brought back into
rest position
<trial instruct_joystickrest>
/validresponse = (change)
/branch = [if (monkey.monkeymode == 1) trial.instruct_pause]
/branch = [if (joystick.y == 0 && joystick.x == 0) trial.Instruct_Pause else trial.instruct_joystickrest]
/recorddata = false
</trial>

<trial Instruct_Pause>
/ stimulusframes = [1 = eraser]
/ timeout = 0
/ recorddata = false
</trial>


**************************************************************************************************************
**************************************************************************************************************
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>

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

*************************
Practice Stimuli
*************************
<text error>
/ items = ("X")
/ position = (50%, 50%)
/ fontstyle = ("Book Antique", 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.practicetrial_A displays the stimulus of format A (here: landscape) by setting
values.selectpracticepicture = 1
*if a forward movement (=push) is detected -> decrease picture
*if a back movement (=pull) is detected -> increase picture
<trial practicetrial_ALK>
/ontrialbegin = [values.targetformat = "alk"]
/ 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=""; values.completertminusrt = 0]

/ stimulusframes = [1 = practicetarget]
/ validresponse = (back, forward)
/ iscorrectresponse = [(values.expcondition == 1 && trial.practicetrial_ALK.response == "forward") ||
                        (values.expcondition == 2 && trial.practicetrial_ALK.response == "back")]
/ errormessage = true(error,0)

/ ontrialend = [values.joystick_y = joystick.y]
/ ontrialend = [values.joystick_change = abs(values.joystick_y)]
/ontrialend = [values.trialcode = "practicetrial_ALK"]
/ontrialend = [values.RT = trial.practicetrial_ALK.latency]
/ontrialend = [values.correct = trial.practicetrial_ALK.correct]
/ontrialend = [values.stimulus = picture.practicetarget.currentitem]
/ontrialend = [if (trial.practicetrial_ALK.response == "forward") values.initialresponse = "PUSH"
                        else values.initialresponse = "PULL"]

/ branch = [if (trial.practicetrial_ALK.response == "forward") trial.practicedecrease else trial.practiceincrease]
/ recorddata = false
</trial>

NOTE:
trial.practicetrial_B displays the stimulus of format B (here: portrait) by setting
values.selectpracticepicture = 2
*if a forward movement (=push) is detected -> decrease picture
*if a back movement (=pull) is detected -> increase picture

<trial practicetrial_NTR>
/ontrialbegin = [values.targetformat = "ntr"]
/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=""; values.completertminusrt = 0]

/ stimulusframes = [1 = practicetarget]
/ validresponse = (back, forward)
/ iscorrectresponse = [(values.expcondition == 1 && trial.practicetrial_NTR.response == "back") ||
                        (values.expcondition == 2 && trial.practicetrial_NTR.response == "forward")]
/ errormessage = true(error,0)

/ontrialend = [values.joystick_y = joystick.y]
/ontrialend = [values.joystick_change = abs(values.joystick_y)]
/ontrialend = [values.trialcode = "practicetrial_NTR"]
/ontrialend = [values.RT = trial.practicetrial_NTR.latency]
/ontrialend = [values.correct = trial.practicetrial_NTR.correct]
/ontrialend = [values.stimulus = picture.practicetarget.currentitem]
/ontrialend = [if (trial.practicetrial_NTR.response == "forward") values.initialresponse = "PUSH"
                        else values.initialresponse = "PULL"]

/ branch = [if (trial.practicetrial_NTR.response == "forward") trial.practicedecrease else trial.practiceincrease]
/recorddata = false
</trial>

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

/ iscorrectresponse = [(values.expcondition == 1 && trial.practicetrial_B.response == "back") ||
                        (values.expcondition == 2 && trial.practicetrial_B.response == "forward")]

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

/ ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px]
/ stimulusframes = [1 = eraser, practicetarget]
/validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ontrialend = [values.joystick_change = abs(values.joystick_y - joystick.y)]

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


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

/branch = [if (joystick.y <= -1000)
                {values.joystick_y = joystick.y; values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.enddecrease_practice}]
/branch = [if (joystick.y <= values.joystick_y)
                {values.joystick_y = joystick.y; trial.practicedecrease}]
/branch = [if (joystick.y > values.joystick_y)
                {values.joystick_y = joystick.y; values.changedirection += 1; trial.practiceincrease}]

/ recorddata = false
</trial>

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

/ ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px]
/ stimulusframes = [1 = practicetarget]
/validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ontrialend = [values.joystick_change = abs(values.joystick_y - joystick.y)]

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

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

/branch = [if (joystick.y >= 1000)
                {values.joystick_y = joystick.y; values.endtime = script.elapsedtime; values.finalresponse = "PULL"; trial.endincrease_practice}]
/branch = [if (joystick.y >= values.joystick_y)
                {values.joystick_y = joystick.y; trial.practiceincrease}]
/branch = [if (joystick.y < values.joystick_y)
                {values.joystick_y = joystick.y; 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.joystick_change/1000 * expressions.maxheightchange_px]
/stimulusframes = [1 = practicetarget]
/timeout = 0
/branch = [trial.joystickrest]
/recorddata = false
</trial>

<trial enddecrease_practice>
/ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px]
/stimulusframes = [1 = eraser, practicetarget]
/timeout = 0
/branch = [trial.joystickrest]
/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>
/ trials = [1-2 = instructions; 3-12 = noreplace(practicetrial_ALK, practicetrial_NTR)]
</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:


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.ALK]
/ branch = [if (values.nextstimulus == 2) trial.NTR]
/ recorddata = false
</trial>


**********************************************************************
trials that select targetstimuli via list.categoryX
and take in initial response
**********************************************************************
<trial ALK>
/ ontrialbegin = [values.selectstimulus = list.category1.nextvalue]
/ ontrialbegin = [values.targetcategory = 1; values.targetformat = "alk"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_A]

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

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (back, forward)
/ iscorrectresponse = [(values.expcondition == 1 && trial.ALK.response == "forward") ||
                                (values.expcondition == 2 && trial.ALK.response == "forward")]

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

/ ontrialend = [values.joystick_y = joystick.y]
/ ontrialend = [values.joystick_change = abs(values.joystick_y)]
/ ontrialend = [values.trialcode = "ALK"]
/ ontrialend = [values.RT = trial.ALK.latency]
/ ontrialend = [values.correct = trial.ALK.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]
/ ontrialend = [if (trial.ALK.response == "forward") values.initialresponse = "PUSH"
                        else values.initialresponse = "PULL"]

/ branch = [if (trial.ALK.response == "forward") trial.decrease else trial.increase]
/recorddata = false
</trial>


<trial NTR>
/ ontrialbegin = [values.selectstimulus = list.category2.nextvalue]
/ ontrialbegin = [values.targetcategory = 1; values.targetformat = "ntr"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_B]

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

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (back, forward)
/ iscorrectresponse = [(values.expcondition == 1 && trial.NTR.response == "back") ||
                                (values.expcondition == 2 && trial.NTR.response == "back")]

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

/ ontrialend = [values.joystick_y = joystick.y]
/ ontrialend = [values.joystick_change = abs(values.joystick_y)]
/ ontrialend = [values.trialcode = "NTR"]
/ ontrialend = [values.RT = trial.NTR.latency]
/ ontrialend = [values.correct = trial.NTR.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]
/ ontrialend = [if (trial.NTR.response == "forward") values.initialresponse = "PUSH"
                        else values.initialresponse = "PULL"]

/branch = [if (trial.NTR.response == "forward") 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
joystick is fully extended
**********************************************************************
<trial decrease>
/ ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px]

/ stimulusframes = [1 = eraser, targetstimulus]
/validresponse = (change)
/ monkeyresponse = ("back", "forward")

/ontrialend = [values.joystick_change = abs(values.joystick_y - joystick.y)]

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

/branch = [if (joystick.y <= -1000)
                {values.joystick_y = joystick.y; values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.enddecrease}]
/branch = [if (joystick.y <= values.joystick_y)
                {values.joystick_y = joystick.y; trial.decrease}]
/branch = [if (joystick.y > values.joystick_y)
                {values.joystick_y = joystick.y; values.changedirection += 1; trial.increase}]
/ recorddata = false
</trial>


<trial increase>
/ ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height + values.joystick_change/1000 * expressions.maxheightchange_px]
/ stimulusframes = [1 = targetstimulus]
/validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ontrialend = [values.joystick_change = abs(values.joystick_y - joystick.y)]

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

/branch = [if (joystick.y >= 1000)
                {values.joystick_y = joystick.y; values.endtime = script.elapsedtime; values.finalresponse = "PULL"; trial.endincrease}]
/branch = [if (joystick.y >= values.joystick_y)
                {values.joystick_y = joystick.y; trial.increase}]
/branch = [if (joystick.y < values.joystick_y)
                {values.joystick_y = joystick.y; 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.joystick_change/1000 * expressions.maxheightchange_px]
/stimulusframes = [1 = targetstimulus]
/timeout = 0
/branch = [trial.joystickrest]
/recorddata = false
</trial>

<trial enddecrease>
/ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px]
/stimulusframes = [1 = eraser, targetstimulus]
/timeout = 0
/branch = [trial.joystickrest]
/recorddata = false
</trial>

**********************************************************************
Helper Trials:
*trial.joystickrest: tracks that joystick was moved back into the rest position
*trial. InterTrialInterval : sets a predetermined InterTrialInterval
(and stores all relevant data in the data file to have one complete dataline for each trial)
**********************************************************************
<trial joystickrest>
/isvalidresponse = [trial.joystickrest.response =="change"]
/branch = [if (joystick.y == 0 && joystick.x == 0) trial.InterTrialInterval else trial.joystickrest]
/recorddata = false
/ monkeyresponse = ("change")
</trial>

<trial InterTrialInterval>
/ontrialbegin = [values.completeRT= values.endtime - values.starttime]
/ stimulusframes = [1 = eraser]
/ timeout = values.intertrialinterval
/ recorddata = true
/ontrialbegin = [values.completeRTminusRT = values.completeRT - values.RT]
</trial>
**************************************************************************************************************
**************************************************************************************************************
AAT EXPERIMENTAL BLOCKS
**************************************************************************************************************
**************************************************************************************************************
Note: if you adjust values.totaltrialcount, you need to adjust the number of trials called by block.AAT

<block AAT>
/ onblockbegin = [values.index = 0]
/ trials = [1 = instructions; 2-151 = AAT_start]
</block>



Note: trial.AAT_start uses a pregenerated trialsequence, if the order of the trial
can be random use the following code:

block AAT>
/ trials = [1 = instructions; 2-81 = noreplace(AAT_1, AAT_2, AAT_3, AAT_4, AAT_5, AAT_6, AAT_7, AAT_8)]
</block>


**************************************************************************************************************
**************************************************************************************************************
EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************
NOTE:
format/direction counterbalanced by group number

<expt >
/ onexptbegin = [values.expcondition = 1]
/ onexptbegin = [values.startheight_A = values.Startheight_ratioA*values.Maxheight_px]
/ onexptbegin = [values.startheight_B = values.Startheight_ratioB* values.Maxheight_px]
/ blocks = [1 = SequenceGenerator; 2 = practice_AAT; 3 = AAT]
/ postinstructions = (End)
/ onexptend = [values.completed = 1]
</expt>



**************************************************************************************************************
                    END OF FILE
**************************************************************************************************************

**** Anpassen Sequenz
**** exp condition: alc ranziehen 1; neutral 2
By Dave - 2/13/2020

poleraze - 2/13/2020
okey, so thats the other code. sorry for the long post but i thought its better when you see the whole thing.
its my first time using inquisit sorry.
**************************************************************************************************************
**************************************************************************************************************
                                            APPROACH-AVOIDANCE TASK (AAT)
**************************************************************************************************************
**************************************************************************************************************
                                                        SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software LLC
Date: 08-17-2012

last updated: 09-04-2014 by K. Borchert for Millisecond Software

Copyright © 09-04-2014 Millisecond Software
**************************************************************************************************************
**************************************************************************************************************
SCRIPT DESCRIPTION/BACKGROUND INFO
**************************************************************************************************************
**************************************************************************************************************
<include>
/ file = "aat_sequencegenerator.iqx"
</include>




*******************************************************************************************************************
*******************************************************************************************************************
    EDITABLE CODE: The code in this section can be easily altered (look for additional instructions were indicated)
*******************************************************************************************************************
*******************************************************************************************************************

***************************************************************************************
*********************************************
Editable Values
*********************************************
***************************************************************************************

<values>
/Startheight_ratioA = 0.5
/Startheight_ratioB = 0.5
/MinHeight_ratioA = 0.05
/MinHeight_ratioB = 0.05
/intertrialinterval = 300

</values>
    
***************************************************************************************
*********************************************
Editable Stimuli
*********************************************
***************************************************************************************
***************************************************************************************
item 1-25 are non-alc stimuli
item 25-50 are alc stimuli
**************************************************************************************

<item targets>

/1 = "HighPoly_0000_HP_64.png"
/2 = "HighPoly_0001_HP_63.png"
/3 = "HighPoly_0002_HP_62.png"
/4 = "HighPoly_0004_HP_59.png"
/5 = "HighPoly_0005_HP_58.png"
/6 = "HighPoly_0010_HP_53.png"
/7 = "HighPoly_0064_HP_01.png"
/8 = "HighPoly_0020_HP_43.png"
/9 = "HighPoly_0015_HP_48.png"
/10 = "HighPoly_0065_HP_01.png"
/11 = "HighPoly_0028_HP_35.png"
/12 = "HighPoly_0016_HP_47.png"
/13 = "HighPoly_0034_HP_29.png"
/14 = "HighPoly_0035_HP_28.png"
/15 = "HighPoly_0038_HP_25.png"
/16 = "HighPoly_0042_HP_21.png"
/17 = "HighPoly_0050_HP_13.png"
/18 = "HighPoly_0019_HP_44.png"
/19 = "HighPoly_0045_HP_18.png"
/20 = "HighPoly_0051_HP_12.png"
/21 = "HighPoly_0054_HP_09.png"
/22 = "HighPoly_0020_HP_43.png"
/23 = "HighPoly_0057_HP_06.png"
/24 = "HighPoly_0061_HP_02.png"
/25 = "HighPoly_0063_HP_01.png"

/26 = "HighPoly_0003_HP_60.png"
/27 = "HighPoly_0006_HP_57.png"
/28 = "HighPoly_0009_HP_54.png"
/29 = "HighPoly_0043_HP_20.png"
/30 = "HighPoly_0013_HP_50.png"
/31 = "HighPoly_0014_HP_49.png"
/32 = "HighPoly_0022_HP_41.png"
/33 = "HighPoly_0023_HP_40.png"
/34 = "HighPoly_0024_HP_39.png"
/35 = "HighPoly_0025_HP_38.png"
/36 = "HighPoly_0026_HP_37.png"
/37 = "HighPoly_0029_HP_34.png"
/38 = "HighPoly_0055_HP_08.png"
/39 = "HighPoly_0031_HP_32.png"
/40 = "HighPoly_0032_HP_31.png"
/41 = "HighPoly_0036_HP_27.png"
/42 = "HighPoly_0037_HP_26.png"
/43 = "HighPoly_0039_HP_24.png"
/44 = "HighPoly_0040_HP_23.png"
/45 = "HighPoly_0041_HP_22.png"
/46 = "HighPoly_0049_HP_14.png"
/47 = "HighPoly_0056_HP_07.png"
/48 = "HighPoly_0059_HP_04.png"
/49 = "HighPoly_0060_HP_03.png"
/50 = "HighPoly_0047_HP_16.png"

</item>



<item practicestimuli>
/1 = "Beer_Probe.png"
/2 = "Water_Probe.png"
</item>
***************************************************************************************
*********************************************
Editable Instructions
*********************************************
***************************************************************************************

<instruct >
/ windowsize = (80%, 60%)
/ fontstyle = ("Book Antique", 2.50%, false, false, false, false, 5, 0)
</instruct>

<item instructions>
/ 1 = "In the following task, you will be presented alcoholic or non-alcoholic images.
~n~nYour task is to:
~n* PULL the joystick towards you if you see a non-alcoholic image
* PUSH the joystick away from you if you see an alcoholic image
~nWhen you PUSH, the image will shrink.
When you PULL, the image will enlarge.
~nYou need to PUSH/PULL until the joystick is FULLY extended in that direction
(aka cannot go any further).
Afterwards you need to bring the joystick back into the rest position
and a new image will be presented.
~n~nMove the joystick to the left to start practice."
/ 2 = "This is practice.
~nYou will be you will be presented alcoholic or non-alcoholic images.
~n* PULL the joystick towards you if you see a non-alcoholic image
* PUSH the joystick away from you if you see an alcoholic image
~nRemember to PULL/PUSH until the joystick is fully extended and then
bring it back into the rest position to start the next trial.
~n~n~nBe as fast and accurate as you possibly can.
~n~nMove the joystick to the left to start the practice trials."
/ 3 = "This is the real task.
~nYou will be you will be presented alcoholic or non-alcoholic images.
~nJust like you did during practice,
~n* PULL the joystick towards you if you see a non-alcoholic image
* PUSH the joystick away from you if you see an alcoholic image
~n~nBe as fast and accurate as you possibly can. There will be 150 images total.
~nMove the joystick to the left to start."
</item>

<page End>
Thats the end of the task. Thank you for your participation.
</page>
***************************************************************************************
*********************************************
Editable Lists
*********************************************
***************************************************************************************
AAT lists contain the indices of the target stimuli for each category

********************************
category1 = alc
category2 = non-alc
********************************

<list category1>
/ items=(26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50)
/ replace = false
</list>

<list category2>
/ items=(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
/ replace = false
</list>


*******************************************************************************************************************
*******************************************************************************************************************
    DATA: this section contains data file information
*******************************************************************************************************************
*******************************************************************************************************************

*****************
raw data
*****************
date, time, subject:            date and time script was run with the current subjectnumber
/expcondition:                    used for counterbalancing experimental conditions
                                    1: push for landscape, pull for portrait
                                    2: pull for landscape, push for portrait

blockcode, blocknum:            the name and number of the current block
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data)
/stimulus:                        the presented stimulus
/targetcategory:                the targetcategory of the targetstimulus, 1 - 4
/targetformat :                    the targetformat of the targetstimulus (l = landscape; p = portrait)
/initialresponse:                stores the original response to the stimulus
/correct:                        stores the correctness of the initial response
/finalresponse:                    stores the final response (at time joystick is fully extended)
/changedirection:                stores whether and how often participant changed direction during zooming (0 = no change)
/RT:                            stores the latency of the initial response (in ms)
/completeRT:                    stores how long it takes until the joystick is fully extended in whatever direction (in ms)

<data >
/file = "AAT_raw.iqdat"
/ separatefiles = true
/ columns = [date, time, subject, group, values.expcondition, blockcode, blocknum, values.trialcode, trialnum, values.stimulus,
            values.targetcategory,values.targetformat,
            values.initialresponse, values.correct, values.finalresponse, values.changedirection,
            values.RT, values.completeRT, values.completeRTminusRT]
</data>


*****************
summary data
*****************
script.elapsedtime:                            time it took to run script (in ms)
completed:                                    0 = script was not completed; 1 = script was completed (all conditions run)

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 joystick is fully extended)

/sequence:     the experimental sequence generated for the participant


<summarydata >
/file = "ATT_summary.iqdat"
/columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, values.completed, values.expcondition,
expressions.aat_diffscore_cat1, expressions.AAT_Median_NTR, expressions.AAT_Median_ALK]
</summarydata>

*******************************************************************************************************************
*******************************************************************************************************************
                            REMAINING CODE: Customize after careful consideration only
*******************************************************************************************************************
*******************************************************************************************************************


**************************************************************************************************************
**************************************************************************************************************
DEFAULT SCREEN SETTING
**************************************************************************************************************
**************************************************************************************************************
requires Inquisit 4.0.4.0

<defaults >
/canvasaspectratio = (4,3)
/minimumversion = "4.0.4.0"
/ inputdevice = joystick
/joystickthreshold = 30
</defaults>

**************************************************************************************************************
**************************************************************************************************************
VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************


             AAT code:
/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_px:                                maximum height for pictures (display.canvasheight) in pixels
/joystick_y:                                helper variable to track the y-position of the joystick                            
/completeRT:                                stores how long it takes until the joystick is fully extended
/changedirection:                            stores whether and how often participant changed direction during zooming
                                            (0 = no change)
/joystickchange:                            stores the absolute change in joystick 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 joystick is fully extended)
completed:                                    0 = script was not completed; 1 = script was completed (all conditions run)


<values >
/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
/repeat = 0
/selectpracticepicture = 0
/starttime = 0
/endtime = 0
/expcondition = 0
/format1 = 0
/format2 = 0
/startheight_A = 0
/startheight_B = 0
/Maxheight_px = display.canvasheight
/joystick_y = 0
/completeRT = 0
/changedirection = 0
/joystick_change = 0
/trialcode = 0
/RT = 0
/correct = 0
/stimulus = 0
/initialresponse = ""
/finalresponse = ""
/completed = 0
/completeRTminusRT = 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 joystick is fully extended)

/maxheightchange_px: max pixel height change of picture

noch offen:
<expressions >
/ AAT_Diffscore_Cat1 = if (values.expcondition == 1) trial.ALK.medianlatency - trial.NTR.medianlatency else
                                    trial.ALK.medianlatency - trial.NTR.medianlatency
/ AAT_Median_NTR = trial.NTR.medianlatency
/ AAT_Median_ALK = trial.ALK.medianlatency
/maxheightchange_px = if (values.targetformat == "alk") {(values.Startheight_ratioA - values.MinHeight_ratioA) * values.Maxheight_px} else
                                        {(values.Startheight_ratioB - values.MinHeight_ratioB) * values.Maxheight_px}
</expressions>

**************************************************************************************************************
**************************************************************************************************************
INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************
<text instruction>
/items = instructions
/select = sequence
/position = (50%, 50%)
/ fontstyle = ("Book Antique", 3%, false, false, false, false, 5, 0)
/txcolor = black
/resetinterval = 3
/size = (80%, 80%)
</text>

<trial instructions>
/stimulusframes = [1 = instruction]
/validresponse = ("left")
/recorddata = false
/branch = [trial.instruct_joystickrest]
</trial>

Note: trial.instruct_joystickrest & trial.instruct_pause make sure that Joystick is brought back into
rest position
<trial instruct_joystickrest>
/validresponse = (change)
/branch = [if (monkey.monkeymode == 1) trial.instruct_pause]
/branch = [if (joystick.y == 0 && joystick.x == 0) trial.Instruct_Pause else trial.instruct_joystickrest]
/recorddata = false
</trial>

<trial Instruct_Pause>
/ stimulusframes = [1 = eraser]
/ timeout = 0
/ recorddata = false
</trial>


**************************************************************************************************************
**************************************************************************************************************
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>

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

*************************
Practice Stimuli
*************************
<text error>
/ items = ("X")
/ position = (50%, 50%)
/ fontstyle = ("Book Antique", 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.practicetrial_A displays the stimulus of format A (here: landscape) by setting
values.selectpracticepicture = 1
*if a forward movement (=push) is detected -> decrease picture
*if a back movement (=pull) is detected -> increase picture
<trial practicetrial_ALK>
/ontrialbegin = [values.targetformat = "alk"]
/ 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=""; values.completertminusrt = 0]

/ stimulusframes = [1 = practicetarget]
/ validresponse = (back, forward)
/ iscorrectresponse = [(values.expcondition == 1 && trial.practicetrial_ALK.response == "forward") ||
                        (values.expcondition == 2 && trial.practicetrial_ALK.response == "back")]
/ errormessage = true(error,0)

/ ontrialend = [values.joystick_y = joystick.y]
/ ontrialend = [values.joystick_change = abs(values.joystick_y)]
/ontrialend = [values.trialcode = "practicetrial_ALK"]
/ontrialend = [values.RT = trial.practicetrial_ALK.latency]
/ontrialend = [values.correct = trial.practicetrial_ALK.correct]
/ontrialend = [values.stimulus = picture.practicetarget.currentitem]
/ontrialend = [if (trial.practicetrial_ALK.response == "forward") values.initialresponse = "PUSH"
                        else values.initialresponse = "PULL"]

/ branch = [if (trial.practicetrial_ALK.response == "forward") trial.practicedecrease else trial.practiceincrease]
/ recorddata = false
</trial>

NOTE:
trial.practicetrial_B displays the stimulus of format B (here: portrait) by setting
values.selectpracticepicture = 2
*if a forward movement (=push) is detected -> decrease picture
*if a back movement (=pull) is detected -> increase picture

<trial practicetrial_NTR>
/ontrialbegin = [values.targetformat = "ntr"]
/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=""; values.completertminusrt = 0]

/ stimulusframes = [1 = practicetarget]
/ validresponse = (back, forward)
/ iscorrectresponse = [(values.expcondition == 1 && trial.practicetrial_NTR.response == "back") ||
                        (values.expcondition == 2 && trial.practicetrial_NTR.response == "forward")]
/ errormessage = true(error,0)

/ontrialend = [values.joystick_y = joystick.y]
/ontrialend = [values.joystick_change = abs(values.joystick_y)]
/ontrialend = [values.trialcode = "practicetrial_NTR"]
/ontrialend = [values.RT = trial.practicetrial_NTR.latency]
/ontrialend = [values.correct = trial.practicetrial_NTR.correct]
/ontrialend = [values.stimulus = picture.practicetarget.currentitem]
/ontrialend = [if (trial.practicetrial_NTR.response == "forward") values.initialresponse = "PUSH"
                        else values.initialresponse = "PULL"]

/ branch = [if (trial.practicetrial_NTR.response == "forward") trial.practicedecrease else trial.practiceincrease]
/recorddata = false
</trial>

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

/ iscorrectresponse = [(values.expcondition == 1 && trial.practicetrial_B.response == "back") ||
                        (values.expcondition == 2 && trial.practicetrial_B.response == "forward")]

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

/ ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px]
/ stimulusframes = [1 = eraser, practicetarget]
/validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ontrialend = [values.joystick_change = abs(values.joystick_y - joystick.y)]

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


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

/branch = [if (joystick.y <= -1000)
                {values.joystick_y = joystick.y; values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.enddecrease_practice}]
/branch = [if (joystick.y <= values.joystick_y)
                {values.joystick_y = joystick.y; trial.practicedecrease}]
/branch = [if (joystick.y > values.joystick_y)
                {values.joystick_y = joystick.y; values.changedirection += 1; trial.practiceincrease}]

/ recorddata = false
</trial>

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

/ ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px]
/ stimulusframes = [1 = practicetarget]
/validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ontrialend = [values.joystick_change = abs(values.joystick_y - joystick.y)]

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

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

/branch = [if (joystick.y >= 1000)
                {values.joystick_y = joystick.y; values.endtime = script.elapsedtime; values.finalresponse = "PULL"; trial.endincrease_practice}]
/branch = [if (joystick.y >= values.joystick_y)
                {values.joystick_y = joystick.y; trial.practiceincrease}]
/branch = [if (joystick.y < values.joystick_y)
                {values.joystick_y = joystick.y; 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.joystick_change/1000 * expressions.maxheightchange_px]
/stimulusframes = [1 = practicetarget]
/timeout = 0
/branch = [trial.joystickrest]
/recorddata = false
</trial>

<trial enddecrease_practice>
/ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px]
/stimulusframes = [1 = eraser, practicetarget]
/timeout = 0
/branch = [trial.joystickrest]
/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>
/ trials = [1-2 = instructions; 3-12 = noreplace(practicetrial_ALK, practicetrial_NTR)]
</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:


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.ALK]
/ branch = [if (values.nextstimulus == 2) trial.NTR]
/ recorddata = false
</trial>


**********************************************************************
trials that select targetstimuli via list.categoryX
and take in initial response
**********************************************************************
<trial ALK>
/ ontrialbegin = [values.selectstimulus = list.category1.nextvalue]
/ ontrialbegin = [values.targetcategory = 1; values.targetformat = "alk"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_A]

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

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (back, forward)
/ iscorrectresponse = [(values.expcondition == 1 && trial.ALK.response == "forward") ||
                                (values.expcondition == 2 && trial.ALK.response == "forward")]

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

/ ontrialend = [values.joystick_y = joystick.y]
/ ontrialend = [values.joystick_change = abs(values.joystick_y)]
/ ontrialend = [values.trialcode = "ALK"]
/ ontrialend = [values.RT = trial.ALK.latency]
/ ontrialend = [values.correct = trial.ALK.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]
/ ontrialend = [if (trial.ALK.response == "forward") values.initialresponse = "PUSH"
                        else values.initialresponse = "PULL"]

/ branch = [if (trial.ALK.response == "forward") trial.decrease else trial.increase]
/recorddata = false
</trial>


<trial NTR>
/ ontrialbegin = [values.selectstimulus = list.category2.nextvalue]
/ ontrialbegin = [values.targetcategory = 1; values.targetformat = "ntr"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_B]

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

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (back, forward)
/ iscorrectresponse = [(values.expcondition == 1 && trial.NTR.response == "back") ||
                                (values.expcondition == 2 && trial.NTR.response == "back")]

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

/ ontrialend = [values.joystick_y = joystick.y]
/ ontrialend = [values.joystick_change = abs(values.joystick_y)]
/ ontrialend = [values.trialcode = "NTR"]
/ ontrialend = [values.RT = trial.NTR.latency]
/ ontrialend = [values.correct = trial.NTR.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]
/ ontrialend = [if (trial.NTR.response == "forward") values.initialresponse = "PUSH"
                        else values.initialresponse = "PULL"]

/branch = [if (trial.NTR.response == "forward") 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
joystick is fully extended
**********************************************************************
<trial decrease>
/ ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px]

/ stimulusframes = [1 = eraser, targetstimulus]
/validresponse = (change)
/ monkeyresponse = ("back", "forward")

/ontrialend = [values.joystick_change = abs(values.joystick_y - joystick.y)]

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

/branch = [if (joystick.y <= -1000)
                {values.joystick_y = joystick.y; values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.enddecrease}]
/branch = [if (joystick.y <= values.joystick_y)
                {values.joystick_y = joystick.y; trial.decrease}]
/branch = [if (joystick.y > values.joystick_y)
                {values.joystick_y = joystick.y; values.changedirection += 1; trial.increase}]
/ recorddata = false
</trial>


<trial increase>
/ ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height + values.joystick_change/1000 * expressions.maxheightchange_px]
/ stimulusframes = [1 = targetstimulus]
/validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ontrialend = [values.joystick_change = abs(values.joystick_y - joystick.y)]

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

/branch = [if (joystick.y >= 1000)
                {values.joystick_y = joystick.y; values.endtime = script.elapsedtime; values.finalresponse = "PULL"; trial.endincrease}]
/branch = [if (joystick.y >= values.joystick_y)
                {values.joystick_y = joystick.y; trial.increase}]
/branch = [if (joystick.y < values.joystick_y)
                {values.joystick_y = joystick.y; 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.joystick_change/1000 * expressions.maxheightchange_px]
/stimulusframes = [1 = targetstimulus]
/timeout = 0
/branch = [trial.joystickrest]
/recorddata = false
</trial>

<trial enddecrease>
/ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px]
/stimulusframes = [1 = eraser, targetstimulus]
/timeout = 0
/branch = [trial.joystickrest]
/recorddata = false
</trial>

**********************************************************************
Helper Trials:
*trial.joystickrest: tracks that joystick was moved back into the rest position
*trial. InterTrialInterval : sets a predetermined InterTrialInterval
(and stores all relevant data in the data file to have one complete dataline for each trial)
**********************************************************************
<trial joystickrest>
/isvalidresponse = [trial.joystickrest.response =="change"]
/branch = [if (joystick.y == 0 && joystick.x == 0) trial.InterTrialInterval else trial.joystickrest]
/recorddata = false
/ monkeyresponse = ("change")
</trial>

<trial InterTrialInterval>
/ontrialbegin = [values.completeRT= values.endtime - values.starttime]
/ stimulusframes = [1 = eraser]
/ timeout = values.intertrialinterval
/ recorddata = true
/ontrialbegin = [values.completeRTminusRT = values.completeRT - values.RT]
</trial>
**************************************************************************************************************
**************************************************************************************************************
AAT EXPERIMENTAL BLOCKS
**************************************************************************************************************
**************************************************************************************************************
Note: if you adjust values.totaltrialcount, you need to adjust the number of trials called by block.AAT

<block AAT>
/ onblockbegin = [values.index = 0]
/ trials = [1 = instructions; 2-151 = AAT_start]
</block>



Note: trial.AAT_start uses a pregenerated trialsequence, if the order of the trial
can be random use the following code:

block AAT>
/ trials = [1 = instructions; 2-81 = noreplace(AAT_1, AAT_2, AAT_3, AAT_4, AAT_5, AAT_6, AAT_7, AAT_8)]
</block>


**************************************************************************************************************
**************************************************************************************************************
EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************
NOTE:
format/direction counterbalanced by group number

<expt >
/ onexptbegin = [values.expcondition = 1]
/ onexptbegin = [values.startheight_A = values.Startheight_ratioA*values.Maxheight_px]
/ onexptbegin = [values.startheight_B = values.Startheight_ratioB* values.Maxheight_px]
/ blocks = [1 = SequenceGenerator; 2 = practice_AAT; 3 = AAT]
/ postinstructions = (End)
/ onexptend = [values.completed = 1]
</expt>



**************************************************************************************************************
                    END OF FILE
**************************************************************************************************************

**** Anpassen Sequenz
**** exp condition: alc ranziehen 1; neutral 2

Please don't paste entire scripts into a post. Instead attach the script by clicking +Insert -> Add File.

In addition, if -- like here -- a script requires external files, provide those as well. Put everything in a ZIP archive and attach that. Further, if -- like here -- things like "some items are sampled more often than they should be" are involved, provide a data file that actually shows the issue. Thank you
By poleraze - 2/13/2020

sorry i can only upload it on googledrive.

AAT
By Dave - 2/13/2020

poleraze - 2/13/2020
sorry i can only upload it on googledrive.

AAT

That's fine.

Do you see the problem?


By poleraze - 2/13/2020

.....are you serious?
Sorry to bother you
Thank you very much.
By Dave - 2/13/2020

poleraze - 2/13/2020
.....are you serious?
Sorry to bother you
Thank you very much.

Yes, there's a single duplicate. The image called "HighPoly_0020_HP_43.png" is entered twice -- once as item #8, and another time as item #22. Thus, you'll see that image a total of 6 times, as you can confirm by looking at the data file you included. It's the only item that ostensibly is shown more often than it should be, although it actually isn't. Item #8 is shown 3 times as it should be, and item #22 is shown 3 times as it should be -- they just happen to be the same image.
By Ali_Cp - 2/15/2020

Hi
Visual Search Task (Threatening Stimuli) - English
Not working in any version of software and Web player!!!
Test don't show any of cue and pictures for visual search!!
By Dave - 2/17/2020

Ali_Cp - 2/16/2020
Hi
Visual Search Task (Threatening Stimuli) - English
Not working in any version of software and Web player!!!
Test don't show any of cue and pictures for visual search!!

As detailed in the manual ( https://www.millisecond.com/download/library/v6/visualsearch/threat/visualsearch.manual ), the stimuli in the demo are placeholders.





The idea is that you plug in stimuli of your own choosing if you are going to use the task for research.
By Ali_Cp - 2/24/2020

Dave - 2/17/2020
Ali_Cp - 2/16/2020
Hi
Visual Search Task (Threatening Stimuli) - English
Not working in any version of software and Web player!!!
Test don't show any of cue and pictures for visual search!!

As detailed in the manual ( https://www.millisecond.com/download/library/v6/visualsearch/threat/visualsearch.manual ), the stimuli in the demo are placeholders.





The idea is that you plug in stimuli of your own choosing if you are going to use the task for research.

Thanks.
By Pearson Sanchez - 2/12/2021

poleraze - 2/13/2020
okey, so thats the other code. sorry for the long post but i thought its better when you see the whole thing.
its my first time using inquisit sorry.
**************************************************************************************************************
**************************************************************************************************************
                                            APPROACH-AVOIDANCE TASK (AAT)
**************************************************************************************************************
**************************************************************************************************************
                                                        SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software LLC
Date: 08-17-2012

last updated: 09-04-2014 by K. Borchert for Millisecond Software

Copyright © 09-04-2014 Millisecond Software
**************************************************************************************************************
**************************************************************************************************************
SCRIPT DESCRIPTION/BACKGROUND INFO
**************************************************************************************************************
**************************************************************************************************************
<include>
/ file = "aat_sequencegenerator.iqx"
</include>




*******************************************************************************************************************
*******************************************************************************************************************
    EDITABLE CODE: The code in this section can be easily altered (look for additional instructions were indicated)
*******************************************************************************************************************
*******************************************************************************************************************

***************************************************************************************
*********************************************
Editable Values
*********************************************
***************************************************************************************

<values>
/Startheight_ratioA = 0.5
/Startheight_ratioB = 0.5
/MinHeight_ratioA = 0.05
/MinHeight_ratioB = 0.05
/intertrialinterval = 300

</values>
    
***************************************************************************************
*********************************************
Editable Stimuli
*********************************************
***************************************************************************************
***************************************************************************************
item 1-25 are non-alc stimuli
item 25-50 are alc stimuli
**************************************************************************************

<item targets>

/1 = "HighPoly_0000_HP_64.png"
/2 = "HighPoly_0001_HP_63.png"
/3 = "HighPoly_0002_HP_62.png"
/4 = "HighPoly_0004_HP_59.png"
/5 = "HighPoly_0005_HP_58.png"
/6 = "HighPoly_0010_HP_53.png"
/7 = "HighPoly_0064_HP_01.png"
/8 = "HighPoly_0020_HP_43.png"
/9 = "HighPoly_0015_HP_48.png"
/10 = "HighPoly_0065_HP_01.png"
/11 = "HighPoly_0028_HP_35.png"
/12 = "HighPoly_0016_HP_47.png"
/13 = "HighPoly_0034_HP_29.png"
/14 = "HighPoly_0035_HP_28.png"
/15 = "HighPoly_0038_HP_25.png"
/16 = "HighPoly_0042_HP_21.png"
/17 = "HighPoly_0050_HP_13.png"
/18 = "HighPoly_0019_HP_44.png"
/19 = "HighPoly_0045_HP_18.png"
/20 = "HighPoly_0051_HP_12.png"
/21 = "HighPoly_0054_HP_09.png"
/22 = "HighPoly_0020_HP_43.png"
/23 = "HighPoly_0057_HP_06.png"
/24 = "HighPoly_0061_HP_02.png"
/25 = "HighPoly_0063_HP_01.png"

/26 = "HighPoly_0003_HP_60.png"
/27 = "HighPoly_0006_HP_57.png"
/28 = "HighPoly_0009_HP_54.png"
/29 = "HighPoly_0043_HP_20.png"
/30 = "HighPoly_0013_HP_50.png"
/31 = "HighPoly_0014_HP_49.png"
/32 = "HighPoly_0022_HP_41.png"
/33 = "HighPoly_0023_HP_40.png"
/34 = "HighPoly_0024_HP_39.png"
/35 = "HighPoly_0025_HP_38.png"
/36 = "HighPoly_0026_HP_37.png"
/37 = "HighPoly_0029_HP_34.png"
/38 = "HighPoly_0055_HP_08.png"
/39 = "HighPoly_0031_HP_32.png"
/40 = "HighPoly_0032_HP_31.png"
/41 = "HighPoly_0036_HP_27.png"
/42 = "HighPoly_0037_HP_26.png"
/43 = "HighPoly_0039_HP_24.png"
/44 = "HighPoly_0040_HP_23.png"
/45 = "HighPoly_0041_HP_22.png"
/46 = "HighPoly_0049_HP_14.png"
/47 = "HighPoly_0056_HP_07.png"
/48 = "HighPoly_0059_HP_04.png"
/49 = "HighPoly_0060_HP_03.png"
/50 = "HighPoly_0047_HP_16.png"

</item>



<item practicestimuli>
/1 = "Beer_Probe.png"
/2 = "Water_Probe.png"
</item>
***************************************************************************************
*********************************************
Editable Instructions
*********************************************
***************************************************************************************

<instruct >
/ windowsize = (80%, 60%)
/ fontstyle = ("Book Antique", 2.50%, false, false, false, false, 5, 0)
</instruct>

<item instructions>
/ 1 = "In the following task, you will be presented alcoholic or non-alcoholic images.
~n~nYour task is to:
~n* PULL the joystick towards you if you see a non-alcoholic image
* PUSH the joystick away from you if you see an alcoholic image
~nWhen you PUSH, the image will shrink.
When you PULL, the image will enlarge.
~nYou need to PUSH/PULL until the joystick is FULLY extended in that direction
(aka cannot go any further).
Afterwards you need to bring the joystick back into the rest position
and a new image will be presented.
~n~nMove the joystick to the left to start practice."
/ 2 = "This is practice.
~nYou will be you will be presented alcoholic or non-alcoholic images.
~n* PULL the joystick towards you if you see a non-alcoholic image
* PUSH the joystick away from you if you see an alcoholic image
~nRemember to PULL/PUSH until the joystick is fully extended and then
bring it back into the rest position to start the next trial.
~n~n~nBe as fast and accurate as you possibly can.
~n~nMove the joystick to the left to start the practice trials."
/ 3 = "This is the real task.
~nYou will be you will be presented alcoholic or non-alcoholic images.
~nJust like you did during practice,
~n* PULL the joystick towards you if you see a non-alcoholic image
* PUSH the joystick away from you if you see an alcoholic image
~n~nBe as fast and accurate as you possibly can. There will be 150 images total.
~nMove the joystick to the left to start."
</item>

<page End>
Thats the end of the task. Thank you for your participation.
</page>
***************************************************************************************
*********************************************
Editable Lists
*********************************************
***************************************************************************************
AAT lists contain the indices of the target stimuli for each category

********************************
category1 = alc
category2 = non-alc
********************************

<list category1>
/ items=(26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50)
/ replace = false
</list>

<list category2>
/ items=(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
/ replace = false
</list>


*******************************************************************************************************************
*******************************************************************************************************************
    DATA: this section contains data file information
*******************************************************************************************************************
*******************************************************************************************************************

*****************
raw data
*****************
date, time, subject:            date and time script was run with the current subjectnumber
/expcondition:                    used for counterbalancing experimental conditions
                                    1: push for landscape, pull for portrait
                                    2: pull for landscape, push for portrait

blockcode, blocknum:            the name and number of the current block
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data)
/stimulus:                        the presented stimulus
/targetcategory:                the targetcategory of the targetstimulus, 1 - 4
/targetformat :                    the targetformat of the targetstimulus (l = landscape; p = portrait)
/initialresponse:                stores the original response to the stimulus
/correct:                        stores the correctness of the initial response
/finalresponse:                    stores the final response (at time joystick is fully extended)
/changedirection:                stores whether and how often participant changed direction during zooming (0 = no change)
/RT:                            stores the latency of the initial response (in ms)
/completeRT:                    stores how long it takes until the joystick is fully extended in whatever direction (in ms)

<data >
/file = "AAT_raw.iqdat"
/ separatefiles = true
/ columns = [date, time, subject, group, values.expcondition, blockcode, blocknum, values.trialcode, trialnum, values.stimulus,
            values.targetcategory,values.targetformat,
            values.initialresponse, values.correct, values.finalresponse, values.changedirection,
            values.RT, values.completeRT, values.completeRTminusRT]
</data>


*****************
summary data
*****************
script.elapsedtime:                            time it took to run script (in ms)
completed:                                    0 = script was not completed; 1 = script was completed (all conditions run)

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 joystick is fully extended)

/sequence:     the experimental sequence generated for the participant


<summarydata >
/file = "ATT_summary.iqdat"
/columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, values.completed, values.expcondition,
expressions.aat_diffscore_cat1, expressions.AAT_Median_NTR, expressions.AAT_Median_ALK]
</summarydata>

*******************************************************************************************************************
*******************************************************************************************************************
                            REMAINING CODE: Customize after careful consideration only
*******************************************************************************************************************
*******************************************************************************************************************


**************************************************************************************************************
**************************************************************************************************************
DEFAULT SCREEN SETTING
**************************************************************************************************************
**************************************************************************************************************
requires Inquisit 4.0.4.0

<defaults >
/canvasaspectratio = (4,3)
/minimumversion = "4.0.4.0"
/ inputdevice = joystick
/joystickthreshold = 30
</defaults>

**************************************************************************************************************
**************************************************************************************************************
VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************


             AAT code:
/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_px:                                maximum height for pictures (display.canvasheight) in pixels
/joystick_y:                                helper variable to track the y-position of the joystick                            
/completeRT:                                stores how long it takes until the joystick is fully extended
/changedirection:                            stores whether and how often participant changed direction during zooming
                                            (0 = no change)
/joystickchange:                            stores the absolute change in joystick 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 joystick is fully extended)
completed:                                    0 = script was not completed; 1 = script was completed (all conditions run)


<values >
/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
/repeat = 0
/selectpracticepicture = 0
/starttime = 0
/endtime = 0
/expcondition = 0
/format1 = 0
/format2 = 0
/startheight_A = 0
/startheight_B = 0
/Maxheight_px = display.canvasheight
/joystick_y = 0
/completeRT = 0
/changedirection = 0
/joystick_change = 0
/trialcode = 0
/RT = 0
/correct = 0
/stimulus = 0
/initialresponse = ""
/finalresponse = ""
/completed = 0
/completeRTminusRT = 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 joystick is fully extended)

/maxheightchange_px: max pixel height change of picture

noch offen:
<expressions >
/ AAT_Diffscore_Cat1 = if (values.expcondition == 1) trial.ALK.medianlatency - trial.NTR.medianlatency else
                                    trial.ALK.medianlatency - trial.NTR.medianlatency
/ AAT_Median_NTR = trial.NTR.medianlatency
/ AAT_Median_ALK = trial.ALK.medianlatency
/maxheightchange_px = if (values.targetformat == "alk") {(values.Startheight_ratioA - values.MinHeight_ratioA) * values.Maxheight_px} else
                                        {(values.Startheight_ratioB - values.MinHeight_ratioB) * values.Maxheight_px}
</expressions>

**************************************************************************************************************
**************************************************************************************************************
INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************
<text instruction>
/items = instructions
/select = sequence
/position = (50%, 50%)
/ fontstyle = ("Book Antique", 3%, false, false, false, false, 5, 0)
/txcolor = black
/resetinterval = 3
/size = (80%, 80%)
</text>

<trial instructions>
/stimulusframes = [1 = instruction]
/validresponse = ("left")
/recorddata = false
/branch = [trial.instruct_joystickrest]
</trial>

Note: trial.instruct_joystickrest & trial.instruct_pause make sure that Joystick is brought back into
rest position
<trial instruct_joystickrest>
/validresponse = (change)
/branch = [if (monkey.monkeymode == 1) trial.instruct_pause]
/branch = [if (joystick.y == 0 && joystick.x == 0) trial.Instruct_Pause else trial.instruct_joystickrest]
/recorddata = false
</trial>

<trial Instruct_Pause>
/ stimulusframes = [1 = eraser]
/ timeout = 0
/ recorddata = false
</trial>


**************************************************************************************************************
**************************************************************************************************************
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>

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

*************************
Practice Stimuli
*************************
<text error>
/ items = ("X")
/ position = (50%, 50%)
/ fontstyle = ("Book Antique", 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.practicetrial_A displays the stimulus of format A (here: landscape) by setting
values.selectpracticepicture = 1
*if a forward movement (=push) is detected -> decrease picture
*if a back movement (=pull) is detected -> increase picture
<trial practicetrial_ALK>
/ontrialbegin = [values.targetformat = "alk"]
/ 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=""; values.completertminusrt = 0]

/ stimulusframes = [1 = practicetarget]
/ validresponse = (back, forward)
/ iscorrectresponse = [(values.expcondition == 1 && trial.practicetrial_ALK.response == "forward") ||
                        (values.expcondition == 2 && trial.practicetrial_ALK.response == "back")]
/ errormessage = true(error,0)

/ ontrialend = [values.joystick_y = joystick.y]
/ ontrialend = [values.joystick_change = abs(values.joystick_y)]
/ontrialend = [values.trialcode = "practicetrial_ALK"]
/ontrialend = [values.RT = trial.practicetrial_ALK.latency]
/ontrialend = [values.correct = trial.practicetrial_ALK.correct]
/ontrialend = [values.stimulus = picture.practicetarget.currentitem]
/ontrialend = [if (trial.practicetrial_ALK.response == "forward") values.initialresponse = "PUSH"
                        else values.initialresponse = "PULL"]

/ branch = [if (trial.practicetrial_ALK.response == "forward") trial.practicedecrease else trial.practiceincrease]
/ recorddata = false
</trial>

NOTE:
trial.practicetrial_B displays the stimulus of format B (here: portrait) by setting
values.selectpracticepicture = 2
*if a forward movement (=push) is detected -> decrease picture
*if a back movement (=pull) is detected -> increase picture

<trial practicetrial_NTR>
/ontrialbegin = [values.targetformat = "ntr"]
/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=""; values.completertminusrt = 0]

/ stimulusframes = [1 = practicetarget]
/ validresponse = (back, forward)
/ iscorrectresponse = [(values.expcondition == 1 && trial.practicetrial_NTR.response == "back") ||
                        (values.expcondition == 2 && trial.practicetrial_NTR.response == "forward")]
/ errormessage = true(error,0)

/ontrialend = [values.joystick_y = joystick.y]
/ontrialend = [values.joystick_change = abs(values.joystick_y)]
/ontrialend = [values.trialcode = "practicetrial_NTR"]
/ontrialend = [values.RT = trial.practicetrial_NTR.latency]
/ontrialend = [values.correct = trial.practicetrial_NTR.correct]
/ontrialend = [values.stimulus = picture.practicetarget.currentitem]
/ontrialend = [if (trial.practicetrial_NTR.response == "forward") values.initialresponse = "PUSH"
                        else values.initialresponse = "PULL"]

/ branch = [if (trial.practicetrial_NTR.response == "forward") trial.practicedecrease else trial.practiceincrease]
/recorddata = false
</trial>

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

/ iscorrectresponse = [(values.expcondition == 1 && trial.practicetrial_B.response == "back") ||
                        (values.expcondition == 2 && trial.practicetrial_B.response == "forward")]

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

/ ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px]
/ stimulusframes = [1 = eraser, practicetarget]
/validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ontrialend = [values.joystick_change = abs(values.joystick_y - joystick.y)]

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


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

/branch = [if (joystick.y <= -1000)
                {values.joystick_y = joystick.y; values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.enddecrease_practice}]
/branch = [if (joystick.y <= values.joystick_y)
                {values.joystick_y = joystick.y; trial.practicedecrease}]
/branch = [if (joystick.y > values.joystick_y)
                {values.joystick_y = joystick.y; values.changedirection += 1; trial.practiceincrease}]

/ recorddata = false
</trial>

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

/ ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px]
/ stimulusframes = [1 = practicetarget]
/validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ontrialend = [values.joystick_change = abs(values.joystick_y - joystick.y)]

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

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

/branch = [if (joystick.y >= 1000)
                {values.joystick_y = joystick.y; values.endtime = script.elapsedtime; values.finalresponse = "PULL"; trial.endincrease_practice}]
/branch = [if (joystick.y >= values.joystick_y)
                {values.joystick_y = joystick.y; trial.practiceincrease}]
/branch = [if (joystick.y < values.joystick_y)
                {values.joystick_y = joystick.y; 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.joystick_change/1000 * expressions.maxheightchange_px]
/stimulusframes = [1 = practicetarget]
/timeout = 0
/branch = [trial.joystickrest]
/recorddata = false
</trial>

<trial enddecrease_practice>
/ontrialbegin = [picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px]
/stimulusframes = [1 = eraser, practicetarget]
/timeout = 0
/branch = [trial.joystickrest]
/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>
/ trials = [1-2 = instructions; 3-12 = noreplace(practicetrial_ALK, practicetrial_NTR)]
</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:


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.ALK]
/ branch = [if (values.nextstimulus == 2) trial.NTR]
/ recorddata = false
</trial>


**********************************************************************
trials that select targetstimuli via list.categoryX
and take in initial response
**********************************************************************
<trial ALK>
/ ontrialbegin = [values.selectstimulus = list.category1.nextvalue]
/ ontrialbegin = [values.targetcategory = 1; values.targetformat = "alk"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_A]

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

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (back, forward)
/ iscorrectresponse = [(values.expcondition == 1 && trial.ALK.response == "forward") ||
                                (values.expcondition == 2 && trial.ALK.response == "forward")]

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

/ ontrialend = [values.joystick_y = joystick.y]
/ ontrialend = [values.joystick_change = abs(values.joystick_y)]
/ ontrialend = [values.trialcode = "ALK"]
/ ontrialend = [values.RT = trial.ALK.latency]
/ ontrialend = [values.correct = trial.ALK.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]
/ ontrialend = [if (trial.ALK.response == "forward") values.initialresponse = "PUSH"
                        else values.initialresponse = "PULL"]

/ branch = [if (trial.ALK.response == "forward") trial.decrease else trial.increase]
/recorddata = false
</trial>


<trial NTR>
/ ontrialbegin = [values.selectstimulus = list.category2.nextvalue]
/ ontrialbegin = [values.targetcategory = 1; values.targetformat = "ntr"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_B]

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

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (back, forward)
/ iscorrectresponse = [(values.expcondition == 1 && trial.NTR.response == "back") ||
                                (values.expcondition == 2 && trial.NTR.response == "back")]

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

/ ontrialend = [values.joystick_y = joystick.y]
/ ontrialend = [values.joystick_change = abs(values.joystick_y)]
/ ontrialend = [values.trialcode = "NTR"]
/ ontrialend = [values.RT = trial.NTR.latency]
/ ontrialend = [values.correct = trial.NTR.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]
/ ontrialend = [if (trial.NTR.response == "forward") values.initialresponse = "PUSH"
                        else values.initialresponse = "PULL"]

/branch = [if (trial.NTR.response == "forward") 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
joystick is fully extended
**********************************************************************
<trial decrease>
/ ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px]

/ stimulusframes = [1 = eraser, targetstimulus]
/validresponse = (change)
/ monkeyresponse = ("back", "forward")

/ontrialend = [values.joystick_change = abs(values.joystick_y - joystick.y)]

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

/branch = [if (joystick.y <= -1000)
                {values.joystick_y = joystick.y; values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.enddecrease}]
/branch = [if (joystick.y <= values.joystick_y)
                {values.joystick_y = joystick.y; trial.decrease}]
/branch = [if (joystick.y > values.joystick_y)
                {values.joystick_y = joystick.y; values.changedirection += 1; trial.increase}]
/ recorddata = false
</trial>


<trial increase>
/ ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height + values.joystick_change/1000 * expressions.maxheightchange_px]
/ stimulusframes = [1 = targetstimulus]
/validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ontrialend = [values.joystick_change = abs(values.joystick_y - joystick.y)]

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

/branch = [if (joystick.y >= 1000)
                {values.joystick_y = joystick.y; values.endtime = script.elapsedtime; values.finalresponse = "PULL"; trial.endincrease}]
/branch = [if (joystick.y >= values.joystick_y)
                {values.joystick_y = joystick.y; trial.increase}]
/branch = [if (joystick.y < values.joystick_y)
                {values.joystick_y = joystick.y; 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.joystick_change/1000 * expressions.maxheightchange_px]
/stimulusframes = [1 = targetstimulus]
/timeout = 0
/branch = [trial.joystickrest]
/recorddata = false
</trial>

<trial enddecrease>
/ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px]
/stimulusframes = [1 = eraser, targetstimulus]
/timeout = 0
/branch = [trial.joystickrest]
/recorddata = false
</trial>

**********************************************************************
Helper Trials:
*trial.joystickrest: tracks that joystick was moved back into the rest position
*trial. InterTrialInterval : sets a predetermined InterTrialInterval
(and stores all relevant data in the data file to have one complete dataline for each trial)
**********************************************************************
<trial joystickrest>
/isvalidresponse = [trial.joystickrest.response =="change"]
/branch = [if (joystick.y == 0 && joystick.x == 0) trial.InterTrialInterval else trial.joystickrest]
/recorddata = false
/ monkeyresponse = ("change")
</trial>

<trial InterTrialInterval>
/ontrialbegin = [values.completeRT= values.endtime - values.starttime]
/ stimulusframes = [1 = eraser]
/ timeout = values.intertrialinterval
/ recorddata = true
/ontrialbegin = [values.completeRTminusRT = values.completeRT - values.RT]
</trial>
**************************************************************************************************************
**************************************************************************************************************
AAT EXPERIMENTAL BLOCKS
**************************************************************************************************************
**************************************************************************************************************
Note: if you adjust values.totaltrialcount, you need to adjust the number of trials called by block.AAT

<block AAT>
/ onblockbegin = [values.index = 0]
/ trials = [1 = instructions; 2-151 = AAT_start]
</block>



Note: trial.AAT_start uses a pregenerated trialsequence, if the order of the trial
can be random use the following code:

block AAT>
/ trials = [1 = instructions; 2-81 = noreplace(AAT_1, AAT_2, AAT_3, AAT_4, AAT_5, AAT_6, AAT_7, AAT_8)]
</block>


**************************************************************************************************************
**************************************************************************************************************
EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************
NOTE:
format/direction counterbalanced by group number

<expt >
/ onexptbegin = [values.expcondition = 1]
/ onexptbegin = [values.startheight_A = values.Startheight_ratioA*values.Maxheight_px]
/ onexptbegin = [values.startheight_B = values.Startheight_ratioB* values.Maxheight_px]
/ blocks = [1 = SequenceGenerator; 2 = practice_AAT; 3 = AAT]
/ postinstructions = (End)
/ onexptend = [values.completed = 1]
</expt>



**************************************************************************************************************
                    END OF FILE
**************************************************************************************************************

**** Anpassen Sequenz
**** exp condition: alc ranziehen 1; neutral 2

Thank you for such a valuable information. I was looking for a long time detailed explanation. Really appreciate your reply!