Millisecond Forums

how to record both keyboard and mouse responses within a single trial

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

By eleonora_parr - 1/13/2021

Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora
By Dave - 1/13/2021

eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>


By eleonora_parr - 1/13/2021

Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora

By Dave - 1/13/2021

eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.


By eleonora_parr - 1/13/2021

Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora
By Dave - 1/13/2021

eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora

No, two input devices in a single <trial> are not possible. However, I don't see where or why you need both keyboard and mouse in

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

That trial, as you currently have it, does not register any responses to begin with, validresponse is set to no response.

You wrote: "They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond)."

That is, <trial safe_3_backward_inc_respond> does not need two input devices, it only needs the mouse. <trial safe_3_backward_inc> can be set to keyboard and register any potential key release as well as log mouse coordinates as demonstrated.
By eleonora_parr - 1/13/2021

Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora

No, two input devices in a single <trial> are not possible. However, I don't see where or why you need both keyboard and mouse in

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

That trial, as you currently have it, does not register any responses to begin with, validresponse is set to no response.

You wrote: "They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond)."

That is, <trial safe_3_backward_inc_respond> does not need two input devices, it only needs the mouse. <trial safe_3_backward_inc> can be set to keyboard and register any potential key release as well as log mouse coordinates as demonstrated.

Oh, sorry, I probably did not express myself well. They have to keep the spacebar pressed for the whole trial safe_3_backward_inc and they can release it when the trial safe_3_backward_inc_respond begins, which is when they have to make the mouse response.
So the potential spacebar release should be recorded during both safe_3_backward_inc AND safe_3_backward_inc_respond, to make sure that they released the spacebar just before making the mouse response (that they did not release it too early) 
However, this trick allow us to check anyway if they released the spacebar before the begin of the trial safe_3_backward_inc_respond, so in some way it kinda solve the problem :-)
Greatly appreciated, thank you so much!

Eleonora
By eleonora_parr - 1/14/2021

eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora

No, two input devices in a single <trial> are not possible. However, I don't see where or why you need both keyboard and mouse in

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

That trial, as you currently have it, does not register any responses to begin with, validresponse is set to no response.

You wrote: "They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond)."

That is, <trial safe_3_backward_inc_respond> does not need two input devices, it only needs the mouse. <trial safe_3_backward_inc> can be set to keyboard and register any potential key release as well as log mouse coordinates as demonstrated.

Oh, sorry, I probably did not express myself well. They have to keep the spacebar pressed for the whole trial safe_3_backward_inc and they can release it when the trial safe_3_backward_inc_respond begins, which is when they have to make the mouse response.
So the potential spacebar release should be recorded during both safe_3_backward_inc AND safe_3_backward_inc_respond, to make sure that they released the spacebar just before making the mouse response (that they did not release it too early) 
However, this trick allow us to check anyway if they released the spacebar before the begin of the trial safe_3_backward_inc_respond, so in some way it kinda solve the problem :-)
Greatly appreciated, thank you so much!

Eleonora

Hi Dave,
Sorry to bother again, but I am having problems in recording the spacebar release in the data: I followed a couple of examples that I found in the forum (https://www.millisecond.com/forums/Topic15810.aspx#15812 and https://www.millisecond.com/forums/Topic16749.aspx#16752) 
For now my code is:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>
<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>


<data>
/ columns = [date,time,group,subject, display.canvaswidth, display.canvasheight, session, build, blocknum, blockcode, trialnum,trialcode, pretrialpause,
posttrialpause, trialduration, values.Actiontype, values.congruency, values.object, values.length, values.fixate_duration, values.spacebarpresscount,
stimulusitem, stimulusitem, stimulusitem, stimulusitem,stimulusitem,stimulusitem,stimulusitem
stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset
correct, latency, response,values.x,values.y]
</data>

But when I run the code, the column spacebarpresscount is always empty. I've also tried /spacebarpresscount= 0 instead of /spacebarpresscount= "", unfortunately nothing changed..
Any suggestion?

Thank you so much!
By Dave - 1/14/2021

eleonora_parr - 1/14/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora

No, two input devices in a single <trial> are not possible. However, I don't see where or why you need both keyboard and mouse in

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

That trial, as you currently have it, does not register any responses to begin with, validresponse is set to no response.

You wrote: "They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond)."

That is, <trial safe_3_backward_inc_respond> does not need two input devices, it only needs the mouse. <trial safe_3_backward_inc> can be set to keyboard and register any potential key release as well as log mouse coordinates as demonstrated.

Oh, sorry, I probably did not express myself well. They have to keep the spacebar pressed for the whole trial safe_3_backward_inc and they can release it when the trial safe_3_backward_inc_respond begins, which is when they have to make the mouse response.
So the potential spacebar release should be recorded during both safe_3_backward_inc AND safe_3_backward_inc_respond, to make sure that they released the spacebar just before making the mouse response (that they did not release it too early) 
However, this trick allow us to check anyway if they released the spacebar before the begin of the trial safe_3_backward_inc_respond, so in some way it kinda solve the problem :-)
Greatly appreciated, thank you so much!

Eleonora

Hi Dave,
Sorry to bother again, but I am having problems in recording the spacebar release in the data: I followed a couple of examples that I found in the forum (https://www.millisecond.com/forums/Topic15810.aspx#15812 and https://www.millisecond.com/forums/Topic16749.aspx#16752) 
For now my code is:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>
<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>


<data>
/ columns = [date,time,group,subject, display.canvaswidth, display.canvasheight, session, build, blocknum, blockcode, trialnum,trialcode, pretrialpause,
posttrialpause, trialduration, values.Actiontype, values.congruency, values.object, values.length, values.fixate_duration, values.spacebarpresscount,
stimulusitem, stimulusitem, stimulusitem, stimulusitem,stimulusitem,stimulusitem,stimulusitem
stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset
correct, latency, response,values.x,values.y]
</data>

But when I run the code, the column spacebarpresscount is always empty. I've also tried /spacebarpresscount= 0 instead of /spacebarpresscount= "", unfortunately nothing changed..
Any suggestion?

Thank you so much!

Please provide code that is complete enough to actually run.
By Dave - 1/14/2021

Dave - 1/14/2021
eleonora_parr - 1/14/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora

No, two input devices in a single <trial> are not possible. However, I don't see where or why you need both keyboard and mouse in

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

That trial, as you currently have it, does not register any responses to begin with, validresponse is set to no response.

You wrote: "They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond)."

That is, <trial safe_3_backward_inc_respond> does not need two input devices, it only needs the mouse. <trial safe_3_backward_inc> can be set to keyboard and register any potential key release as well as log mouse coordinates as demonstrated.

Oh, sorry, I probably did not express myself well. They have to keep the spacebar pressed for the whole trial safe_3_backward_inc and they can release it when the trial safe_3_backward_inc_respond begins, which is when they have to make the mouse response.
So the potential spacebar release should be recorded during both safe_3_backward_inc AND safe_3_backward_inc_respond, to make sure that they released the spacebar just before making the mouse response (that they did not release it too early) 
However, this trick allow us to check anyway if they released the spacebar before the begin of the trial safe_3_backward_inc_respond, so in some way it kinda solve the problem :-)
Greatly appreciated, thank you so much!

Eleonora

