Reply To: Is it possible to shuffle trials according to a % of times?

PennController for IBEX Forums Support Is it possible to shuffle trials according to a % of times? Reply To: Is it possible to shuffle trials according to a % of times?

#8128
Jeremy
Keymaster

Hi,

Using shuffle in the sequence will “specif[y] that items matching the given predicates should be shuffled together in such a way that items matching each predicate are evenly spaced. The original relative ordering between items of the same type is preserved.”

For example, the following will get as close as possible to separate two B, two C and two D trials with 9 other trials in between, but A trials won’t be separated by more than ~2 trials overall, because of the proportions of trials

Sequence(shuffle("A","B","C","D"))

for (let i = 0; i<70; i++)  newTrial("A", newButton("A"+i).print().wait())
for (let i = 0; i<10; i++)  newTrial("B", newButton("B"+i).print().wait())
for (let i = 0; i<10; i++)  newTrial("C", newButton("C"+i).print().wait())
for (let i = 0; i<10; i++)  newTrial("D", newButton("D"+i).print().wait())

That's if you have 4 different labels, and actually create 70/10/10/10 trials. But if you only create a total 4 trials, but want to repeat them following a 70/10/10/10 distribution, you could do that:

Sequence(shuffle(
    ...[...new Array(70)].map(v=>"A"),
    ...[...new Array(10)].map(v=>"B"),
    ...[...new Array(10)].map(v=>"C"),
    ...[...new Array(10)].map(v=>"D"),
))

newTrial("A", newButton("A").print().wait())
newTrial("B", newButton("B").print().wait())
newTrial("C", newButton("C").print().wait())
newTrial("D", newButton("D").print().wait())

Does that answer your question?

Jeremy