Millisecond Forums

Randomly Selecting Block From A List

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

By Whitman - 11/28/2012

Hi,


I have several blocks that fall into a given category and I'd like to show one block of each category in random order, along with other blocks that are the only kind in their category.


For example:


<expt >
/blocks = [1-2=noreplace(BlockType1, BlockType2)]
</expt>


Where BlockType1 is a category of blocks that include 3 different blocks and BlockType2 is always just one block.


I tried using the List element, but the items attribute didn't accept block terms. I also tried using the noreplace() command within a groups attribute in a variables element. For example:


<variables>
/ group = (1 of 1) (BlockType1=noreplace(BlockA, BlockB, BlockC))
</variables>


Is there a parsimonious way of achieving this without creating all the iterations in the form of expt elements?



Thank you!

By Dave - 11/28/2012

E.g.:


<list blockselector>
/ items = (list.type1blocklist.nextvalue, list.type2blocklist.nextvalue)
/ selectionmode = random
</list>


<list type2blocklist>
/ items = (block.type2, block.type3, block.type4)
/ selectionmode = random
</list>

<list type1blocklist>
/ items = (block.type1a, block.type1b, block.type1c)
/ selectionmode = random
</list>

<expt>
/ blocks = [1-2=list.blockselector; 3-4=list.blockselector; 5-6=list.blockselector]
</expt>

<block type1a>
/ trials = [1=mytrial]
</block>

<block type1b>
/ trials = [1=mytrial]
</block>

<block type1c>
/ trials = [1=mytrial]
</block>

<block type2>
/ trials = [1=mytrial]
</block>

<block type3>
/ trials = [1=mytrial]
</block>

<block type4>
/ trials = [1=mytrial]
</block>

<trial mytrial>
/ stimulusframes = [1=mytext]
/ validresponse = (57)
</trial>

<text mytext>
/ items = ("<%script.currentblock%>")
</text>


Regards,


~Dave

By Whitman - 12/3/2012

Hi Dave,


Thanks for help on how to use the list element script. I've fiddled around with it, but now I'm having problems with only a subset of the blocks showing. Specifically, I want 6 blocks to appear without replacement, but only 1 OR 2 do (I can't figure out the pattern of when one versus the other occurs). Do you have any idea about why this might be going on?


Below is a truncated example of the script that I've written:


<list PairSelect1>
/ items = (list.WBm1.nextvalue, list.WWm1.nextvalue, list.WBf1.nextvalue, list.WWf1.nextvalue, list.Filler5, list.Filler8)
/ selectionmode = random
/ replace = false
</list>

<list Filler5>
/ items = (block.Filler5)
</list>

<list Filler8>
/ items = (block.Filler8)
</list>

<list WBm1>
/ items = (block.WM1BMa, block.WM2BMb, block.WM3BMc, block.WM4BMd)
/ selectionmode = random
</list>

<list WWm1>
/ items = (block.WM5WMa, block.WM6WMb, block.WM7WMc, block.WM8WMd)
/ selectionmode = random
</list>

<list WBf1>
/ items = (block.WF1BFa, block.WF2BFb, block.WF3BFc, block.WF4BFd)
/ selectionmode = random
</list>

<list WWf1>
/ items = (block.WF5WFa, block.WF6WFb, block.WF7WFc, block.WF8WFd)
/ selectionmode = random
</list>


<expt >
/blocks = [ 1-6=list.pairselect1]
/ subjects = (1 of 4)
</expt>



Where each of the blocks is set up similar to this (each trial is a separate question):


<block WM1BMa>
/ trials = [ 1-10=noreplace(WM1BMagetalong, WM1BMacomm1, WM1BMadisgust, WM1BMaanger, WM1BMaanxious, WM1BMaexpect1, WM1BMaexpect2, WM1BMasimilar1, WM1BMasimilar2, WM1BMasimilar3)]
</block>

By Dave - 12/3/2012

See the documentation for /resetinterval (also applicable to <list>).

By Dave - 12/3/2012

FWIW, here's a script mimicking your block setup and sampling logic:


<list blockselector>
/ items = (list.a.nextvalue, list.b.nextvalue, list.c.nextvalue, list.d.nextvalue, list.e.nextvalue, list.f.nextvalue)
/ selectionmode = random
</list>

<list a>
/ items = (block.a1, block.a2, block.a3, block.a4)
/ selectionmode = random
</list>

<list b>
/ items = (block.b1, block.b2, block.b3, block.b4)
/ selectionmode = random
</list>

<list c>
/ items = (block.c1, block.c2, block.c3, block.c4)
/ selectionmode = random
</list>

<list d>
/ items = (block.d1, block.d2, block.d3, block.d4)
/ selectionmode = random
</list>

<list e>
/ items = (block.e)
/ selectionmode = random
</list>

<list f>
/ items = (block.f)
/ selectionmode = random
</list>

<expt>
/ blocks = [1-6=list.blockselector]
</expt>

<block a1>
/ trials = [1=mytrial]
</block>

<block a2>
/ trials = [1=mytrial]
</block>

<block a3>
/ trials = [1=mytrial]
</block>

<block a4>
/ trials = [1=mytrial]
</block>

<block b1>
/ trials = [1=mytrial]
</block>

<block b2>
/ trials = [1=mytrial]
</block>

<block b3>
/ trials = [1=mytrial]
</block>

<block b4>
/ trials = [1=mytrial]
</block>

<block c1>
/ trials = [1=mytrial]
</block>

<block c2>
/ trials = [1=mytrial]
</block>

<block c3>
/ trials = [1=mytrial]
</block>

<block c4>
/ trials = [1=mytrial]
</block>

<block d1>
/ trials = [1=mytrial]
</block>

<block d2>
/ trials = [1=mytrial]
</block>

<block d3>
/ trials = [1=mytrial]
</block>

<block d4>
/ trials = [1=mytrial]
</block>

<block e>
/ trials = [1=mytrial]
</block>

<block f>
/ trials = [1=mytrial]
</block>

<trial mytrial>
/ stimulusframes = [1=mytext]
/ validresponse = (57)
</trial>

<text mytext>
/ items = ("<%script.currentblock%>")
</text>


It runs as expected for me (using Inquisit 4.0.0.1 on Windows). I.e., I get one random sample from each list just as intended.


I am thus inclined to think that your issues stem from syntax errors in your


<list PairSelect1>
/ items = (list.WBm1.nextvalue, list.WWm1.nextvalue, list.WBf1.nextvalue, list.WWf1.nextvalue, list.Filler5, list.Filler8)
/ selectionmode = random
/ replace = false
</list>


Note the missing '.nextvalue'.


By Whitman - 12/3/2012

Yep. That's it. Sorry to ask when it ended up being such a simple thing (I was mistaken about the  .nextvalue function), but I really appreciate your help. Thanks much!

By Dave - 12/3/2012

Sorry to ask when it ended up being such a simple thing


Don't be. I for one prefer simple mistakes over hard-to-find ones any day!


(Insufferable nerd comment: .nextvalue is a property, not a function.)

By Whitman - 12/3/2012

Haha noted