Hi Dave,
Sorry to bother again, but I am having problems in recording the spacebar release in the data: I followed a couple of examples that I found in the forum (https://www.millisecond.com/forums/Topic15810.aspx#15812 and https://www.millisecond.com/forums/Topic16749.aspx#16752) 
For now my code is:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>
<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>


<data>
/ columns = [date,time,group,subject, display.canvaswidth, display.canvasheight, session, build, blocknum, blockcode, trialnum,trialcode, pretrialpause,
posttrialpause, trialduration, values.Actiontype, values.congruency, values.object, values.length, values.fixate_duration, values.spacebarpresscount,
stimulusitem, stimulusitem, stimulusitem, stimulusitem,stimulusitem,stimulusitem,stimulusitem
stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset
correct, latency, response,values.x,values.y]
</data>

But when I run the code, the column spacebarpresscount is always empty. I've also tried /spacebarpresscount= 0 instead of /spacebarpresscount= "", unfortunately nothing changed..
Any suggestion?

Thank you so much!

Please provide code that is complete enough to actually run.

One problem you have here

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

is that there's actually no time in the trial during which it would poll for any response. By default, Inquisit only starts accepting responses once the trial has completed its entire stimulus presentation sequence, here: after/coinciding with the onset of picture.safe_minus_third_frame. That, however, is also the time where the trial actually ends. If you want to accept responses *while* the stimulus presentation sequence is still in progress, from the very start of the <trial> object, set /beginresponsetime = -1.

https://www.millisecond.com/support/docs/v6/html/language/attributes/beginresponsetime.htm

Then, depending on what you want to happen when a response is registered (here: release of the space bar), you may in addition have to change the trial's /responseinterrupt.

https://www.millisecond.com/support/docs/v6/html/language/attributes/responseinterrupt.htm

The default is immediate, i.e. the trial will not present the remaining stimuli once a response has been registered. If you want the trial to complete the stimulus presentation sequence instead, set /responseinterrupt = frames.

In sum, something like this:

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [
    trial.safe_3_backward_inc.resetstimulusframes();
    trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ beginresponsetime = -1
/ responseinterrupt = frames
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

By eleonora_parr - 1/14/2021

Dave - 1/14/2021
Dave - 1/14/2021
eleonora_parr - 1/14/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora

No, two input devices in a single <trial> are not possible. However, I don't see where or why you need both keyboard and mouse in

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

That trial, as you currently have it, does not register any responses to begin with, validresponse is set to no response.

You wrote: "They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond)."

That is, <trial safe_3_backward_inc_respond> does not need two input devices, it only needs the mouse. <trial safe_3_backward_inc> can be set to keyboard and register any potential key release as well as log mouse coordinates as demonstrated.

Oh, sorry, I probably did not express myself well. They have to keep the spacebar pressed for the whole trial safe_3_backward_inc and they can release it when the trial safe_3_backward_inc_respond begins, which is when they have to make the mouse response.
So the potential spacebar release should be recorded during both safe_3_backward_inc AND safe_3_backward_inc_respond, to make sure that they released the spacebar just before making the mouse response (that they did not release it too early) 
However, this trick allow us to check anyway if they released the spacebar before the begin of the trial safe_3_backward_inc_respond, so in some way it kinda solve the problem :-)
Greatly appreciated, thank you so much!

Eleonora

Hi Dave,
Sorry to bother again, but I am having problems in recording the spacebar release in the data: I followed a couple of examples that I found in the forum (https://www.millisecond.com/forums/Topic15810.aspx#15812 and https://www.millisecond.com/forums/Topic16749.aspx#16752) 
For now my code is:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>
<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>


<data>
/ columns = [date,time,group,subject, display.canvaswidth, display.canvasheight, session, build, blocknum, blockcode, trialnum,trialcode, pretrialpause,
posttrialpause, trialduration, values.Actiontype, values.congruency, values.object, values.length, values.fixate_duration, values.spacebarpresscount,
stimulusitem, stimulusitem, stimulusitem, stimulusitem,stimulusitem,stimulusitem,stimulusitem
stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset
correct, latency, response,values.x,values.y]
</data>

But when I run the code, the column spacebarpresscount is always empty. I've also tried /spacebarpresscount= 0 instead of /spacebarpresscount= "", unfortunately nothing changed..
Any suggestion?

Thank you so much!

Please provide code that is complete enough to actually run.

One problem you have here

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

is that there's actually no time in the trial during which it would poll for any response. By default, Inquisit only starts accepting responses once the trial has completed its entire stimulus presentation sequence, here: after/coinciding with the onset of picture.safe_minus_third_frame. That, however, is also the time where the trial actually ends. If you want to accept responses *while* the stimulus presentation sequence is still in progress, from the very start of the <trial> object, set /beginresponsetime = -1.

https://www.millisecond.com/support/docs/v6/html/language/attributes/beginresponsetime.htm

Then, depending on what you want to happen when a response is registered (here: release of the space bar), you may in addition have to change the trial's /responseinterrupt.

https://www.millisecond.com/support/docs/v6/html/language/attributes/responseinterrupt.htm

The default is immediate, i.e. the trial will not present the remaining stimuli once a response has been registered. If you want the trial to complete the stimulus presentation sequence instead, set /responseinterrupt = frames.

In sum, something like this:

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [
    trial.safe_3_backward_inc.resetstimulusframes();
    trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ beginresponsetime = -1
/ responseinterrupt = frames
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>


Hi Dave,
So, with this solution the spacebar release recording is working, but unfortunately this option completely screws up the frame presentation timing, so that sometimes the audio is cut by the appearance of the subsequent frame ..
Here is the code:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>
****************************************
<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.time_sound = round(rand(1000,3000)); values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [
                trial.safe_3_backward_inc.resetstimulusframes();
                trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = frames
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]

</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>
By Dave - 1/14/2021

eleonora_parr - 1/14/2021
Dave - 1/14/2021
Dave - 1/14/2021
eleonora_parr - 1/14/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora

No, two input devices in a single <trial> are not possible. However, I don't see where or why you need both keyboard and mouse in

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

That trial, as you currently have it, does not register any responses to begin with, validresponse is set to no response.

You wrote: "They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond)."

That is, <trial safe_3_backward_inc_respond> does not need two input devices, it only needs the mouse. <trial safe_3_backward_inc> can be set to keyboard and register any potential key release as well as log mouse coordinates as demonstrated.

Oh, sorry, I probably did not express myself well. They have to keep the spacebar pressed for the whole trial safe_3_backward_inc and they can release it when the trial safe_3_backward_inc_respond begins, which is when they have to make the mouse response.
So the potential spacebar release should be recorded during both safe_3_backward_inc AND safe_3_backward_inc_respond, to make sure that they released the spacebar just before making the mouse response (that they did not release it too early) 
However, this trick allow us to check anyway if they released the spacebar before the begin of the trial safe_3_backward_inc_respond, so in some way it kinda solve the problem :-)
Greatly appreciated, thank you so much!

Eleonora

Hi Dave,
Sorry to bother again, but I am having problems in recording the spacebar release in the data: I followed a couple of examples that I found in the forum (https://www.millisecond.com/forums/Topic15810.aspx#15812 and https://www.millisecond.com/forums/Topic16749.aspx#16752) 
For now my code is:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>
<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>


<data>
/ columns = [date,time,group,subject, display.canvaswidth, display.canvasheight, session, build, blocknum, blockcode, trialnum,trialcode, pretrialpause,
posttrialpause, trialduration, values.Actiontype, values.congruency, values.object, values.length, values.fixate_duration, values.spacebarpresscount,
stimulusitem, stimulusitem, stimulusitem, stimulusitem,stimulusitem,stimulusitem,stimulusitem
stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset
correct, latency, response,values.x,values.y]
</data>

But when I run the code, the column spacebarpresscount is always empty. I've also tried /spacebarpresscount= 0 instead of /spacebarpresscount= "", unfortunately nothing changed..
Any suggestion?

Thank you so much!

Please provide code that is complete enough to actually run.

One problem you have here

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

is that there's actually no time in the trial during which it would poll for any response. By default, Inquisit only starts accepting responses once the trial has completed its entire stimulus presentation sequence, here: after/coinciding with the onset of picture.safe_minus_third_frame. That, however, is also the time where the trial actually ends. If you want to accept responses *while* the stimulus presentation sequence is still in progress, from the very start of the <trial> object, set /beginresponsetime = -1.

https://www.millisecond.com/support/docs/v6/html/language/attributes/beginresponsetime.htm

Then, depending on what you want to happen when a response is registered (here: release of the space bar), you may in addition have to change the trial's /responseinterrupt.

https://www.millisecond.com/support/docs/v6/html/language/attributes/responseinterrupt.htm

The default is immediate, i.e. the trial will not present the remaining stimuli once a response has been registered. If you want the trial to complete the stimulus presentation sequence instead, set /responseinterrupt = frames.

In sum, something like this:

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [
    trial.safe_3_backward_inc.resetstimulusframes();
    trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ beginresponsetime = -1
/ responseinterrupt = frames
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>


Hi Dave,
So, with this solution the spacebar release recording is working, but unfortunately this option completely screws up the frame presentation timing, so that sometimes the audio is cut by the appearance of the subsequent frame ..
Here is the code:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>
****************************************
<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.time_sound = round(rand(1000,3000)); values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [
                trial.safe_3_backward_inc.resetstimulusframes();
                trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = frames
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]

</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>

Try /responseinterrupt = trial then and/or setting the <sound> element to /erase=false.
By Dave - 1/14/2021

Dave - 1/14/2021
eleonora_parr - 1/14/2021
Dave - 1/14/2021
Dave - 1/14/2021
eleonora_parr - 1/14/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora

No, two input devices in a single <trial> are not possible. However, I don't see where or why you need both keyboard and mouse in

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

That trial, as you currently have it, does not register any responses to begin with, validresponse is set to no response.

You wrote: "They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond)."

That is, <trial safe_3_backward_inc_respond> does not need two input devices, it only needs the mouse. <trial safe_3_backward_inc> can be set to keyboard and register any potential key release as well as log mouse coordinates as demonstrated.

Oh, sorry, I probably did not express myself well. They have to keep the spacebar pressed for the whole trial safe_3_backward_inc and they can release it when the trial safe_3_backward_inc_respond begins, which is when they have to make the mouse response.
So the potential spacebar release should be recorded during both safe_3_backward_inc AND safe_3_backward_inc_respond, to make sure that they released the spacebar just before making the mouse response (that they did not release it too early) 
However, this trick allow us to check anyway if they released the spacebar before the begin of the trial safe_3_backward_inc_respond, so in some way it kinda solve the problem :-)
Greatly appreciated, thank you so much!

Eleonora

Hi Dave,
Sorry to bother again, but I am having problems in recording the spacebar release in the data: I followed a couple of examples that I found in the forum (https://www.millisecond.com/forums/Topic15810.aspx#15812 and https://www.millisecond.com/forums/Topic16749.aspx#16752) 
For now my code is:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>
<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>


<data>
/ columns = [date,time,group,subject, display.canvaswidth, display.canvasheight, session, build, blocknum, blockcode, trialnum,trialcode, pretrialpause,
posttrialpause, trialduration, values.Actiontype, values.congruency, values.object, values.length, values.fixate_duration, values.spacebarpresscount,
stimulusitem, stimulusitem, stimulusitem, stimulusitem,stimulusitem,stimulusitem,stimulusitem
stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset
correct, latency, response,values.x,values.y]
</data>

But when I run the code, the column spacebarpresscount is always empty. I've also tried /spacebarpresscount= 0 instead of /spacebarpresscount= "", unfortunately nothing changed..
Any suggestion?

Thank you so much!

Please provide code that is complete enough to actually run.

One problem you have here

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

is that there's actually no time in the trial during which it would poll for any response. By default, Inquisit only starts accepting responses once the trial has completed its entire stimulus presentation sequence, here: after/coinciding with the onset of picture.safe_minus_third_frame. That, however, is also the time where the trial actually ends. If you want to accept responses *while* the stimulus presentation sequence is still in progress, from the very start of the <trial> object, set /beginresponsetime = -1.

https://www.millisecond.com/support/docs/v6/html/language/attributes/beginresponsetime.htm

Then, depending on what you want to happen when a response is registered (here: release of the space bar), you may in addition have to change the trial's /responseinterrupt.

https://www.millisecond.com/support/docs/v6/html/language/attributes/responseinterrupt.htm

The default is immediate, i.e. the trial will not present the remaining stimuli once a response has been registered. If you want the trial to complete the stimulus presentation sequence instead, set /responseinterrupt = frames.

In sum, something like this:

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [
    trial.safe_3_backward_inc.resetstimulusframes();
    trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ beginresponsetime = -1
/ responseinterrupt = frames
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>


Hi Dave,
So, with this solution the spacebar release recording is working, but unfortunately this option completely screws up the frame presentation timing, so that sometimes the audio is cut by the appearance of the subsequent frame ..
Here is the code:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>
****************************************
<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.time_sound = round(rand(1000,3000)); values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [
                trial.safe_3_backward_inc.resetstimulusframes();
                trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = frames
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]

</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>

Try /responseinterrupt = trial then and/or setting the <sound> element to /erase=false.

And again, please, in the future provide code that will actually run. What I have available from you is a mere fraction, so it's not possible for me to spot all issues that may exist. In addition, if your code relies on any external files (images, audio files), you need to provide those as well.
By eleonora_parr - 1/14/2021

Dave - 1/14/2021
Dave - 1/14/2021
eleonora_parr - 1/14/2021
Dave - 1/14/2021
Dave - 1/14/2021
eleonora_parr - 1/14/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora

No, two input devices in a single <trial> are not possible. However, I don't see where or why you need both keyboard and mouse in

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

That trial, as you currently have it, does not register any responses to begin with, validresponse is set to no response.

You wrote: "They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond)."

That is, <trial safe_3_backward_inc_respond> does not need two input devices, it only needs the mouse. <trial safe_3_backward_inc> can be set to keyboard and register any potential key release as well as log mouse coordinates as demonstrated.

Oh, sorry, I probably did not express myself well. They have to keep the spacebar pressed for the whole trial safe_3_backward_inc and they can release it when the trial safe_3_backward_inc_respond begins, which is when they have to make the mouse response.
So the potential spacebar release should be recorded during both safe_3_backward_inc AND safe_3_backward_inc_respond, to make sure that they released the spacebar just before making the mouse response (that they did not release it too early) 
However, this trick allow us to check anyway if they released the spacebar before the begin of the trial safe_3_backward_inc_respond, so in some way it kinda solve the problem :-)
Greatly appreciated, thank you so much!

Eleonora

Hi Dave,
Sorry to bother again, but I am having problems in recording the spacebar release in the data: I followed a couple of examples that I found in the forum (https://www.millisecond.com/forums/Topic15810.aspx#15812 and https://www.millisecond.com/forums/Topic16749.aspx#16752) 
For now my code is:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>
<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>


<data>
/ columns = [date,time,group,subject, display.canvaswidth, display.canvasheight, session, build, blocknum, blockcode, trialnum,trialcode, pretrialpause,
posttrialpause, trialduration, values.Actiontype, values.congruency, values.object, values.length, values.fixate_duration, values.spacebarpresscount,
stimulusitem, stimulusitem, stimulusitem, stimulusitem,stimulusitem,stimulusitem,stimulusitem
stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset
correct, latency, response,values.x,values.y]
</data>

But when I run the code, the column spacebarpresscount is always empty. I've also tried /spacebarpresscount= 0 instead of /spacebarpresscount= "", unfortunately nothing changed..
Any suggestion?

Thank you so much!

Please provide code that is complete enough to actually run.

One problem you have here

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

is that there's actually no time in the trial during which it would poll for any response. By default, Inquisit only starts accepting responses once the trial has completed its entire stimulus presentation sequence, here: after/coinciding with the onset of picture.safe_minus_third_frame. That, however, is also the time where the trial actually ends. If you want to accept responses *while* the stimulus presentation sequence is still in progress, from the very start of the <trial> object, set /beginresponsetime = -1.

https://www.millisecond.com/support/docs/v6/html/language/attributes/beginresponsetime.htm

Then, depending on what you want to happen when a response is registered (here: release of the space bar), you may in addition have to change the trial's /responseinterrupt.

https://www.millisecond.com/support/docs/v6/html/language/attributes/responseinterrupt.htm

The default is immediate, i.e. the trial will not present the remaining stimuli once a response has been registered. If you want the trial to complete the stimulus presentation sequence instead, set /responseinterrupt = frames.

In sum, something like this:

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [
    trial.safe_3_backward_inc.resetstimulusframes();
    trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ beginresponsetime = -1
/ responseinterrupt = frames
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>


Hi Dave,
So, with this solution the spacebar release recording is working, but unfortunately this option completely screws up the frame presentation timing, so that sometimes the audio is cut by the appearance of the subsequent frame ..
Here is the code:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>
****************************************
<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.time_sound = round(rand(1000,3000)); values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [
                trial.safe_3_backward_inc.resetstimulusframes();
                trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = frames
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]

</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>

Try /responseinterrupt = trial then and/or setting the <sound> element to /erase=false.

And again, please, in the future provide code that will actually run. What I have available from you is a mere fraction, so it's not possible for me to spot all issues that may exist. In addition, if your code relies on any external files (images, audio files), you need to provide those as well.

It works perfectly now! You're awesome!!Thank you!! 
And, yes sorry I will provide the entire code the next time. 

Eleonora
By eleonora_parr - 1/15/2021

Dave - 1/14/2021
Dave - 1/14/2021
eleonora_parr - 1/14/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora

No, two input devices in a single <trial> are not possible. However, I don't see where or why you need both keyboard and mouse in

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

That trial, as you currently have it, does not register any responses to begin with, validresponse is set to no response.

You wrote: "They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond)."

That is, <trial safe_3_backward_inc_respond> does not need two input devices, it only needs the mouse. <trial safe_3_backward_inc> can be set to keyboard and register any potential key release as well as log mouse coordinates as demonstrated.

Oh, sorry, I probably did not express myself well. They have to keep the spacebar pressed for the whole trial safe_3_backward_inc and they can release it when the trial safe_3_backward_inc_respond begins, which is when they have to make the mouse response.
So the potential spacebar release should be recorded during both safe_3_backward_inc AND safe_3_backward_inc_respond, to make sure that they released the spacebar just before making the mouse response (that they did not release it too early) 
However, this trick allow us to check anyway if they released the spacebar before the begin of the trial safe_3_backward_inc_respond, so in some way it kinda solve the problem :-)
Greatly appreciated, thank you so much!

Eleonora

Hi Dave,
Sorry to bother again, but I am having problems in recording the spacebar release in the data: I followed a couple of examples that I found in the forum (https://www.millisecond.com/forums/Topic15810.aspx#15812 and https://www.millisecond.com/forums/Topic16749.aspx#16752) 
For now my code is:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>
<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>


<data>
/ columns = [date,time,group,subject, display.canvaswidth, display.canvasheight, session, build, blocknum, blockcode, trialnum,trialcode, pretrialpause,
posttrialpause, trialduration, values.Actiontype, values.congruency, values.object, values.length, values.fixate_duration, values.spacebarpresscount,
stimulusitem, stimulusitem, stimulusitem, stimulusitem,stimulusitem,stimulusitem,stimulusitem
stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset
correct, latency, response,values.x,values.y]
</data>

But when I run the code, the column spacebarpresscount is always empty. I've also tried /spacebarpresscount= 0 instead of /spacebarpresscount= "", unfortunately nothing changed..
Any suggestion?

Thank you so much!

Please provide code that is complete enough to actually run.

One problem you have here

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

is that there's actually no time in the trial during which it would poll for any response. By default, Inquisit only starts accepting responses once the trial has completed its entire stimulus presentation sequence, here: after/coinciding with the onset of picture.safe_minus_third_frame. That, however, is also the time where the trial actually ends. If you want to accept responses *while* the stimulus presentation sequence is still in progress, from the very start of the <trial> object, set /beginresponsetime = -1.

https://www.millisecond.com/support/docs/v6/html/language/attributes/beginresponsetime.htm

Then, depending on what you want to happen when a response is registered (here: release of the space bar), you may in addition have to change the trial's /responseinterrupt.

https://www.millisecond.com/support/docs/v6/html/language/attributes/responseinterrupt.htm

The default is immediate, i.e. the trial will not present the remaining stimuli once a response has been registered. If you want the trial to complete the stimulus presentation sequence instead, set /responseinterrupt = frames.

In sum, something like this:

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [
    trial.safe_3_backward_inc.resetstimulusframes();
    trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ beginresponsetime = -1
/ responseinterrupt = frames
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>


Hi Dave,
I just noticed that with the option "resetsframes" the timing of each frame presentation does not last as specified in the trial: each frame should last 83.5 ms.
In the log file I noticed that sometimes each frame lasts 70/71 ms, sometimes it lasts 83.5 ms. I also tried to change stimulusframes with stimulustimes and I also tried to set this interval "fixed" in the values (I thought that the problem could be that the values were updated everytime at the beginning of each trial), but nothing changed, there is always in the trial a frame that lasts less than 83.5 ms. (Refresh rate is currently 60 Hz) 
May I ask you why this could happen?

Here is the code:

<list forward>
/ items = [noreplace(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)]
/ selectionrate = block
/ resetinterval = 1
</list>

<picture safe_minus_fifth_frame>
/ items = safe_minus_fifth_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<picture pain_minus_fifth_frame>
/ items = pain_minus_fifth_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_minus_fifth_frame>
/1 = "bon05.jpg"
/2 = "bon06.jpg"
/3 = "bon07.jpg"
/4 = "bon08.jpg"
/5 = "bon09.jpg"
/6 = "gln05.jpg"
/7= "gln06.jpg"
/8 = "gln07.jpg"
/9= "gln08.jpg"
/10 = "gln09.jpg"
/11= "knn05.jpg"
/12= "knn06.jpg"
/13 = "knn07.jpg"
/14= "knn08.jpg"
/15 = "knn09.jpg"
/16= "wgn05.jpg"
/17= "wgn05.jpg"
/18 = "wgn07.jpg"
/19= "wgn08.jpg"
/20 = "wgn09.jpg"
</item>

<item pain_minus_fifth_frame>
/1 = "cap05.jpg"
/2 = "cap06.jpg"
/3 = "cap07.jpg"
/4 = "cap08.jpg"
/5 = "cap09.jpg"
/6 = "glp05.jpg"
/7="glp06.jpg"
/8 = "glp07.jpg"
/9= "glp08.jpg"
/10 = "glp09.jpg"
/11 = "knp05.jpg"
/12= "knp06.jpg"
/13 = "knp07.jpg"
/14= "knp08.jpg"
/15 = "knp09.jpg"
/16= "wgp05.jpg"
/17= "wgp06.jpg"
/18 ="wgp07.jpg"
/19= "wgp08.jpg"
/20 = "wgp09.jpg"
</item>

<picture pain_minus_fourth_frame>
/ items = pain_minus_fourth_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<picture safe_minus_fourth_frame>
/ items = safe_minus_fourth_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_minus_fourth_frame>
/1 = "bon07.jpg"
/2 = "bon08.jpg"
/3 = "bon09.jpg"
/4 = "bon10.jpg"
/5 = "bon11.jpg"
/6 = "gln07.jpg"
/7= "gln08.jpg"
/8= "gln09.jpg"
/9= "gln10.jpg"
/10 = "gln11.jpg"
/11= "knn07.jpg"
/12= "knn08.jpg"
/13 = "knn09.jpg"
/14= "knn10.jpg"
/15 = "knn11.jpg"
/16= "wgn07.jpg"
/17= "wgn08.jpg"
/18 = "wgn09.jpg"
/19= "wgn10.jpg"
/20 = "wgn11.jpg"
</item>

<item pain_minus_fourth_frame>
/1 = "cap07.jpg"
/2= "cap08.jpg"
/3= "cap09.jpg"
/4= "cap10.jpg"
/5 = "cap11.jpg"
/6 = "glp07.jpg"
/7= "glp08.jpg"
/8 = "glp09.jpg"
/9= "glp10.jpg"
/10 = "glp11.jpg"
/11= "knp07.jpg"
/12= "knp08.jpg"
/13 = "knp09.jpg"
/14= "knp10.jpg"
/15 = "knp11.jpg"
/16= "wgp07.jpg"
/17= "wgp08.jpg"
/18 = "wgp09.jpg"
/19= "wgp10.jpg"
/20 = "wgp11.jpg"
</item>

<picture safe_minus_third_frame>
/ items = safe_minus_third_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<picture pain_minus_third_frame>
/ items = pain_minus_third_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_minus_third_frame>
/1 = "bon09.jpg"
/2 = "bon10.jpg"
/3 = "bon11.jpg"
/4 = "bon12.jpg"
/5 = "bon13.jpg"
/6 = "gln09.jpg"
/7= "gln10.jpg"
/8 = "gln11.jpg"
/9= "gln12.jpg"
/10 = "gln13.jpg"
/11= "knn09.jpg"
/12= "knn10.jpg"
/13 = "knn11.jpg"
/14= "knn12.jpg"
/15 = "knn13.jpg"
/16= "wgn09.jpg"
/17= "wgn10.jpg"
/18 = "wgn11.jpg"
/19= "wgn12.jpg"
/20 = "wgn13.jpg"
</item>

<item pain_minus_third_frame>
/1 = "cap09.jpg"
/2 = "cap10.jpg"
/3 = "cap11.jpg"
/4 = "cap12.jpg"
/5 = "cap13.jpg"
/6 = "glp09.jpg"
/7= "glp10.jpg"
/8 = "glp11.jpg"
/9= "glp12.jpg"
/10 = "glp13.jpg"
/11= "knp09.jpg"
/12= "knp10.jpg"
/13 = "knp11.jpg"
/14= "knp12.jpg"
/15 = "knp13.jpg"
/16= "wgp09.jpg"
/17= "wgp10.jpg"
/18 = "wgp11.jpg"
/19= "wgp12.jpg"
/20 = "wgp13.jpg"
</item>


<picture pain_minus_second_frame>
/ items = pain_minus_second_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<picture safe_minus_second_frame>
/ items = safe_minus_second_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_minus_second_frame>
/1 = "bon11.jpg"
/2 = "bon12.jpg"
/3 = "bon13.jpg"
/4 = "bon14.jpg"
/5 = "bon15.jpg"
/6 = "gln11.jpg"
/7= "gln12.jpg"
/8 = "gln13.jpg"
/9= "gln14.jpg"
/10 = "gln15.jpg"
/11= "knn11.jpg"
/12= "knn12.jpg"
/13 = "knn13.jpg"
/14= "knn14.jpg"
/15 = "knn15.jpg"
/16= "wgn11.jpg"
/17= "wgn12.jpg"
/18 = "wgn13.jpg"
/19= "wgn14.jpg"
/20 = "wgn15.jpg"

</item>

<item pain_minus_second_frame>
/1 = "cap11.jpg"
/2= "cap12.jpg"
/3 = "cap13.jpg"
/4 = "cap14.jpg"
/5 = "cap15.jpg"
/6 = "glp11.jpg"
/7= "glp12.jpg"
/8 = "glp13.jpg"
/9= "glp14.jpg"
/10 = "glp15.jpg"
/11= "knp11.jpg"
/12= "knp12.jpg"
/13 = "knp13.jpg"
/14= "knp14.jpg"
/15 = "knp15.jpg"
/16= "wgp11.jpg"
/17= "wgp12.jpg"
/18 = "wgp13.jpg"
/19= "wgp14.jpg"
/20 = "wgp15.jpg"
</item>



<picture safe_first_frame>
/ items = safe_first_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>


<picture pain_first_frame>
/ items = pain_first_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_first_frame>
/1 = "bon13.jpg"
/2 = "bon14.jpg"
/3 = "bon15.jpg"
/4 = "bon16.jpg"
/5 = "bon17.jpg"
/6 = "gln13.jpg"
/7= "gln14.jpg"
/8 = "gln15.jpg"
/9= "gln16.jpg"
/10 = "gln17.jpg"
/11= "knn13.jpg"
/12= "knn14.jpg"
/13 = "knn15.jpg"
/14= "knn16.jpg"
/15 = "knn17.jpg"
/16= "wgn13.jpg"
/17= "wgn14.jpg"
/18 = "wgn15.jpg"
/19= "wgn16.jpg"
/20 = "wgn17.jpg"
</item>


<item pain_first_frame>
/1 = "cap13.jpg"
/2 = "cap14.jpg"
/3 = "cap15.jpg"
/4 = "cap16.jpg"
/5 = "cap17.jpg"
/6 = "glp13.jpg"
/7= "glp14.jpg"
/8 = "glp15.jpg"
/9= "glp16.jpg"
/10 = "glp17.jpg"
/11= "knp13.jpg"
/12= "knp14.jpg"
/13 = "knp15.jpg"
/14= "knp16.jpg"
/15 = "knp17.jpg"
/16= "wgp13.jpg"
/17= "wgp14.jpg"
/18 = "wgp15.jpg"
/19= "wgp16.jpg"
/20 = "wgp17.jpg"
</item>




<picture pain_plus_second_frame>
/ items = pain_plus_second_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture safe_plus_second_frame>
/ items = safe_plus_second_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<item safe_plus_second_frame>
/1 = "bon15.jpg"
/2 = "bon16.jpg"
/3 = "bon17.jpg"
/4 = "bon18.jpg"
/5 = "bon19.jpg"
/6 = "gln15.jpg"
/7= "gln16.jpg"
/8 = "gln17.jpg"
/9= "gln18.jpg"
/10 = "gln19.jpg"
/11= "knn15.jpg"
/12= "knn16.jpg"
/13 = "knn17.jpg"
/14= "knn18.jpg"
/15 = "knn19.jpg"
/16= "wgn15.jpg"
/17= "wgn16.jpg"
/18 = "wgn17.jpg"
/19= "wgn18.jpg"
/20 = "wgn19.jpg"
</item>

<item pain_plus_second_frame>
/1= "cap15.jpg"
/2= "cap16.jpg"
/3 = "cap17.jpg"
/4= "cap18.jpg"
/5 = "cap19.jpg"
/6 = "glp15.jpg"
/7= "glp16.jpg"
/8 = "glp17.jpg"
/9= "glp18.jpg"
/10 = "glp19.jpg"
/11= "knp15.jpg"
/12= "knp16.jpg"
/13 = "knp17.jpg"
/14= "knp18.jpg"
/15 = "knp19.jpg"
/16= "wgp15.jpg"
/17= "wgp16.jpg"
/18 = "wgp17.jpg"
/19= "wgp18.jpg"
/20 = "wgp19.jpg"
</item>

<picture pain_plus_third_frame>
/ items = pain_plus_third_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture safe_plus_third_frame>
/ items = safe_plus_third_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<item safe_plus_third_frame>
/1 = "bon17.jpg"
/2 = "bon18.jpg"
/3 = "bon19.jpg"
/4 = "bon20.jpg"
/5 = "bon21.jpg"
/6 = "gln17.jpg"
/7= "gln18.jpg"
/8 = "gln19.jpg"
/9= "gln20.jpg"
/10 = "gln21.jpg"
/11= "knn17.jpg"
/12= "knn18.jpg"
/13 = "knn19.jpg"
/14= "knn20.jpg"
/15 = "knn21.jpg"
/16= "wgn17.jpg"
/17= "wgn18.jpg"
/18 = "wgn19.jpg"
/19= "wgn20.jpg"
/20 = "wgn21.jpg"
</item>

<item pain_plus_third_frame>
/1 = "cap17.jpg"
/2 = "cap18.jpg"
/3 = "cap19.jpg"
/4= "cap20.jpg"
/5 = "cap21.jpg"
/6 = "glp17.jpg"
/7= "glp18.jpg"
/8 = "glp19.jpg"
/9= "glp20.jpg"
/10 = "glp21.jpg"
/11= "knp17.jpg"
/12= "knp18.jpg"
/13 = "knp19.jpg"
/14= "knp20.jpg"
/15 = "knp21.jpg"
/16= "wgp17.jpg"
/17= "wgp18.jpg"
/18 = "wgp19.jpg"
/19= "wgp20.jpg"
/20 = "wgp21.jpg"
</item>

<picture safe_plus_fourth_frame>
/ items = safe_plus_fourth_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture pain_plus_fourth_frame>
/ items = pain_plus_fourth_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<item safe_plus_fourth_frame>
/1 = "bon19.jpg"
/2 = "bon20.jpg"
/3 = "bon21.jpg"
/4 = "bon22.jpg"
/5 = "bon23.jpg"
/6 = "gln19.jpg"
/7= "gln20.jpg"
/8 = "gln21.jpg"
/9= "gln22.jpg"
/10 = "gln23.jpg"
/11= "knn19.jpg"
/12= "knn20.jpg"
/13 = "knn21.jpg"
/14= "knn22.jpg"
/15 = "knn23.jpg"
/16= "wgn19.jpg"
/17= "wgn20.jpg"
/18 = "wgn21.jpg"
/19= "wgn22.jpg"
/20 = "wgn23.jpg"
</item>

<item pain_plus_fourth_frame>
/1 = "cap19.jpg"
/2 = "cap20.jpg"
/3 = "cap21.jpg"
/4 = "cap22.jpg"
/5 = "cap23.jpg"
/6 = "glp19.jpg"
/7= "glp20.jpg"
/8 = "glp21.jpg"
/9= "glp22.jpg"
/10 = "glp23.jpg"
/11= "knp19.jpg"
/12= "knp20.jpg"
/13 = "knp21.jpg"
/14= "knp22.jpg"
/15 = "knp23.jpg"
/16= "wgp19.jpg"
/17= "wgp20.jpg"
/18 = "wgp21.jpg"
/19= "wgp22.jpg"
/20 = "wgp23.jpg"
</item>

<picture safe_plus_fifth_frame>
/ items = safe_plus_fifth_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture pain_plus_fifth_frame>
/ items = pain_plus_fifth_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<item safe_plus_fifth_frame>
/1 = "bon21.jpg"
/2 = "bon22.jpg"
/3 = "bon23.jpg"
/4 = "bon24.jpg"
/5 = "bon25.jpg"
/6 = "gln21.jpg"
/7= "gln22.jpg"
/8 = "gln23.jpg"
/9= "gln24.jpg"
/10 = "gln25.jpg"
/11= "knn21.jpg"
/12= "knn22.jpg"
/13 = "knn23.jpg"
/14= "knn24.jpg"
/15 = "knn25.jpg"
/16= "wgn21.jpg"
/17= "wgn22.jpg"
/18 = "wgn23.jpg"
/19= "wgn24.jpg"
/20 = "wgn25.jpg"
</item>

<item pain_plus_fifth_frame>
/1 = "cap21.jpg"
/2 = "cap22.jpg"
/3 = "cap23.jpg"
/4 = "cap24.jpg"
/5 = "cap25.jpg"
/6 = "glp21.jpg"
/7= "glp22.jpg"
/8 = "glp23.jpg"
/9= "glp24.jpg"
/10 = "glp25.jpg"
/11= "knp21.jpg"
/12= "knp22.jpg"
/13 = "knp23.jpg"
/14= "knp24.jpg"
/15 = "knp25.jpg"
/16= "wgp21.jpg"
/17= "wgp22.jpg"
/18 = "wgp23.jpg"
/19= "wgp24.jpg"
/20 = "wgp25.jpg"
</item>

<item safe_w>
/1 = "bonwithouthand.jpg"
/2 = "bonwithouthand.jpg"
/3 = "bonwithouthand.jpg"
/4 = "bonwithouthand.jpg"
/5 = "bonwithouthand.jpg"
/6 = "glnwithouthand.jpg"
/7 = "glnwithouthand.jpg"
/8 = "glnwithouthand.jpg"
/9 = "glnwithouthand.jpg"
/10 = "glnwithouthand.jpg"
/11= "knnwithouthand.jpg"
/12= "knnwithouthand.jpg"
/13 = "knnwithouthand.jpg"
/14= "knnwithouthand.jpg"
/15 = "knnwithouthand.jpg"
/16= "wgnwithouthand.jpg"
/17= "wgnwithouthand.jpg"
/18 = "wgnwithouthand.jpg"
/19= "wgnwithouthand.jpg"
/20 = "wgnwithouthand.jpg"
</item>

<item pain_w>
/1 = "capwithouthand.jpg"
/2 = "capwithouthand.jpg"
/3 = "capwithouthand.jpg"
/4 = "capwithouthand.jpg"
/5 = "capwithouthand.jpg"
/6 = "glpwithouthand.jpg"
/7= "glpwithouthand.jpg"
/8 = "glpwithouthand.jpg"
/9= "glpwithouthand.jpg"
/10 = "glpwithouthand.jpg"
/11= "knpwithouthand.jpg"
/12= "knpwithouthand.jpg"
/13 = "knpwithouthand.jpg"
/14= "knpwithouthand.jpg"
/15 = "knpwithouthand.jpg"
/16= "wgpwithouthand.jpg"
/17= "wgpwithouthand.jpg"
/18 = "wgpwithouthand.jpg"
/19= "wgpwithouthand.jpg"
/20= "wgpwithouthand.jpg"
</item>

<picture safe_w>
/ items = safe_w
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture pain_w>
/ items = pain_w
/ select = list.forward
/ size = (100%, 100%)
</picture>


<sound take>
/ items = ("illtakeit.wav")
</sound>

<sound leave>
/ items = ("illleaveit.wav")
</sound>

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = ""
/time_second_frame = ""
/time_third_frame = ""
/time_fourth_frame = ""
/time_fifth_frame = ""
/spacebarpresscount= ""
</values>


****************************************

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [values.time_sound = round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83;
                trial.safe_3_backward_inc.resetstimulusframes();
                trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<trial safe_3_backward_con>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Congruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_con.resetstimulusframes();
                trial.safe_3_backward_con.insertstimulustime(sound.leave, values.time_sound);
                trial.safe_3_backward_con.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_con.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ isvalidresponse = [if(trial.safe_3_backward_con.response == -57){values.spacebarpresscount += 1;}]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_con_respond;]
</trial>
<trial safe_3_backward_con_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_con_respond.responsex;values.y=trial.safe_3_backward_con_respond.responsey;]
/ branch = [trial.space;]
</trial>




<trial safe_4_backward_inc>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83; values.time_fourth_frame = values.time_third_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 4]
/ ontrialbegin = [trial.safe_4_backward_inc.resetstimulusframes();
                trial.safe_4_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_4_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_4_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);
                trial.safe_4_backward_inc.insertstimulustime(picture.safe_minus_fourth_frame, values.time_fourth_frame)]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ isvalidresponse = [if(trial.safe_4_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_fourth_frame
/ branch = [trial.safe_4_backward_inc_respond;]
</trial>
<trial safe_4_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_4_backward_inc_respond.responsex;values.y=trial.safe_4_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<trial safe_4_backward_con>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83; values.time_fourth_frame = values.time_third_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount="";values.congruency = "Congruent"; values.object = "safe"; values.length = 4]
/ ontrialbegin = [trial.safe_4_backward_con.resetstimulusframes();
                trial.safe_4_backward_con.insertstimulustime(sound.leave, values.time_sound);
                trial.safe_4_backward_con.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_4_backward_con.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);
                trial.safe_4_backward_con.insertstimulustime(picture.safe_minus_fourth_frame, values.time_fourth_frame)]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ isvalidresponse = [if(trial.safe_4_backward_con.response == -57){values.spacebarpresscount += 1;}]
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_fourth_frame
/ branch = [trial.safe_4_backward_con_respond;]
</trial>
<trial safe_4_backward_con_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_4_backward_con_respond.responsex;values.y=trial.safe_4_backward_con_respond.responsey;]
/ branch = [trial.space;]
</trial>

<trial safe_5_backward_inc>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83; values.time_fourth_frame = values.time_third_frame+83; values.time_fifth_frame=values.time_fourth_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount="";values.congruency = "Incongruent"; values.object = "safe"; values.length = 5]
/ ontrialbegin = [trial.safe_5_backward_inc.resetstimulusframes();
                trial.safe_5_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_5_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_5_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);
                trial.safe_5_backward_inc.insertstimulustime(picture.safe_minus_fourth_frame, values.time_fourth_frame);
                trial.safe_5_backward_inc.insertstimulustime(picture.safe_minus_fifth_frame, values.time_fifth_frame)]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ isvalidresponse = [if(trial.safe_5_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_fifth_frame
/ branch = [trial.safe_5_backward_inc_respond;]
</trial>
<trial safe_5_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_5_backward_inc_respond.responsex;values.y=trial.safe_5_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<trial safe_5_backward_con>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83; values.time_fourth_frame = values.time_third_frame+83; values.time_fifth_frame=values.time_fourth_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount="";values.congruency = "Congruent"; values.object = "safe"; values.length = 5]
/ ontrialbegin = [trial.safe_5_backward_con.resetstimulusframes();
                trial.safe_5_backward_con.insertstimulustime(sound.leave, values.time_sound);
                trial.safe_5_backward_con.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_5_backward_con.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);
                trial.safe_5_backward_con.insertstimulustime(picture.safe_minus_fourth_frame, values.time_fourth_frame);
                trial.safe_5_backward_con.insertstimulustime(picture.safe_minus_fifth_frame, values.time_fifth_frame)]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ isvalidresponse = [if(trial.safe_5_backward_con.response == -57){values.spacebarpresscount += 1;}]
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_fifth_frame
/ branch = [trial.safe_5_backward_con_respond;]
</trial>
<trial safe_5_backward_con_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_5_backward_con_respond.responsex;values.y=trial.safe_5_backward_con_respond.responsey;]
/ branch = [trial.space;]
</trial>

