Millisecond Forums

BIOSEMİ ACTIVE2 MID TASK TRIGGER PROBLEM

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

By cansu - 2/17/2025

Hi, I am having problems sending triggers to biosemi active two system. We changed LPT to COM6. The task is running without error but not sending any trigger. here is a part of my code.


<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>
By cansu - 2/17/2025

cansu - 2/17/2025
Hi, I am having problems sending triggers to biosemi active two system. We changed LPT to COM6. The task is running without error but not sending any trigger. here is a part of my code.


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

We are trying to send triggers by using python now. But ıt seems not to find pyhton file. Can ınquisit use Python script. I checked by python script is sending my trigger correctlly but ınquisit can't find it. 
Here is my code:
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
  script.processRun("python send_trigger.py 3"); // ✅ Sends trigger 3 for non-incentive cue
  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(shape.target, (values.cueduration + values.delayduration));
]
Error:item not found.
By Dave - 2/17/2025

cansu - 2/17/2025
cansu - 2/17/2025
Hi, I am having problems sending triggers to biosemi active two system. We changed LPT to COM6. The task is running without error but not sending any trigger. here is a part of my code.


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

We are trying to send triggers by using python now. But ıt seems not to find pyhton file. Can ınquisit use Python script. I checked by python script is sending my trigger correctlly but ınquisit can't find it. 
Here is my code:
<trial nonincentive>
/inputdevice = mousekey
/validresponse = (lbuttondown, rbuttondown)
/correctresponse = (lbuttondown, rbuttondown)
/responsemessage = (lbuttondown,nonincentivecue, 100)
/responsemessage = (rbuttondown,nonincentivecue, 100)

/ ontrialbegin = [
  script.processRun("python send_trigger.py 3"); // ✅ Sends trigger 3 for non-incentive cue
  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(shape.target, (values.cueduration + values.delayduration));
]
Error:item not found.

No, Inquisit cannot use Python.

For the triggers to be sent, you need to have your <trial> elements display the <port> stimuli at the desired times, just like any other stimulus.
By cansu - 2/17/2025

Thanks for your reply, how can I send triggers to Biosemiactive2 with com6 serial Port?
Can you give an example script for it?
I define com6 but ıt still doesnt send any any trigger to biosemi.
By Dave - 2/17/2025

cansu - 2/17/2025
Thanks for your reply, how can I send triggers to Biosemiactive2 with com6 serial Port? Can you give an example script for it?I define com6 but ıt still doesnt send any any trigger to biosemi.

Again, a <port> element is a stimulus like any other. You need to "display" it at the time you want in a <trial>, just like you display <text> or <picture> stimuli.

Whereas a visual stimulus (<text>, <picture>, etc.) is output on the screen, the <port> stimulus is instead output on the serial interface you specified.

Examples for using port stimuli are in the documentation and example scripts are in the library. Whether you output to a parallel (LPT) or serial (COM) interface, does not make a difference in terms of how you "dispay" port stimuli.

https://www.millisecond.com/support/docs/v6/html/howto/howtosendport.htm
https://www.millisecond.com/download/library/oddball
By cansu - 2/17/2025

Thanks for answering
As you mentioned,I define com6 as Port :

/ port = COM6
/ subport = data
/ items = ("00001111")


But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?
By Dave - 2/18/2025

cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.
By cansu - 2/18/2025

Dave - 2/18/2025
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2
By Dave - 2/18/2025

cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.
By cansu - 2/18/2025

Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?
By Dave - 2/18/2025

cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
By cansu - 2/18/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
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
Thanks Dave,
I am new in coding and I am unfamiliar to Millisecond language,so sorry about taking your time.
Should I delete last two line to revise the script.:

trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);

If it is not,can you share me the final revised version of this script? :(

By 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
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
Thanks Dave,
I am new in coding and I am unfamiliar to Millisecond language,so sorry about taking your time.
Should I delete last two line to revise the script.:

trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);

If it is not,can you share me the final revised version of this script? :(


Try this:

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
/ windowsize = (800px, 600px)
</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
/ items = (1)
/ erase = false
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = com6
/ items = (3)
/ erase = false
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = com6
/ items = (0)
/ erase = false
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = com6
/ items = (7)
/ erase = false
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = com6
/ items = (15)
/ erase = false
</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
/ items = (31)
/ erase = false
</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(port.incentivecueeeg, 0); // raise incentive signal
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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(port.nonincentivecueeeg, 0); // raise nonincentive signal
trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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; 3 = erasereeg]
/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
End of File
**************************************************************************************************************
By cansu - 2/18/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
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
Thanks Dave,
I am new in coding and I am unfamiliar to Millisecond language,so sorry about taking your time.
Should I delete last two line to revise the script.:

trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);

If it is not,can you share me the final revised version of this script? :(


Try this:

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
/ windowsize = (800px, 600px)
</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
/ items = (1)
/ erase = false
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = com6
/ items = (3)
/ erase = false
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = com6
/ items = (0)
/ erase = false
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = com6
/ items = (7)
/ erase = false
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = com6
/ items = (15)
/ erase = false
</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
/ items = (31)
/ erase = false
</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(port.incentivecueeeg, 0); // raise incentive signal
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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(port.nonincentivecueeeg, 0); // raise nonincentive signal
trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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; 3 = erasereeg]
/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



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

It doesnt work,I still can't send trigger to Biosemiactive2. Can it be a port problem? I use usb serial com6 port,not a LPT1 port :(
By 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
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
Thanks Dave,
I am new in coding and I am unfamiliar to Millisecond language,so sorry about taking your time.
Should I delete last two line to revise the script.:

trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);

If it is not,can you share me the final revised version of this script? :(


Try this:

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
/ windowsize = (800px, 600px)
</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
/ items = (1)
/ erase = false
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = com6
/ items = (3)
/ erase = false
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = com6
/ items = (0)
/ erase = false
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = com6
/ items = (7)
/ erase = false
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = com6
/ items = (15)
/ erase = false
</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
/ items = (31)
/ erase = false
</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(port.incentivecueeeg, 0); // raise incentive signal
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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(port.nonincentivecueeeg, 0); // raise nonincentive signal
trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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; 3 = erasereeg]
/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



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

It doesnt work,I still can't send trigger to Biosemiactive2. Can it be a port problem? I use usb serial com6 port,not a LPT1 port :(

