BIOSEMİ ACTIVE2 MID TASK TRIGGER PROBLEM


Author
Message
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 106K
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
> It sends trigger from serial port but it does not send while the code is running.

I have no idea what this is supposed to mean. It sends trigger from serial port when?

I also hve no idea what you want me to do with that old code. I asked you to test the code in my previous response and report back. Have you done that? With what result?

What I mean is that when I send a trigger via tools -> serial port-send byte in the script you sent, I can see the trigger on the actiview screen. However, when I say run test, it does not send the triggers it is supposed to send as written in the script. So I tried your script.

The serial port monitor has nothing to do with any particular script. It's just there to test sending and receiving via any servial interface availale on the system in general. What script, if any, you have open at that time does not matter.

I don't know why the script doesn't work on your system when you run it. It works fine on mine, under both Inquisit 6 and 7.

In any case, for whatever reason thiings seem to work for you in Inquisit 4, so for the time being I suggest you use that version.

thank you very much for everything, for spending your time and effort,
yes everything seems fine in inquisit 4 but i can't even close the task from the task manager while the task is ongoing, i think the program closing code is missing. i tried quit, abort codes, i couldn't. actually that was the reason i wrote it for inquisit 6, if we can solve the problem in 4 there will be no problem
thanks in advance for the answer :)

Under Inquisit 4, as under 6 and 7, CTRL+Q is the shortcut to terminate the currently running script, and CTRL+B is the shortcut to terminate the currently running block.

You can specify a custom /quitcommand in <defaults> in addition, such as

/ quitcommand = (Ctrl+Alt+'X')

Thank you so much for your support  :) It must have been quite the challenge for you to deal with someone as inexperienced as me:)))

Not at all. And it's a weird issue, through no fault of your own. It's baffling to me why the triggers don't work on your system under version 6 and 7, but do under version 4. Whereas on my test systems, they work under version 4, 6, and 7. I am unfortunately out of ideas what combination of factors causes this strange result on your setup, and am even more baffled that e.g. the oddball task's triggers do work under at least Inquisit 6. It's just... very strange
cansu
cansu
Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)
Group: Forum Members
Posts: 38, Visits: 136
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
> It sends trigger from serial port but it does not send while the code is running.

I have no idea what this is supposed to mean. It sends trigger from serial port when?

I also hve no idea what you want me to do with that old code. I asked you to test the code in my previous response and report back. Have you done that? With what result?

What I mean is that when I send a trigger via tools -> serial port-send byte in the script you sent, I can see the trigger on the actiview screen. However, when I say run test, it does not send the triggers it is supposed to send as written in the script. So I tried your script.

The serial port monitor has nothing to do with any particular script. It's just there to test sending and receiving via any servial interface availale on the system in general. What script, if any, you have open at that time does not matter.

I don't know why the script doesn't work on your system when you run it. It works fine on mine, under both Inquisit 6 and 7.

In any case, for whatever reason thiings seem to work for you in Inquisit 4, so for the time being I suggest you use that version.

thank you very much for everything, for spending your time and effort,
yes everything seems fine in inquisit 4 but i can't even close the task from the task manager while the task is ongoing, i think the program closing code is missing. i tried quit, abort codes, i couldn't. actually that was the reason i wrote it for inquisit 6, if we can solve the problem in 4 there will be no problem
thanks in advance for the answer :)

Under Inquisit 4, as under 6 and 7, CTRL+Q is the shortcut to terminate the currently running script, and CTRL+B is the shortcut to terminate the currently running block.

You can specify a custom /quitcommand in <defaults> in addition, such as

/ quitcommand = (Ctrl+Alt+'X')

Thank you so much for your support  :) It must have been quite the challenge for you to deal with someone as inexperienced as me:)))

Not at all. And it's a weird issue, through no fault of your own. It's baffling to me why the triggers don't work on your system under version 6 and 7, but do under version 4. Whereas on my test systems, they work under version 4, 6, and 7. I am unfortunately out of ideas what combination of factors causes this strange result on your setup, and am even more baffled that e.g. the oddball task's triggers do work under at least Inquisit 6. It's just... very strange
Hello again,
The script running on Inquisit 4 sends triggers to the biosemi active device, but there is a new problem.
The trigger that comes after the nonincentive and incentive cue is not one, but two.
If I need to explain in more detail, when the incentive cue appears on the screen, a trigger like '1' appears in the eeg record, but immediately after it comes '1' again. Then the targer trigger comes as '7', and immediately after that the feedback trigger comes as '15'.

In other words, I can see it in the eeg record in the order of 1-1-7-15.

I should only take a single '1' trigger so that it does not get mixed up in the analysis.

Similarly, the nonincentive cue trigger comes as '3' in a row.

It is like '3-3-7-15'.
What should happen is that a single nonincentive cue trigger comes in the form of '3-7-15'.

This usually comes in pairs, but sometimes it comes in single and I cannot understand why.
What could be the solution to this?
I'm leaving my script that works in Inquisit 4 below. I'd be happy if you could help me.

here is the 2 working scripts that give same error.

FİRST
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 20
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
/ branch = [
    if (values.incentive_condition == 1) {
        trial.nonincentive;
    };
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

**************************************************************************************************************
                                                End of File
**************************************************************************************************************
SECOND 
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 40
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false

]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

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


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 106K
cansu - 2/25/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
> It sends trigger from serial port but it does not send while the code is running.

I have no idea what this is supposed to mean. It sends trigger from serial port when?

I also hve no idea what you want me to do with that old code. I asked you to test the code in my previous response and report back. Have you done that? With what result?

What I mean is that when I send a trigger via tools -> serial port-send byte in the script you sent, I can see the trigger on the actiview screen. However, when I say run test, it does not send the triggers it is supposed to send as written in the script. So I tried your script.

The serial port monitor has nothing to do with any particular script. It's just there to test sending and receiving via any servial interface availale on the system in general. What script, if any, you have open at that time does not matter.

I don't know why the script doesn't work on your system when you run it. It works fine on mine, under both Inquisit 6 and 7.

In any case, for whatever reason thiings seem to work for you in Inquisit 4, so for the time being I suggest you use that version.

thank you very much for everything, for spending your time and effort,
yes everything seems fine in inquisit 4 but i can't even close the task from the task manager while the task is ongoing, i think the program closing code is missing. i tried quit, abort codes, i couldn't. actually that was the reason i wrote it for inquisit 6, if we can solve the problem in 4 there will be no problem
thanks in advance for the answer :)

Under Inquisit 4, as under 6 and 7, CTRL+Q is the shortcut to terminate the currently running script, and CTRL+B is the shortcut to terminate the currently running block.

You can specify a custom /quitcommand in <defaults> in addition, such as

/ quitcommand = (Ctrl+Alt+'X')

Thank you so much for your support  :) It must have been quite the challenge for you to deal with someone as inexperienced as me:)))

Not at all. And it's a weird issue, through no fault of your own. It's baffling to me why the triggers don't work on your system under version 6 and 7, but do under version 4. Whereas on my test systems, they work under version 4, 6, and 7. I am unfortunately out of ideas what combination of factors causes this strange result on your setup, and am even more baffled that e.g. the oddball task's triggers do work under at least Inquisit 6. It's just... very strange
Hello again,
The script running on Inquisit 4 sends triggers to the biosemi active device, but there is a new problem.
The trigger that comes after the nonincentive and incentive cue is not one, but two.
If I need to explain in more detail, when the incentive cue appears on the screen, a trigger like '1' appears in the eeg record, but immediately after it comes '1' again. Then the targer trigger comes as '7', and immediately after that the feedback trigger comes as '15'.

In other words, I can see it in the eeg record in the order of 1-1-7-15.

I should only take a single '1' trigger so that it does not get mixed up in the analysis.

Similarly, the nonincentive cue trigger comes as '3' in a row.

It is like '3-3-7-15'.
What should happen is that a single nonincentive cue trigger comes in the form of '3-7-15'.

This usually comes in pairs, but sometimes it comes in single and I cannot understand why.
What could be the solution to this?
I'm leaving my script that works in Inquisit 4 below. I'd be happy if you could help me.

here is the 2 working scripts that give same error.

FİRST
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 20
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
/ branch = [
    if (values.incentive_condition == 1) {
        trial.nonincentive;
    };
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

**************************************************************************************************************
                                                End of File
**************************************************************************************************************
SECOND 
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 40
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false

]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

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


You're sedning the incentivecue and nonincentive cue triggers twice, at different times.

<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 1;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration); // second time
  trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total] // first time
...
</trial>

...

<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 2;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration); // second time
  trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total] // first time
...
</trial>