<block space>
/trials = [1=space]
</block>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>
<block 3_safe_backward_inc>
/ trials = [1= sequence(fixate,safe_3_backward_inc)]
</block>

<block 4_safe_backward_con>
/ trials = [1= sequence(fixate,safe_4_backward_con)]
</block>
<block 4_safe_backward_inc>
/ trials = [1= sequence(fixate,safe_4_backward_inc)]
</block>

<block 5_safe_backward_con>
/ trials = [1= sequence(fixate,safe_5_backward_con)]
</block>
<block 5_safe_backward_inc>
/ trials = [1= sequence(fixate,safe_5_backward_inc)]
</block>


Thanks a lot,

Eleonora
By Dave - 1/15/2021

eleonora_parr - 1/15/2021
Dave - 1/14/2021
Dave - 1/14/2021
eleonora_parr - 1/14/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora

No, two input devices in a single <trial> are not possible. However, I don't see where or why you need both keyboard and mouse in

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

That trial, as you currently have it, does not register any responses to begin with, validresponse is set to no response.

You wrote: "They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond)."

That is, <trial safe_3_backward_inc_respond> does not need two input devices, it only needs the mouse. <trial safe_3_backward_inc> can be set to keyboard and register any potential key release as well as log mouse coordinates as demonstrated.

