Millisecond Forums

within-participant randomization

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

By S F - 6/28/2019

Hi!

We have an experiment were we want participants to get 18 different trials, and within that we have 2 conditions and 6 trial types (three trials fall into each trial type). We want participants to see 3 trial types (9 trials) in one condition and 3 of the trial types in another condition (if a trial type appears in one condition, we do not want it to appear in the other condition for the same participant). If we want to randomize this as much as possible, how do we group these trials together into blocks without running the risk of having unbalanced condition assignment at the expt level? Or, if we don't group the trials together in a block by trial type, I think we might end up repeating the same trial type in different conditions.


So far we are just counterbalancing it pseudorandomly by hard coding a few different combinations. Here is one counterbalancing condition:


<expt controlandintervention>
/ blocks = [1=noreplace(block.condition1, block.condition2, block.condition3)]
</expt>

<block condition1>
/ trials = [1=playcond1; 2-10=noreplace(c_cap1, c_bottlecap2,c_lid3, c_drinkingglasses4, c_eyeglasses5, c_goggles6, c_bullshorn7, 
c_insthorn8, c_croissant9); 11=trial.whitescreen1 ;12-20=noreplace(i_paper10, i_bedsheet11, i_leaf12, i_globe13, i_hotairballoon14, 
i_rubberballoon15, i_shirtcollar16, i_dogcollar17, i_neckalace18)]
</block>

<trial playcond1>
/ stimulusframes = [1=greenarrowcond1]
/ inputdevice = mouse
/ validresponse = (greenarrowcond1)
/ recorddata = false
</trial>


<picture greenarrowcond1>
/ items = ("play_green copy.jpg")
/ size = (500, 500)
/ position = (50,50)
</picture>

<trial whitescreen1>
/ stimulusframes = [1=whitescreen1]
/ timeout = 3500
</trial>

<picture whitescreen1>
/ items = ("whitescreen.jpg")
/ size = (1000,1000)
</picture>


<trial c_cap1>
/ stimulusframes=[1=c_cap1]
/ timeout = 3500
</trial>

<trial c_bottlecap2>
/ stimulusframes=[1=c_bottlecap2]
/ timeout = 3500
</trial>

<trial c_lid3>
/ stimulusframes=[1=c_lid3]
/ timeout = 3500
</trial>

<picture c_cap1>
/ items = ("capA.jpg")
/ size = (500, 500) 
/ animation = circle(2000, 2, 0, 600, 375, 50)
</picture>

<picture c_bottlecap2>
/ items = ("capB.HEIC copy.jpg")
/ size = (500, 500) 
/ animation = path(2000, 1, 35, 50, 65, 50, 50, 50)
</picture>

<picture c_lid3>
/ items = ("capC.jpg")
/ size = (500, 500) 
/ animation = circle(2000, 2, 0, 600, 375, 50)
</picture>

<trial c_drinkingglasses4>
/ stimulusframes=[1=c_drinkingglasses4]
/ timeout = 3500
</trial>

<trial c_eyeglasses5>
/ stimulusframes=[1=c_eyeglasses5]
/ timeout = 3500
</trial>

<trial c_goggles6>
/ stimulusframes=[1=c_goggles6]
/ timeout = 3500
</trial>

<picture c_drinkingglasses4>
/ items = ("glassesA.jpg")
/ size = (500, 500) 
/ animation = circle(2000, 2, 0, 600, 375, 50)
</picture>


<picture c_eyeglasses5>
/ items = ("glassesB.jpg")
/ size = (500, 500) 
/ animation = path(2000, 1, 35, 50, 65, 50, 50, 50)
</picture>

<picture c_goggles6>
/ items = ("glassesC.jpg")
/ size = (500, 500) 
/ animation = circle(2000, 2, 0, 600, 375, 50)
</picture>


<trial c_bullshorn7>
/ stimulusframes=[1=c_bullshorn7]
/ timeout = 3500
</trial>

