Millisecond Forums

Varying stimulustime within a trial?

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

By Kolfers - 8/26/2014

Hi all, 

I have a question I hope you can help me with:

Currently I am trying to implement a version of the Dual Nback (loosely based on the existing example in the library). 
In this task a presented stimulus needs to be erased (within the trial), which is currently done by presenting a shape with the background color at the same position. 
Eg:
/stimulustimes = [0 = stim_square; 1000 = stim_eraser]

However I would like to make the duration of the presented stimulus (i.e. the time before it is erased) adaptive between trials. In essence I would need something like:
/stimulustimes = [0 = stim_square; values.stimduration = stim_eraser]

However the above does not work. I realise I could put two trials in sequence with the erasing and response collection done in the second trial. However, I'm afraid this will introduce an additional unpredictability in timing as the second trial would take some time to prepare (not to mention complicate the script even further): the erasing would not take place exactly at the required time and therefore the response latency would also be off with regards to the actual stimulus presentation.

Is there any straightforward workaround for this, besides fiddling with a second trial and pretrial pause?

Thank you!

By Dave - 8/26/2014

You cannot use variables in /stimulustimes or -frames as in

/stimulustimes = [0 = stim_square; values.stimduration = stim_eraser]


Instead you need to make use of the <trial> element's setstimulustime() and resetstimuluframes() functions (see the language reference for the <trial> element for further details). In a nutshell:

<trial mytrial>
/ ontrialbegin = [trial.mytrial.setstimulustime(shape.stim_eraser,values.stimduration);]
/ ontrialend = [trial.mytrial.resetstimulusframes();]
/ stimulustimes = [0 = stim_square]
...
</trial>


By Kolfers - 8/26/2014

Great, thank that was what I was looking for!