Oh, sorry, I probably did not express myself well. They have to keep the spacebar pressed for the whole trial safe_3_backward_inc and they can release it when the trial safe_3_backward_inc_respond begins, which is when they have to make the mouse response.
So the potential spacebar release should be recorded during both safe_3_backward_inc AND safe_3_backward_inc_respond, to make sure that they released the spacebar just before making the mouse response (that they did not release it too early) 
However, this trick allow us to check anyway if they released the spacebar before the begin of the trial safe_3_backward_inc_respond, so in some way it kinda solve the problem :-)
Greatly appreciated, thank you so much!

Eleonora

Hi Dave,
Sorry to bother again, but I am having problems in recording the spacebar release in the data: I followed a couple of examples that I found in the forum (https://www.millisecond.com/forums/Topic15810.aspx#15812 and https://www.millisecond.com/forums/Topic16749.aspx#16752) 
For now my code is:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>
<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>


<data>
/ columns = [date,time,group,subject, display.canvaswidth, display.canvasheight, session, build, blocknum, blockcode, trialnum,trialcode, pretrialpause,
posttrialpause, trialduration, values.Actiontype, values.congruency, values.object, values.length, values.fixate_duration, values.spacebarpresscount,
stimulusitem, stimulusitem, stimulusitem, stimulusitem,stimulusitem,stimulusitem,stimulusitem
stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset
correct, latency, response,values.x,values.y]
</data>

But when I run the code, the column spacebarpresscount is always empty. I've also tried /spacebarpresscount= 0 instead of /spacebarpresscount= "", unfortunately nothing changed..
Any suggestion?

Thank you so much!

Please provide code that is complete enough to actually run.

One problem you have here

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

is that there's actually no time in the trial during which it would poll for any response. By default, Inquisit only starts accepting responses once the trial has completed its entire stimulus presentation sequence, here: after/coinciding with the onset of picture.safe_minus_third_frame. That, however, is also the time where the trial actually ends. If you want to accept responses *while* the stimulus presentation sequence is still in progress, from the very start of the <trial> object, set /beginresponsetime = -1.

https://www.millisecond.com/support/docs/v6/html/language/attributes/beginresponsetime.htm

Then, depending on what you want to happen when a response is registered (here: release of the space bar), you may in addition have to change the trial's /responseinterrupt.

https://www.millisecond.com/support/docs/v6/html/language/attributes/responseinterrupt.htm

The default is immediate, i.e. the trial will not present the remaining stimuli once a response has been registered. If you want the trial to complete the stimulus presentation sequence instead, set /responseinterrupt = frames.

In sum, something like this:

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [
    trial.safe_3_backward_inc.resetstimulusframes();
    trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ beginresponsetime = -1
/ responseinterrupt = frames
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>


Hi Dave,
I just noticed that with the option "resetsframes" the timing of each frame presentation does not last as specified in the trial: each frame should last 83.5 ms.
In the log file I noticed that sometimes each frame lasts 70/71 ms, sometimes it lasts 83.5 ms. I also tried to change stimulusframes with stimulustimes and I also tried to set this interval "fixed" in the values (I thought that the problem could be that the values were updated everytime at the beginning of each trial), but nothing changed, there is always in the trial a frame that lasts less than 83.5 ms. (Refresh rate is currently 60 Hz) 
May I ask you why this could happen?

Here is the code:

<list forward>
/ items = [noreplace(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)]
/ selectionrate = block
/ resetinterval = 1
</list>

<picture safe_minus_fifth_frame>
/ items = safe_minus_fifth_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<picture pain_minus_fifth_frame>
/ items = pain_minus_fifth_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_minus_fifth_frame>
/1 = "bon05.jpg"
/2 = "bon06.jpg"
/3 = "bon07.jpg"
/4 = "bon08.jpg"
/5 = "bon09.jpg"
/6 = "gln05.jpg"
/7= "gln06.jpg"
/8 = "gln07.jpg"
/9= "gln08.jpg"
/10 = "gln09.jpg"
/11= "knn05.jpg"
/12= "knn06.jpg"
/13 = "knn07.jpg"
/14= "knn08.jpg"
/15 = "knn09.jpg"
/16= "wgn05.jpg"
/17= "wgn05.jpg"
/18 = "wgn07.jpg"
/19= "wgn08.jpg"
/20 = "wgn09.jpg"
</item>

<item pain_minus_fifth_frame>
/1 = "cap05.jpg"
/2 = "cap06.jpg"
/3 = "cap07.jpg"
/4 = "cap08.jpg"
/5 = "cap09.jpg"
/6 = "glp05.jpg"
/7="glp06.jpg"
/8 = "glp07.jpg"
/9= "glp08.jpg"
/10 = "glp09.jpg"
/11 = "knp05.jpg"
/12= "knp06.jpg"
/13 = "knp07.jpg"
/14= "knp08.jpg"
/15 = "knp09.jpg"
/16= "wgp05.jpg"
/17= "wgp06.jpg"
/18 ="wgp07.jpg"
/19= "wgp08.jpg"
/20 = "wgp09.jpg"
</item>

<picture pain_minus_fourth_frame>
/ items = pain_minus_fourth_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<picture safe_minus_fourth_frame>
/ items = safe_minus_fourth_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_minus_fourth_frame>
/1 = "bon07.jpg"
/2 = "bon08.jpg"
/3 = "bon09.jpg"
/4 = "bon10.jpg"
/5 = "bon11.jpg"
/6 = "gln07.jpg"
/7= "gln08.jpg"
/8= "gln09.jpg"
/9= "gln10.jpg"
/10 = "gln11.jpg"
/11= "knn07.jpg"
/12= "knn08.jpg"
/13 = "knn09.jpg"
/14= "knn10.jpg"
/15 = "knn11.jpg"
/16= "wgn07.jpg"
/17= "wgn08.jpg"
/18 = "wgn09.jpg"
/19= "wgn10.jpg"
/20 = "wgn11.jpg"
</item>

<item pain_minus_fourth_frame>
/1 = "cap07.jpg"
/2= "cap08.jpg"
/3= "cap09.jpg"
/4= "cap10.jpg"
/5 = "cap11.jpg"
/6 = "glp07.jpg"
/7= "glp08.jpg"
/8 = "glp09.jpg"
/9= "glp10.jpg"
/10 = "glp11.jpg"
/11= "knp07.jpg"
/12= "knp08.jpg"
/13 = "knp09.jpg"
/14= "knp10.jpg"
/15 = "knp11.jpg"
/16= "wgp07.jpg"
/17= "wgp08.jpg"
/18 = "wgp09.jpg"
/19= "wgp10.jpg"
/20 = "wgp11.jpg"
</item>

<picture safe_minus_third_frame>
/ items = safe_minus_third_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<picture pain_minus_third_frame>
/ items = pain_minus_third_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_minus_third_frame>
/1 = "bon09.jpg"
/2 = "bon10.jpg"
/3 = "bon11.jpg"
/4 = "bon12.jpg"
/5 = "bon13.jpg"
/6 = "gln09.jpg"
/7= "gln10.jpg"
/8 = "gln11.jpg"
/9= "gln12.jpg"
/10 = "gln13.jpg"
/11= "knn09.jpg"
/12= "knn10.jpg"
/13 = "knn11.jpg"
/14= "knn12.jpg"
/15 = "knn13.jpg"
/16= "wgn09.jpg"
/17= "wgn10.jpg"
/18 = "wgn11.jpg"
/19= "wgn12.jpg"
/20 = "wgn13.jpg"
</item>

<item pain_minus_third_frame>
/1 = "cap09.jpg"
/2 = "cap10.jpg"
/3 = "cap11.jpg"
/4 = "cap12.jpg"
/5 = "cap13.jpg"
/6 = "glp09.jpg"
/7= "glp10.jpg"
/8 = "glp11.jpg"
/9= "glp12.jpg"
/10 = "glp13.jpg"
/11= "knp09.jpg"
/12= "knp10.jpg"
/13 = "knp11.jpg"
/14= "knp12.jpg"
/15 = "knp13.jpg"
/16= "wgp09.jpg"
/17= "wgp10.jpg"
/18 = "wgp11.jpg"
/19= "wgp12.jpg"
/20 = "wgp13.jpg"
</item>


<picture pain_minus_second_frame>
/ items = pain_minus_second_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<picture safe_minus_second_frame>
/ items = safe_minus_second_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_minus_second_frame>
/1 = "bon11.jpg"
/2 = "bon12.jpg"
/3 = "bon13.jpg"
/4 = "bon14.jpg"
/5 = "bon15.jpg"
/6 = "gln11.jpg"
/7= "gln12.jpg"
/8 = "gln13.jpg"
/9= "gln14.jpg"
/10 = "gln15.jpg"
/11= "knn11.jpg"
/12= "knn12.jpg"
/13 = "knn13.jpg"
/14= "knn14.jpg"
/15 = "knn15.jpg"
/16= "wgn11.jpg"
/17= "wgn12.jpg"
/18 = "wgn13.jpg"
/19= "wgn14.jpg"
/20 = "wgn15.jpg"

</item>

<item pain_minus_second_frame>
/1 = "cap11.jpg"
/2= "cap12.jpg"
/3 = "cap13.jpg"
/4 = "cap14.jpg"
/5 = "cap15.jpg"
/6 = "glp11.jpg"
/7= "glp12.jpg"
/8 = "glp13.jpg"
/9= "glp14.jpg"
/10 = "glp15.jpg"
/11= "knp11.jpg"
/12= "knp12.jpg"
/13 = "knp13.jpg"
/14= "knp14.jpg"
/15 = "knp15.jpg"
/16= "wgp11.jpg"
/17= "wgp12.jpg"
/18 = "wgp13.jpg"
/19= "wgp14.jpg"
/20 = "wgp15.jpg"
</item>



<picture safe_first_frame>
/ items = safe_first_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>


<picture pain_first_frame>
/ items = pain_first_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_first_frame>
/1 = "bon13.jpg"
/2 = "bon14.jpg"
/3 = "bon15.jpg"
/4 = "bon16.jpg"
/5 = "bon17.jpg"
/6 = "gln13.jpg"
/7= "gln14.jpg"
/8 = "gln15.jpg"
/9= "gln16.jpg"
/10 = "gln17.jpg"
/11= "knn13.jpg"
/12= "knn14.jpg"
/13 = "knn15.jpg"
/14= "knn16.jpg"
/15 = "knn17.jpg"
/16= "wgn13.jpg"
/17= "wgn14.jpg"
/18 = "wgn15.jpg"
/19= "wgn16.jpg"
/20 = "wgn17.jpg"
</item>


<item pain_first_frame>
/1 = "cap13.jpg"
/2 = "cap14.jpg"
/3 = "cap15.jpg"
/4 = "cap16.jpg"
/5 = "cap17.jpg"
/6 = "glp13.jpg"
/7= "glp14.jpg"
/8 = "glp15.jpg"
/9= "glp16.jpg"
/10 = "glp17.jpg"
/11= "knp13.jpg"
/12= "knp14.jpg"
/13 = "knp15.jpg"
/14= "knp16.jpg"
/15 = "knp17.jpg"
/16= "wgp13.jpg"
/17= "wgp14.jpg"
/18 = "wgp15.jpg"
/19= "wgp16.jpg"
/20 = "wgp17.jpg"
</item>




<picture pain_plus_second_frame>
/ items = pain_plus_second_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture safe_plus_second_frame>
/ items = safe_plus_second_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<item safe_plus_second_frame>
/1 = "bon15.jpg"
/2 = "bon16.jpg"
/3 = "bon17.jpg"
/4 = "bon18.jpg"
/5 = "bon19.jpg"
/6 = "gln15.jpg"
/7= "gln16.jpg"
/8 = "gln17.jpg"
/9= "gln18.jpg"
/10 = "gln19.jpg"
/11= "knn15.jpg"
/12= "knn16.jpg"
/13 = "knn17.jpg"
/14= "knn18.jpg"
/15 = "knn19.jpg"
/16= "wgn15.jpg"
/17= "wgn16.jpg"
/18 = "wgn17.jpg"
/19= "wgn18.jpg"
/20 = "wgn19.jpg"
</item>

<item pain_plus_second_frame>
/1= "cap15.jpg"
/2= "cap16.jpg"
/3 = "cap17.jpg"
/4= "cap18.jpg"
/5 = "cap19.jpg"
/6 = "glp15.jpg"
/7= "glp16.jpg"
/8 = "glp17.jpg"
/9= "glp18.jpg"
/10 = "glp19.jpg"
/11= "knp15.jpg"
/12= "knp16.jpg"
/13 = "knp17.jpg"
/14= "knp18.jpg"
/15 = "knp19.jpg"
/16= "wgp15.jpg"
/17= "wgp16.jpg"
/18 = "wgp17.jpg"
/19= "wgp18.jpg"
/20 = "wgp19.jpg"
</item>

<picture pain_plus_third_frame>
/ items = pain_plus_third_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture safe_plus_third_frame>
/ items = safe_plus_third_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<item safe_plus_third_frame>
/1 = "bon17.jpg"
/2 = "bon18.jpg"
/3 = "bon19.jpg"
/4 = "bon20.jpg"
/5 = "bon21.jpg"
/6 = "gln17.jpg"
/7= "gln18.jpg"
/8 = "gln19.jpg"
/9= "gln20.jpg"
/10 = "gln21.jpg"
/11= "knn17.jpg"
/12= "knn18.jpg"
/13 = "knn19.jpg"
/14= "knn20.jpg"
/15 = "knn21.jpg"
/16= "wgn17.jpg"
/17= "wgn18.jpg"
/18 = "wgn19.jpg"
/19= "wgn20.jpg"
/20 = "wgn21.jpg"
</item>

<item pain_plus_third_frame>
/1 = "cap17.jpg"
/2 = "cap18.jpg"
/3 = "cap19.jpg"
/4= "cap20.jpg"
/5 = "cap21.jpg"
/6 = "glp17.jpg"
/7= "glp18.jpg"
/8 = "glp19.jpg"
/9= "glp20.jpg"
/10 = "glp21.jpg"
/11= "knp17.jpg"
/12= "knp18.jpg"
/13 = "knp19.jpg"
/14= "knp20.jpg"
/15 = "knp21.jpg"
/16= "wgp17.jpg"
/17= "wgp18.jpg"
/18 = "wgp19.jpg"
/19= "wgp20.jpg"
/20 = "wgp21.jpg"
</item>

<picture safe_plus_fourth_frame>
/ items = safe_plus_fourth_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture pain_plus_fourth_frame>
/ items = pain_plus_fourth_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<item safe_plus_fourth_frame>
/1 = "bon19.jpg"
/2 = "bon20.jpg"
/3 = "bon21.jpg"
/4 = "bon22.jpg"
/5 = "bon23.jpg"
/6 = "gln19.jpg"
/7= "gln20.jpg"
/8 = "gln21.jpg"
/9= "gln22.jpg"
/10 = "gln23.jpg"
/11= "knn19.jpg"
/12= "knn20.jpg"
/13 = "knn21.jpg"
/14= "knn22.jpg"
/15 = "knn23.jpg"
/16= "wgn19.jpg"
/17= "wgn20.jpg"
/18 = "wgn21.jpg"
/19= "wgn22.jpg"
/20 = "wgn23.jpg"
</item>

<item pain_plus_fourth_frame>
/1 = "cap19.jpg"
/2 = "cap20.jpg"
/3 = "cap21.jpg"
/4 = "cap22.jpg"
/5 = "cap23.jpg"
/6 = "glp19.jpg"
/7= "glp20.jpg"
/8 = "glp21.jpg"
/9= "glp22.jpg"
/10 = "glp23.jpg"
/11= "knp19.jpg"
/12= "knp20.jpg"
/13 = "knp21.jpg"
/14= "knp22.jpg"
/15 = "knp23.jpg"
/16= "wgp19.jpg"
/17= "wgp20.jpg"
/18 = "wgp21.jpg"
/19= "wgp22.jpg"
/20 = "wgp23.jpg"
</item>

<picture safe_plus_fifth_frame>
/ items = safe_plus_fifth_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture pain_plus_fifth_frame>
/ items = pain_plus_fifth_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<item safe_plus_fifth_frame>
/1 = "bon21.jpg"
/2 = "bon22.jpg"
/3 = "bon23.jpg"
/4 = "bon24.jpg"
/5 = "bon25.jpg"
/6 = "gln21.jpg"
/7= "gln22.jpg"
/8 = "gln23.jpg"
/9= "gln24.jpg"
/10 = "gln25.jpg"
/11= "knn21.jpg"
/12= "knn22.jpg"
/13 = "knn23.jpg"
/14= "knn24.jpg"
/15 = "knn25.jpg"
/16= "wgn21.jpg"
/17= "wgn22.jpg"
/18 = "wgn23.jpg"
/19= "wgn24.jpg"
/20 = "wgn25.jpg"
</item>

<item pain_plus_fifth_frame>
/1 = "cap21.jpg"
/2 = "cap22.jpg"
/3 = "cap23.jpg"
/4 = "cap24.jpg"
/5 = "cap25.jpg"
/6 = "glp21.jpg"
/7= "glp22.jpg"
/8 = "glp23.jpg"
/9= "glp24.jpg"
/10 = "glp25.jpg"
/11= "knp21.jpg"
/12= "knp22.jpg"
/13 = "knp23.jpg"
/14= "knp24.jpg"
/15 = "knp25.jpg"
/16= "wgp21.jpg"
/17= "wgp22.jpg"
/18 = "wgp23.jpg"
/19= "wgp24.jpg"
/20 = "wgp25.jpg"
</item>

<item safe_w>
/1 = "bonwithouthand.jpg"
/2 = "bonwithouthand.jpg"
/3 = "bonwithouthand.jpg"
/4 = "bonwithouthand.jpg"
/5 = "bonwithouthand.jpg"
/6 = "glnwithouthand.jpg"
/7 = "glnwithouthand.jpg"
/8 = "glnwithouthand.jpg"
/9 = "glnwithouthand.jpg"
/10 = "glnwithouthand.jpg"
/11= "knnwithouthand.jpg"
/12= "knnwithouthand.jpg"
/13 = "knnwithouthand.jpg"
/14= "knnwithouthand.jpg"
/15 = "knnwithouthand.jpg"
/16= "wgnwithouthand.jpg"
/17= "wgnwithouthand.jpg"
/18 = "wgnwithouthand.jpg"
/19= "wgnwithouthand.jpg"
/20 = "wgnwithouthand.jpg"
</item>

<item pain_w>
/1 = "capwithouthand.jpg"
/2 = "capwithouthand.jpg"
/3 = "capwithouthand.jpg"
/4 = "capwithouthand.jpg"
/5 = "capwithouthand.jpg"
/6 = "glpwithouthand.jpg"
/7= "glpwithouthand.jpg"
/8 = "glpwithouthand.jpg"
/9= "glpwithouthand.jpg"
/10 = "glpwithouthand.jpg"
/11= "knpwithouthand.jpg"
/12= "knpwithouthand.jpg"
/13 = "knpwithouthand.jpg"
/14= "knpwithouthand.jpg"
/15 = "knpwithouthand.jpg"
/16= "wgpwithouthand.jpg"
/17= "wgpwithouthand.jpg"
/18 = "wgpwithouthand.jpg"
/19= "wgpwithouthand.jpg"
/20= "wgpwithouthand.jpg"
</item>

<picture safe_w>
/ items = safe_w
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture pain_w>
/ items = pain_w
/ select = list.forward
/ size = (100%, 100%)
</picture>


<sound take>
/ items = ("illtakeit.wav")
</sound>

<sound leave>
/ items = ("illleaveit.wav")
</sound>

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = ""
/time_second_frame = ""
/time_third_frame = ""
/time_fourth_frame = ""
/time_fifth_frame = ""
/spacebarpresscount= ""
</values>


****************************************

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [values.time_sound = round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83;
                trial.safe_3_backward_inc.resetstimulusframes();
                trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<trial safe_3_backward_con>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Congruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_con.resetstimulusframes();
                trial.safe_3_backward_con.insertstimulustime(sound.leave, values.time_sound);
                trial.safe_3_backward_con.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_con.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ isvalidresponse = [if(trial.safe_3_backward_con.response == -57){values.spacebarpresscount += 1;}]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_con_respond;]
</trial>
<trial safe_3_backward_con_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_con_respond.responsex;values.y=trial.safe_3_backward_con_respond.responsey;]
/ branch = [trial.space;]
</trial>




<trial safe_4_backward_inc>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83; values.time_fourth_frame = values.time_third_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 4]
/ ontrialbegin = [trial.safe_4_backward_inc.resetstimulusframes();
                trial.safe_4_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_4_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_4_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);
                trial.safe_4_backward_inc.insertstimulustime(picture.safe_minus_fourth_frame, values.time_fourth_frame)]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ isvalidresponse = [if(trial.safe_4_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_fourth_frame
/ branch = [trial.safe_4_backward_inc_respond;]
</trial>
<trial safe_4_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_4_backward_inc_respond.responsex;values.y=trial.safe_4_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<trial safe_4_backward_con>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83; values.time_fourth_frame = values.time_third_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount="";values.congruency = "Congruent"; values.object = "safe"; values.length = 4]
/ ontrialbegin = [trial.safe_4_backward_con.resetstimulusframes();
                trial.safe_4_backward_con.insertstimulustime(sound.leave, values.time_sound);
                trial.safe_4_backward_con.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_4_backward_con.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);
                trial.safe_4_backward_con.insertstimulustime(picture.safe_minus_fourth_frame, values.time_fourth_frame)]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ isvalidresponse = [if(trial.safe_4_backward_con.response == -57){values.spacebarpresscount += 1;}]
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_fourth_frame
/ branch = [trial.safe_4_backward_con_respond;]
</trial>
<trial safe_4_backward_con_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_4_backward_con_respond.responsex;values.y=trial.safe_4_backward_con_respond.responsey;]
/ branch = [trial.space;]
</trial>