Get rid of the 2nd instance you insert /ontrialbegin.
cansu
cansu
Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)
Group: Forum Members
Posts: 38, Visits: 136
Dave - 2/25/2025
cansu - 2/25/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
> It sends trigger from serial port but it does not send while the code is running.

I have no idea what this is supposed to mean. It sends trigger from serial port when?

I also hve no idea what you want me to do with that old code. I asked you to test the code in my previous response and report back. Have you done that? With what result?

What I mean is that when I send a trigger via tools -> serial port-send byte in the script you sent, I can see the trigger on the actiview screen. However, when I say run test, it does not send the triggers it is supposed to send as written in the script. So I tried your script.

The serial port monitor has nothing to do with any particular script. It's just there to test sending and receiving via any servial interface availale on the system in general. What script, if any, you have open at that time does not matter.

I don't know why the script doesn't work on your system when you run it. It works fine on mine, under both Inquisit 6 and 7.

In any case, for whatever reason thiings seem to work for you in Inquisit 4, so for the time being I suggest you use that version.

thank you very much for everything, for spending your time and effort,
yes everything seems fine in inquisit 4 but i can't even close the task from the task manager while the task is ongoing, i think the program closing code is missing. i tried quit, abort codes, i couldn't. actually that was the reason i wrote it for inquisit 6, if we can solve the problem in 4 there will be no problem
thanks in advance for the answer :)

Under Inquisit 4, as under 6 and 7, CTRL+Q is the shortcut to terminate the currently running script, and CTRL+B is the shortcut to terminate the currently running block.

You can specify a custom /quitcommand in <defaults> in addition, such as

/ quitcommand = (Ctrl+Alt+'X')

Thank you so much for your support  :) It must have been quite the challenge for you to deal with someone as inexperienced as me:)))

Not at all. And it's a weird issue, through no fault of your own. It's baffling to me why the triggers don't work on your system under version 6 and 7, but do under version 4. Whereas on my test systems, they work under version 4, 6, and 7. I am unfortunately out of ideas what combination of factors causes this strange result on your setup, and am even more baffled that e.g. the oddball task's triggers do work under at least Inquisit 6. It's just... very strange
Hello again,
The script running on Inquisit 4 sends triggers to the biosemi active device, but there is a new problem.
The trigger that comes after the nonincentive and incentive cue is not one, but two.
If I need to explain in more detail, when the incentive cue appears on the screen, a trigger like '1' appears in the eeg record, but immediately after it comes '1' again. Then the targer trigger comes as '7', and immediately after that the feedback trigger comes as '15'.

In other words, I can see it in the eeg record in the order of 1-1-7-15.

I should only take a single '1' trigger so that it does not get mixed up in the analysis.

Similarly, the nonincentive cue trigger comes as '3' in a row.

It is like '3-3-7-15'.
What should happen is that a single nonincentive cue trigger comes in the form of '3-7-15'.

This usually comes in pairs, but sometimes it comes in single and I cannot understand why.
What could be the solution to this?
I'm leaving my script that works in Inquisit 4 below. I'd be happy if you could help me.

here is the 2 working scripts that give same error.

FİRST
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 20
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
/ branch = [
    if (values.incentive_condition == 1) {
        trial.nonincentive;
    };
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

**************************************************************************************************************
                                                End of File
**************************************************************************************************************
SECOND 
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 40
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false

]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

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


You're sedning the incentivecue and nonincentive cue triggers twice, at different times.

<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 1;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration); // second time
  trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total] // first time
...
</trial>

...

<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 2;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration); // second time
  trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total] // first time
...
</trial>

Get rid of the 2nd instance you insert /ontrialbegin.

I have done it,it works with one trigger.
Thank you so much for your support and time :)
cansu
cansu
Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)
Group: Forum Members
Posts: 38, Visits: 136
cansu - 3/10/2025
cansu - 2/27/2025
Dave - 2/25/2025
cansu - 2/25/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
> It sends trigger from serial port but it does not send while the code is running.

I have no idea what this is supposed to mean. It sends trigger from serial port when?

I also hve no idea what you want me to do with that old code. I asked you to test the code in my previous response and report back. Have you done that? With what result?

What I mean is that when I send a trigger via tools -> serial port-send byte in the script you sent, I can see the trigger on the actiview screen. However, when I say run test, it does not send the triggers it is supposed to send as written in the script. So I tried your script.

The serial port monitor has nothing to do with any particular script. It's just there to test sending and receiving via any servial interface availale on the system in general. What script, if any, you have open at that time does not matter.

I don't know why the script doesn't work on your system when you run it. It works fine on mine, under both Inquisit 6 and 7.

In any case, for whatever reason thiings seem to work for you in Inquisit 4, so for the time being I suggest you use that version.

thank you very much for everything, for spending your time and effort,
yes everything seems fine in inquisit 4 but i can't even close the task from the task manager while the task is ongoing, i think the program closing code is missing. i tried quit, abort codes, i couldn't. actually that was the reason i wrote it for inquisit 6, if we can solve the problem in 4 there will be no problem
thanks in advance for the answer :)

Under Inquisit 4, as under 6 and 7, CTRL+Q is the shortcut to terminate the currently running script, and CTRL+B is the shortcut to terminate the currently running block.

You can specify a custom /quitcommand in <defaults> in addition, such as

/ quitcommand = (Ctrl+Alt+'X')

Thank you so much for your support  :) It must have been quite the challenge for you to deal with someone as inexperienced as me:)))

Not at all. And it's a weird issue, through no fault of your own. It's baffling to me why the triggers don't work on your system under version 6 and 7, but do under version 4. Whereas on my test systems, they work under version 4, 6, and 7. I am unfortunately out of ideas what combination of factors causes this strange result on your setup, and am even more baffled that e.g. the oddball task's triggers do work under at least Inquisit 6. It's just... very strange
Hello again,
The script running on Inquisit 4 sends triggers to the biosemi active device, but there is a new problem.
The trigger that comes after the nonincentive and incentive cue is not one, but two.
If I need to explain in more detail, when the incentive cue appears on the screen, a trigger like '1' appears in the eeg record, but immediately after it comes '1' again. Then the targer trigger comes as '7', and immediately after that the feedback trigger comes as '15'.

In other words, I can see it in the eeg record in the order of 1-1-7-15.

I should only take a single '1' trigger so that it does not get mixed up in the analysis.

Similarly, the nonincentive cue trigger comes as '3' in a row.

It is like '3-3-7-15'.
What should happen is that a single nonincentive cue trigger comes in the form of '3-7-15'.

This usually comes in pairs, but sometimes it comes in single and I cannot understand why.
What could be the solution to this?
I'm leaving my script that works in Inquisit 4 below. I'd be happy if you could help me.

here is the 2 working scripts that give same error.

FİRST
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 20
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
/ branch = [
    if (values.incentive_condition == 1) {
        trial.nonincentive;
    };
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

**************************************************************************************************************
                                                End of File
**************************************************************************************************************
SECOND 
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 40
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false

]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

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


You're sedning the incentivecue and nonincentive cue triggers twice, at different times.

<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 1;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration); // second time
  trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total] // first time
...
</trial>

...

<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 2;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration); // second time
  trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total] // first time
...
</trial>

Get rid of the 2nd instance you insert /ontrialbegin.

I have done it,it works with one trigger.
Thank you so much for your support and time :)



Hello again:)
I see that in the MID task, it gives 1 trigger for incentive cues and 3 triggers for nonincentive cues. What should I change in the script to make it give different triggers for reward and loss cues?
I couldn't see that in the script, it gives 1 for reward cues, 7 for target, 15 for feedback.
How can I do this by separating the reward and punishment for incentive cues, for example, 1 for reward cues, 3 for nonincentive, 2 for loss, 3 for nonincentive?
thanks for your help !
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 106K
cansu - 3/10/2025
cansu - 3/10/2025
cansu - 2/27/2025
Dave - 2/25/2025
cansu - 2/25/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
> It sends trigger from serial port but it does not send while the code is running.

I have no idea what this is supposed to mean. It sends trigger from serial port when?

I also hve no idea what you want me to do with that old code. I asked you to test the code in my previous response and report back. Have you done that? With what result?

What I mean is that when I send a trigger via tools -> serial port-send byte in the script you sent, I can see the trigger on the actiview screen. However, when I say run test, it does not send the triggers it is supposed to send as written in the script. So I tried your script.

The serial port monitor has nothing to do with any particular script. It's just there to test sending and receiving via any servial interface availale on the system in general. What script, if any, you have open at that time does not matter.

I don't know why the script doesn't work on your system when you run it. It works fine on mine, under both Inquisit 6 and 7.

In any case, for whatever reason thiings seem to work for you in Inquisit 4, so for the time being I suggest you use that version.

