## within-participant randomization

 Author Message S F  Partner Member         Group: Forum Members Posts: 27, Visits: 166 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:/ blocks = [1=noreplace(block.condition1, block.condition2, block.condition3)]/ 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)]/ stimulusframes = [1=greenarrowcond1]/ inputdevice = mouse/ validresponse = (greenarrowcond1)/ recorddata = false/ items = ("play_green copy.jpg")/ size = (500, 500)/ position = (50,50)/ stimulusframes = [1=whitescreen1]/ timeout = 3500/ items = ("whitescreen.jpg")/ size = (1000,1000)/ stimulusframes=[1=c_cap1]/ timeout = 3500/ stimulusframes=[1=c_bottlecap2]/ timeout = 3500/ stimulusframes=[1=c_lid3]/ timeout = 3500/ items = ("capA.jpg")/ size = (500, 500) / animation = circle(2000, 2, 0, 600, 375, 50)/ items = ("capB.HEIC copy.jpg")/ size = (500, 500) / animation = path(2000, 1, 35, 50, 65, 50, 50, 50)/ items = ("capC.jpg")/ size = (500, 500) / animation = circle(2000, 2, 0, 600, 375, 50)/ stimulusframes=[1=c_drinkingglasses4]/ timeout = 3500/ stimulusframes=[1=c_eyeglasses5]/ timeout = 3500/ stimulusframes=[1=c_goggles6]/ timeout = 3500/ items = ("glassesA.jpg")/ size = (500, 500) / animation = circle(2000, 2, 0, 600, 375, 50)/ items = ("glassesB.jpg")/ size = (500, 500) / animation = path(2000, 1, 35, 50, 65, 50, 50, 50)/ items = ("glassesC.jpg")/ size = (500, 500) / animation = circle(2000, 2, 0, 600, 375, 50)/ stimulusframes=[1=c_bullshorn7]/ timeout = 3500/ stimulusframes=[1=c_insthorn8]/ timeout = 3500/ stimulusframes=[1=c_croissant9]/ timeout = 3500/ items = ("hornA.jpg")/ size = (500, 500) / animation = path(2000, 1, 35, 50, 65, 50, 50, 50)/ items = ("hornB.HEIC copy.jpg")/ size = (500, 500) / animation = circle(2000, 2, 0, 600, 375, 50)/ items = ("hornC.jpg")/ size = (500, 500) / animation = path(2000, 1, 35, 50, 65, 50, 50, 50)/ stimulusframes=[1=i_paper10]/ timeout = 3500/ stimulusframes=[1=i_bedsheet11]/ timeout = 3500/ stimulusframes=[1=i_leaf12]/ timeout = 3500/ items = ("sheetA.HEIC copy.jpg")/ size = (500, 500) / animation = circle(2000, 2, 0, 600, 375, 50)/ items = ("sheetB.HEIC copy.jpg")/ size = (500, 500) / animation = path(2000, 1, 35, 50, 65, 50, 50, 50)/ items = ("sheetC.HEIC copy.jpg")/ size = (500, 500) / animation = path(2000, 1, 35, 50, 65, 50, 50, 50)/ stimulusframes=[1=i_globe13]/ timeout = 3500/ stimulusframes=[1=i_hotairballoon14]/ timeout = 3500/ stimulusframes=[1=i_rubberballoon15]/ timeout = 3500/ items = ("balloonA.HEIC copy.jpg")/ size = (500, 500) / animation = circle(2000, 2, 0, 600, 375, 50)/ items = ("balloonB.HEIC copy.jpg")/ size = (500, 500) / animation = path(2000, 1, 35, 50, 65, 50, 50, 50)/ items = ("balloonC.jpg")/ size = (500, 500) / animation = circle(2000, 2, 0, 600, 375, 50)/ stimulusframes=[1=i_shirtcollar16]/ timeout = 3500/ stimulusframes=[1=i_dogcollar17]/ timeout = 3500/ stimulusframes=[1=i_neckalace18]/ timeout = 3500/ items = ("collarA.HEIC copy.jpg")/ size = (500, 500) / animation = path(2000, 1, 35, 50, 65, 50, 50, 50)/ items = ("collarB.jpg")/ size = (500, 500) / animation = circle(2000, 2, 0, 600, 375, 50)/ items = ("collarC copy.jpg")/ size = (500, 500) / animation = path(2000, 1, 35, 50, 65, 50, 50, 50) Dave  Supreme Being         Group: Administrators Posts: 9.6K, Visits: 44K 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. S F  Partner Member         Group: Forum Members Posts: 27, Visits: 166 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? Dave  Supreme Being         Group: Administrators Posts: 9.6K, Visits: 44K +xS F - 6/28/2019Oh 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 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 and elements, although they are referenced in your 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. Dave  Supreme Being         Group: Administrators Posts: 9.6K, Visits: 44K +xDave - 6/28/2019+xS F - 6/28/2019Oh 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 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 and elements, although they are referenced in your 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 elements. That is Type A = , , and Type B = , , and ...Type F = , , and 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 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/ 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]/ preinstructions = (pg1)/ trials = [1-9 = list.block1trials]/ preinstructions = (pg2)/ trials = [1-9 = list.block2trials]// 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/ items = (1,2,3,4,5,6)/ selectionrate = always// types for the two blocks are selected onexptbegin/ 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/ 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//Type A/ items = (trial.a1, trial.a2, trial.a3)/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000//Type B/ items = (trial.b1, trial.b2, trial.b3)/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000//Type C/ items = (trial.c1, trial.c2, trial.c3)/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000//Type D/ items = (trial.d1, trial.d2, trial.d3)/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000//Type E/ items = (trial.e1, trial.e2, trial.e3)/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000//Type F/ items = (trial.f1, trial.f2, trial.f3)/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000/ stimulusframes = [1=mytext]/ validresponse = (0)/ trialduration = 1000// the unimportant stuff/ items = ("<%script.currenttrial%>")^This is the 1st block of 9 trials.^This is the 2nd block of 9 trials./ separatefiles = true