+x+xLet me try that again.
Default duration of the stimulus is 4000ms if the participant presses z every press of z adds 100 ms on to this time.
If the participant presses n every press of n
decreases the stimulus duration by 100 milliseconds.
The keypresses should occur whilst the stimulus is on the screen.
The sequence of keypresses and their timing relative to the start of the trial should also be recorded.
Thanks
Kevin
<trial t>
/ stimulustimes = [0=t]
/ beginresponsetime = 0
/ inputdevice = keyboard
/ validresponse = (44,49)
/ responseinterrupt = trial
/ isvalidresponse = [
if(trial.t.response == 44) {trial.t.trialduration = trial.t.trialduration + 100; false} else if
(trial.t.response == 49) {trial.t.trialduration = trial.t.trialduration - 100;false}
]
/trialduration = 4000
</trial>
<text t>
/items =("X")
/ erase = false
</text>
Actually, scratch what I posted previously. It won't work reliably that way. The fundamental problem is that a trial's duration really isn't meant to be changed once it's underway, for obvious performance and timing reasons. So, back to the drawing board. Not sure this can be done, or done well, i.e. without incurring serious timing hiccups
Alright, the following should work reasonably well:
<values>
/ tduration = 0
/ up_responses = 0
/ down_responses = 0
/ latency = 0
/ stimonset = null
/ timeleft = 0
</values>
<block myblock>
/ trials = [1-4 = trial.t]
</block>
<trial t>
/ ontrialbegin = [
values.tduration = 4000; // set default duration
values.up_responses = 0; // count up responses in current trial
values.down_responses = 0; // count down responses
values.latency = 0;
values.timeleft = 0;
]
/ ontrialend = [
values.stimonset = text.t.timestamp; // store stimulus timestamp
]
/ stimulustimes = [0=clearscreen, t]
/ validresponse = (0)
/ trialduration = 0
/ branch = [
return trial.t_adjust;
]
</trial>
<trial t_adjust>
/ ontrialbegin = [
values.timeleft = values.tduration - values.latency;
]
/ ontrialend = [
values.latency = script.elapsedtime - values.stimonset; // calculate latency relative to stimulus onset
if (trial.t_adjust.response == 44) { // up response
values.tduration += 100;
values.up_responses += 1;
} else if (trial.t_adjust.response ==49) { // down response
values.tduration -= 100;
values.down_responses += 1;
};
]
/ validresponse = (44, 49)
/ beginresponsetime = -1
/ timeout = values.timeleft
/ branch = [
if (trial.t_adjust.response == 0) {
return trial.iti;
} else {
return trial.t_adjust;
};
]
</trial>
<trial iti>
/ stimulustimes = [0=clearscreen]
/ trialduration = 500
/ validresponse = (0)
/ recorddata = false
</trial>
<text t>
/ items = ("T")
/ erase = false
</text>
<data>
/ columns = (date time subject group session blocknum blockcode trialnum trialcode response responsetext latency
values.tduration values.up_responses values.down_responses values.latency values.timeleft)
</data>