thank you very much for everything, for spending your time and effort,
yes everything seems fine in inquisit 4 but i can't even close the task from the task manager while the task is ongoing, i think the program closing code is missing. i tried quit, abort codes, i couldn't. actually that was the reason i wrote it for inquisit 6, if we can solve the problem in 4 there will be no problem
thanks in advance for the answer :)

Under Inquisit 4, as under 6 and 7, CTRL+Q is the shortcut to terminate the currently running script, and CTRL+B is the shortcut to terminate the currently running block.

You can specify a custom /quitcommand in <defaults> in addition, such as

/ quitcommand = (Ctrl+Alt+'X')

Thank you so much for your support  :) It must have been quite the challenge for you to deal with someone as inexperienced as me:)))

Not at all. And it's a weird issue, through no fault of your own. It's baffling to me why the triggers don't work on your system under version 6 and 7, but do under version 4. Whereas on my test systems, they work under version 4, 6, and 7. I am unfortunately out of ideas what combination of factors causes this strange result on your setup, and am even more baffled that e.g. the oddball task's triggers do work under at least Inquisit 6. It's just... very strange
Hello again,
The script running on Inquisit 4 sends triggers to the biosemi active device, but there is a new problem.
The trigger that comes after the nonincentive and incentive cue is not one, but two.
If I need to explain in more detail, when the incentive cue appears on the screen, a trigger like '1' appears in the eeg record, but immediately after it comes '1' again. Then the targer trigger comes as '7', and immediately after that the feedback trigger comes as '15'.

In other words, I can see it in the eeg record in the order of 1-1-7-15.

I should only take a single '1' trigger so that it does not get mixed up in the analysis.

Similarly, the nonincentive cue trigger comes as '3' in a row.

It is like '3-3-7-15'.
What should happen is that a single nonincentive cue trigger comes in the form of '3-7-15'.

This usually comes in pairs, but sometimes it comes in single and I cannot understand why.
What could be the solution to this?
I'm leaving my script that works in Inquisit 4 below. I'd be happy if you could help me.

here is the 2 working scripts that give same error.

FİRST
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 20
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
/ branch = [
    if (values.incentive_condition == 1) {
        trial.nonincentive;
    };
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

**************************************************************************************************************
                                                End of File
**************************************************************************************************************
SECOND 
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 40
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false

]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

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


You're sedning the incentivecue and nonincentive cue triggers twice, at different times.

<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 1;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration); // second time
  trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total] // first time
...
</trial>

...

<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 2;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration); // second time
  trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total] // first time
...
</trial>

Get rid of the 2nd instance you insert /ontrialbegin.

I have done it,it works with one trigger.
Thank you so much for your support and time :)



Hello again:)
I see that in the MID task, it gives 1 trigger for incentive cues and 3 triggers for nonincentive cues. What should I change in the script to make it give different triggers for reward and loss cues?
I couldn't see that in the script, it gives 1 for reward cues, 7 for target, 15 for feedback.
How can I do this by separating the reward and punishment for incentive cues, for example, 1 for reward cues, 3 for nonincentive, 2 for loss, 3 for nonincentive?
thanks for your help !

I have no idea what you mean.
cansu
cansu
Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)
Group: Forum Members
Posts: 38, Visits: 136
Dave - 3/10/2025
cansu - 3/10/2025
cansu - 3/10/2025
cansu - 2/27/2025
Dave - 2/25/2025
cansu - 2/25/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
> It sends trigger from serial port but it does not send while the code is running.

I have no idea what this is supposed to mean. It sends trigger from serial port when?

I also hve no idea what you want me to do with that old code. I asked you to test the code in my previous response and report back. Have you done that? With what result?

What I mean is that when I send a trigger via tools -> serial port-send byte in the script you sent, I can see the trigger on the actiview screen. However, when I say run test, it does not send the triggers it is supposed to send as written in the script. So I tried your script.

The serial port monitor has nothing to do with any particular script. It's just there to test sending and receiving via any servial interface availale on the system in general. What script, if any, you have open at that time does not matter.

I don't know why the script doesn't work on your system when you run it. It works fine on mine, under both Inquisit 6 and 7.

In any case, for whatever reason thiings seem to work for you in Inquisit 4, so for the time being I suggest you use that version.

thank you very much for everything, for spending your time and effort,
yes everything seems fine in inquisit 4 but i can't even close the task from the task manager while the task is ongoing, i think the program closing code is missing. i tried quit, abort codes, i couldn't. actually that was the reason i wrote it for inquisit 6, if we can solve the problem in 4 there will be no problem
thanks in advance for the answer :)

Under Inquisit 4, as under 6 and 7, CTRL+Q is the shortcut to terminate the currently running script, and CTRL+B is the shortcut to terminate the currently running block.

You can specify a custom /quitcommand in <defaults> in addition, such as

/ quitcommand = (Ctrl+Alt+'X')

Thank you so much for your support  :) It must have been quite the challenge for you to deal with someone as inexperienced as me:)))

Not at all. And it's a weird issue, through no fault of your own. It's baffling to me why the triggers don't work on your system under version 6 and 7, but do under version 4. Whereas on my test systems, they work under version 4, 6, and 7. I am unfortunately out of ideas what combination of factors causes this strange result on your setup, and am even more baffled that e.g. the oddball task's triggers do work under at least Inquisit 6. It's just... very strange
Hello again,
The script running on Inquisit 4 sends triggers to the biosemi active device, but there is a new problem.
The trigger that comes after the nonincentive and incentive cue is not one, but two.
If I need to explain in more detail, when the incentive cue appears on the screen, a trigger like '1' appears in the eeg record, but immediately after it comes '1' again. Then the targer trigger comes as '7', and immediately after that the feedback trigger comes as '15'.

In other words, I can see it in the eeg record in the order of 1-1-7-15.

I should only take a single '1' trigger so that it does not get mixed up in the analysis.

Similarly, the nonincentive cue trigger comes as '3' in a row.

It is like '3-3-7-15'.
What should happen is that a single nonincentive cue trigger comes in the form of '3-7-15'.

This usually comes in pairs, but sometimes it comes in single and I cannot understand why.
What could be the solution to this?
I'm leaving my script that works in Inquisit 4 below. I'd be happy if you could help me.

here is the 2 working scripts that give same error.

FİRST
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 20
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
/ branch = [
    if (values.incentive_condition == 1) {
        trial.nonincentive;
    };
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

**************************************************************************************************************
                                                End of File
**************************************************************************************************************
SECOND 
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 40
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false

]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

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


You're sedning the incentivecue and nonincentive cue triggers twice, at different times.

<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 1;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration); // second time
  trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total] // first time
...
</trial>

...

<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 2;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration); // second time
  trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total] // first time
...
</trial>

Get rid of the 2nd instance you insert /ontrialbegin.

I have done it,it works with one trigger.
Thank you so much for your support and time :)



Hello again:)
I see that in the MID task, it gives 1 trigger for incentive cues and 3 triggers for nonincentive cues. What should I change in the script to make it give different triggers for reward and loss cues?
I couldn't see that in the script, it gives 1 for reward cues, 7 for target, 15 for feedback.
How can I do this by separating the reward and punishment for incentive cues, for example, 1 for reward cues, 3 for nonincentive, 2 for loss, 3 for nonincentive?
thanks for your help !

I have no idea what you mean.

Let me explain.
Task consists of 3 blocks.
There are no reward and punishment feedbacks in the 1st block.
In the 2nd block, patients receive the feedback that they won when they press the target for the required time after the incentive cue. A nonincentive cue also comes in the same block. They do not earn money when they press the target for the required time after that.
In other words, there are two different cues in the 2nd block: nonincentive cue and incentive cue.
When the incentive cue comes out, a trigger of 1 is sent to the eeg device.
When the nonincentive cue comes out, a trigger of 3 is sent to the eeg device.
In the 3rd block, there are loss and neutral trials.
Similarly, when the target is pressed when the incentive cue comes out, they avoid losing money.
When the incentive cue (loss cue) comes, a trigger of 1 comes to the eeg device again.
When the nonincentive cue comes, a trigger of 3 comes to the eeg device.

What I mean is,
In block 2, the cue that codes the reward sends a trigger of '1'.
In block 3, the cue that codes the loss also sends a trigger of '1'.

If a different trigger for the loss in block 3, for example '2', would be used, this would prevent confusion during the analysis phase.

I could not see the part in the script that makes these triggers come as '1', '3'.
Where is the script section regarding how it sends the trigger to the EEG device?
Thanks.
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 106K
cansu - 3/11/2025
Dave - 3/10/2025
cansu - 3/10/2025
cansu - 3/10/2025
cansu - 2/27/2025
Dave - 2/25/2025
cansu - 2/25/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
> It sends trigger from serial port but it does not send while the code is running.

