Millisecond Forums

How to program: if the participant doesn't respond - use posttrialpause(2,5 seconds), if the user responds - no pause.

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

By mingwu - 11/23/2016

I have posttrialpause set for 2,5 seconds. What i would like to change: if the participant doesn't respond - use posttrialpause (2,5 seconds), if the participant responds - no pause.
Here is the script: 
<trial redcontrol2> 

/ontrialbegin = [
    values.congruency = 3;
]
/ timeout = 2500
/ posttrialpause = 2500
/ stimulustimes = [1=redcontrol, redreminder, greenreminder, bluereminder, purplereminder]
/ correctresponse = ("d")
/ validresponse = ("d", "f", "j", "k")
/ontrialend = [
    list.responses.insertitem(trial.redcontrol2.correct, 1);
    list.responses_control.insertitem(trial.redcontrol2.correct, 1);
    
    if (trial.redcontrol2.correct) {
        list.latencies.insertitem(trial.redcontrol.latency, 1);
        list.latencies_control.insertitem(trial.redcontrol2.latency, 1);
    }
]
</trial>
By Dave - 11/24/2016

mingwu - Wednesday, November 23, 2016
I have posttrialpause set for 2,5 seconds. What i would like to change: if the participant doesn't respond - use posttrialpause (2,5 seconds), if the participant responds - no pause.
Here is the script: 
<trial redcontrol2> 

/ontrialbegin = [
    values.congruency = 3;
]
/ timeout = 2500
/ posttrialpause = 2500
/ stimulustimes = [1=redcontrol, redreminder, greenreminder, bluereminder, purplereminder]
/ correctresponse = ("d")
/ validresponse = ("d", "f", "j", "k")
/ontrialend = [
    list.responses.insertitem(trial.redcontrol2.correct, 1);
    list.responses_control.insertitem(trial.redcontrol2.correct, 1);
    
    if (trial.redcontrol2.correct) {
        list.latencies.insertitem(trial.redcontrol.latency, 1);
        list.latencies_control.insertitem(trial.redcontrol2.latency, 1);
    }
]
</trial>

You can't do this using /posttrialpause. The currently running instance of a <trial> cannot manipulate the current instance's /posttrialpause.

What you need to do is create a separate <trial> that serves as "posttrialpause". Then /branch to that trial as needed.

<trial mytrial>
/ stimulusframes = [1=mytext]
/ correctresponse = ("d")
/ validresponse = ("d", "f", "j", "k")
/ timeout = 2500
/ branch = [
    if (trial.mytrial.response == 0) trial.post_tp;
]
</trial>

<trial post_tp>
/ trialduration = 2500
/ validresponse = (0)
</trial>


<text mytext>
/ items = ("EXAMPLE")
</text>

<block myblock>
/ trials = [1-10 = mytrial]
</block>