Millisecond Forums

Jittering a trial with conditional branching

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

By jfanderson - 11/28/2018

Hello,

I'm working on a script and would like to add in a jitter to the pretrial pause. However, the jitter isn't executing and I am instead seeing all trials last exactly 2000ms (the upper limit of the range).

The trial should start with a pause ranging between 100 and 2000 milliseconds, then execute the stimulus sequence, then timeout and branch to the next trial based on a list.

<trial player1turninclusion3to1>
/ pretrialpause = replace(100-2000)
/ stimulustimes = [1=ball3, blank2, blank1; 100=blank3, ball1to3e; 200=blank1to3e; 220=ball1to3d; 320=blank1to3d; 340=ball1to3c; 440=blank1to3c; 460=ball1to3b; 560=blank1to3b; 580=ball1to3a; 680=blank1to3a; 700=ball1]
/ validresponse = (noresponse)
/ timeout = 800
/ branch = [if (counter.inclusionplayer1.selectedvalue == 2) trial.player2turninclusion1to2]
/ branch = [if (counter.inclusionplayer1.selectedvalue == 3) trial.yourturninclusion1to3]
</trial>

Any idea why the pretrialpause isn't jittering?

Thanks!
Jason
By Dave - 11/28/2018

jfanderson - Wednesday, November 28, 2018
Hello,

I'm working on a script and would like to add in a jitter to the pretrial pause. However, the jitter isn't executing and I am instead seeing all trials last exactly 2000ms (the upper limit of the range).

The trial should start with a pause ranging between 100 and 2000 milliseconds, then execute the stimulus sequence, then timeout and branch to the next trial based on a list.

<trial player1turninclusion3to1>
/ pretrialpause = replace(100-2000)
/ stimulustimes = [1=ball3, blank2, blank1; 100=blank3, ball1to3e; 200=blank1to3e; 220=ball1to3d; 320=blank1to3d; 340=ball1to3c; 440=blank1to3c; 460=ball1to3b; 560=blank1to3b; 580=ball1to3a; 680=blank1to3a; 700=ball1]
/ validresponse = (noresponse)
/ timeout = 800
/ branch = [if (counter.inclusionplayer1.selectedvalue == 2) trial.player2turninclusion1to2]
/ branch = [if (counter.inclusionplayer1.selectedvalue == 3) trial.yourturninclusion1to3]
</trial>

Any idea why the pretrialpause isn't jittering?

Thanks!
Jason

/ pretrialpause = replace(100-2000)

is not not really valid syntax  in this context -- i.e. it will not sample from the range 100 to 2000, as I suspect you intend it to. Instead the above will evaluate 100-2000 as a mathematical expression, yielding -1900 as result, and then take that as the pretrialpause. Since a pretrialpause can be no shorter than 0 ms, you see none at all.

Doing

/ pretrialpause = replace(100, 500, 1000, 1500, 2000)

on the other hand would be valid syntax in this context, and you would see jittering.

That said, to sample from the full range 100 to 2000 at random for the pretrialpause, you'll want to do something like this:

<expressions>
/ randomjitter = round(rand(100,2000))
</expressions>

<values>
/ randompretrialpause = 0
</values>

<trial player1turninclusion3to1>
/ ontrialbegin = [values.randompretrialpause = expressions.randomjitter;]
/ pretrialpause = values.randompretrialpause
/ stimulustimes = [1=ball3, blank2, blank1; 100=blank3, ball1to3e; 200=blank1to3e; 220=ball1to3d; 320=blank1to3d; 340=ball1to3c; 440=blank1to3c; 460=ball1to3b; 560=blank1to3b; 580=ball1to3a; 680=blank1to3a; 700=ball1]
/ validresponse = (noresponse)
/ timeout = 800
/ branch = [if (counter.inclusionplayer1.selectedvalue == 2) trial.player2turninclusion1to2]
/ branch = [if (counter.inclusionplayer1.selectedvalue == 3) trial.yourturninclusion1to3]
</trial>

Hope this helps.