<trial safe_5_backward_inc>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83; values.time_fourth_frame = values.time_third_frame+83; values.time_fifth_frame=values.time_fourth_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount="";values.congruency = "Incongruent"; values.object = "safe"; values.length = 5]
/ ontrialbegin = [trial.safe_5_backward_inc.resetstimulusframes();
                trial.safe_5_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_5_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_5_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);
                trial.safe_5_backward_inc.insertstimulustime(picture.safe_minus_fourth_frame, values.time_fourth_frame);
                trial.safe_5_backward_inc.insertstimulustime(picture.safe_minus_fifth_frame, values.time_fifth_frame)]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ isvalidresponse = [if(trial.safe_5_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_fifth_frame
/ branch = [trial.safe_5_backward_inc_respond;]
</trial>
<trial safe_5_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_5_backward_inc_respond.responsex;values.y=trial.safe_5_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<trial safe_5_backward_con>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83; values.time_fourth_frame = values.time_third_frame+83; values.time_fifth_frame=values.time_fourth_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount="";values.congruency = "Congruent"; values.object = "safe"; values.length = 5]
/ ontrialbegin = [trial.safe_5_backward_con.resetstimulusframes();
                trial.safe_5_backward_con.insertstimulustime(sound.leave, values.time_sound);
                trial.safe_5_backward_con.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_5_backward_con.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);
                trial.safe_5_backward_con.insertstimulustime(picture.safe_minus_fourth_frame, values.time_fourth_frame);
                trial.safe_5_backward_con.insertstimulustime(picture.safe_minus_fifth_frame, values.time_fifth_frame)]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ isvalidresponse = [if(trial.safe_5_backward_con.response == -57){values.spacebarpresscount += 1;}]
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_fifth_frame
/ branch = [trial.safe_5_backward_con_respond;]
</trial>
<trial safe_5_backward_con_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_5_backward_con_respond.responsex;values.y=trial.safe_5_backward_con_respond.responsey;]
/ branch = [trial.space;]
</trial>