<trial c_insthorn8>
/ stimulusframes=[1=c_insthorn8]
/ timeout = 3500
</trial>

<trial c_croissant9>
/ stimulusframes=[1=c_croissant9]
/ timeout = 3500
</trial>


<picture c_bullshorn7>
/ items = ("hornA.jpg")
/ size = (500, 500) 
/ animation = path(2000, 1, 35, 50, 65, 50, 50, 50)
</picture>

<picture c_insthorn8>
/ items = ("hornB.HEIC copy.jpg")
/ size = (500, 500) 
/ animation = circle(2000, 2, 0, 600, 375, 50)
</picture>

<picture c_croissant9>
/ items = ("hornC.jpg")
/ size = (500, 500) 
/ animation = path(2000, 1, 35, 50, 65, 50, 50, 50)
</picture>







<trial i_paper10>
/ stimulusframes=[1=i_paper10]
/ timeout = 3500
</trial>

<trial i_bedsheet11>
/ stimulusframes=[1=i_bedsheet11]
/ timeout = 3500
</trial>

<trial i_leaf12>
/ stimulusframes=[1=i_leaf12]
/ timeout = 3500
</trial>

<picture i_paper10>
/ items = ("sheetA.HEIC copy.jpg")
/ size = (500, 500) 
/ animation = circle(2000, 2, 0, 600, 375, 50)
</picture>

<picture i_bedsheet11>
/ items = ("sheetB.HEIC copy.jpg")
/ size = (500, 500) 
/ animation = path(2000, 1, 35, 50, 65, 50, 50, 50)
</picture>

<picture i_leaf12>
/ items = ("sheetC.HEIC copy.jpg")
/ size = (500, 500) 
/ animation = path(2000, 1, 35, 50, 65, 50, 50, 50)
</picture>

<trial i_globe13>
/ stimulusframes=[1=i_globe13]
/ timeout = 3500
</trial>

<trial i_hotairballoon14>
/ stimulusframes=[1=i_hotairballoon14]
/ timeout = 3500
</trial>

<trial i_rubberballoon15>
/ stimulusframes=[1=i_rubberballoon15]
/ timeout = 3500
</trial>

<picture i_globe13>
/ items = ("balloonA.HEIC copy.jpg")
/ size = (500, 500) 
/ animation = circle(2000, 2, 0, 600, 375, 50)
</picture>

<picture i_hotairballoon14>
/ items = ("balloonB.HEIC copy.jpg")
/ size = (500, 500) 
/ animation = path(2000, 1, 35, 50, 65, 50, 50, 50)
</picture>

<picture i_rubberballoon15>
/ items = ("balloonC.jpg")
/ size = (500, 500) 
/ animation = circle(2000, 2, 0, 600, 375, 50)
</picture>

<trial i_shirtcollar16>
/ stimulusframes=[1=i_shirtcollar16]
/ timeout = 3500
</trial>

<trial i_dogcollar17>
/ stimulusframes=[1=i_dogcollar17]
/ timeout = 3500
</trial>

<trial i_neckalace18>
/ stimulusframes=[1=i_neckalace18]
/ timeout = 3500
</trial>

<picture i_shirtcollar16>
/ items = ("collarA.HEIC copy.jpg")
/ size = (500, 500) 
/ animation = path(2000, 1, 35, 50, 65, 50, 50, 50)
</picture>

<picture i_dogcollar17>
/ items = ("collarB.jpg")
/ size = (500, 500) 
/ animation = circle(2000, 2, 0, 600, 375, 50)
</picture>

<picture i_neckalace18>
/ items = ("collarC copy.jpg")
/ size = (500, 500) 
/ animation = path(2000, 1, 35, 50, 65, 50, 50, 50)
</picture>


By Dave - 6/28/2019


Sorry, it's not clear at all from your code what the "3 trial types" are. Please take the time and explain -- clearly -- which trials belong together (i.e. are of the same type) and how you want those randomized.
By S F - 6/28/2019

