﻿<?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 6  » Change duration of a trial depending on participant response.</title><generator>InstantForum 2017-1 Final</generator><description>Millisecond Forums</description><link>https://forums.millisecond.com/</link><webMaster>Millisecond Forums</webMaster><lastBuildDate>Sun, 28 Jun 2026 13:29:56 GMT</lastBuildDate><ttl>20</ttl><item><title>Change duration of a trial depending on participant response.</title><link>https://forums.millisecond.com/Topic35823.aspx</link><description>Hi,&lt;br/&gt;&lt;br/&gt;I would like to create an experiment where participants view images.&lt;br/&gt;I would like to be able to have a participant increase or decrease the amount of time the stimulus is shown to them for by pressing keys.&lt;br/&gt;Press one key to increase the stimulus duration, press another key to decrease it.&lt;br/&gt;What would be the best way to implement this with inquisit?&lt;br/&gt;&lt;br/&gt;Thanks&lt;br/&gt;Kevin</description><pubDate>Wed, 06 Dec 2023 14:29:38 GMT</pubDate><dc:creator>kev_dent</dc:creator></item><item><title>RE: Change duration of a trial depending on participant response.</title><link>https://forums.millisecond.com/Topic35834.aspx</link><description>Thanks for your help Dave.&lt;br/&gt;I will have a play with this code.</description><pubDate>Wed, 06 Dec 2023 14:29:38 GMT</pubDate><dc:creator>kev_dent</dc:creator></item><item><title>RE: Change duration of a trial depending on participant response.</title><link>https://forums.millisecond.com/Topic35833.aspx</link><description>&lt;blockquote data-id="35831" class="if-quote-wrapper" unselectable="on" data-guid="1701872269195" contenteditable="false" id="if_insertedNode_1701872268908"&gt;&lt;a class="quote-para" unselectable="on" style="display: none;" href="#" data-id="35831" 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="35831" 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="35831" title=" "&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[b]&lt;/span&gt;Dave - 12/6/2023&lt;span unselectable="on" class="quote-markup"&gt;[/b]&lt;/span&gt;&lt;/div&gt;&lt;div class="if-quote-message if-quote-message-35831"&gt;&lt;div class="if-quote-message-margin" contenteditable="true"&gt;&lt;blockquote data-id="35828" class="if-quote-wrapper" unselectable="on" data-guid="1701872269195" contenteditable="false" id="if_insertedNode_1701869356468"&gt;&lt;a class="quote-para" unselectable="on" style="display: none;" href="#" data-id="35828" 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="35828" 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="35828" title=" "&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[b]&lt;/span&gt;kev_dent - 12/6/2023&lt;span unselectable="on" class="quote-markup"&gt;[/b]&lt;/span&gt;&lt;/div&gt;&lt;div class="if-quote-message if-quote-message-35828"&gt;&lt;div class="if-quote-message-margin" contenteditable="true"&gt;Let me try that again.&lt;br/&gt;&lt;br/&gt;Default duration of the stimulus is 4000ms if the participant presses z every press of z adds 100 ms on to this time.&lt;br/&gt;If the participant presses n every press of n &lt;strong&gt;decreases&lt;/strong&gt; the stimulus duration by 100 milliseconds.&lt;br/&gt;The keypresses should occur whilst the stimulus is on the screen.&lt;br/&gt;The sequence of keypresses and their timing relative to the start of the trial should also be recorded.&lt;br/&gt;Thanks&lt;br/&gt;Kevin&lt;br/&gt;&lt;br/&gt;&amp;lt;trial t&amp;gt;&lt;br/&gt;/ stimulustimes = [0=t]&lt;br/&gt;/ beginresponsetime = 0&lt;br/&gt;/ inputdevice = keyboard&lt;br/&gt;/ validresponse = (44,49)&lt;br/&gt;/ responseinterrupt = trial&lt;br/&gt;/ isvalidresponse = [&lt;br/&gt;&amp;nbsp; if(trial.t.response == 44) {trial.t.trialduration = trial.t.trialduration + 100; false} else if&lt;br/&gt;  (trial.t.response == 49) {trial.t.trialduration = trial.t.trialduration - 100;false}&lt;br/&gt;]&lt;br/&gt;/trialduration = 4000&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text t&amp;gt;&lt;br/&gt;/items =("X")&lt;br/&gt;/ erase = false&lt;br/&gt;&amp;lt;/text&amp;gt; &lt;a class="if-quote-goto quote-link" href="#" data-id="35828"&gt;&lt;span class="goto"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[/quote]&lt;/span&gt;&lt;/blockquote&gt;&lt;br/&gt;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&lt;br/&gt;&lt;a class="if-quote-goto quote-link" href="#" data-id="35831"&gt;&lt;span class="goto"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[/quote]&lt;/span&gt;&lt;/blockquote&gt;&lt;br/&gt;Alright, the following should work reasonably well:&lt;br/&gt;&lt;br/&gt;[code]&amp;lt;values&amp;gt;&lt;br/&gt;/ tduration = 0&lt;br/&gt;/ up_responses = 0&lt;br/&gt;/ down_responses = 0&lt;br/&gt;/ latency = 0&lt;br/&gt;/ stimonset = null&lt;br/&gt;/ timeleft = 0&lt;br/&gt;&amp;lt;/values&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;block myblock&amp;gt;&lt;br/&gt;/ trials = [1-4 = trial.t]&lt;br/&gt;&amp;lt;/block&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;trial t&amp;gt;&lt;br/&gt;/ ontrialbegin = [&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.tduration = 4000; // set default duration&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.up_responses = 0; // count up responses in current trial&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.down_responses = 0; // count down responses&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.latency = 0;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.timeleft = 0;&lt;br/&gt;]&lt;br/&gt;/ ontrialend = [&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.stimonset = text.t.timestamp; // store stimulus timestamp&lt;br/&gt;]&lt;br/&gt;/ stimulustimes = [0=clearscreen, t]&lt;br/&gt;/ validresponse = (0)&lt;br/&gt;/ trialduration = 0&lt;br/&gt;/ branch = [&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return trial.t_adjust;&lt;br/&gt;]&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;trial t_adjust&amp;gt;&lt;br/&gt;/ ontrialbegin = [&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.timeleft = values.tduration - values.latency;&lt;br/&gt;]&lt;br/&gt;/ ontrialend = [&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.latency = script.elapsedtime - values.stimonset; // calculate latency relative to stimulus onset&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (trial.t_adjust.response == 44) { // up response&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.tduration += 100;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.up_responses += 1;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else if (trial.t_adjust.response ==49) { // down response&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.tduration -= 100;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.down_responses += 1;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;br/&gt;]&lt;br/&gt;/ validresponse = (44, 49)&lt;br/&gt;/ beginresponsetime = -1&lt;br/&gt;/ timeout = values.timeleft&lt;br/&gt;/ branch = [&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (trial.t_adjust.response == 0) {&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return trial.iti;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else {&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return trial.t_adjust;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;br/&gt;]&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;trial iti&amp;gt;&lt;br/&gt;/ stimulustimes = [0=clearscreen]&lt;br/&gt;/ trialduration = 500&lt;br/&gt;/ validresponse = (0)&lt;br/&gt;/ recorddata = false&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text t&amp;gt;&lt;br/&gt;/ items = ("T")&lt;br/&gt;/ erase = false&lt;br/&gt;&amp;lt;/text&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;data&amp;gt;&lt;br/&gt;/ columns = (date time subject group session blocknum blockcode trialnum trialcode response responsetext latency&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.tduration values.up_responses values.down_responses values.latency values.timeleft)&lt;br/&gt;&amp;lt;/data&amp;gt;[/code]</description><pubDate>Wed, 06 Dec 2023 14:18:17 GMT</pubDate><dc:creator>Dave</dc:creator></item><item><title>RE: Change duration of a trial depending on participant response.</title><link>https://forums.millisecond.com/Topic35831.aspx</link><description>&lt;blockquote data-id="35828" class="if-quote-wrapper" unselectable="on" data-guid="1701869357399" contenteditable="false" id="if_insertedNode_1701869356468"&gt;&lt;a class="quote-para" unselectable="on" style="display: none;" href="#" data-id="35828" 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="35828" 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="35828" title=" "&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[b]&lt;/span&gt;kev_dent - 12/6/2023&lt;span unselectable="on" class="quote-markup"&gt;[/b]&lt;/span&gt;&lt;/div&gt;&lt;div class="if-quote-message if-quote-message-35828"&gt;&lt;div class="if-quote-message-margin" contenteditable="true"&gt;Let me try that again.&lt;br/&gt;&lt;br/&gt;Default duration of the stimulus is 4000ms if the participant presses z every press of z adds 100 ms on to this time.&lt;br/&gt;If the participant presses n every press of n &lt;strong&gt;decreases&lt;/strong&gt; the stimulus duration by 100 milliseconds.&lt;br/&gt;The keypresses should occur whilst the stimulus is on the screen.&lt;br/&gt;The sequence of keypresses and their timing relative to the start of the trial should also be recorded.&lt;br/&gt;Thanks&lt;br/&gt;Kevin&lt;br/&gt;&lt;br/&gt;&amp;lt;trial t&amp;gt;&lt;br/&gt;/ stimulustimes = [0=t]&lt;br/&gt;/ beginresponsetime = 0&lt;br/&gt;/ inputdevice = keyboard&lt;br/&gt;/ validresponse = (44,49)&lt;br/&gt;/ responseinterrupt = trial&lt;br/&gt;/ isvalidresponse = [&lt;br/&gt;&amp;nbsp; if(trial.t.response == 44) {trial.t.trialduration = trial.t.trialduration + 100; false} else if&lt;br/&gt;  (trial.t.response == 49) {trial.t.trialduration = trial.t.trialduration - 100;false}&lt;br/&gt;]&lt;br/&gt;/trialduration = 4000&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text t&amp;gt;&lt;br/&gt;/items =("X")&lt;br/&gt;/ erase = false&lt;br/&gt;&amp;lt;/text&amp;gt; &lt;a class="if-quote-goto quote-link" href="#" data-id="35828"&gt;&lt;span class="goto"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[/quote]&lt;/span&gt;&lt;/blockquote&gt;&lt;br/&gt;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&lt;br/&gt;</description><pubDate>Wed, 06 Dec 2023 13:32:37 GMT</pubDate><dc:creator>Dave</dc:creator></item><item><title>RE: Change duration of a trial depending on participant response.</title><link>https://forums.millisecond.com/Topic35828.aspx</link><description>Let me try that again.&lt;br/&gt;&lt;br/&gt;Default duration of the stimulus is 4000ms if the participant presses z every press of z adds 100 ms on to this time.&lt;br/&gt;If the participant presses n every press of n &lt;strong&gt;decreases&lt;/strong&gt; the stimulus duration by 100 milliseconds.&lt;br/&gt;The keypresses should occur whilst the stimulus is on the screen.&lt;br/&gt;The sequence of keypresses and their timing relative to the start of the trial should also be recorded.&lt;br/&gt;Thanks&lt;br/&gt;Kevin&lt;br/&gt;&lt;br/&gt;&amp;lt;trial t&amp;gt;&lt;br/&gt;/ stimulustimes = [0=t]&lt;br/&gt;/ beginresponsetime = 0&lt;br/&gt;/ inputdevice = keyboard&lt;br/&gt;/ validresponse = (44,49)&lt;br/&gt;/ responseinterrupt = trial&lt;br/&gt;/ isvalidresponse = [&lt;br/&gt;&amp;nbsp; if(trial.t.response == 44) {trial.t.trialduration = trial.t.trialduration + 100; false} else if&lt;br/&gt;  (trial.t.response == 49) {trial.t.trialduration = trial.t.trialduration - 100;false}&lt;br/&gt;]&lt;br/&gt;/trialduration = 4000&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text t&amp;gt;&lt;br/&gt;/items =("X")&lt;br/&gt;/ erase = false&lt;br/&gt;&amp;lt;/text&amp;gt; </description><pubDate>Wed, 06 Dec 2023 12:13:56 GMT</pubDate><dc:creator>kev_dent</dc:creator></item><item><title>RE: Change duration of a trial depending on participant response.</title><link>https://forums.millisecond.com/Topic35827.aspx</link><description>Ok sure here is some toy code to illustrate what I want to do.&lt;br/&gt;Default duration of the stimulus is 4000ms if the participant presses z every press of z adds 100 ms on to this time.&lt;br/&gt;If the participant presses n every press of n increases the stimulus duration by 100 milliseconds.&lt;br/&gt;The keypresses should occur whilst the stimulus is on the screen.&lt;br/&gt;The sequence of keypresses and their timing relative to the start of the trial should also be recorded.&lt;br/&gt;Thanks&lt;br/&gt;Kevin&lt;br/&gt;&lt;br/&gt;&amp;lt;trial t&amp;gt;&lt;br/&gt;/ stimulustimes = [0=t]&lt;br/&gt;/ beginresponsetime = 0&lt;br/&gt;/ inputdevice = keyboard&lt;br/&gt;/ validresponse = (44,49)&lt;br/&gt;/ responseinterrupt = trial&lt;br/&gt;/ isvalidresponse = [&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(trial.t.response == 44) {trial.t.trialduration = trial.t.trialduration + 100; false} else if&lt;br/&gt;&amp;nbsp; (trial.t.response == 49) {trial.t.trialduration = trial.t.trialduration + 100;false}&lt;br/&gt;]&lt;br/&gt;/trialduration = 4000&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text t&amp;gt;&lt;br/&gt;/items =("X")&lt;br/&gt;/ erase = false&lt;br/&gt;&amp;lt;/text&amp;gt;</description><pubDate>Wed, 06 Dec 2023 12:11:46 GMT</pubDate><dc:creator>kev_dent</dc:creator></item><item><title>RE: Change duration of a trial depending on participant response.</title><link>https://forums.millisecond.com/Topic35825.aspx</link><description>&lt;blockquote data-id="35823" class="if-quote-wrapper" unselectable="on" data-guid="1701863651401" contenteditable="false" id="if_insertedNode_1701863650502"&gt;&lt;a class="quote-para" unselectable="on" style="display: none;" href="#" data-id="35823" 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="35823" 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="35823" title=" "&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[b]&lt;/span&gt;kev_dent - 12/6/2023&lt;span unselectable="on" class="quote-markup"&gt;[/b]&lt;/span&gt;&lt;/div&gt;&lt;div class="if-quote-message if-quote-message-35823"&gt;&lt;div class="if-quote-message-margin" contenteditable="true"&gt;Hi,&lt;br/&gt;&lt;br/&gt;I would like to create an experiment where participants view images.&lt;br/&gt;I would like to be able to have a participant increase or decrease the amount of time the stimulus is shown to them for by pressing keys.&lt;br/&gt;Press one key to increase the stimulus duration, press another key to decrease it.&lt;br/&gt;What would be the best way to implement this with inquisit?&lt;br/&gt;&lt;br/&gt;Thanks&lt;br/&gt;Kevin&lt;a class="if-quote-goto quote-link" href="#" data-id="35823"&gt;&lt;span class="goto"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[/quote]&lt;/span&gt;&lt;/blockquote&gt;&lt;br/&gt;You want that for the currently running trial (i.e, the image is already on-screen) or you want that sometime before any image(s) are displayed? Give a concrete example.</description><pubDate>Wed, 06 Dec 2023 11:55:10 GMT</pubDate><dc:creator>Dave</dc:creator></item></channel></rss>