I have no idea what this is supposed to mean. It sends trigger from serial port when?

I also hve no idea what you want me to do with that old code. I asked you to test the code in my previous response and report back. Have you done that? With what result?

What I mean is that when I send a trigger via tools -> serial port-send byte in the script you sent, I can see the trigger on the actiview screen. However, when I say run test, it does not send the triggers it is supposed to send as written in the script. So I tried your script.

The serial port monitor has nothing to do with any particular script. It's just there to test sending and receiving via any servial interface availale on the system in general. What script, if any, you have open at that time does not matter.

I don't know why the script doesn't work on your system when you run it. It works fine on mine, under both Inquisit 6 and 7.

In any case, for whatever reason thiings seem to work for you in Inquisit 4, so for the time being I suggest you use that version.

thank you very much for everything, for spending your time and effort,
yes everything seems fine in inquisit 4 but i can't even close the task from the task manager while the task is ongoing, i think the program closing code is missing. i tried quit, abort codes, i couldn't. actually that was the reason i wrote it for inquisit 6, if we can solve the problem in 4 there will be no problem
thanks in advance for the answer :)

Under Inquisit 4, as under 6 and 7, CTRL+Q is the shortcut to terminate the currently running script, and CTRL+B is the shortcut to terminate the currently running block.

You can specify a custom /quitcommand in <defaults> in addition, such as

/ quitcommand = (Ctrl+Alt+'X')

Thank you so much for your support  :) It must have been quite the challenge for you to deal with someone as inexperienced as me:)))

Not at all. And it's a weird issue, through no fault of your own. It's baffling to me why the triggers don't work on your system under version 6 and 7, but do under version 4. Whereas on my test systems, they work under version 4, 6, and 7. I am unfortunately out of ideas what combination of factors causes this strange result on your setup, and am even more baffled that e.g. the oddball task's triggers do work under at least Inquisit 6. It's just... very strange
Hello again,
The script running on Inquisit 4 sends triggers to the biosemi active device, but there is a new problem.
The trigger that comes after the nonincentive and incentive cue is not one, but two.
If I need to explain in more detail, when the incentive cue appears on the screen, a trigger like '1' appears in the eeg record, but immediately after it comes '1' again. Then the targer trigger comes as '7', and immediately after that the feedback trigger comes as '15'.

In other words, I can see it in the eeg record in the order of 1-1-7-15.

I should only take a single '1' trigger so that it does not get mixed up in the analysis.

Similarly, the nonincentive cue trigger comes as '3' in a row.

It is like '3-3-7-15'.
What should happen is that a single nonincentive cue trigger comes in the form of '3-7-15'.

This usually comes in pairs, but sometimes it comes in single and I cannot understand why.
What could be the solution to this?
I'm leaving my script that works in Inquisit 4 below. I'd be happy if you could help me.

here is the 2 working scripts that give same error.

FİRST
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 20
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
/ branch = [
    if (values.incentive_condition == 1) {
        trial.nonincentive;
    };
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

**************************************************************************************************************
                                                End of File
**************************************************************************************************************
SECOND 
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 40
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false

]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

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


You're sedning the incentivecue and nonincentive cue triggers twice, at different times.

<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 1;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration); // second time
  trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total] // first time
...
</trial>

...

<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 2;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration); // second time
  trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total] // first time
...
</trial>

Get rid of the 2nd instance you insert /ontrialbegin.

I have done it,it works with one trigger.
Thank you so much for your support and time :)



Hello again:)
I see that in the MID task, it gives 1 trigger for incentive cues and 3 triggers for nonincentive cues. What should I change in the script to make it give different triggers for reward and loss cues?
I couldn't see that in the script, it gives 1 for reward cues, 7 for target, 15 for feedback.
How can I do this by separating the reward and punishment for incentive cues, for example, 1 for reward cues, 3 for nonincentive, 2 for loss, 3 for nonincentive?
thanks for your help !

I have no idea what you mean.

Let me explain.
Task consists of 3 blocks.
There are no reward and punishment feedbacks in the 1st block.
In the 2nd block, patients receive the feedback that they won when they press the target for the required time after the incentive cue. A nonincentive cue also comes in the same block. They do not earn money when they press the target for the required time after that.
In other words, there are two different cues in the 2nd block: nonincentive cue and incentive cue.
When the incentive cue comes out, a trigger of 1 is sent to the eeg device.
When the nonincentive cue comes out, a trigger of 3 is sent to the eeg device.
In the 3rd block, there are loss and neutral trials.
Similarly, when the target is pressed when the incentive cue comes out, they avoid losing money.
When the incentive cue (loss cue) comes, a trigger of 1 comes to the eeg device again.
When the nonincentive cue comes, a trigger of 3 comes to the eeg device.

What I mean is,
In block 2, the cue that codes the reward sends a trigger of '1'.
In block 3, the cue that codes the loss also sends a trigger of '1'.

If a different trigger for the loss in block 3, for example '2', would be used, this would prevent confusion during the analysis phase.

I could not see the part in the script that makes these triggers come as '1', '3'.
Where is the script section regarding how it sends the trigger to the EEG device?
Thanks.

The condition (control vs reward vs punishment) is reflected in values.exp_condition (0, 1, 2).

You can use conditional logic /ontrialbegin to insert different port stimuli into the given trial via insertstimulustime(), depending on the condition you're in.
cansu
cansu
Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)Associate Member (89 reputation)
Group: Forum Members
Posts: 38, Visits: 136
Dave - 3/11/2025
cansu - 3/11/2025
Dave - 3/10/2025
cansu - 3/10/2025
cansu - 3/10/2025
cansu - 2/27/2025
Dave - 2/25/2025
cansu - 2/25/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
> It sends trigger from serial port but it does not send while the code is running.

I have no idea what this is supposed to mean. It sends trigger from serial port when?

I also hve no idea what you want me to do with that old code. I asked you to test the code in my previous response and report back. Have you done that? With what result?

What I mean is that when I send a trigger via tools -> serial port-send byte in the script you sent, I can see the trigger on the actiview screen. However, when I say run test, it does not send the triggers it is supposed to send as written in the script. So I tried your script.

The serial port monitor has nothing to do with any particular script. It's just there to test sending and receiving via any servial interface availale on the system in general. What script, if any, you have open at that time does not matter.

I don't know why the script doesn't work on your system when you run it. It works fine on mine, under both Inquisit 6 and 7.

In any case, for whatever reason thiings seem to work for you in Inquisit 4, so for the time being I suggest you use that version.

thank you very much for everything, for spending your time and effort,
yes everything seems fine in inquisit 4 but i can't even close the task from the task manager while the task is ongoing, i think the program closing code is missing. i tried quit, abort codes, i couldn't. actually that was the reason i wrote it for inquisit 6, if we can solve the problem in 4 there will be no problem
thanks in advance for the answer :)

Under Inquisit 4, as under 6 and 7, CTRL+Q is the shortcut to terminate the currently running script, and CTRL+B is the shortcut to terminate the currently running block.

You can specify a custom /quitcommand in <defaults> in addition, such as

/ quitcommand = (Ctrl+Alt+'X')

Thank you so much for your support  :) It must have been quite the challenge for you to deal with someone as inexperienced as me:)))

Not at all. And it's a weird issue, through no fault of your own. It's baffling to me why the triggers don't work on your system under version 6 and 7, but do under version 4. Whereas on my test systems, they work under version 4, 6, and 7. I am unfortunately out of ideas what combination of factors causes this strange result on your setup, and am even more baffled that e.g. the oddball task's triggers do work under at least Inquisit 6. It's just... very strange
Hello again,
The script running on Inquisit 4 sends triggers to the biosemi active device, but there is a new problem.
The trigger that comes after the nonincentive and incentive cue is not one, but two.
If I need to explain in more detail, when the incentive cue appears on the screen, a trigger like '1' appears in the eeg record, but immediately after it comes '1' again. Then the targer trigger comes as '7', and immediately after that the feedback trigger comes as '15'.

In other words, I can see it in the eeg record in the order of 1-1-7-15.

I should only take a single '1' trigger so that it does not get mixed up in the analysis.

Similarly, the nonincentive cue trigger comes as '3' in a row.

It is like '3-3-7-15'.
What should happen is that a single nonincentive cue trigger comes in the form of '3-7-15'.

This usually comes in pairs, but sometimes it comes in single and I cannot understand why.
What could be the solution to this?
I'm leaving my script that works in Inquisit 4 below. I'd be happy if you could help me.

here is the 2 working scripts that give same error.

FİRST
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 20
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
/ branch = [
    if (values.incentive_condition == 1) {
        trial.nonincentive;
    };
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

**************************************************************************************************************
                                                End of File
**************************************************************************************************************
SECOND 
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 40
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false

]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

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


