Reply To: Randomization of Stimuli Across Blocks

PennController for IBEX Forums Support Randomization of Stimuli Across Blocks Reply To: Randomization of Stimuli Across Blocks

#5706
Jeremy
Keymaster

Hi Andreas,

Here’s an example of what you can do. I use left-right vs right-left spelling to represent your design’s different accents, but in your case you probably want to point to different audio files. I’m also defining only 4 items, but set NITEMS to 24 if this is how many items you have (make sure you have 24 corresponding rows in your table—25 including the header)

AddTable("myTable", `leftRight,rightLeft
hello,olleh
world,dlrow
bye,eyb
mate,etam`)

NITEMS = 4
order = [...new Array(NITEMS)].map((v,i)=>i<NITEMS/2).sort(v=>Math.random()>=0.5)

Sequence( randomize("leftRight") , randomize("rightLeft") )

Template( "myTable" , row =>
  newTrial( (order[0]?"leftRight":"rightLeft") ,
    newText( (order.shift()?row.leftRight:row.rightLeft) ).print()
    ,
    newButton("Next").print().wait()
  )
)

Let me know if you have any questions

Jeremy