Oh no, sorry about that! Thanks for asking.

There are 6 words which each have 3 different meanings or images associated with them (for example, one trial would have a picture of drinking glasses, another trial that would show a picture of reading glasses, and a third trial that would have a picture of goggles-- together, the three of these form a "glasses" category). So I was trying to describe the three trials together as a trial type.

And we want all three of these trials to either appear with one set of three audio stimuli or all three appear with another three audio stimuli (this reflects the condition assignment) and we want the word/trial type to be randomly selected for a given participant and we want the condition to be randomly selected, but we want to be sure the participants get the same number of trials in each condition and we never want to split trial types across conditions (so if one of the three glasses trials appears in condition A, none of the other two glasses trials can appear in condition B)-- and we have to have order completely randomized.

Are we better off just hard coding pseudo-randomizations?
By Dave - 6/28/2019

S F - 6/28/2019
Oh no, sorry about that! Thanks for asking.

There are 6 words which each have 3 different meanings or images associated with them (for example, one trial would have a picture of drinking glasses, another trial that would show a picture of reading glasses, and a third trial that would have a picture of goggles-- together, the three of these form a "glasses" category). So I was trying to describe the three trials together as a trial type.

And we want all three of these trials to either appear with one set of three audio stimuli or all three appear with another three audio stimuli (this reflects the condition assignment) and we want the word/trial type to be randomly selected for a given participant and we want the condition to be randomly selected, but we want to be sure the participants get the same number of trials in each condition and we never want to split trial types across conditions (so if one of the three glasses trials appears in condition A, none of the other two glasses trials can appear in condition B)-- and we have to have order completely randomized.

Are we better off just hard coding pseudo-randomizations?

Could you please spell out which <trial> elements belong together and refer to those trial elements exactly as you named them in the script? I don't have your image files, the code appears otherwise incomplete (there are no <block condition2> and <block condition3> elements, although they are referenced in your <expt> element), and it's still not clear to me what the condition assignment is supposed to be.

You mention sets of three audio stimuli, yet I cannot find any audio stimuli referenced anywhere in the code.
By Dave - 6/28/2019

Dave - 6/28/2019
S F - 6/28/2019
Oh no, sorry about that! Thanks for asking.

There are 6 words which each have 3 different meanings or images associated with them (for example, one trial would have a picture of drinking glasses, another trial that would show a picture of reading glasses, and a third trial that would have a picture of goggles-- together, the three of these form a "glasses" category). So I was trying to describe the three trials together as a trial type.

And we want all three of these trials to either appear with one set of three audio stimuli or all three appear with another three audio stimuli (this reflects the condition assignment) and we want the word/trial type to be randomly selected for a given participant and we want the condition to be randomly selected, but we want to be sure the participants get the same number of trials in each condition and we never want to split trial types across conditions (so if one of the three glasses trials appears in condition A, none of the other two glasses trials can appear in condition B)-- and we have to have order completely randomized.

Are we better off just hard coding pseudo-randomizations?

Could you please spell out which <trial> elements belong together and refer to those trial elements exactly as you named them in the script? I don't have your image files, the code appears otherwise incomplete (there are no <block condition2> and <block condition3> elements, although they are referenced in your <expt> element), and it's still not clear to me what the condition assignment is supposed to be.

You mention sets of three audio stimuli, yet I cannot find any audio stimuli referenced anywhere in the code.

Okay, let me try to tackle this schematically. Suppose you have six "types" A to F (or 1 to 6 in numerical terms), with each type made up of three separated <trial> elements. That is

Type A = <trial a1>, <trial a2>, and <trial a3>
Type B = <trial b1>, <trial b2>, and <trial b3>
...
Type F = <trial f1>, <trial f2>, and <trial f3>

You want to distribute the types across two blocks of 9 trials each.
So, block1 might run trials b1, b2, b3, e1, e2, e3,  f1, f2, and f3 in random order; that is types B, E, and F. The 2nd block, then, would necessarily run trials a1, a2, a3, c1, c2, c3, d1, d2, and d3 (also all in random order), that is: the remaining types A, C, and D.