You're sedning the incentivecue and nonincentive cue triggers twice, at different times.

<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 1;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration); // second time
  trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total] // first time
...
</trial>

...

<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 2;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration); // second time
  trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total] // first time
...
</trial>

Get rid of the 2nd instance you insert /ontrialbegin.

I have done it,it works with one trigger.
Thank you so much for your support and time :)



Hello again:)
I see that in the MID task, it gives 1 trigger for incentive cues and 3 triggers for nonincentive cues. What should I change in the script to make it give different triggers for reward and loss cues?
I couldn't see that in the script, it gives 1 for reward cues, 7 for target, 15 for feedback.
How can I do this by separating the reward and punishment for incentive cues, for example, 1 for reward cues, 3 for nonincentive, 2 for loss, 3 for nonincentive?
thanks for your help !

I have no idea what you mean.

Let me explain.
Task consists of 3 blocks.
There are no reward and punishment feedbacks in the 1st block.
In the 2nd block, patients receive the feedback that they won when they press the target for the required time after the incentive cue. A nonincentive cue also comes in the same block. They do not earn money when they press the target for the required time after that.
In other words, there are two different cues in the 2nd block: nonincentive cue and incentive cue.
When the incentive cue comes out, a trigger of 1 is sent to the eeg device.
When the nonincentive cue comes out, a trigger of 3 is sent to the eeg device.
In the 3rd block, there are loss and neutral trials.
Similarly, when the target is pressed when the incentive cue comes out, they avoid losing money.
When the incentive cue (loss cue) comes, a trigger of 1 comes to the eeg device again.
When the nonincentive cue comes, a trigger of 3 comes to the eeg device.

What I mean is,
In block 2, the cue that codes the reward sends a trigger of '1'.
In block 3, the cue that codes the loss also sends a trigger of '1'.

If a different trigger for the loss in block 3, for example '2', would be used, this would prevent confusion during the analysis phase.

I could not see the part in the script that makes these triggers come as '1', '3'.
Where is the script section regarding how it sends the trigger to the EEG device?
Thanks.

The condition (control vs reward vs punishment) is reflected in values.exp_condition (0, 1, 2).

You can use conditional logic /ontrialbegin to insert different port stimuli into the given trial via insertstimulustime(), depending on the condition you're in.

  Thanks for your answer,
In this part of the script , the item reflected by the port of the incentive cue is shown as 00000001, I see it as 1 in the eeg record.
The item reflected by the port of the nonincentive cue is 00000011, but I see it as 3 in the eeg record.In this script, where and how do we send triggers via the port and number the triggers as 1,3 in the eeg record?

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")


For example, the incentive cues coming in the reward block are reflected as '1' in the eeg record via the port.
I want the incentive cues coming in the punishment block to be reflected as 2 in the record.
Is it possible to rewrite the script by doing this?


Here is my total script:

<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (4000ms):
cue (500ms) -> random delay* (2000-2500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 100
/ Punishment_loss = 100
/ punishment_startamount = 4000
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (2000, 2100, 2200, 2300, 2400, 2500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 4000ms
cueduration = 500ms
max. delay = 2500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false

]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

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


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 106K
cansu - 3/12/2025
Dave - 3/11/2025
cansu - 3/11/2025
Dave - 3/10/2025
cansu - 3/10/2025
cansu - 3/10/2025
cansu - 2/27/2025
Dave - 2/25/2025
cansu - 2/25/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
> It sends trigger from serial port but it does not send while the code is running.

I have no idea what this is supposed to mean. It sends trigger from serial port when?

I also hve no idea what you want me to do with that old code. I asked you to test the code in my previous response and report back. Have you done that? With what result?

What I mean is that when I send a trigger via tools -> serial port-send byte in the script you sent, I can see the trigger on the actiview screen. However, when I say run test, it does not send the triggers it is supposed to send as written in the script. So I tried your script.

The serial port monitor has nothing to do with any particular script. It's just there to test sending and receiving via any servial interface availale on the system in general. What script, if any, you have open at that time does not matter.

I don't know why the script doesn't work on your system when you run it. It works fine on mine, under both Inquisit 6 and 7.

In any case, for whatever reason thiings seem to work for you in Inquisit 4, so for the time being I suggest you use that version.

thank you very much for everything, for spending your time and effort,
yes everything seems fine in inquisit 4 but i can't even close the task from the task manager while the task is ongoing, i think the program closing code is missing. i tried quit, abort codes, i couldn't. actually that was the reason i wrote it for inquisit 6, if we can solve the problem in 4 there will be no problem
thanks in advance for the answer :)

Under Inquisit 4, as under 6 and 7, CTRL+Q is the shortcut to terminate the currently running script, and CTRL+B is the shortcut to terminate the currently running block.

You can specify a custom /quitcommand in <defaults> in addition, such as

/ quitcommand = (Ctrl+Alt+'X')

Thank you so much for your support  :) It must have been quite the challenge for you to deal with someone as inexperienced as me:)))

Not at all. And it's a weird issue, through no fault of your own. It's baffling to me why the triggers don't work on your system under version 6 and 7, but do under version 4. Whereas on my test systems, they work under version 4, 6, and 7. I am unfortunately out of ideas what combination of factors causes this strange result on your setup, and am even more baffled that e.g. the oddball task's triggers do work under at least Inquisit 6. It's just... very strange
Hello again,
The script running on Inquisit 4 sends triggers to the biosemi active device, but there is a new problem.
The trigger that comes after the nonincentive and incentive cue is not one, but two.
If I need to explain in more detail, when the incentive cue appears on the screen, a trigger like '1' appears in the eeg record, but immediately after it comes '1' again. Then the targer trigger comes as '7', and immediately after that the feedback trigger comes as '15'.

In other words, I can see it in the eeg record in the order of 1-1-7-15.

I should only take a single '1' trigger so that it does not get mixed up in the analysis.

Similarly, the nonincentive cue trigger comes as '3' in a row.

It is like '3-3-7-15'.
What should happen is that a single nonincentive cue trigger comes in the form of '3-7-15'.

This usually comes in pairs, but sometimes it comes in single and I cannot understand why.
What could be the solution to this?
I'm leaving my script that works in Inquisit 4 below. I'd be happy if you could help me.

here is the 2 working scripts that give same error.

FİRST
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 20
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
/ branch = [
    if (values.incentive_condition == 1) {
        trial.nonincentive;
    };
]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-80 = noreplace(incentive, nonincentive, nonincentive, nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

**************************************************************************************************************
                                                End of File
**************************************************************************************************************
SECOND 
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (6000ms):
cue (500ms) -> random delay* (4000-4500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 1
/ Punishment_loss = 1
/ punishment_startamount = 40
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (4000, 4100, 4200, 4300, 4400, 4500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 6000ms
cueduration = 500ms
max. delay = 4500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);
    trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration);
    trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false

]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

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


You're sedning the incentivecue and nonincentive cue triggers twice, at different times.

<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 1;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration); // second time
  trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total] // first time
...
</trial>

...

<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
  values.incentive_condition = 2;
  values.iti=0;
  values.targetduration = expressions.determineDuration;
  values.delayduration = list.delay.nextvalue;
trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
trial.nonincentive.insertstimulustime(port.nonincentivecueeeg, values.cueduration); // second time
  trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
  trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total] // first time
...
</trial>

Get rid of the 2nd instance you insert /ontrialbegin.

I have done it,it works with one trigger.
Thank you so much for your support and time :)



Hello again:)
I see that in the MID task, it gives 1 trigger for incentive cues and 3 triggers for nonincentive cues. What should I change in the script to make it give different triggers for reward and loss cues?
I couldn't see that in the script, it gives 1 for reward cues, 7 for target, 15 for feedback.
How can I do this by separating the reward and punishment for incentive cues, for example, 1 for reward cues, 3 for nonincentive, 2 for loss, 3 for nonincentive?
thanks for your help !

I have no idea what you mean.

Let me explain.
Task consists of 3 blocks.
There are no reward and punishment feedbacks in the 1st block.
In the 2nd block, patients receive the feedback that they won when they press the target for the required time after the incentive cue. A nonincentive cue also comes in the same block. They do not earn money when they press the target for the required time after that.
In other words, there are two different cues in the 2nd block: nonincentive cue and incentive cue.
When the incentive cue comes out, a trigger of 1 is sent to the eeg device.
When the nonincentive cue comes out, a trigger of 3 is sent to the eeg device.
In the 3rd block, there are loss and neutral trials.
Similarly, when the target is pressed when the incentive cue comes out, they avoid losing money.
When the incentive cue (loss cue) comes, a trigger of 1 comes to the eeg device again.
When the nonincentive cue comes, a trigger of 3 comes to the eeg device.