It works fine over serial, I've tested it on my system. Different com port number, but that doesn't make a difference. Double-check that you have the correct com port number. What are the settings for the port in the device manager (baud rate, etc.). And, again, because your previous response was unclear, when you send some bytes to your EEG via the serial port monitor, do these register at all?
By cansu - 2/18/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
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
Thanks Dave,
I am new in coding and I am unfamiliar to Millisecond language,so sorry about taking your time.
Should I delete last two line to revise the script.:

trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);

If it is not,can you share me the final revised version of this script? :(


Try this:

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
/ windowsize = (800px, 600px)
</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
/ items = (1)
/ erase = false
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = com6
/ items = (3)
/ erase = false
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = com6
/ items = (0)
/ erase = false
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = com6
/ items = (7)
/ erase = false
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = com6
/ items = (15)
/ erase = false
</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
/ items = (31)
/ erase = false
</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(port.incentivecueeeg, 0); // raise incentive signal
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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(port.nonincentivecueeeg, 0); // raise nonincentive signal
trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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; 3 = erasereeg]
/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



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

It doesnt work,I still can't send trigger to Biosemiactive2. Can it be a port problem? I use usb serial com6 port,not a LPT1 port :(

It works fine over serial, I've tested it on my system. Different com port number, but that doesn't make a difference. Double-check that you have the correct com port number. What are the settings for the port in the device manager (baud rate, etc.). And, again, because your previous response was unclear, when you send some bytes to your EEG via the serial port monitor, do these register at all?

A task written in Python sends a trigger when it runs on the same device. Port definition written in Python:port = serial.Serial("COM6", baudrate=115200)
By 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
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
Thanks Dave,
I am new in coding and I am unfamiliar to Millisecond language,so sorry about taking your time.
Should I delete last two line to revise the script.:

trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);

If it is not,can you share me the final revised version of this script? :(


Try this:

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
/ windowsize = (800px, 600px)
</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
/ items = (1)
/ erase = false
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = com6
/ items = (3)
/ erase = false
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = com6
/ items = (0)
/ erase = false
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = com6
/ items = (7)
/ erase = false
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = com6
/ items = (15)
/ erase = false
</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
/ items = (31)
/ erase = false
</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(port.incentivecueeeg, 0); // raise incentive signal
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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(port.nonincentivecueeeg, 0); // raise nonincentive signal
trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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; 3 = erasereeg]
/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



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

It doesnt work,I still can't send trigger to Biosemiactive2. Can it be a port problem? I use usb serial com6 port,not a LPT1 port :(

It works fine over serial, I've tested it on my system. Different com port number, but that doesn't make a difference. Double-check that you have the correct com port number. What are the settings for the port in the device manager (baud rate, etc.). And, again, because your previous response was unclear, when you send some bytes to your EEG via the serial port monitor, do these register at all?

A task written in Python sends a trigger when it runs on the same device. Port definition written in Python:port = serial.Serial("COM6", baudrate=115200)

That's all well and good, but it doesn't answer two if the questions I asked. So, once again:
(1) What are the port settings in the device manager?
(2) Can you get bytes to register on your EEG via Tools -> Serial Port Monitor?
By cansu - 2/18/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
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
Thanks Dave,
I am new in coding and I am unfamiliar to Millisecond language,so sorry about taking your time.
Should I delete last two line to revise the script.:

trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);

If it is not,can you share me the final revised version of this script? :(


Try this:

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
/ windowsize = (800px, 600px)
</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
/ items = (1)
/ erase = false
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = com6
/ items = (3)
/ erase = false
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = com6
/ items = (0)
/ erase = false
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = com6
/ items = (7)
/ erase = false
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = com6
/ items = (15)
/ erase = false
</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
/ items = (31)
/ erase = false
</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(port.incentivecueeeg, 0); // raise incentive signal
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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(port.nonincentivecueeeg, 0); // raise nonincentive signal
trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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; 3 = erasereeg]
/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



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

It doesnt work,I still can't send trigger to Biosemiactive2. Can it be a port problem? I use usb serial com6 port,not a LPT1 port :(

It works fine over serial, I've tested it on my system. Different com port number, but that doesn't make a difference. Double-check that you have the correct com port number. What are the settings for the port in the device manager (baud rate, etc.). And, again, because your previous response was unclear, when you send some bytes to your EEG via the serial port monitor, do these register at all?

A task written in Python sends a trigger when it runs on the same device. Port definition written in Python:port = serial.Serial("COM6", baudrate=115200)

That's all well and good, but it doesn't answer two if the questions I asked. So, once again:
(1) What are the port settings in the device manager?
(2) Can you get bytes to register on your EEG via Tools -> Serial Port Monitor?

1) baudrate:115200 data bits:8 parity:none stop:1 flow control :none
2)yes,ı get bites
 how can I define port as com6 with settings
Also I tried every version of inquisit,ı can send triggers while task is working in inquisit 4,but ı cannot with inquisit 6,how can ıt be possible?
By 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
cansu - 2/18/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
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
Thanks Dave,
I am new in coding and I am unfamiliar to Millisecond language,so sorry about taking your time.
Should I delete last two line to revise the script.:

trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);

If it is not,can you share me the final revised version of this script? :(


Try this:

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
/ windowsize = (800px, 600px)
</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
/ items = (1)
/ erase = false
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = com6
/ items = (3)
/ erase = false
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = com6
/ items = (0)
/ erase = false
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = com6
/ items = (7)
/ erase = false
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = com6
/ items = (15)
/ erase = false
</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
/ items = (31)
/ erase = false
</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(port.incentivecueeeg, 0); // raise incentive signal
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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(port.nonincentivecueeeg, 0); // raise nonincentive signal
trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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; 3 = erasereeg]
/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



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

It doesnt work,I still can't send trigger to Biosemiactive2. Can it be a port problem? I use usb serial com6 port,not a LPT1 port :(

It works fine over serial, I've tested it on my system. Different com port number, but that doesn't make a difference. Double-check that you have the correct com port number. What are the settings for the port in the device manager (baud rate, etc.). And, again, because your previous response was unclear, when you send some bytes to your EEG via the serial port monitor, do these register at all?

A task written in Python sends a trigger when it runs on the same device. Port definition written in Python:port = serial.Serial("COM6", baudrate=115200)

