﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Millisecond Forums » Millisecond Forums » Inquisit 4  » Jittering a trial with conditional branching</title><generator>InstantForum 2017-1 Final</generator><description>Millisecond Forums</description><link>https://forums.millisecond.com/</link><webMaster>Millisecond Forums</webMaster><lastBuildDate>Tue, 25 Aug 2026 21:52:24 GMT</lastBuildDate><ttl>20</ttl><item><title>Jittering a trial with conditional branching</title><link>https://forums.millisecond.com/Topic26129.aspx</link><description>Hello,&lt;br/&gt;&lt;br/&gt;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).&lt;br/&gt;&lt;br/&gt;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.&lt;br/&gt;&lt;br/&gt;&amp;lt;trial player1turninclusion3to1&amp;gt;&lt;br/&gt;/ pretrialpause = replace(100-2000)&lt;br/&gt;/ 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]&lt;br/&gt;/ validresponse = (noresponse)&lt;br/&gt;/ timeout = 800&lt;br/&gt;/ branch = [if (counter.inclusionplayer1.selectedvalue == 2) trial.player2turninclusion1to2]&lt;br/&gt;/ branch = [if (counter.inclusionplayer1.selectedvalue == 3) trial.yourturninclusion1to3]&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;Any idea why the pretrialpause isn't jittering?&lt;br/&gt;&lt;br/&gt;Thanks!&lt;br/&gt;Jason</description><pubDate>Wed, 28 Nov 2018 13:44:16 GMT</pubDate><dc:creator>jfanderson</dc:creator></item><item><title>RE: Jittering a trial with conditional branching</title><link>https://forums.millisecond.com/Topic26131.aspx</link><description>&lt;div data-id="26129" class="if-quote-wrapper" unselectable="on" data-guid="1543440733683"&gt;&lt;a class="quote-para" unselectable="on" style="display: none;" href="#" data-id="26129" title="Move Cursor Below" contenteditable="false"&gt;&lt;span unselectable="on"&gt;+&lt;/span&gt;&lt;/a&gt;&lt;a class="quote-delete" unselectable="on" style="display: none;" href="#" data-id="26129" title="Delete Quote" contenteditable="false"&gt;&lt;span unselectable="on"&gt;x&lt;/span&gt;&lt;/a&gt;&lt;span unselectable="on" class="quote-markup"&gt;[quote]&lt;/span&gt;&lt;div unselectable="on" class="if-quote-header" contenteditable="false"&gt;&lt;div unselectable="on" class="if-quote-toggle-wrapper"&gt;&lt;a class="if-quote-toggle quote-link" href="#" data-id="26129" title=" "&gt;&lt;/a&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[b]&lt;/span&gt;jfanderson - Wednesday, November 28, 2018&lt;span unselectable="on" class="quote-markup"&gt;[/b]&lt;/span&gt;&lt;/div&gt;&lt;div class="if-quote-message if-quote-message-26129"&gt;&lt;div class="if-quote-message-margin"&gt;Hello,&lt;br/&gt;&lt;br/&gt;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).&lt;br/&gt;&lt;br/&gt;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.&lt;br/&gt;&lt;br/&gt;&amp;lt;trial player1turninclusion3to1&amp;gt;&lt;br/&gt;/ pretrialpause = replace(100-2000)&lt;br/&gt;/ 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]&lt;br/&gt;/ validresponse = (noresponse)&lt;br/&gt;/ timeout = 800&lt;br/&gt;/ branch = [if (counter.inclusionplayer1.selectedvalue == 2) trial.player2turninclusion1to2]&lt;br/&gt;/ branch = [if (counter.inclusionplayer1.selectedvalue == 3) trial.yourturninclusion1to3]&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;Any idea why the pretrialpause isn't jittering?&lt;br/&gt;&lt;br/&gt;Thanks!&lt;br/&gt;Jason&lt;a class="if-quote-goto quote-link" href="#" data-id="26129"&gt;&lt;span class="goto"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class="quote-markup"&gt;[/quote]&lt;/span&gt;&lt;/div&gt;&lt;br/&gt;/ pretrialpause = &lt;strong&gt;replace(100-2000)&lt;br/&gt;&lt;/strong&gt;&lt;br/&gt;is not not really valid syntax&amp;nbsp; 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.&lt;br/&gt;&lt;br/&gt;Doing&lt;br/&gt;&lt;br/&gt;/ pretrialpause = replace(100, 500, 1000, 1500, 2000)&lt;br/&gt;&lt;br/&gt;on the other hand would be valid syntax in this context, and you would see jittering.&lt;br/&gt;&lt;br/&gt;That said, to sample from the full range 100 to 2000 at random for the pretrialpause, you'll want to do something like this:&lt;br/&gt;&lt;br/&gt;&amp;lt;expressions&amp;gt;&lt;br/&gt;/ randomjitter = round(rand(100,2000))&lt;br/&gt;&amp;lt;/expressions&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;values&amp;gt;&lt;br/&gt;/ randompretrialpause = 0&lt;br/&gt;&amp;lt;/values&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;trial player1turninclusion3to1&amp;gt;&lt;br/&gt;/ ontrialbegin = [values.randompretrialpause = expressions.randomjitter;]&lt;br/&gt;/ pretrialpause = values.randompretrialpause&lt;br/&gt;/ 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]&lt;br/&gt;/ validresponse = (noresponse)&lt;br/&gt;/ timeout = 800&lt;br/&gt;/ branch = [if (counter.inclusionplayer1.selectedvalue == 2) trial.player2turninclusion1to2]&lt;br/&gt;/ branch = [if (counter.inclusionplayer1.selectedvalue == 3) trial.yourturninclusion1to3]&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;Hope this helps.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;</description><pubDate>Wed, 28 Nov 2018 13:44:16 GMT</pubDate><dc:creator>Dave</dc:creator></item></channel></rss>