<block space>
/trials = [1=space]
</block>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>
<block 3_safe_backward_inc>
/ trials = [1= sequence(fixate,safe_3_backward_inc)]
</block>

<block 4_safe_backward_con>
/ trials = [1= sequence(fixate,safe_4_backward_con)]
</block>
<block 4_safe_backward_inc>
/ trials = [1= sequence(fixate,safe_4_backward_inc)]
</block>

<block 5_safe_backward_con>
/ trials = [1= sequence(fixate,safe_5_backward_con)]
</block>
<block 5_safe_backward_inc>
/ trials = [1= sequence(fixate,safe_5_backward_inc)]
</block>


Thanks a lot,

Eleonora

You randomize the trial timings, by picking a random onset time for the sound per

values.time_sound = round(rand(1000,3000));

and then calculating all subsequent onset times based on that. Inquisit will pick the onset closest to the calculated time achievable *given the refresh rate* on your system. Stimuli can only be drawn to the screen when a new refresh cycle begins (duration of a refresh cycle when running at 60Hz is ~16.67ms), so depending on how exactly the timings shake out, some frames will necessarily be either a bit longer or a bit shorter.

Even with completely fixed timings, the onset of a frame (typically the first or second) may drift forward because it wasn't possible to catch a refresh cycle, delaying the onset on the order of one refresh cycle and thus making the given frame approx. 16.67ms shorter (4 x  16.67ms = 66.68ms vs. 5 x 16.67ms = 83.35ms). I do not believe this can be fully avoided.
By eleonora_parr - 1/15/2021

Dave - 1/15/2021
eleonora_parr - 1/15/2021
Dave - 1/14/2021
Dave - 1/14/2021
eleonora_parr - 1/14/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Dave - 1/13/2021
eleonora_parr - 1/13/2021
Hi all, 
I am programming an experiment in which I would need to record both mouse coordinates and keyboard responses within a single trial:
the structure of the experiment looks like this:

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/time_sound = (round(rand(60,180)))
/time_second_frame = time_sound+60+5
/time_third_frame = time_sound+60+5+5
/time_fourth_frame = time_sound+60+5+5+5
/time_fifth_frame = time_sound+60+5+5+5+5
</values>


<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulusframes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

So that the intertrial interval is represented by the "space trial": here participants have to press the spacebar to start the next trial and keep it pressed for the whole trial. They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond).
I need to know and make sure that participants keep the spacebar pressed for the whole trial interval, as this information represents an exclusion criterion for the experiment. 
Is there a way to record both spacebar release (or the duration of spacebar pressing) and mouse coordinates wihin a single trial? 

Thank you very much.

Eleonora

To record the potential space bar release, you need to set inputdevice to keyboard in <trial safe_3_backward_inc> and define the valid response as -57 (the prepended minus indicates a key release). To record mouse coordinates during that same trial, you can use /datastreams.

<trial example>
// press on the space bar starts the trial
/ pretrialsignal = (keyboard, 57)
/ stimulusframes = [1=mytext]
/ inputdevice = keyboard
/ showmousecursor = true
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ timeout = 5000
/ datastreams = (mousecoordinates)
</trial>

<datastream mousecoordinates> 
/ columns = (build, computer.platform,
date, time, subject, group, session,
display.canvasheight, display.canvaswidth,
blockcode, blocknum,
trialcode, trialnum,
script.elapsedtime,
mouse.x, mouse.y)
</datastream>

<text mytext>
/ items = ("Don't release.")
</text>

<block myblock>
/ trials = [1=example]
</block>



Hi Dave,
Thank you very much for your response.
May I ask you to clarify what the subsequent attribute/function do ?
/ pretrialsignal = (keyboard, 57)
Can I also ask you why would you set this timeout to the trial?
/ timeout = 5000
Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have. 
Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element? 
Thank you so much!

Eleonora


/ pretrialsignal = (keyboard, 57)

https://www.millisecond.com/support/docs/v6/html/language/attributes/pretrialsignal.htm

This just makes sure that the space barr is down when the example trial actually starts. It's just there for the sake of the example code, you probably handle that in <trial space> in your code (which I don't have).

> Can I also ask you why would you set this timeout to the trial?
> / timeout = 5000

Again, this is only for the sake of illustration. I want the example trial to immediately end if the space bar is released during the trial, and this achieves just that. You're using /trialduration in the corresponding trial, which fixes the duration.

> Also, I have 24 types of trials like the trial safe_3_backward_inc. Is it sufficient to just set / datastreams = (mousecoordinates) at the end of each trial to record the mouse coordinates for every trial that I have.

Yes, that's sufficient.

> Last question: Is the datastream function equivalent to data? Can I insert in there also other data that I want to record or do I have to create an additional <data> element?

The data will end up in a separate data file, with columns as defined in the <datastream mousecoordinates> elements. This is separate from and in addition to any data file defined per <data>.



Oh I see, the only problem is that the trial should end when subjects make the mouse response..
Indeed before I set this in the trial safe_3_backward_inc_respond as:
/ correctresponse = (lbuttondown)
That was why I asked if 2 input devices could be used within a trial, as I need to both record mouse and keyboard responses, but the mouse click should also be what triggers the end of the trial.
I am afraid that if the inputdevice is set as keyboard this is not possible though.. ? Is there any trick that can be used? 

Thank you again,

Eleonora