That's all well and good, but it doesn't answer two if the questions I asked. So, once again:
(1) What are the port settings in the device manager?
(2) Can you get bytes to register on your EEG via Tools -> Serial Port Monitor?

1) baudrate:115200 data bits:8 parity:none stop:1 flow control :none
2)yes,ı get bites
 how can I define port as com6 with settings
Also I tried every version of inquisit,ı can send triggers while task is working in inquisit 4,but ı cannot with inquisit 6,how can ıt be possible?

> how can I define port as com6 with settings

You don't. You look up what the port number is in the device manager. You use that number in your code. You previously stated that it's COM6, so that is what you use. If it's something else, then use that.

Other than that, baudrate settings etc. seem fine. No idea why things aren't working under Inquisit 6 (or 7) -- they should.
By cansu - 2/18/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
cansu - 2/18/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
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
Thanks Dave,
I am new in coding and I am unfamiliar to Millisecond language,so sorry about taking your time.
Should I delete last two line to revise the script.:

trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);

If it is not,can you share me the final revised version of this script? :(


Try this:

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
/ windowsize = (800px, 600px)
</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
/ items = (1)
/ erase = false
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = com6
/ items = (3)
/ erase = false
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = com6
/ items = (0)
/ erase = false
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = com6
/ items = (7)
/ erase = false
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = com6
/ items = (15)
/ erase = false
</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
/ items = (31)
/ erase = false
</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(port.incentivecueeeg, 0); // raise incentive signal
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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(port.nonincentivecueeeg, 0); // raise nonincentive signal
trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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; 3 = erasereeg]
/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



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

It doesnt work,I still can't send trigger to Biosemiactive2. Can it be a port problem? I use usb serial com6 port,not a LPT1 port :(

It works fine over serial, I've tested it on my system. Different com port number, but that doesn't make a difference. Double-check that you have the correct com port number. What are the settings for the port in the device manager (baud rate, etc.). And, again, because your previous response was unclear, when you send some bytes to your EEG via the serial port monitor, do these register at all?

A task written in Python sends a trigger when it runs on the same device. Port definition written in Python:port = serial.Serial("COM6", baudrate=115200)

That's all well and good, but it doesn't answer two if the questions I asked. So, once again:
(1) What are the port settings in the device manager?
(2) Can you get bytes to register on your EEG via Tools -> Serial Port Monitor?

1) baudrate:115200 data bits:8 parity:none stop:1 flow control :none
2)yes,ı get bites
 how can I define port as com6 with settings
Also I tried every version of inquisit,ı can send triggers while task is working in inquisit 4,but ı cannot with inquisit 6,how can ıt be possible?

> how can I define port as com6 with settings

You don't. You look up what the port number is in the device manager. You use that number in your code. You previously stated that it's COM6, so that is what you use. If it's something else, then use that.

Other than that, baudrate settings etc. seem fine. No idea why things aren't working under Inquisit 6 (or 7) -- they should.
Thanks but unfortunately ıt doesn't work with inquisit 6, triggers are sent in inquisit 4 so ı can use ınquisit 4 for my research but ı have no registiration number for it,ı have inquisit 7 license.

Please help
By 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
cansu - 2/18/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
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
Thanks Dave,
I am new in coding and I am unfamiliar to Millisecond language,so sorry about taking your time.
Should I delete last two line to revise the script.:

trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);

If it is not,can you share me the final revised version of this script? :(


Try this:

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
/ windowsize = (800px, 600px)
</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
/ items = (1)
/ erase = false
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = com6
/ items = (3)
/ erase = false
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = com6
/ items = (0)
/ erase = false
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = com6
/ items = (7)
/ erase = false
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = com6
/ items = (15)
/ erase = false
</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
/ items = (31)
/ erase = false
</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(port.incentivecueeeg, 0); // raise incentive signal
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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(port.nonincentivecueeeg, 0); // raise nonincentive signal
trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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; 3 = erasereeg]
/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



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

It doesnt work,I still can't send trigger to Biosemiactive2. Can it be a port problem? I use usb serial com6 port,not a LPT1 port :(

It works fine over serial, I've tested it on my system. Different com port number, but that doesn't make a difference. Double-check that you have the correct com port number. What are the settings for the port in the device manager (baud rate, etc.). And, again, because your previous response was unclear, when you send some bytes to your EEG via the serial port monitor, do these register at all?

A task written in Python sends a trigger when it runs on the same device. Port definition written in Python:port = serial.Serial("COM6", baudrate=115200)

That's all well and good, but it doesn't answer two if the questions I asked. So, once again:
(1) What are the port settings in the device manager?
(2) Can you get bytes to register on your EEG via Tools -> Serial Port Monitor?

1) baudrate:115200 data bits:8 parity:none stop:1 flow control :none
2)yes,ı get bites
 how can I define port as com6 with settings
Also I tried every version of inquisit,ı can send triggers while task is working in inquisit 4,but ı cannot with inquisit 6,how can ıt be possible?

> how can I define port as com6 with settings

You don't. You look up what the port number is in the device manager. You use that number in your code. You previously stated that it's COM6, so that is what you use. If it's something else, then use that.

Other than that, baudrate settings etc. seem fine. No idea why things aren't working under Inquisit 6 (or 7) -- they should.
Thanks but unfortunately ıt doesn't work with inquisit 6, triggers are sent in inquisit 4 so ı can use ınquisit 4 for my research but ı have no registiration number for it,ı have inquisit 7 license.

Please help

We've already responded to your emailed request regarding use o Inquisit 4.
By cansu - 2/18/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
cansu - 2/18/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
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
Thanks Dave,
I am new in coding and I am unfamiliar to Millisecond language,so sorry about taking your time.
Should I delete last two line to revise the script.:

trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);

If it is not,can you share me the final revised version of this script? :(


Try this:

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
/ windowsize = (800px, 600px)
</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
/ items = (1)
/ erase = false
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = com6
/ items = (3)
/ erase = false
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = com6
/ items = (0)
/ erase = false
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = com6
/ items = (7)
/ erase = false
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = com6
/ items = (15)
/ erase = false
</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
/ items = (31)
/ erase = false
</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(port.incentivecueeeg, 0); // raise incentive signal
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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(port.nonincentivecueeeg, 0); // raise nonincentive signal
trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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; 3 = erasereeg]
/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



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

It doesnt work,I still can't send trigger to Biosemiactive2. Can it be a port problem? I use usb serial com6 port,not a LPT1 port :(

