﻿<?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  » Code to Randomize Stimuli per Trial</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:39 GMT</lastBuildDate><ttl>20</ttl><item><title>Code to Randomize Stimuli per Trial</title><link>https://forums.millisecond.com/Topic35908.aspx</link><description>Hi everyone,&lt;br/&gt;&lt;br/&gt;I'm working on a project involving the Balloon Analogue Risk Task (BART), and I need some help with editing the code. The original task involves a red balloon that participants inflate to earn money, risking it popping. In my version, I want to introduce a twist: the balloon's color should change randomly at the start of each of the 30 trials.&lt;br/&gt;&lt;br/&gt;I have six different balloon images and have figured out how to integrate them into the code. However, my current challenge is that the balloon's type changes with every press of the "pump up" button. I need the balloon's type (color) to remain constant throughout a single trial and only change when a new trial begins.&lt;br/&gt;&lt;br/&gt;Could anyone guide me on how to modify the code to achieve this? I have attached the code file for reference.&lt;br/&gt;&lt;br/&gt;Thank you in advance for your assistance!</description><pubDate>Fri, 26 Jan 2024 18:13:21 GMT</pubDate><dc:creator>Marusil2yada</dc:creator></item><item><title>RE: Code to Randomize Stimuli per Trial</title><link>https://forums.millisecond.com/Topic35914.aspx</link><description>Dear Dave,&lt;br/&gt;&lt;br/&gt;Thank you so much. It works now!&lt;br/&gt;&lt;br/&gt;Have a nice day!</description><pubDate>Fri, 26 Jan 2024 18:13:21 GMT</pubDate><dc:creator>Marusil2yada</dc:creator></item><item><title>RE: Code to Randomize Stimuli per Trial</title><link>https://forums.millisecond.com/Topic35911.aspx</link><description>&lt;blockquote data-id="35908" class="if-quote-wrapper" unselectable="on" data-guid="1706273220831" contenteditable="false" id="if_insertedNode_1706273220456"&gt;&lt;a class="quote-para" unselectable="on" style="display: none;" href="#" data-id="35908" 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="35908" 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="35908" title=" "&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[b]&lt;/span&gt;Marusil2yada - 1/26/2024&lt;span unselectable="on" class="quote-markup"&gt;[/b]&lt;/span&gt;&lt;/div&gt;&lt;div class="if-quote-message if-quote-message-35908"&gt;&lt;div class="if-quote-message-margin" contenteditable="true"&gt;Hi everyone,&lt;br/&gt;&lt;br/&gt;I'm working on a project involving the Balloon Analogue Risk Task (BART), and I need some help with editing the code. The original task involves a red balloon that participants inflate to earn money, risking it popping. In my version, I want to introduce a twist: the balloon's color should change randomly at the start of each of the 30 trials.&lt;br/&gt;&lt;br/&gt;I have six different balloon images and have figured out how to integrate them into the code. However, my current challenge is that the balloon's type changes with every press of the "pump up" button. I need the balloon's type (color) to remain constant throughout a single trial and only change when a new trial begins.&lt;br/&gt;&lt;br/&gt;Could anyone guide me on how to modify the code to achieve this? I have attached the code file for reference.&lt;br/&gt;&lt;br/&gt;Thank you in advance for your assistance!&lt;a class="if-quote-goto quote-link" href="#" data-id="35908"&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 have six balloon items. You need a &amp;lt;list&amp;gt; with item numbers 1 to 6.&lt;br/&gt;&lt;br/&gt;[code]&amp;lt;list balloonitemnumbers&amp;gt;&lt;br/&gt;/ items = (1,2,3,4,5,6)&lt;br/&gt;/ selectionmode = random&lt;br/&gt;/ poolsize = 30&lt;br/&gt;&amp;lt;/list&amp;gt;[/code]&lt;br/&gt;&lt;br/&gt;You need to define a variable to store the balloon item number applicable to the given round&lt;br/&gt;&lt;br/&gt;[code]&amp;lt;values&amp;gt;&lt;br/&gt;...&lt;br/&gt;/ balloonitemnumber = 1&lt;br/&gt;...&lt;br/&gt;&amp;lt;/values&amp;gt;[/code]&lt;br/&gt;&lt;br/&gt;and you'll want the balloon picture element to select the item this variable will hold, i.e.&lt;br/&gt;&lt;br/&gt;[code]&amp;lt;picture balloon&amp;gt;&lt;br/&gt;/ items = ("balloon_red.jpg", "balloon_blue.jpg", "balloon_yellow.jpg", "balloon_red_shiny.jpg", "balloon_blue_shiny.jpg", "balloon_yellow_shiny.jpg")&lt;br/&gt;/ position = (33%, 83%)&lt;br/&gt;/ select = values.balloonitemnumber // here&lt;br/&gt;/ valign = bottom&lt;br/&gt;/ erase = false&lt;br/&gt;/ scale = values.scalingFactor&lt;br/&gt;/ size = (expressions.balloonSize, expressions.balloonSize)&lt;br/&gt;&amp;lt;/picture&amp;gt;[/code]&lt;br/&gt;&lt;br/&gt;Finally, at the start of each round, sample the item number to use in the ensuing round.&lt;br/&gt;&lt;br/&gt;[code]&amp;lt;trial init&amp;gt;&lt;br/&gt;/ ontrialbegin = [&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.pumpcount = 0;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.timebefore1stpump  = 0;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.timebeforecollectwithoutpump = 0;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.timebtwlastpumpandcollect =0;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.timebtwpumps = 0;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.sum_timebtwpumps = 0;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.mean_timebtwpumps = 0;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.countchoice = 0;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.scalingFactor = 1;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;values.balloonitemnumber = list.balloonitemnumbers.nextvalue; // pick balloon item for this round&lt;br/&gt;]&lt;br/&gt;...&lt;br/&gt;&amp;lt;/trial&amp;gt;[/code]&lt;br/&gt;</description><pubDate>Fri, 26 Jan 2024 12:57:37 GMT</pubDate><dc:creator>Dave</dc:creator></item></channel></rss>