The way to pull this would be by populating separate <list> elements for each block with randomly selected type numbers at the beginning of the experiment (/onexptbegin), like so:

// we select three types per block and fill per-block condition lists accordingly
<expt>
/ onexptbegin = [
list.cond1types.appenditem(list.typelist.nextvalue);
list.cond1types.appenditem(list.typelist.currentvalue);
list.cond1types.appenditem(list.typelist.currentvalue);
list.cond1types.appenditem(list.typelist.nextvalue);
list.cond1types.appenditem(list.typelist.currentvalue);
list.cond1types.appenditem(list.typelist.currentvalue);
list.cond1types.appenditem(list.typelist.nextvalue);
list.cond1types.appenditem(list.typelist.currentvalue);
list.cond1types.appenditem(list.typelist.currentvalue);

list.cond2types.appenditem(list.typelist.nextvalue);
list.cond2types.appenditem(list.typelist.currentvalue);
list.cond2types.appenditem(list.typelist.currentvalue);
list.cond2types.appenditem(list.typelist.nextvalue);
list.cond2types.appenditem(list.typelist.currentvalue);
list.cond2types.appenditem(list.typelist.currentvalue);
list.cond2types.appenditem(list.typelist.nextvalue);
list.cond2types.appenditem(list.typelist.currentvalue);
list.cond2types.appenditem(list.typelist.currentvalue);
]
/ blocks = [1=block1; 2=block2]
</expt>

<block block1>
/ preinstructions = (pg1)
/ trials = [1-9 = list.block1trials]
</block>

<block block2>
/ preinstructions = (pg2)
/ trials = [1-9 = list.block2trials]
</block>

// we have six types A to F
// A = 1
// B = 2
// ...
// F = 6
// we'll select 3 types at random for each of the two blocks
<list typelist>
/ items = (1,2,3,4,5,6)
/ selectionrate = always
</list>

// types for the two blocks are selected onexptbegin
<list cond1types>
</list>

<list cond2types>
</list>

<list block1trials>
/ items = (list.type_a.nextvalue, list.type_b.nextvalue, list.type_c.nextvalue, list.type_d.nextvalue, list.type_e.nextvalue, list.type_f.nextvalue)
/ select = list.cond1types.nextvalue
</list>

<list block2trials>
/ items = (list.type_a.nextvalue, list.type_b.nextvalue, list.type_c.nextvalue, list.type_d.nextvalue, list.type_e.nextvalue, list.type_f.nextvalue)
/ select = list.cond2types.nextvalue
</list>

//Type A
<list type_a>
/ items = (trial.a1, trial.a2, trial.a3)
</list>

<trial a1>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial a2>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial a3>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>

//Type B
<list type_b>
/ items = (trial.b1, trial.b2, trial.b3)
</list>

<trial b1>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial b2>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial b3>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>

//Type C
<list type_c>
/ items = (trial.c1, trial.c2, trial.c3)
</list>

<trial c1>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial c2>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial c3>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>

//Type D
<list type_d>
/ items = (trial.d1, trial.d2, trial.d3)
</list>

<trial d1>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial d2>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial d3>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>

//Type E
<list type_e>
/ items = (trial.e1, trial.e2, trial.e3)
</list>

<trial e1>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial e2>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial e3>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>

//Type F
<list type_f>
/ items = (trial.f1, trial.f2, trial.f3)
</list>

<trial f1>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial f2>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial f3>
/ stimulusframes = [1=mytext]
/ validresponse = (0)
/ trialduration = 1000
</trial>

// the unimportant stuff
<text mytext>
/ items = ("<%script.currenttrial%>")
</text>

<page pg1>
^This is the 1st block of 9 trials.
</page>

<page pg2>
^This is the 2nd block of 9 trials.
</page>

<data>
/ separatefiles = true
</data>