What I mean is,
In block 2, the cue that codes the reward sends a trigger of '1'.
In block 3, the cue that codes the loss also sends a trigger of '1'.

If a different trigger for the loss in block 3, for example '2', would be used, this would prevent confusion during the analysis phase.

I could not see the part in the script that makes these triggers come as '1', '3'.
Where is the script section regarding how it sends the trigger to the EEG device?
Thanks.

The condition (control vs reward vs punishment) is reflected in values.exp_condition (0, 1, 2).

You can use conditional logic /ontrialbegin to insert different port stimuli into the given trial via insertstimulustime(), depending on the condition you're in.

  Thanks for your answer,
In this part of the script , the item reflected by the port of the incentive cue is shown as 00000001, I see it as 1 in the eeg record.
The item reflected by the port of the nonincentive cue is 00000011, but I see it as 3 in the eeg record.In this script, where and how do we send triggers via the port and number the triggers as 1,3 in the eeg record?

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")


For example, the incentive cues coming in the reward block are reflected as '1' in the eeg record via the port.
I want the incentive cues coming in the punishment block to be reflected as 2 in the record.
Is it possible to rewrite the script by doing this?


Here is my total script:

<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Script Copyright © 02-09-2018 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
This script implements the Monetary Incentive Delay Task as described in:

Knutson, B., Westdorp, A., Kaiser, E., & Hommer, D. (2000). FMRI visualization of brain activity during a monetary
incentive delay task. Neuroimage, 12(1), 20-27


                                             *Task*
Participants are asked to respond to a brief target shape that follows 2 different cues: one an incentive cue (e.g. an orange shape)
and the other a nonincentive cue (e.g. a blue shape).
Responses to nonincentive targets (aka targets following nonincentive cues) never have an impact on money gained
or money lost; nevertheless participants receive verbal feedback whether they were fast enough or not.
Responses to incentive targets have different consequences depending on three different reward conditions: Control vs. Reward vs. Punishment.

In the Reward condition, participants who respond fast enough to a target that follows an incentive cue get a monetary reward (e.g. $1).
If they are not fast enough, no money is won.
In the Punishment condition, participants who respond fast enough to a target that follows an incentive cue do not lose any money (e.g. $1).
If they fail to respond in time, they lose money (e.g. $1).
In the control condition, there is no difference between incentive and nonincentive targets. Participants can neither win any money,
nor can they lose any.


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'MonetaryIncentiveDelayTask_raw*.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
/order:                        'reward->punish' vs. 'punish->reward'
blockcode, blocknum:            the name and number of the current block
/exp_condition:                    0 = control condition; 1 = Reward condition; 2 = Punishment Condition
trialcode, trialnum:             the name and number of the currently recorded trial
                                    (Note: not all trials that are run might record data; by default data is collected unless /recorddata = false is set for a particular trial/block)
/incentive_condition:            1 = incentive; 2 = nonincentive
/delayduration:                    the current delay duration in ms
/targetduration:                the current target duration in ms (also the response window)
stimulusitem:                    the presented stimuli in order of trial presentation (only static elements)
response:                        the participant's response (here: scancode of response button)
correct:                        the correctness of the response (1 = correct; 0 = incorrect)
latency:                         the response latency (in ms)
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition

(2) Summary data file: 'MonetaryIncentiveDelayTask_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
/order:                            'reward->punish' vs. 'punish->reward'
/total_control:                    the total earned in control condition
/total_reward:                    the total earned in reward condition
/total_punishment:                the total earned in punishment condition
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition    
    
EXPERIMENTAL SET-UP

3 conditions: Control vs. Reward vs. Punishment, tested within in a blocked design.
All participants start with the Control condition.
The assignment to Reward -> Punishment vs. Punishment -> Reward is counterbalanced by groupnumber
(odd groupnumbers start with Reward; even groupnumbers start with Punishment)

In each condition:
- 100 trials
    - 20 incentive trials
    - 80 nonincentive trials
    => The order is randomized with the constraint that incentive trials cannot be presented consecutively
- the color for incentive/nonincentive trials is different for each condition

Trial Sequence (4000ms):
cue (500ms) -> random delay* (2000-2500ms)-> target (variable, duration = 60th percentile RT)** -> Feedback (500ms) -> ITI (variable to round trial sequence duration to ~6s)

*Random Delay: is controlled by list.delay under section Editable Lists
**Target Durations: in this script, the targetduration is set to the 60th percentile RT as assessed during baseline ~ 60% correct performance
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)
Note: if the 60th percentile > 500ms the script aborts automatically (500ms is the max. possible target duration given all other default trial durations)

STIMULI
cues/targets: squares (size can be controlled via values.stimsize under section Editable Values)
targets: white in all conditions
Control: incentive cue: red; nonincentive cue: green
Reward: incentive cue: orange; nonincentive cue: blue
Punishment: incentive cue: yellow; nonincentive cue: pink

INSTRUCTIONS
are not original to Knutson et al (2000) - they can be edited under section Editable Instructions

EDITABLE CODE:
check below for (relatively) easily editable values, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The values you can change are:


/responsekey:                the scancode of the response key (default: 57 = Spacebar; check Tools-> keyboard scancode for different options)
/responsekey_label:            the label of the response key (default: Spacebar)
/cueduration:                the duration of the cue in ms (default: 500)
/feedbackduration:            the duration of the feedback in ms (default: 500)
/trialduration:                the duration of a complete trial sequence in ms (default: 6000)
/Reward_win:                the number of points ($) won in the Reward condition (default: 1)
/Punishment_loss:            the number of points ($) lost in the Punishment condition (default: 1)
/punishment_startamount:    the amount of money provided at the beginning of the punishment condition (default: 20)
/reward_startamount:        the amount of money provided at the beginning of the reward condition (default: 0)
/control_startamount:        the amount of money provided at the beginning of the control condition (default: 0)
/stimsize:                    the size of the cues/targets as percentages of canvas height (default: 10%)
/presenttotal:                true = present the "Total earned" throughout Reward and Punishment Blocks.
                            false = does not present the "Total earned" throughout Reward and Punishment Blocks.


Note: the expressions under Editable values can be changed to change the 10 targetdurations.

</usermanual>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE values: change editable values here
**************************************************************************************************************
**************************************************************************************************************

<values>
/ responsekey = 57
/ responsekey_label = "Spacebar"
/ cueduration = 500
/ feedbackduration = 1500
/ trialduration = 7500
/ fixediti = 1500
/ Reward_win = 100
/ Punishment_loss = 100
/ punishment_startamount = 4000
/ reward_startamount = 0
/ control_startamount = 0
/ stimsize = 10%
/ presenttotal = true
</values>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item feedback>
/ 1 = "Harika! KAZANDIN."
/ 2 = "Harika!"
/ 3 = "Çok yavaş. KAZANAMADIN."
/ 4 = "Çok yavaş."
/ 5 = "Harika! KAYBETMEDİN."
/ 6 = "Çok yavaş. KAYBETTİN."
</item>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
<instruct>
/ fontstyle = ("Arial", 5.00%, false, false, false, false, 5, 1)
/ txcolor = (black)
/ windowsize = (100%, 100%)
</instruct>


<page Intro>
^Bu deneyde para kazanmak için, basit bir tepki verme zamanı görevini gerçekleştirmeniz istenecektir.
</page>

<page baseline>
^İlk olarak, temel olan tepki verme görevini çalışalım:
^^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır. Ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAYINIZ. Hazır olduğunuzda başlayabilirsiniz.

</page>

<page testStart>
^Temel görevi çalıştığınıza göre şimdi gelecek denemelerle devam edebilirsiniz.
^^Talimatları dikkatlice okuyun. Şimdiki deneme bir öncekinden biraz farklı olacak.

</page>

<page Control>
^Birazdan gelecek olan denemelerde, BEYAZ bir kare sunulacaktır ve sizden ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, BEYAZ kare sunumu, ya YEŞİL ya da KIRMIZI kare tarafından sinyallenecektir. YEŞİL ya da KIRMIZI kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.


</page>

<page Control2>
^Testin bu aşamasında, performansınıza bağlı olarak ya para kazanacaksınız ya da para kaybedeceksiniz.Bunu da olası performansınız sonucu karşılacağınız durumlar için bir ön çalışma olarak görebilirsiniz.
^^Bilgisayar başarılı olduğunuzda ya da BEYAZ kareye yanıt vermede çok yavaş olduğunuzda sizi bilgilendirecek.
^^^Deneye başlamak için hazır olduğunuzda başlayabilirsiniz.


</page>