It works fine over serial, I've tested it on my system. Different com port number, but that doesn't make a difference. Double-check that you have the correct com port number. What are the settings for the port in the device manager (baud rate, etc.). And, again, because your previous response was unclear, when you send some bytes to your EEG via the serial port monitor, do these register at all?

A task written in Python sends a trigger when it runs on the same device. Port definition written in Python:port = serial.Serial("COM6", baudrate=115200)

That's all well and good, but it doesn't answer two if the questions I asked. So, once again:
(1) What are the port settings in the device manager?
(2) Can you get bytes to register on your EEG via Tools -> Serial Port Monitor?

1) baudrate:115200 data bits:8 parity:none stop:1 flow control :none
2)yes,ı get bites
 how can I define port as com6 with settings
Also I tried every version of inquisit,ı can send triggers while task is working in inquisit 4,but ı cannot with inquisit 6,how can ıt be possible?

> how can I define port as com6 with settings

You don't. You look up what the port number is in the device manager. You use that number in your code. You previously stated that it's COM6, so that is what you use. If it's something else, then use that.

Other than that, baudrate settings etc. seem fine. No idea why things aren't working under Inquisit 6 (or 7) -- they should.
Thanks but unfortunately ıt doesn't work with inquisit 6, triggers are sent in inquisit 4 so ı can use ınquisit 4 for my research but ı have no registiration number for it,ı have inquisit 7 license.

Please help

We've already responded to your emailed request regarding use o Inquisit 4.

I tried  AUDITORY ODDBALL TASK .
it worked correctly with triggers.Iı just changed port settings (defined as com6).
In Auditory Oddball, the port object is invoked directly within the stimuli.
In MID Task that ı sent you , timing is set with the insertstimulustime function.
What is the possible error about MID task? It has no problem with sending triggers  AUDITORY ODDBALL TASK in inquisit 6.
By 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
cansu - 2/18/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
cansu - 2/18/2025
Dave - 2/18/2025
cansu - 2/18/2025
Thanks for answeringAs you mentioned,I define com6 as Port :/ port = COM6/ subport = data/ items = ("00001111") But ı cant see triggers on EEG record,ı still have that problem, what is te possible problem?

You've defined a <port> stimulus. That's step one. Step two is to actually *display* it when you want it to be sent.

Where are you doing that? There's nothing in the code you've shown.


                                    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 = COM8
/ 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

/ 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

/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Here is my script. Task runs but doesnt send any triggers to Biosemiactive2

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);

You lower all the bits at the same time you try to raise them. So this can't send anything.

Apart from that, use Tools -> Serial Port Monitor to see if you can get any signal out to your device at all.

I checked by using Tools -> Serial Port Monitor to see if you can get any signal out to your device at all. It doesnt seem like any problem with it.

But ı couldnt understand what do you mean with 'You lower all the bits at the same time you try to raise them. So this can't send anything.' 
What should ı change with the script?

port.eraseeg must not be output at the same time as port.incentivecueeeg.
Thanks Dave,
I am new in coding and I am unfamiliar to Millisecond language,so sorry about taking your time.
Should I delete last two line to revise the script.:

trial.incentive.insertstimulustime(shape.incentivecue, values.cueduration);
trial.incentive.insertstimulustime(port.incentivecueeeg, values.cueduration);

If it is not,can you share me the final revised version of this script? :(


Try this:

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
/ windowsize = (800px, 600px)
</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
/ items = (1)
/ erase = false
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = com6
/ items = (3)
/ erase = false
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = com6
/ items = (0)
/ erase = false
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = com6
/ items = (7)
/ erase = false
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = com6
/ items = (15)
/ erase = false
</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
/ items = (31)
/ erase = false
</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(port.incentivecueeeg, 0); // raise incentive signal
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.incentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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(port.nonincentivecueeeg, 0); // raise nonincentive signal
trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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; 3 = erasereeg]
/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



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

It doesnt work,I still can't send trigger to Biosemiactive2. Can it be a port problem? I use usb serial com6 port,not a LPT1 port :(

It works fine over serial, I've tested it on my system. Different com port number, but that doesn't make a difference. Double-check that you have the correct com port number. What are the settings for the port in the device manager (baud rate, etc.). And, again, because your previous response was unclear, when you send some bytes to your EEG via the serial port monitor, do these register at all?

A task written in Python sends a trigger when it runs on the same device. Port definition written in Python:port = serial.Serial("COM6", baudrate=115200)

That's all well and good, but it doesn't answer two if the questions I asked. So, once again:
(1) What are the port settings in the device manager?
(2) Can you get bytes to register on your EEG via Tools -> Serial Port Monitor?

1) baudrate:115200 data bits:8 parity:none stop:1 flow control :none
2)yes,ı get bites
 how can I define port as com6 with settings
Also I tried every version of inquisit,ı can send triggers while task is working in inquisit 4,but ı cannot with inquisit 6,how can ıt be possible?

> how can I define port as com6 with settings

You don't. You look up what the port number is in the device manager. You use that number in your code. You previously stated that it's COM6, so that is what you use. If it's something else, then use that.

Other than that, baudrate settings etc. seem fine. No idea why things aren't working under Inquisit 6 (or 7) -- they should.
Thanks but unfortunately ıt doesn't work with inquisit 6, triggers are sent in inquisit 4 so ı can use ınquisit 4 for my research but ı have no registiration number for it,ı have inquisit 7 license.

Please help

We've already responded to your emailed request regarding use o Inquisit 4.

I tried  AUDITORY ODDBALL TASK .
it worked correctly with triggers.Iı just changed port settings (defined as com6).
In Auditory Oddball, the port object is invoked directly within the stimuli.
In MID Task that ı sent you , timing is set with the insertstimulustime function.
What is the possible error about MID task? It has no problem with sending triggers  AUDITORY ODDBALL TASK in inquisit 6.

It makes no difference whether you specify directly in /stimulustimes (or /stimulusframes) or use functions to set up the stimulus presentation sequence. Moreover, some ports are directly in /stimulustimes in the MID task as well (trial feedback), so if the use of functions in the other trials were the issue, you would at least see the feedback triggers.