No, two input devices in a single <trial> are not possible. However, I don't see where or why you need both keyboard and mouse in

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulusframe(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulusframe(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulusframes = [1 = safe_first_frame]
/ validresponse = (0)
/ inputdevice = mousekey
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

That trial, as you currently have it, does not register any responses to begin with, validresponse is set to no response.

You wrote: "They can release the spacebar just at the end of the trial safe_3_backward_inc, when they have then to make the mouse response (trial safe_3_backward_inc_respond)."

That is, <trial safe_3_backward_inc_respond> does not need two input devices, it only needs the mouse. <trial safe_3_backward_inc> can be set to keyboard and register any potential key release as well as log mouse coordinates as demonstrated.

Oh, sorry, I probably did not express myself well. They have to keep the spacebar pressed for the whole trial safe_3_backward_inc and they can release it when the trial safe_3_backward_inc_respond begins, which is when they have to make the mouse response.
So the potential spacebar release should be recorded during both safe_3_backward_inc AND safe_3_backward_inc_respond, to make sure that they released the spacebar just before making the mouse response (that they did not release it too early) 
However, this trick allow us to check anyway if they released the spacebar before the begin of the trial safe_3_backward_inc_respond, so in some way it kinda solve the problem :-)
Greatly appreciated, thank you so much!

Eleonora

Hi Dave,
Sorry to bother again, but I am having problems in recording the spacebar release in the data: I followed a couple of examples that I found in the forum (https://www.millisecond.com/forums/Topic15810.aspx#15812 and https://www.millisecond.com/forums/Topic16749.aspx#16752) 
For now my code is:
<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = round(rand(1000,3000))
/time_second_frame = time_sound+1000+83.5
/time_third_frame = time_sound+1000+83.5+83.5
/time_fourth_frame = time_sound+1000+83.5+83.5+83.5
/time_fifth_frame = time_sound++1000+83.5+83.5+83.5+83.5
/spacebarpresscount= ""
</values>

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>
<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>


<data>
/ columns = [date,time,group,subject, display.canvaswidth, display.canvasheight, session, build, blocknum, blockcode, trialnum,trialcode, pretrialpause,
posttrialpause, trialduration, values.Actiontype, values.congruency, values.object, values.length, values.fixate_duration, values.spacebarpresscount,
stimulusitem, stimulusitem, stimulusitem, stimulusitem,stimulusitem,stimulusitem,stimulusitem
stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset, stimulusonset
correct, latency, response,values.x,values.y]
</data>

But when I run the code, the column spacebarpresscount is always empty. I've also tried /spacebarpresscount= 0 instead of /spacebarpresscount= "", unfortunately nothing changed..
Any suggestion?

Thank you so much!

Please provide code that is complete enough to actually run.

One problem you have here

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
      trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>

is that there's actually no time in the trial during which it would poll for any response. By default, Inquisit only starts accepting responses once the trial has completed its entire stimulus presentation sequence, here: after/coinciding with the onset of picture.safe_minus_third_frame. That, however, is also the time where the trial actually ends. If you want to accept responses *while* the stimulus presentation sequence is still in progress, from the very start of the <trial> object, set /beginresponsetime = -1.

https://www.millisecond.com/support/docs/v6/html/language/attributes/beginresponsetime.htm

Then, depending on what you want to happen when a response is registered (here: release of the space bar), you may in addition have to change the trial's /responseinterrupt.

https://www.millisecond.com/support/docs/v6/html/language/attributes/responseinterrupt.htm

The default is immediate, i.e. the trial will not present the remaining stimuli once a response has been registered. If you want the trial to complete the stimulus presentation sequence instead, set /responseinterrupt = frames.

In sum, something like this:

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [
    trial.safe_3_backward_inc.resetstimulusframes();
    trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
    trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ beginresponsetime = -1
/ responseinterrupt = frames
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>


Hi Dave,
I just noticed that with the option "resetsframes" the timing of each frame presentation does not last as specified in the trial: each frame should last 83.5 ms.
In the log file I noticed that sometimes each frame lasts 70/71 ms, sometimes it lasts 83.5 ms. I also tried to change stimulusframes with stimulustimes and I also tried to set this interval "fixed" in the values (I thought that the problem could be that the values were updated everytime at the beginning of each trial), but nothing changed, there is always in the trial a frame that lasts less than 83.5 ms. (Refresh rate is currently 60 Hz) 
May I ask you why this could happen?

Here is the code:

<list forward>
/ items = [noreplace(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)]
/ selectionrate = block
/ resetinterval = 1
</list>

<picture safe_minus_fifth_frame>
/ items = safe_minus_fifth_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<picture pain_minus_fifth_frame>
/ items = pain_minus_fifth_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_minus_fifth_frame>
/1 = "bon05.jpg"
/2 = "bon06.jpg"
/3 = "bon07.jpg"
/4 = "bon08.jpg"
/5 = "bon09.jpg"
/6 = "gln05.jpg"
/7= "gln06.jpg"
/8 = "gln07.jpg"
/9= "gln08.jpg"
/10 = "gln09.jpg"
/11= "knn05.jpg"
/12= "knn06.jpg"
/13 = "knn07.jpg"
/14= "knn08.jpg"
/15 = "knn09.jpg"
/16= "wgn05.jpg"
/17= "wgn05.jpg"
/18 = "wgn07.jpg"
/19= "wgn08.jpg"
/20 = "wgn09.jpg"
</item>

<item pain_minus_fifth_frame>
/1 = "cap05.jpg"
/2 = "cap06.jpg"
/3 = "cap07.jpg"
/4 = "cap08.jpg"
/5 = "cap09.jpg"
/6 = "glp05.jpg"
/7="glp06.jpg"
/8 = "glp07.jpg"
/9= "glp08.jpg"
/10 = "glp09.jpg"
/11 = "knp05.jpg"
/12= "knp06.jpg"
/13 = "knp07.jpg"
/14= "knp08.jpg"
/15 = "knp09.jpg"
/16= "wgp05.jpg"
/17= "wgp06.jpg"
/18 ="wgp07.jpg"
/19= "wgp08.jpg"
/20 = "wgp09.jpg"
</item>

<picture pain_minus_fourth_frame>
/ items = pain_minus_fourth_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<picture safe_minus_fourth_frame>
/ items = safe_minus_fourth_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_minus_fourth_frame>
/1 = "bon07.jpg"
/2 = "bon08.jpg"
/3 = "bon09.jpg"
/4 = "bon10.jpg"
/5 = "bon11.jpg"
/6 = "gln07.jpg"
/7= "gln08.jpg"
/8= "gln09.jpg"
/9= "gln10.jpg"
/10 = "gln11.jpg"
/11= "knn07.jpg"
/12= "knn08.jpg"
/13 = "knn09.jpg"
/14= "knn10.jpg"
/15 = "knn11.jpg"
/16= "wgn07.jpg"
/17= "wgn08.jpg"
/18 = "wgn09.jpg"
/19= "wgn10.jpg"
/20 = "wgn11.jpg"
</item>

<item pain_minus_fourth_frame>
/1 = "cap07.jpg"
/2= "cap08.jpg"
/3= "cap09.jpg"
/4= "cap10.jpg"
/5 = "cap11.jpg"
/6 = "glp07.jpg"
/7= "glp08.jpg"
/8 = "glp09.jpg"
/9= "glp10.jpg"
/10 = "glp11.jpg"
/11= "knp07.jpg"
/12= "knp08.jpg"
/13 = "knp09.jpg"
/14= "knp10.jpg"
/15 = "knp11.jpg"
/16= "wgp07.jpg"
/17= "wgp08.jpg"
/18 = "wgp09.jpg"
/19= "wgp10.jpg"
/20 = "wgp11.jpg"
</item>

<picture safe_minus_third_frame>
/ items = safe_minus_third_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<picture pain_minus_third_frame>
/ items = pain_minus_third_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_minus_third_frame>
/1 = "bon09.jpg"
/2 = "bon10.jpg"
/3 = "bon11.jpg"
/4 = "bon12.jpg"
/5 = "bon13.jpg"
/6 = "gln09.jpg"
/7= "gln10.jpg"
/8 = "gln11.jpg"
/9= "gln12.jpg"
/10 = "gln13.jpg"
/11= "knn09.jpg"
/12= "knn10.jpg"
/13 = "knn11.jpg"
/14= "knn12.jpg"
/15 = "knn13.jpg"
/16= "wgn09.jpg"
/17= "wgn10.jpg"
/18 = "wgn11.jpg"
/19= "wgn12.jpg"
/20 = "wgn13.jpg"
</item>

<item pain_minus_third_frame>
/1 = "cap09.jpg"
/2 = "cap10.jpg"
/3 = "cap11.jpg"
/4 = "cap12.jpg"
/5 = "cap13.jpg"
/6 = "glp09.jpg"
/7= "glp10.jpg"
/8 = "glp11.jpg"
/9= "glp12.jpg"
/10 = "glp13.jpg"
/11= "knp09.jpg"
/12= "knp10.jpg"
/13 = "knp11.jpg"
/14= "knp12.jpg"
/15 = "knp13.jpg"
/16= "wgp09.jpg"
/17= "wgp10.jpg"
/18 = "wgp11.jpg"
/19= "wgp12.jpg"
/20 = "wgp13.jpg"
</item>


<picture pain_minus_second_frame>
/ items = pain_minus_second_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<picture safe_minus_second_frame>
/ items = safe_minus_second_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_minus_second_frame>
/1 = "bon11.jpg"
/2 = "bon12.jpg"
/3 = "bon13.jpg"
/4 = "bon14.jpg"
/5 = "bon15.jpg"
/6 = "gln11.jpg"
/7= "gln12.jpg"
/8 = "gln13.jpg"
/9= "gln14.jpg"
/10 = "gln15.jpg"
/11= "knn11.jpg"
/12= "knn12.jpg"
/13 = "knn13.jpg"
/14= "knn14.jpg"
/15 = "knn15.jpg"
/16= "wgn11.jpg"
/17= "wgn12.jpg"
/18 = "wgn13.jpg"
/19= "wgn14.jpg"
/20 = "wgn15.jpg"

</item>

<item pain_minus_second_frame>
/1 = "cap11.jpg"
/2= "cap12.jpg"
/3 = "cap13.jpg"
/4 = "cap14.jpg"
/5 = "cap15.jpg"
/6 = "glp11.jpg"
/7= "glp12.jpg"
/8 = "glp13.jpg"
/9= "glp14.jpg"
/10 = "glp15.jpg"
/11= "knp11.jpg"
/12= "knp12.jpg"
/13 = "knp13.jpg"
/14= "knp14.jpg"
/15 = "knp15.jpg"
/16= "wgp11.jpg"
/17= "wgp12.jpg"
/18 = "wgp13.jpg"
/19= "wgp14.jpg"
/20 = "wgp15.jpg"
</item>



<picture safe_first_frame>
/ items = safe_first_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>


<picture pain_first_frame>
/ items = pain_first_frame
/ erase = false
/ size = (100%, 100%)
/ select = list.forward
</picture>

<item safe_first_frame>
/1 = "bon13.jpg"
/2 = "bon14.jpg"
/3 = "bon15.jpg"
/4 = "bon16.jpg"
/5 = "bon17.jpg"
/6 = "gln13.jpg"
/7= "gln14.jpg"
/8 = "gln15.jpg"
/9= "gln16.jpg"
/10 = "gln17.jpg"
/11= "knn13.jpg"
/12= "knn14.jpg"
/13 = "knn15.jpg"
/14= "knn16.jpg"
/15 = "knn17.jpg"
/16= "wgn13.jpg"
/17= "wgn14.jpg"
/18 = "wgn15.jpg"
/19= "wgn16.jpg"
/20 = "wgn17.jpg"
</item>


<item pain_first_frame>
/1 = "cap13.jpg"
/2 = "cap14.jpg"
/3 = "cap15.jpg"
/4 = "cap16.jpg"
/5 = "cap17.jpg"
/6 = "glp13.jpg"
/7= "glp14.jpg"
/8 = "glp15.jpg"
/9= "glp16.jpg"
/10 = "glp17.jpg"
/11= "knp13.jpg"
/12= "knp14.jpg"
/13 = "knp15.jpg"
/14= "knp16.jpg"
/15 = "knp17.jpg"
/16= "wgp13.jpg"
/17= "wgp14.jpg"
/18 = "wgp15.jpg"
/19= "wgp16.jpg"
/20 = "wgp17.jpg"
</item>




<picture pain_plus_second_frame>
/ items = pain_plus_second_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture safe_plus_second_frame>
/ items = safe_plus_second_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<item safe_plus_second_frame>
/1 = "bon15.jpg"
/2 = "bon16.jpg"
/3 = "bon17.jpg"
/4 = "bon18.jpg"
/5 = "bon19.jpg"
/6 = "gln15.jpg"
/7= "gln16.jpg"
/8 = "gln17.jpg"
/9= "gln18.jpg"
/10 = "gln19.jpg"
/11= "knn15.jpg"
/12= "knn16.jpg"
/13 = "knn17.jpg"
/14= "knn18.jpg"
/15 = "knn19.jpg"
/16= "wgn15.jpg"
/17= "wgn16.jpg"
/18 = "wgn17.jpg"
/19= "wgn18.jpg"
/20 = "wgn19.jpg"
</item>

<item pain_plus_second_frame>
/1= "cap15.jpg"
/2= "cap16.jpg"
/3 = "cap17.jpg"
/4= "cap18.jpg"
/5 = "cap19.jpg"
/6 = "glp15.jpg"
/7= "glp16.jpg"
/8 = "glp17.jpg"
/9= "glp18.jpg"
/10 = "glp19.jpg"
/11= "knp15.jpg"
/12= "knp16.jpg"
/13 = "knp17.jpg"
/14= "knp18.jpg"
/15 = "knp19.jpg"
/16= "wgp15.jpg"
/17= "wgp16.jpg"
/18 = "wgp17.jpg"
/19= "wgp18.jpg"
/20 = "wgp19.jpg"
</item>

<picture pain_plus_third_frame>
/ items = pain_plus_third_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture safe_plus_third_frame>
/ items = safe_plus_third_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<item safe_plus_third_frame>
/1 = "bon17.jpg"
/2 = "bon18.jpg"
/3 = "bon19.jpg"
/4 = "bon20.jpg"
/5 = "bon21.jpg"
/6 = "gln17.jpg"
/7= "gln18.jpg"
/8 = "gln19.jpg"
/9= "gln20.jpg"
/10 = "gln21.jpg"
/11= "knn17.jpg"
/12= "knn18.jpg"
/13 = "knn19.jpg"
/14= "knn20.jpg"
/15 = "knn21.jpg"
/16= "wgn17.jpg"
/17= "wgn18.jpg"
/18 = "wgn19.jpg"
/19= "wgn20.jpg"
/20 = "wgn21.jpg"
</item>

<item pain_plus_third_frame>
/1 = "cap17.jpg"
/2 = "cap18.jpg"
/3 = "cap19.jpg"
/4= "cap20.jpg"
/5 = "cap21.jpg"
/6 = "glp17.jpg"
/7= "glp18.jpg"
/8 = "glp19.jpg"
/9= "glp20.jpg"
/10 = "glp21.jpg"
/11= "knp17.jpg"
/12= "knp18.jpg"
/13 = "knp19.jpg"
/14= "knp20.jpg"
/15 = "knp21.jpg"
/16= "wgp17.jpg"
/17= "wgp18.jpg"
/18 = "wgp19.jpg"
/19= "wgp20.jpg"
/20 = "wgp21.jpg"
</item>

<picture safe_plus_fourth_frame>
/ items = safe_plus_fourth_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture pain_plus_fourth_frame>
/ items = pain_plus_fourth_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<item safe_plus_fourth_frame>
/1 = "bon19.jpg"
/2 = "bon20.jpg"
/3 = "bon21.jpg"
/4 = "bon22.jpg"
/5 = "bon23.jpg"
/6 = "gln19.jpg"
/7= "gln20.jpg"
/8 = "gln21.jpg"
/9= "gln22.jpg"
/10 = "gln23.jpg"
/11= "knn19.jpg"
/12= "knn20.jpg"
/13 = "knn21.jpg"
/14= "knn22.jpg"
/15 = "knn23.jpg"
/16= "wgn19.jpg"
/17= "wgn20.jpg"
/18 = "wgn21.jpg"
/19= "wgn22.jpg"
/20 = "wgn23.jpg"
</item>

<item pain_plus_fourth_frame>
/1 = "cap19.jpg"
/2 = "cap20.jpg"
/3 = "cap21.jpg"
/4 = "cap22.jpg"
/5 = "cap23.jpg"
/6 = "glp19.jpg"
/7= "glp20.jpg"
/8 = "glp21.jpg"
/9= "glp22.jpg"
/10 = "glp23.jpg"
/11= "knp19.jpg"
/12= "knp20.jpg"
/13 = "knp21.jpg"
/14= "knp22.jpg"
/15 = "knp23.jpg"
/16= "wgp19.jpg"
/17= "wgp20.jpg"
/18 = "wgp21.jpg"
/19= "wgp22.jpg"
/20 = "wgp23.jpg"
</item>

<picture safe_plus_fifth_frame>
/ items = safe_plus_fifth_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture pain_plus_fifth_frame>
/ items = pain_plus_fifth_frame
/ erase = false
/ select = list.forward
/ size = (100%, 100%)
</picture>

<item safe_plus_fifth_frame>
/1 = "bon21.jpg"
/2 = "bon22.jpg"
/3 = "bon23.jpg"
/4 = "bon24.jpg"
/5 = "bon25.jpg"
/6 = "gln21.jpg"
/7= "gln22.jpg"
/8 = "gln23.jpg"
/9= "gln24.jpg"
/10 = "gln25.jpg"
/11= "knn21.jpg"
/12= "knn22.jpg"
/13 = "knn23.jpg"
/14= "knn24.jpg"
/15 = "knn25.jpg"
/16= "wgn21.jpg"
/17= "wgn22.jpg"
/18 = "wgn23.jpg"
/19= "wgn24.jpg"
/20 = "wgn25.jpg"
</item>

<item pain_plus_fifth_frame>
/1 = "cap21.jpg"
/2 = "cap22.jpg"
/3 = "cap23.jpg"
/4 = "cap24.jpg"
/5 = "cap25.jpg"
/6 = "glp21.jpg"
/7= "glp22.jpg"
/8 = "glp23.jpg"
/9= "glp24.jpg"
/10 = "glp25.jpg"
/11= "knp21.jpg"
/12= "knp22.jpg"
/13 = "knp23.jpg"
/14= "knp24.jpg"
/15 = "knp25.jpg"
/16= "wgp21.jpg"
/17= "wgp22.jpg"
/18 = "wgp23.jpg"
/19= "wgp24.jpg"
/20 = "wgp25.jpg"
</item>

<item safe_w>
/1 = "bonwithouthand.jpg"
/2 = "bonwithouthand.jpg"
/3 = "bonwithouthand.jpg"
/4 = "bonwithouthand.jpg"
/5 = "bonwithouthand.jpg"
/6 = "glnwithouthand.jpg"
/7 = "glnwithouthand.jpg"
/8 = "glnwithouthand.jpg"
/9 = "glnwithouthand.jpg"
/10 = "glnwithouthand.jpg"
/11= "knnwithouthand.jpg"
/12= "knnwithouthand.jpg"
/13 = "knnwithouthand.jpg"
/14= "knnwithouthand.jpg"
/15 = "knnwithouthand.jpg"
/16= "wgnwithouthand.jpg"
/17= "wgnwithouthand.jpg"
/18 = "wgnwithouthand.jpg"
/19= "wgnwithouthand.jpg"
/20 = "wgnwithouthand.jpg"
</item>

<item pain_w>
/1 = "capwithouthand.jpg"
/2 = "capwithouthand.jpg"
/3 = "capwithouthand.jpg"
/4 = "capwithouthand.jpg"
/5 = "capwithouthand.jpg"
/6 = "glpwithouthand.jpg"
/7= "glpwithouthand.jpg"
/8 = "glpwithouthand.jpg"
/9= "glpwithouthand.jpg"
/10 = "glpwithouthand.jpg"
/11= "knpwithouthand.jpg"
/12= "knpwithouthand.jpg"
/13 = "knpwithouthand.jpg"
/14= "knpwithouthand.jpg"
/15 = "knpwithouthand.jpg"
/16= "wgpwithouthand.jpg"
/17= "wgpwithouthand.jpg"
/18 = "wgpwithouthand.jpg"
/19= "wgpwithouthand.jpg"
/20= "wgpwithouthand.jpg"
</item>

<picture safe_w>
/ items = safe_w
/ select = list.forward
/ size = (100%, 100%)
</picture>

<picture pain_w>
/ items = pain_w
/ select = list.forward
/ size = (100%, 100%)
</picture>


<sound take>
/ items = ("illtakeit.wav")
</sound>

<sound leave>
/ items = ("illleaveit.wav")
</sound>

<text space>
/ fontstyle = ("Arial", 18pt, true)
/ items = ("Press the spacebar to continue")
</text>

<trial space>
/ stimulusframes = [1=space]
/ inputdevice = keyboard
/ correctresponse =(57)
/ validresponse = (57)
/ posttrialpause = 500
</trial>

<values>
/Actiontype=0
/congruency = 0
/object = 0
/length = 0
/ x=0
/ y=0
/fixate_duration = 0
/time_sound = ""
/time_second_frame = ""
/time_third_frame = ""
/time_fourth_frame = ""
/time_fifth_frame = ""
/spacebarpresscount= ""
</values>


****************************************

<trial fixate>
/ pretrialpause = 1000
/ ontrialbegin = [values.fixate_duration = round(rand(500,1000))]
/ stimulusframes = [1 = cross]
/ trialduration = values.fixate_duration
</trial>

<trial safe_3_backward_inc>
/ ontrialbegin = [values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [values.time_sound = round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83;
                trial.safe_3_backward_inc.resetstimulusframes();
                trial.safe_3_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ isvalidresponse = [if(trial.safe_3_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ monkeyresponse = (-57)
/ branch = [trial.safe_3_backward_inc_respond;]
</trial>
<trial safe_3_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_inc_respond.responsex;values.y=trial.safe_3_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<trial safe_3_backward_con>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Congruent"; values.object = "safe"; values.length = 3]
/ ontrialbegin = [trial.safe_3_backward_con.resetstimulusframes();
                trial.safe_3_backward_con.insertstimulustime(sound.leave, values.time_sound);
                trial.safe_3_backward_con.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_3_backward_con.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);]
/ stimulustimes = [1 = safe_first_frame]
/ isvalidresponse = [if(trial.safe_3_backward_con.response == -57){values.spacebarpresscount += 1;}]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_third_frame
/ branch = [trial.safe_3_backward_con_respond;]
</trial>
<trial safe_3_backward_con_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_3_backward_con_respond.responsex;values.y=trial.safe_3_backward_con_respond.responsey;]
/ branch = [trial.space;]
</trial>




<trial safe_4_backward_inc>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83; values.time_fourth_frame = values.time_third_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount=""; values.congruency = "Incongruent"; values.object = "safe"; values.length = 4]
/ ontrialbegin = [trial.safe_4_backward_inc.resetstimulusframes();
                trial.safe_4_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_4_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_4_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);
                trial.safe_4_backward_inc.insertstimulustime(picture.safe_minus_fourth_frame, values.time_fourth_frame)]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ isvalidresponse = [if(trial.safe_4_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_fourth_frame
/ branch = [trial.safe_4_backward_inc_respond;]
</trial>
<trial safe_4_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_4_backward_inc_respond.responsex;values.y=trial.safe_4_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<trial safe_4_backward_con>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83; values.time_fourth_frame = values.time_third_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount="";values.congruency = "Congruent"; values.object = "safe"; values.length = 4]
/ ontrialbegin = [trial.safe_4_backward_con.resetstimulusframes();
                trial.safe_4_backward_con.insertstimulustime(sound.leave, values.time_sound);
                trial.safe_4_backward_con.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_4_backward_con.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);
                trial.safe_4_backward_con.insertstimulustime(picture.safe_minus_fourth_frame, values.time_fourth_frame)]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ isvalidresponse = [if(trial.safe_4_backward_con.response == -57){values.spacebarpresscount += 1;}]
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_fourth_frame
/ branch = [trial.safe_4_backward_con_respond;]
</trial>
<trial safe_4_backward_con_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_4_backward_con_respond.responsex;values.y=trial.safe_4_backward_con_respond.responsey;]
/ branch = [trial.space;]
</trial>

<trial safe_5_backward_inc>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83; values.time_fourth_frame = values.time_third_frame+83; values.time_fifth_frame=values.time_fourth_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount="";values.congruency = "Incongruent"; values.object = "safe"; values.length = 5]
/ ontrialbegin = [trial.safe_5_backward_inc.resetstimulusframes();
                trial.safe_5_backward_inc.insertstimulustime(sound.take, values.time_sound);
                trial.safe_5_backward_inc.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_5_backward_inc.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);
                trial.safe_5_backward_inc.insertstimulustime(picture.safe_minus_fourth_frame, values.time_fourth_frame);
                trial.safe_5_backward_inc.insertstimulustime(picture.safe_minus_fifth_frame, values.time_fifth_frame)]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ isvalidresponse = [if(trial.safe_5_backward_inc.response == -57){values.spacebarpresscount += 1;}]
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_fifth_frame
/ branch = [trial.safe_5_backward_inc_respond;]
</trial>
<trial safe_5_backward_inc_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_5_backward_inc_respond.responsex;values.y=trial.safe_5_backward_inc_respond.responsey;]
/ branch = [trial.space;]
</trial>