<page Reward>
^Birazdan gelecek olan denemelerde, tekrar BEYAZ bir kare sunulacaktır ve sizden yine ekrana beyaz kare geldiğinde mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli.Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya TURUNCU ya da MAVİ kare tarafından sinyallenecektir. TURUNCU ya da MAVİ kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Reward2>
^Testin bu aşamasında, TURUNCU karenin sinyallediği BEYAZ kareye yeterince hızlı yanıt verirseniz <%values.reward_win%> TL KAZANACAKSINIZ, FAREYİ TIKLAMAKTA gecikirseniz de total değeriniz değişmeyecek.
^^MAVİ kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın. Deneye başlamak için devam edin.

</page>

<page RewardEnd>
^Deneyin bu kısmında <%values.total_reward%> TL kazandınız.

</page>


<page Punishment>
^Birazdan gelecek olan denemelerde, BEYAZ kare sunumundan sonra yine mümkün olduğunca hızlı bir şekilde FAREYİ TIKLAMANIZ istenecektir.
^^BEYAZ kare KISA bir süreliğine ekrana geleceğinden mümkün olduğunca hızlı yanıt vermeniz önemli. Ekrandan kaybolduğunda deneme biter.
^^^Size yardımcı olmak adına, bu kez BEYAZ kare sunumu, ya SARI ya da PEMBE kare tarafından sinyallenecektir. SARI ya da PEMBE kare ortadan kaybolduğunda BEYAZ kare kısa bir süreliğine sunulacak ve sizin FAREYİ TIKLAMANIZ gerekecektir.

</page>

<page Punishment2>
^Testin bu aşamasında, <%values.punishment_startamount%> TL ile başlayıp SARI karenin sinyallediği BEYAZ kareye yanıt vermede yavaş kalırsanız <%values.punishment_loss%> TL kaybetmeye başlarsınız , FAREYİ zamanında TIKLARSANIZ total değeriniz değişmeyecek.
^^PEMBE kareden sonra BEYAZ karenin geldiği denemelerde performansınız totali etkilememektedir fakat tepki süreleriniz de değerlendirildiğinden yine de elinizden gelenin en iyisini yapın.
^^^Deneye başlamak için devam edin

</page>

<page PunishmentEnd>
^Deneyin bu kısmında <%values.total_punishment%> TL kazandınız.

</page>


<page End>
^Deneyin sonuna geldiniz.
^^ <%values.total_reward + values.total_punishment%> TL kazandınız.
^^^KATILIMINIZ İÇİN TEŞEKKÜRLER!!!

</page>

This alert appears on screen if the 40th percentile of baseline reaction times falls below 100ms or above 500ms (max. possible duration)
<text alert>
/ items = ("Yanıt verme süreleri sınırların dışındaydı.
Deney sonlandırılacak.")
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txcolor = white
/ erase = false
</text>

****************************************************************************************************
general instruction expressions: adjust the instruction text depending on device used to run script
****************************************************************************************************
<expressions>
/buttoninstruct1 = "FARE"
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

<list delay>
/ items = (2000, 2100, 2200, 2300, 2400, 2500)
/ replace = true
</list>

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


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.0.0 or higher

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "4.0.0.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = black
/ txcolor = (white)
/ screencolor = black
</defaults>

**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

***********************
raw data file
***********************
<data>
/ separatefiles = true
/ columns = [build, computer.platform, date, time, subject, group, values.order, blockcode, blocknum, values.exp_condition, trialcode, trialnum,
values.incentive_condition, values.delayduration, values.targetduration, expressions.baselineRT60,
stimulusitem, response, correct, latency, values.total_control, values.total_reward, values.total_punishment]
</data>

***********************
summary data file
***********************
<summarydata>
/ columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.order, expressions.meanRT_baseline, expressions.SD_baseline, expressions.baselineRT60,
values.total_control, values.total_reward, values.total_punishment,
expressions.propCorrect_IncentiveReward, expressions.propCorrect_NonIncentiveReward,
expressions.propCorrect_IncentivePunishment, expressions.propCorrect_NonIncentivePunishment,
expressions.propCorrect_IncentiveControl, expressions.propCorrect_NonIncentiveControl]
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed; 1 = script was completed (all conditions run)
/order:                    'reward->punish' vs. 'punish->reward'
/exp_condition:            0 = control condition; 1 = Reward condition; 2 = Punishment Condition
/incentive_condition:    1 = incentive; 2 = nonincentive
/delayduration:            the current delay duration in ms
/targetduration:        the current target duration in ms
/total:                    helper variable that stores the total money for the current block
/total_control:            the total earned in control condition
/total_reward:            the total earned in reward condition
/total_punishment:        the total earned in punishment condition
/feedback:                stores the itemnumber of the current feedback stimulus
/iti:                    stores the duration of the current iti duration

<values>
/ completed = 0
/ order = ""
/ exp_condition = 1
/ incentive_condition = 1
/ delayduration = 0
/ targetduration = 0
/ total = 0
/ total_control = 0
/ total_reward = 0
/ total_punishment = 0
/ feedback = 0
/ iti = 0
/countcorrect_IncentiveReward = 0
/count_IncentiveReward = 0
/countcorrect_NonIncentiveReward = 0
/count_NonIncentiveReward = 0
/countcorrect_IncentivePunishment = 0
/count_IncentivePunishment = 0
/countcorrect_NonIncentivePunishment = 0
/count_NonIncentivePunishment = 0
/countcorrect_IncentiveControl = 0
/count_IncentiveControl = 0
/countcorrect_NonIncentiveControl = 0
/count_NonIncentiveControl = 0
</values>
**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

IMPORTANT NOTE: with the default settings of
trialduration = 4000ms
cueduration = 500ms
max. delay = 2500ms
feedback = 500ms

the max. targetduration that is possible is 500ms.
Knutson et al (2000) report to have used targetdurations beween 160ms and 260ms (p.21)-

/meanRT_baseline:        determines the baseline mean reaction time in ms
/SD_baseline:            determines the standard deviation of the baseline reaction times in ms
/baselineRT60:            determines the 60th percentile reaction time (in ms) based on mean and standard deviation: X = z-score(60th percentile)*SD +
                        (60th percentile = 60% of all reaction times lie below it)
/determineDuration:        determines the target Duration for a given trial (rounds baselineRT60 to the nearest digit)
                        
/propCorrect_IncentiveReward:        proportion correct for incentive trials in the reward condition
/propCorrect_NonIncentiveReward:    proportion correct for nonincentive trials in the reward condition
/propCorrect_IncentivePunishment:    proportion correct for incentive trials in the punishment condition
/propCorrect_NonIncentivePunishment:proportion correct for nonincentive trials in the punishment condition
/propCorrect_IncentiveControl:        proportion correct for incentive trials in the control condition
/propCorrect_NonIncentiveControl:    proportion correct for nonincentive trials in the control condition                        
                        
<expressions >
/ meanRT_baseline = trial.baseline.totalmeanlatency
/ SD_baseline = trial.baseline.totalsdlatency
/ baselineRT60 = 0.2533*expressions.SD_baseline + expressions.meanRT_baseline    
/ determineDuration = round(expressions.baselineRT60)
/ propCorrect_IncentiveReward = values.countcorrect_IncentiveReward/values.count_IncentiveReward
/ propCorrect_NonIncentiveReward = values.countcorrect_NonIncentiveReward/values.count_NonIncentiveReward
/ propCorrect_IncentivePunishment = values.countcorrect_IncentivePunishment/values.count_IncentivePunishment
/ propCorrect_NonIncentivePunishment = values.countcorrect_NonIncentivePunishment/values.count_NonIncentivePunishment
/ propCorrect_IncentiveControl = values.countcorrect_IncentiveControl/values.count_IncentiveControl
/ propCorrect_NonIncentiveControl = values.countcorrect_NonIncentiveControl/values.count_NonIncentiveControl
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************



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

<shape incentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port incentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ subport = data
/ items = ("00000011")
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ subport = data
/ items = ("00000000")
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ subport = data
/ items = ("00000111")
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<text total>
/ items = (" Total = <%values.total%> TL ")
/ vjustify = center
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ position = (50%, 90%)
/ txcolor = gray
/ erase = false
</text>
<port totaleeg>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

Note: list.baselineRT fills during runtime with all baseline latencies
<list baselineRT>
</list>

Note: the following lists store the success (1) and failures (0) for each experimental condition, separately for incentive/nonincentive trials
<list successIncentive_Reward>
</list>

<list successNonIncentive_Reward>
</list>

<list successIncentive_Punishment>
</list>

<list successNonIncentive_Punishment>
</list>

<list successIncentive_Control>
</list>

<list successNonIncentive_Control>
</list>

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