Only other difference I can think of is that the oddball task rellies on automatic erasing, instead of lowering signals explicitly. Try that for the MID task and see if it does something.

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
/ items = (1)
// erase = false
</port>
<shape nonincentivecue>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = red
</shape>
<port nonincentivecueeeg>
/ port = COM6
/ items = (3)
// erase = false
</port>
<shape eraser>
/ shape = rectangle
/ size = (values.stimsize * 2 * 0.75, values.stimsize * 2)
/ position = (50%, 50%)
/ color = black
</shape>
<port erasereeg>
/ port = COM6
/ items = (0)
// erase = false
</port>
<shape target>
/ shape = rectangle
/ size = (values.stimsize * 0.75, values.stimsize)
/ position = (50%, 50%)
/ color = white
</shape>
<port targeteeg>
/ port = COM6
/ items = (7)
// erase = false
</port>
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg>
/ port = COM6
/ items = (15)
// erase = false
</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
/ items = (31)
// erase = false
</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(port.incentivecueeeg, 0); // raise incentive signal
trial.incentive.insertstimulustime(shape.eraser, values.cueduration);
//trial.incentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.incentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.incentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
//trial.incentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = incentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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(port.nonincentivecueeeg, 0); // raise nonincentive signal
trial.nonincentive.insertstimulustime(shape.eraser, values.cueduration);
//trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration); // lower incentive signal
trial.nonincentive.insertstimulustime(shape.target, (values.cueduration + values.delayduration));
trial.nonincentive.insertstimulustime(port.targeteeg, (values.cueduration + values.delayduration)); // raise target signal
//trial.nonincentive.insertstimulustime(port.erasereeg, values.cueduration + values.delayduration + 40); // lower target signal
]
/ posttrialpause = values.fixediti
/ stimulustimes = [0 = nonincentivecue, total]
/ beginresponsetime = values.cueduration + values.delayduration
/ responseinterrupt = frames
/ timeout = values.cueduration + values.delayduration + values.targetduration

/ 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; 3 = erasereeg]
/ 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-5 = baseline; 6 = 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-5 = 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-5 = 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-5 = 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>



**************************************************************************************************************
End of File
**************************************************************************************************************
By cansu - 2/18/2025

It sends trigger from serial port but it does not send while the code is running. In the code I posted, it sends trigger without any problem while the task is running in Inquisit 4.
<usermanual>
                        
                                    MONETARY INCENTIVE DELAY TASK
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. () for Millisecond Software, LLC
Date: 08-28-2015
last updated: 02-09-2018 by K.Borchert () 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
**************************************************************************************************************

By 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?
By 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.
By 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.
By 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 :)
By 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')
By 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:)))
By 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
By 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
**************************************************************************************************************

By 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.
By 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 :)
By 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 !
By 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.
By cansu - 3/10/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.
By 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.
By 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
**************************************************************************************************************

By Dave - 3/12/2025

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>
By cansu - 3/12/2025

Thanks for the reply
For feedback triggers, is it possible to send different triggers for feedback after reward cue ,different triggers for feedback after punishment cue,different triggers for feedback after nonincentive cue? Is there anything I can do to send feedback triggers differently according to the nature of the initial cue using the method you mentioned?
By Dave - 3/12/2025

cansu - 3/12/2025
Thanks for the replyFor feedback triggers, is it possible to send different triggers for feedback after reward cue ,different triggers for feedback after punishment cue,different triggers for feedback after nonincentive cue? Is there anything I can do to send feedback triggers differently according to the nature of the initial cue using the method you mentioned?

The exact same method applies.
By cansu - 3/12/2025

I really appreciate your help but as I mentioned before I am unfamiliar with the inquisit language and I have no idea which parts of the script I will add these additions to. As I said, I did not understand the revision I will make after defining the reward and loss cues in two different ports. If possible, can you do these revisions and share the full script version that sends different triggers for reward and punishment?
Thanks for you help again🙏🏻🙏🏻:(
By cansu - 3/12/2025

I am a psychiatrist and I am not proficient in codes other than Python. I am aware that I ask a lot of questions, unfortunately this is due to my lack of proficiency in the Inquisit language. I would be grateful if you could help me.🙏🏻
By cansu - 3/12/2025

Since I will be working on ERP in the eeg waves after feedback, it will be necessary for the feedback triggers that come after the reward cues to be different during the analysis phase.
If you can make the feedback trigger that comes after the reward cue '1' as '15', the feedback trigger that comes after the nonincentive cue as 'a different number other than 15'; and similarly, the trigger that comes after the loss cue in the loss block and the trigger that comes after the neutral cue are also different numbers than 15, I would be very happy.
If you explain how to do this in more detail, I will try to do it of course.
By Dave - 3/12/2025

cansu - 3/12/2025
Since I will be working on ERP in the eeg waves after feedback, it will be necessary for the feedback triggers that come after the reward cues to be different during the analysis phase.If you can make the feedback trigger that comes after the reward cue '1' as '15', the feedback trigger that comes after the nonincentive cue as 'a different number other than 15'; and similarly, the trigger that comes after the loss cue in the loss block and the trigger that comes after the neutral cue are also different numbers than 15, I would be very happy.If you explain how to do this in more detail, I will try to do it of course.

Please work through the Programmer's Manual available at https://www.millisecond.com/support/Inquisit%20Programmer's%20Manual.pdf and then through your script until you have a better understanding of how it actually works and what does what.

Given that you are familiary with other programming languages (e.g. Python), you should be able to pick up the basic structure and syntax rules quickly.

Then try to make the modifications on the basis of what I explained previously.

If you get stuck, you are more than welcome to ask concrete questions.
By cansu - 3/12/2025

I will take a look at the manuel you sent, thank you very much.
If you share with me the version of the reward and loss cues defined with different triggers as you answered in my previous questions, I can have a better understanding of including the port and trigger commands in the script.🙏🏻🙏🏻
I reviewed the manual you sent, I could not see a detailed explanation about the port and trigger, but I will take a look again.
By Dave - 3/12/2025

cansu - 3/12/2025
I will take a look at the manuel you sent, thank you very much.If you share with me the version of the reward and loss cues defined with different triggers as you answered in my previous questions, I can have a better understanding of including the port and trigger commands in the script.🙏🏻🙏🏻I reviewed the manual you sent, I could not see a detailed explanation about the port and trigger, but I will take a look again.

You don't need a detailed explanation of <port> elements. They are stimulus elements like any other (<text>, <picture>, <sound>, etc.) and are to be treated in the same way as any other stimulus element.

The code for different incentive cue triggers in reward vs punishment condition is already in this thread.
By cansu - 3/12/2025

I will change this part of y script below with yours and add port definitions.
After that, there will be a task script that sends different triggers for cues. As far as I understand, I don't think I need to make any other changes.



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]