<trial safe_5_backward_con>
/ ontrialbegin = [values.time_sound =round(rand(1000,3000)); values.time_second_frame = values.time_sound+1200; values.time_third_frame = values.time_second_frame+83; values.time_fourth_frame = values.time_third_frame+83; values.time_fifth_frame=values.time_fourth_frame+83;
values.Actiontype="Withdrawal"; values.spacebarpresscount="";values.congruency = "Congruent"; values.object = "safe"; values.length = 5]
/ ontrialbegin = [trial.safe_5_backward_con.resetstimulusframes();
                trial.safe_5_backward_con.insertstimulustime(sound.leave, values.time_sound);
                trial.safe_5_backward_con.insertstimulustime(picture.safe_minus_second_frame, values.time_second_frame);
                trial.safe_5_backward_con.insertstimulustime(picture.safe_minus_third_frame, values.time_third_frame);
                trial.safe_5_backward_con.insertstimulustime(picture.safe_minus_fourth_frame, values.time_fourth_frame);
                trial.safe_5_backward_con.insertstimulustime(picture.safe_minus_fifth_frame, values.time_fifth_frame)]
/ stimulustimes = [1 = safe_first_frame]
/ inputdevice = keyboard
/ beginresponsetime = -1
/ responseinterrupt = trial
/ isvalidresponse = [if(trial.safe_5_backward_con.response == -57){values.spacebarpresscount += 1;}]
/ validresponse = (-57, 0)
/ correctresponse = (0)
/ showmousecursor = false
/ trialduration = values.time_fifth_frame
/ branch = [trial.safe_5_backward_con_respond;]
</trial>
<trial safe_5_backward_con_respond>
/ stimulustimes = [1=safe_w]
/ inputdevice = mouse
/ showmousecursor = true
/ validresponse = (lbuttondown)
/ correctresponse = (lbuttondown)
/ ontrialend = [values.x=trial.safe_5_backward_con_respond.responsex;values.y=trial.safe_5_backward_con_respond.responsey;]
/ branch = [trial.space;]
</trial>

<block space>
/trials = [1=space]
</block>

<block 3_safe_backward_con>
/ trials = [1= sequence(fixate,safe_3_backward_con)]
</block>
<block 3_safe_backward_inc>
/ trials = [1= sequence(fixate,safe_3_backward_inc)]
</block>

<block 4_safe_backward_con>
/ trials = [1= sequence(fixate,safe_4_backward_con)]
</block>
<block 4_safe_backward_inc>
/ trials = [1= sequence(fixate,safe_4_backward_inc)]
</block>

<block 5_safe_backward_con>
/ trials = [1= sequence(fixate,safe_5_backward_con)]
</block>
<block 5_safe_backward_inc>
/ trials = [1= sequence(fixate,safe_5_backward_inc)]
</block>


Thanks a lot,

Eleonora

You randomize the trial timings, by picking a random onset time for the sound per

values.time_sound = round(rand(1000,3000));

and then calculating all subsequent onset times based on that. Inquisit will pick the onset closest to the calculated time achievable *given the refresh rate* on your system. Stimuli can only be drawn to the screen when a new refresh cycle begins (duration of a refresh cycle when running at 60Hz is ~16.67ms), so depending on how exactly the timings shake out, some frames will necessarily be either a bit longer or a bit shorter.

Even with completely fixed timings, the onset of a frame (typically the first or second) may drift forward because it wasn't possible to catch a refresh cycle, delaying the onset on the order of one refresh cycle and thus making the given frame approx. 16.67ms shorter (4 x  16.67ms = 66.68ms vs. 5 x 16.67ms = 83.35ms). I do not believe this can be fully avoided.

Thank you very much Dave!
It is clear now!

Eleonora