Note: trial.baseline presents a simple reaction time task
* after a variable duration (randomly sampled with replacement), the target appears and
participant has to press the responsekey as fast as possible
* latencies are stored in list.baselineRT

<trial baseline>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)

/ ontrialbegin = [
    values.delayduration = list.delay.nextvalue;
    trial.baseline.insertstimulustime(shape.target, values.delayduration);
]
/ beginresponsetime = values.delayduration
/ ontrialend = [
  trial.baseline.resetstimulusframes();
  list.baselineRT.insertitem(trial.baseline.latency, 1);
]
</trial>
<trial baselineAlert>
/ skip = [
    expressions.baselineRT60 < 500
]
/ stimulusframes = [1 = alert]
/ trialduration = 1000
/ ontrialend = [
    script.abort();
]
</trial>

Note:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 1;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
  trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, incentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.incentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_IncentiveControl += 1;
   values.countcorrect_IncentiveControl += trial.incentive.correct;
   list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_IncentiveReward += 1;
   values.countcorrect_IncentiveReward += trial.incentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_IncentivePunishment += 1;
   values.countcorrect_IncentivePunishment += trial.incentive.correct;
   list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Notes:
* trial presents cue (programmed as static stimulus) and target (programmed as dynamic stimulus)
* takes in responses at onset of target
* times out after response OR after (cueduration+delay+targetduration) whichever comes first
* calculates values.iti and calls trial.feedback
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
    values.incentive_condition = 2;
    values.iti=0;
    values.targetduration = expressions.determineDuration;
    values.delayduration = list.delay.nextvalue;
  trial.nonincentive.insertstimulustime(shape.nonincentivecue, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
    trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration);
  trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
  trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));
 
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, nonincentivecueeeg, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
  trial.nonincentive.resetstimulusframes();
  values.iti = values.trialduration - values.cueduration - values.delayduration - trial.nonincentive.latency - values.feedbackduration;
  if (values.exp_condition == 0) {
   values.count_NonIncentiveControl += 1;
   values.countcorrect_NonIncentiveControl += trial.nonincentive.correct;
   list.successNonIncentive_Control.insertitem(trial.nonincentive.correct, 1);
  } else if (values.exp_condition == 1) {
   values.count_NonIncentiveReward += 1;
   values.countcorrect_NonIncentiveReward += trial.nonincentive.correct;
   list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
  } else if (values.exp_condition == 2) {
   values.count_NonIncentivePunishment += 1;
   values.countcorrect_NonIncentivePunishment += trial.nonincentive.correct;
   list.successNonIncentive_Punishment.insertitem(trial.nonincentive.correct, 1);
  } ;
]  
/ branch = [trial.feedback]
</trial>

Note:
trial.feedback presents the appropriate feedback for a predetermined duration
(Note: code that determines the feedback can be found under BLOCKS)
IF the current trial was an incentive trial, trial.feedback calls a nonincentive trial next
to avoid consecutive incentive trials
<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback,feedbackeeg, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false

]
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

Note: runs the baseline trials to assess baseline RT
<block baseline>
/ onblockbegin = [
    values.exp_condition = "baseline";
    values.incentive_condition = 0;
]
/ preinstructions = (baseline)
/ postinstructions = (testStart)
/ trials = [1-10 = baseline; 11 = baselineAlert]

</block>

Note: block.control/reward/punishment run 100 trials: 20 incentive, 80 nonincentive trials.
The order is randomized with the constraint that incentive trials cannot be presented consecutively.
To prevent consecutive incentive trials, each incentive trial is followed by a nonincentive trial (this is programmed on the trial
level via branch commands)
=> 20 incentive trials (followed automatically by 20 nonincentive trials) + 60 nonincentive trials => 80 trials called on the block level.
The blocks differ in the feedback presented and calculations of total points.

<block control>
/ preinstructions = (Control, Control2)
/ onblockbegin = [
    values.exp_condition = 0;
    values.total_control = values.control_startamount;
    values.total = values.total_control;
]
/ onblockbegin = [
    text.total.textcolor = black;
    shape.incentivecue.color = red;
    shape.nonincentivecue.color = green;
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 4
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block reward>
/ preinstructions = (Reward, Reward2)
/ postinstructions = (RewardEnd)
/ onblockbegin = [
    values.exp_condition = 1;
    values.total_reward = values.reward_startamount;
    values.total = values.total_reward
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
        
    shape.incentivecue.color = orange;
    shape.nonincentivecue.color = blue
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct && script.currenttrial != "feedback" ) {
        values.total_reward += values.Reward_win;
        values.feedback = 1;
        values.total = values.total_reward
    };
    if (values.incentive_condition == 1 && trial.incentive.error) {
        values.feedback = 3
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>


<block punishment>
/ preinstructions = (Punishment, Punishment2)
/ postinstructions = (PunishmentEnd)

/ onblockbegin = [
    values.exp_condition = 2;
    values.total_punishment = values.punishment_startamount;
    values.total = values.total_punishment
]
/ onblockbegin = [
    if (values.presenttotal == 1)
        text.total.textcolor = gray
    else
        text.total.textcolor = black;
    shape.incentivecue.color = yellow;
    shape.nonincentivecue.color = pink
]
/ trials = [1-150 = noreplace(incentive, incentive, incentive,incentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive, nonincentive,nonincentive,nonincentive,nonincentive,nonincentive)]
/ ontrialend = [
    if (values.incentive_condition == 1 && trial.incentive.correct) {
        values.feedback = 5
    };
    if (values.incentive_condition == 1 && trial.incentive.error && script.currenttrial != "feedback") {
        values.total_punishment -= values.Punishment_loss;
        values.total = values.total_punishment;
        values.feedback = 6
    };
    if (values.incentive_condition == 2 && trial.nonincentive.correct) {
        values.feedback = 2
    };
    if (values.incentive_condition == 2 && trial.nonincentive.error) {
        values.feedback = 4
    }
]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

Note: order of reward and punishment blocks (after control) counterbalanced by groupnumber
odd groupnumbers -> reward, punishment
even groupnumbers -> punishment, reward

<expt>
/ subjects = (1 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="reward->punish"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = reward;
    4 = punishment;
]
</expt>


<expt>
/ subjects = (2 of 2)
/ groupassignment = groupnumber
/ preinstructions = (Intro)
/ postinstructions = (End)
/ onexptbegin = [values.order="punish->reward"]
/ onexptend = [values.completed = 1]
/ blocks = [
    1 = baseline;
    2 = control;
    3 = punishment;
    4 = reward;
]
</expt>

<monkey>
/ latencydistribution = normal(230,10)
</monkey>

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


> For example, the incentive cues coming in the reward block are reflected as '1' in the eeg record via the port.
> I want the incentive cues coming in the punishment block to be reflected as 2 in the record.
> Is it possible to rewrite the script by doing this?

I already answered that. Define two port elements: one for the reward condition, one for the punishment condition. Have the trial send the applicable one by using conditional logic as I described in my previous response.

<port incentivecueeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>

<port incentivecueeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00000010")
</port>


You've said nothing about the control condition, so I'm leaving that out. Extend the code along the same lines as needed.

trial incentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,incentivecue, 100)
/responsemessage = (rbuttondown,incentivecue, 100)

/ ontrialbegin = [
values.incentive_condition = 1;
values.iti=0;
values.targetduration = expressions.determineDuration;
values.delayduration = list.delay.nextvalue;
    if (values.exp_condition == 1) {
        trial.incentive.insertstimulustime(port.incentivecueeeg_reward, 0);
    } else if (values.exp_condition == 2) {
        trial.incentive.insertstimulustime(port.incentivecueeeg_punishment, 0);
    };
trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration);
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration));

]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = immediate
/ timeout = values.cueduration + values.delayduration + values.targetduration
/ monkeyresponse = (values.responsekey)
/ ontrialend = [
trial.incentive.resetstimulusframes();
values.iti = values.trialduration - values.cueduration - values.delayduration - trial.incentive.latency - values.feedbackduration;
if (values.exp_condition == 0) {
values.count_IncentiveControl += 1;
values.countcorrect_IncentiveControl += trial.incentive.correct;
list.successIncentive_Control.insertitem(trial.incentive.correct, 1);
} else if (values.exp_condition == 1) {
values.count_IncentiveReward += 1;
values.countcorrect_IncentiveReward += trial.incentive.correct;
list.successIncentive_Reward.insertitem(trial.incentive.correct, 1);
} else if (values.exp_condition == 2) {
values.count_IncentivePunishment += 1;
values.countcorrect_IncentivePunishment += trial.incentive.correct;
list.successIncentive_Punishment.insertitem(trial.incentive.correct, 1);
} ;
]
/ branch = [trial.feedback]
</trial>

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search