Millisecond Forums

using previous response latencies as presentation times

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

By plush - 7/21/2015

Dear friends, I'm sure my question has been answered before somewhere, however I did not manage to find the answer.

What I would like to do, is use the response latencies provided in a first block, as the presentation times for a stimuli in a second block.

Is there an efficient way to do this? Thx for the help!
By Dave - 7/21/2015

Yes, you can do that. You need to store the latency / latencies (or mean latency?) from the 1st block somewhere. You can then set the stimulus duration in the 2nd block via the <trial> element's setstimulustime() function. Simple example:

<expt>
/ blocks = [1=block1; 2=block2]
</expt>

<values>
/ alatency= 0
</values>


<block block1>
/ trials = [1=atrial]
</block>

<block block2>
/ trials = [1=btrial]
</block>

<trial atrial>
/ ontrialend = [values.alatency=trial.atrial.latency]
/ stimulusframes = [1=atext]
/ validresponse = (57)
</trial>

<trial btrial>
/ ontrialbegin = [trial.btrial.setstimulustime(shape.eraser, values.alatency); ]
/ stimulusframes = [1=btext]
/ validresponse = (57)
</trial>

<text atext>
/ items = ("Press the spacebar")
</text>

<text btext>
/ items = ("This stimulus will disappear after <%values.alatency%> milliseconds.")
</text>

<shape eraser>
/ shape = rectangle
/ color = white
/ size = (100%, 25%)
</shape>

By plush - 7/22/2015

Thx for the response as always! I was hoping for something along the following lines to work: 

<values>
/ one_trialslatency=0
</values>

<expt >
/blocks = [1=one;2=two]
</expt>

<block one>
/trials = [1-5=one_trials]
</block>

<block two>
/trials = [1-5=two_trials]
</block>

<trial one_trials>
/stimulustimes = [1=press]
/validresponse = (" ")
/ ontrialend = [values.one_trialslatency=trial.one_trials.latency]
</trial>

<trial two_trials>
/stimulustimes = [1=fixationcross]
/ timeout = values.one_trialslatency
</trial>

<text fixationcross>
/items = (" + ")
</text>

<text press>
/items = (" press the spacebar ")
</text>

The big question is whether I can save somehow 5 latencies, as timeouts for 5 trials in the second block. As it is currently designed it only uses the latency of the last trial.

Thx!
By Dave - 7/22/2015

You can absolutely store several latencies and use them later on. You can use a <list> for that:

<expt >
/blocks = [1=one;2=two]
</expt>

<block one>
/trials = [1-5=one_trials]
</block>

<block two>
/trials = [1-5=two_trials]
</block>

<trial one_trials>
/stimulustimes = [1=press]
/validresponse = (" ")
/ ontrialend = [list.latencylist.appenditem(trial.one_trials.latency)]
</trial>

<list latencylist>
/ selectionmode = sequence
</list>


<trial two_trials>
/stimulustimes = [1=fixationcross]
/ timeout = list.latencylist.nextvalue
</trial>

<text fixationcross>
/items = (" + ")
</text>

<text press>
/items = (" press the spacebar ")
</text>

By plush - 7/22/2015

Works great! Thx for the quick replies!