By Dave - 3/12/2025

cansu - 3/12/2025
I will change this part of y script below with yours and add port definitions.After that, there will be a task script that sends different triggers for cues. As far as I understand, I don't think I need to make any other changes.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]

In addition to changing <trial incentive> this way, you also need to add the two port elements I included in my response -- <port incentivecueeeg_reward> and <port incentivecueeeg_punishment> -- to your script.

<port incentivecueeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00000001")
</port>

<port incentivecueeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00000010")
</port>


After that forget about triggers and the MID task for a while. Instead work through the Programmer's Manual from front to back and focus on understanding the basic building blocks that every Inquisit script is made up of. I.e., what are stimulus elements and what do they do? What do trial elements do? What do blocks do? And so forth.

Once you have acquired these basics, you should be able to actually "read" the MID task code and have a general sense of what each thing in it does and why.
By cansu - 3/12/2025

Thank you four your help🙏🏻
By cansu - 3/13/2025

cansu - 3/12/2025
Thank you four your help🙏🏻

I was able to trigger reward and loss cues differently with your guidance, thanks again.

I defined feedback punishment feedback reward and feedback loss ports with the same method,
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00111111")
</port>






But I couldn't understand how to place these newly defined ports in the trial feedback section in the script.
<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>

This is the only part missing from the experiment, I would be happy if you could help. :(
By Dave - 3/13/2025

cansu - 3/13/2025
cansu - 3/12/2025
Thank you four your help🙏🏻

I was able to trigger reward and loss cues differently with your guidance, thanks again.

I defined feedback punishment feedback reward and feedback loss ports with the same method,
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00111111")
</port>






But I couldn't understand how to place these newly defined ports in the trial feedback section in the script.
<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>

This is the only part missing from the experiment, I would be happy if you could help. :(

You need to remove feedbackeeg from /stimulusframes. Then you need to use conditional logic /ontrialbegin to insert the applicable port stimulus into the trial, based on the condition. This is the exact same thing I showed you for the incentive trial. If you understand how that works, you can do it for the feedback trials as well.
By cansu - 3/14/2025

Dave - 3/13/2025
cansu - 3/13/2025
cansu - 3/12/2025
Thank you four your help🙏🏻

I was able to trigger reward and loss cues differently with your guidance, thanks again.

I defined feedback punishment feedback reward and feedback loss ports with the same method,
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00111111")
</port>






But I couldn't understand how to place these newly defined ports in the trial feedback section in the script.
<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>

This is the only part missing from the experiment, I would be happy if you could help. :(

You need to remove feedbackeeg from /stimulusframes. Then you need to use conditional logic /ontrialbegin to insert the applicable port stimulus into the trial, based on the condition. This is the exact same thing I showed you for the incentive trial. If you understand how that works, you can do it for the feedback trials as well.

<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>

<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00010000")
</port>

<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00010001")
</port>

<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };


  if (values.exp_condition == 0) {
   trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
  } else if (values.exp_condition == 1) {
   trial.feedback.insertstimulustime(port.feedbackeeg_reward, 0);
  } else if (values.exp_condition == 2) {
   trial.feedback.insertstimulustime(port.feedbackeeg_punishment, 0);
  };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
</trial>


I made the changes as you said to send feedback with separate triggers in reward and punishment blocks. I defined a port. However, consistent fixed triggers are not coming in reward and loss blocks. A wide variety of triggers came. What is the problem?
By Dave - 3/14/2025

cansu - 3/14/2025
Dave - 3/13/2025
cansu - 3/13/2025
cansu - 3/12/2025
Thank you four your help🙏🏻

I was able to trigger reward and loss cues differently with your guidance, thanks again.

I defined feedback punishment feedback reward and feedback loss ports with the same method,
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00111111")
</port>






But I couldn't understand how to place these newly defined ports in the trial feedback section in the script.
<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>

This is the only part missing from the experiment, I would be happy if you could help. :(

You need to remove feedbackeeg from /stimulusframes. Then you need to use conditional logic /ontrialbegin to insert the applicable port stimulus into the trial, based on the condition. This is the exact same thing I showed you for the incentive trial. If you understand how that works, you can do it for the feedback trials as well.

<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>

<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00010000")
</port>

<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00010001")
</port>

<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };


  if (values.exp_condition == 0) {
   trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
  } else if (values.exp_condition == 1) {
   trial.feedback.insertstimulustime(port.feedbackeeg_reward, 0);
  } else if (values.exp_condition == 2) {
   trial.feedback.insertstimulustime(port.feedbackeeg_punishment, 0);
  };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
</trial>


I made the changes as you said to send feedback with separate triggers in reward and punishment blocks. I defined a port. However, consistent fixed triggers are not coming in reward and loss blocks. A wide variety of triggers came. What is the problem?

What you are missing is a reset of the stimulus presentation sequence per resetstimulusframes() /ontrialend. See the incentive trial. Anything you add to the stimulus presentation sequence  persists and is cumulative otherwise.

/ ontrialend = [
    trial.feedback.resetstimulusframes();
]


See the Programmer's Manual, page 78 and onwards.
By cansu - 3/14/2025

Dave - 3/14/2025
cansu - 3/14/2025
Dave - 3/13/2025
cansu - 3/13/2025
cansu - 3/12/2025
Thank you four your help🙏🏻

I was able to trigger reward and loss cues differently with your guidance, thanks again.

I defined feedback punishment feedback reward and feedback loss ports with the same method,
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00111111")
</port>






But I couldn't understand how to place these newly defined ports in the trial feedback section in the script.
<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>

This is the only part missing from the experiment, I would be happy if you could help. :(

You need to remove feedbackeeg from /stimulusframes. Then you need to use conditional logic /ontrialbegin to insert the applicable port stimulus into the trial, based on the condition. This is the exact same thing I showed you for the incentive trial. If you understand how that works, you can do it for the feedback trials as well.

<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>

<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00010000")
</port>

<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00010001")
</port>

<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };


  if (values.exp_condition == 0) {
   trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
  } else if (values.exp_condition == 1) {
   trial.feedback.insertstimulustime(port.feedbackeeg_reward, 0);
  } else if (values.exp_condition == 2) {
   trial.feedback.insertstimulustime(port.feedbackeeg_punishment, 0);
  };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
</trial>


I made the changes as you said to send feedback with separate triggers in reward and punishment blocks. I defined a port. However, consistent fixed triggers are not coming in reward and loss blocks. A wide variety of triggers came. What is the problem?

What you are missing is a reset of the stimulus presentation sequence per resetstimulusframes() /ontrialend. See the incentive trial. Anything you add to the stimulus presentation sequence  persists and is cumulative otherwise.

/ ontrialend = [
    trial.feedback.resetstimulusframes();
]


See the Programmer's Manual, page 78 and onwards.




I want to define a condition in this section.

<trial feedback>
/ ontrialbegin = [


  trial.feedback.insertstimulustime(text.debug_feedback, 0);
  if (values.exp_condition == 0) {
   trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
  } else if (values.exp_condition == 1) {

   trial.feedback.insertstimulustime(port.feedbackeeg_reward, 0);
  } else if (values.exp_condition == 2) {
   trial.feedback.insertstimulustime(port.feedbackeeg_punishment, 0);
  };


  if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
   text.feedback.textcolor = green;
  } else {
   text.feedback.textcolor = red;
  };
]


if nonincentive cue comes, feedbackeeg_control comes
<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>

when incentive cue comes, feedbackeeg_reward comes

<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00010000")
</port>

what should I do for this?
By Dave - 3/14/2025

cansu - 3/14/2025
Dave - 3/14/2025
cansu - 3/14/2025
Dave - 3/13/2025
cansu - 3/13/2025
cansu - 3/12/2025
Thank you four your help🙏🏻

I was able to trigger reward and loss cues differently with your guidance, thanks again.

I defined feedback punishment feedback reward and feedback loss ports with the same method,
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00111111")
</port>






But I couldn't understand how to place these newly defined ports in the trial feedback section in the script.
<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>

This is the only part missing from the experiment, I would be happy if you could help. :(

You need to remove feedbackeeg from /stimulusframes. Then you need to use conditional logic /ontrialbegin to insert the applicable port stimulus into the trial, based on the condition. This is the exact same thing I showed you for the incentive trial. If you understand how that works, you can do it for the feedback trials as well.

<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>

<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00010000")
</port>

<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00010001")
</port>

<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };


  if (values.exp_condition == 0) {
   trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
  } else if (values.exp_condition == 1) {
   trial.feedback.insertstimulustime(port.feedbackeeg_reward, 0);
  } else if (values.exp_condition == 2) {
   trial.feedback.insertstimulustime(port.feedbackeeg_punishment, 0);
  };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
</trial>


I made the changes as you said to send feedback with separate triggers in reward and punishment blocks. I defined a port. However, consistent fixed triggers are not coming in reward and loss blocks. A wide variety of triggers came. What is the problem?

What you are missing is a reset of the stimulus presentation sequence per resetstimulusframes() /ontrialend. See the incentive trial. Anything you add to the stimulus presentation sequence  persists and is cumulative otherwise.

/ ontrialend = [
    trial.feedback.resetstimulusframes();
]


See the Programmer's Manual, page 78 and onwards.




I want to define a condition in this section.

<trial feedback>
/ ontrialbegin = [


  trial.feedback.insertstimulustime(text.debug_feedback, 0);
  if (values.exp_condition == 0) {
   trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
  } else if (values.exp_condition == 1) {

   trial.feedback.insertstimulustime(port.feedbackeeg_reward, 0);
  } else if (values.exp_condition == 2) {
   trial.feedback.insertstimulustime(port.feedbackeeg_punishment, 0);
  };


  if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
   text.feedback.textcolor = green;
  } else {
   text.feedback.textcolor = red;
  };
]


