Millisecond Forums

Two alternatives for stimulus presentation times

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

By ewa2702 - 6/8/2016

Hi all,

Sorry if this has been asked before!

I am trying to create a trial where participants are shown an image for EITHER 400 or 1600 milliseconds (and are then shown an error message depending on whether they correctly or incorrectly identified the trial as being longer or shorter than 850ms; this bit is irrelevant to my problem, just here for some context). However, the following code (which, as far as I can tell, should do exactly that; I have highlighted the relevant line) seems to show the stimulus for a value somewhere BETWEEN 400-1600ms, rather than either/or.

<trial practise_trial>
/ontrialbegin = [values.fixduration = 400 + round(rand(0,1))*1200]
/ontrialbegin = [trial.practise_trial.insertstimulustime(picture.mask, 200+values.fixduration);]
/stimulustimes = [1=fixation_cross_text; 200=practise_picture]
/validresponse = (31, 38)
/ontrialend = [values.presponse = trial.practise_trial.response]
/ontrialend = [if(values.fixduration <= 850) values.correctresponse = "31"]
/ontrialend = [if(values.fixduration >=851) values.correctresponse = "38"]
/ontrialend=[if(values.correctresponse == values.presponse) values.trialoutcome = 1]
/ontrialend=[if(values.correctresponse != values.presponse) values.trialoutcome = 0]
/pretrialpause = (400)
/inputdevice= keyboard
/recorddata= false
/ branch=[if(values.trialoutcome == 1) trial.correctfb]
/ branch=[if(values.trialoutcome == 0) trial.errorfb]
</trial>

Can anyone help? Thanks in advance!
By Dave - 6/9/2016

#1: If you want only two distinct values for fixduration, you should simply do:

/ ontrialbegin = [values.fixduration = replace(400, 1600)]

#2: You will want to *reset* the stimulus presentation sequence /ontrialend. Otherwise the insertion of stimuli will be cumulative across trials.

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

Beyond that, the timings should work out regardless of whether you do

/ontrialbegin = [values.fixduration = 400 + round(rand(0,1))*1200]

or

/ ontrialbegin = [values.fixduration = replace(400, 1600)]

If you run

<values>
/ fixduration = 0
</values>

<trial practice_trial>
/ontrialbegin = [values.fixduration = 400 + round(rand(0,1))*1200]
/ontrialbegin = [trial.practice_trial.insertstimulustime(text.mask, 200+values.fixduration);]
/stimulustimes = [1=fixation_cross_text; 200=practice_text]
/validresponse = (31, 38)
/ ontrialend = [trial.practice_trial.resetstimulusframes(); ]
</trial>

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

<text practice_text>
/ items = ("fixduration = <%values.fixduration%>")
</text>

<text mask>
/ items = ("MASK_MASK_MASK")
</text>

<block myblock>
/ trials = [1-4 = practice_trial]
</block>

<data>
/ columns = [trialnum values.fixduration text.mask.stimulusonset]
/ separatefiles = true
</data>

vs

<values>
/ fixduration = 0
</values>

<trial practice_trial>
/ ontrialbegin = [values.fixduration = replace(400, 1600)]
/ontrialbegin = [trial.practice_trial.insertstimulustime(text.mask, 200+values.fixduration);]
/stimulustimes = [1=fixation_cross_text; 200=practice_text]
/validresponse = (31, 38)
/ ontrialend = [trial.practice_trial.resetstimulusframes(); ]
</trial>

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

<text practice_text>
/ items = ("fixduration = <%values.fixduration%>")
</text>

<text mask>
/ items = ("MASK_MASK_MASK")
</text>

<block myblock>
/ trials = [1-4 = practice_trial]
</block>

<data>
/ columns = [trialnum values.fixduration text.mask.stimulusonset]
/ separatefiles = true
</data>

and look at the text.mask.stimulusonset column, you should see that the timings are what they are supposed to be in both cases:

1    1600    1799   
2    1600    1799   
3    400    599   
4    400    599   
By ewa2702 - 6/9/2016

That's perfect, thanks so much!!