PennController for IBEX › Forums › Support › Randomization of Stimuli Across Blocks › Reply To: Randomization of Stimuli Across Blocks
Hi Andreas,
Yes, the code should work across browsers (or at least, you won’t have to use a different code for Firefox vs Chrome)
The new design you are describing has 4 conditions instead of 2, so you will need to adapt the code I gave you accordingly. So I worked on a slightly more general version of the code:
AddTable("myTable", `leftRight_familiar,rightLeft_familiar,leftRight_unfamiliar,rightLeft_unfamiliar hello_familiar,olleh_familiar,hello_unfamiliar,olleh_unfamiliar world_familiar,dlrow_familiar,world_unfamiliar,dlrow_unfamiliar bye_familiar,eyb_familiar,bye_unfamiliar,eyb_unfamiliar mate_familiar,etam_familiar,mate_unfamiliar,etam_unfamiliar`) NITEMS = 4 CONDITIONS = ['leftRight_familiar','rightLeft_familiar','leftRight_unfamiliar','rightLeft_unfamiliar'] order = [...new Array(NITEMS)].map((v,i)=>i%CONDITIONS.length).sort(v=>Math.random()>=0.5) Sequence( randomize("leftRight_familiar"), randomize("rightLeft_familiar"), randomize("leftRight_unfamiliar"), randomize("rightLeft_unfamiliar"), ) Template( "myTable" , row => newTrial( CONDITIONS[order[0]] , newText( row[CONDITIONS[order.shift()]] ).print() , newButton("Next").print().wait() ) )
Now if you update your design to use more or less conditions, you only have to change the content of Sequence and the value of CONDITIONS (and NITEMS if you have a different number of items). Notice that I took the liberty to replace 1 and 2 with familiar and unfamiliar for more transparency.
Let me know if you have any questions
Jeremy