if nonincentive cue comes, feedbackeeg_control comes
<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>

when incentive cue comes, feedbackeeg_reward comes

<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00010000")
</port>

what should I do for this?

You should be sufficiently familair with your script by now. So: Do you have the incentive condition in a variable (a value) somewhere, like the exp_condition? Which variable is that?
By cansu - 3/14/2025

Dave - 3/14/2025
cansu - 3/14/2025
Dave - 3/14/2025
cansu - 3/14/2025
Dave - 3/13/2025
cansu - 3/13/2025
cansu - 3/12/2025
Thank you four your help🙏🏻

I was able to trigger reward and loss cues differently with your guidance, thanks again.

I defined feedback punishment feedback reward and feedback loss ports with the same method,
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00111111")
</port>






But I couldn't understand how to place these newly defined ports in the trial feedback section in the script.
<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>

This is the only part missing from the experiment, I would be happy if you could help. :(

You need to remove feedbackeeg from /stimulusframes. Then you need to use conditional logic /ontrialbegin to insert the applicable port stimulus into the trial, based on the condition. This is the exact same thing I showed you for the incentive trial. If you understand how that works, you can do it for the feedback trials as well.

<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>

<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00010000")
</port>

<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00010001")
</port>

<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };


  if (values.exp_condition == 0) {
   trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
  } else if (values.exp_condition == 1) {
   trial.feedback.insertstimulustime(port.feedbackeeg_reward, 0);
  } else if (values.exp_condition == 2) {
   trial.feedback.insertstimulustime(port.feedbackeeg_punishment, 0);
  };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
</trial>


I made the changes as you said to send feedback with separate triggers in reward and punishment blocks. I defined a port. However, consistent fixed triggers are not coming in reward and loss blocks. A wide variety of triggers came. What is the problem?

What you are missing is a reset of the stimulus presentation sequence per resetstimulusframes() /ontrialend. See the incentive trial. Anything you add to the stimulus presentation sequence  persists and is cumulative otherwise.

/ ontrialend = [
    trial.feedback.resetstimulusframes();
]


See the Programmer's Manual, page 78 and onwards.




I want to define a condition in this section.

<trial feedback>
/ ontrialbegin = [


  trial.feedback.insertstimulustime(text.debug_feedback, 0);
  if (values.exp_condition == 0) {
   trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
  } else if (values.exp_condition == 1) {

   trial.feedback.insertstimulustime(port.feedbackeeg_reward, 0);
  } else if (values.exp_condition == 2) {
   trial.feedback.insertstimulustime(port.feedbackeeg_punishment, 0);
  };


  if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
   text.feedback.textcolor = green;
  } else {
   text.feedback.textcolor = red;
  };
]


if nonincentive cue comes, feedbackeeg_control comes
<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>

when incentive cue comes, feedbackeeg_reward comes

<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00010000")
</port>

what should I do for this?

You should be sufficiently familair with your script by now. So: Do you have the incentive condition in a variable (a value) somewhere, like the exp_condition? Which variable is that?

<trial feedback>
/ ontrialbegin = [



  if (values.exp_condition == 0) {
   trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
  }
  else if (values.exp_condition == 1) {
   if (values.feedback == 1) {
    trial.feedback.insertstimulustime(port.feedbackeeg_reward1, 0);
   }
   else if (values.feedback == 3) {
    trial.feedback.insertstimulustime(port.feedbackeeg_reward3, 0);
   }
   else if (values.feedback == 2 || values.feedback == 4) {
    trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
   }
  }

  else if (values.exp_condition == 2) {
   if (values.feedback == 5) {
    trial.feedback.insertstimulustime(port.feedbackeeg_punishment5, 0);
   }
   else if (values.feedback == 6) {
    trial.feedback.insertstimulustime(port.feedbackeeg_punishment6, 0);
   }
   else if (values.feedback == 2 || values.feedback == 4) {
    trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
   }
  }

  if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
   text.feedback.textcolor = green;
  } else {
   text.feedback.textcolor = red;
  }
]
values.exp condition == 2 feedback triggers do not come.
values.exp condition == 1 also comes. Could this be because else cannot pass from if to another?
What should I do for this?
By cansu - 3/14/2025

cansu - 3/14/2025
Dave - 3/14/2025
cansu - 3/14/2025
Dave - 3/14/2025
cansu - 3/14/2025
Dave - 3/13/2025
cansu - 3/13/2025
cansu - 3/12/2025
Thank you four your help🙏🏻

I was able to trigger reward and loss cues differently with your guidance, thanks again.

I defined feedback punishment feedback reward and feedback loss ports with the same method,
<text feedback>
/ items = feedback
/ select = values.feedback
/ vjustify = center
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
</text>
<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>
<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00011111")
</port>
<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00111111")
</port>






But I couldn't understand how to place these newly defined ports in the trial feedback section in the script.
<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>

This is the only part missing from the experiment, I would be happy if you could help. :(

You need to remove feedbackeeg from /stimulusframes. Then you need to use conditional logic /ontrialbegin to insert the applicable port stimulus into the trial, based on the condition. This is the exact same thing I showed you for the incentive trial. If you understand how that works, you can do it for the feedback trials as well.

<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>

<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00010000")
</port>

<port feedbackeeg_punishment>
/ port = COM6
/ subport = data
/ items = ("00010001")
</port>

<trial feedback>
/ ontrialbegin = [
    if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
        text.feedback.textcolor = green;
    } else {
        text.feedback.textcolor = red;
    };


  if (values.exp_condition == 0) {
   trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
  } else if (values.exp_condition == 1) {
   trial.feedback.insertstimulustime(port.feedbackeeg_reward, 0);
  } else if (values.exp_condition == 2) {
   trial.feedback.insertstimulustime(port.feedbackeeg_punishment, 0);
  };
]
/ posttrialpause = values.fixediti
/ stimulusframes = [1 = feedback, total]
/ timeout = values.cueduration + values.targetduration
/ posttrialpause = values.iti
/ recorddata = false
</trial>


I made the changes as you said to send feedback with separate triggers in reward and punishment blocks. I defined a port. However, consistent fixed triggers are not coming in reward and loss blocks. A wide variety of triggers came. What is the problem?

What you are missing is a reset of the stimulus presentation sequence per resetstimulusframes() /ontrialend. See the incentive trial. Anything you add to the stimulus presentation sequence  persists and is cumulative otherwise.

/ ontrialend = [
    trial.feedback.resetstimulusframes();
]


See the Programmer's Manual, page 78 and onwards.




I want to define a condition in this section.

<trial feedback>
/ ontrialbegin = [


  trial.feedback.insertstimulustime(text.debug_feedback, 0);
  if (values.exp_condition == 0) {
   trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
  } else if (values.exp_condition == 1) {

   trial.feedback.insertstimulustime(port.feedbackeeg_reward, 0);
  } else if (values.exp_condition == 2) {
   trial.feedback.insertstimulustime(port.feedbackeeg_punishment, 0);
  };


  if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
   text.feedback.textcolor = green;
  } else {
   text.feedback.textcolor = red;
  };
]


if nonincentive cue comes, feedbackeeg_control comes
<port feedbackeeg_control>
/ port = COM6
/ subport = data
/ items = ("00001111")
</port>

when incentive cue comes, feedbackeeg_reward comes

<port feedbackeeg_reward>
/ port = COM6
/ subport = data
/ items = ("00010000")
</port>

what should I do for this?

You should be sufficiently familair with your script by now. So: Do you have the incentive condition in a variable (a value) somewhere, like the exp_condition? Which variable is that?

<trial feedback>
/ ontrialbegin = [



  if (values.exp_condition == 0) {
   trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
  }
  else if (values.exp_condition == 1) {
   if (values.feedback == 1) {
    trial.feedback.insertstimulustime(port.feedbackeeg_reward1, 0);
   }
   else if (values.feedback == 3) {
    trial.feedback.insertstimulustime(port.feedbackeeg_reward3, 0);
   }
   else if (values.feedback == 2 || values.feedback == 4) {
    trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
   }
  }

  else if (values.exp_condition == 2) {
   if (values.feedback == 5) {
    trial.feedback.insertstimulustime(port.feedbackeeg_punishment5, 0);
   }
   else if (values.feedback == 6) {
    trial.feedback.insertstimulustime(port.feedbackeeg_punishment6, 0);
   }
   else if (values.feedback == 2 || values.feedback == 4) {
    trial.feedback.insertstimulustime(port.feedbackeeg_control, 0);
   }
  }

  if (values.feedback == 1 || values.feedback == 2 || values.feedback == 5) {
   text.feedback.textcolor = green;
  } else {
   text.feedback.textcolor = red;
  }
]
values.exp condition == 2 feedback triggers do not come.
values.exp condition == 1 also comes. Could this be because else cannot pass from if to another?
What should I do for this?

I got it done, no need, thanks