Pseudorandom trial structure /Importing CSV trial structure?
Hello! This is my first time running an experiment with open sesame and OSWeb. My online study requires a pseudorandomized trial structure, but I've noticed that open sesame/osweb does not support psuedorandomization, nor importing a CSV. I've been able to copy-paste a CSV table into the table from the loop - but this is quite a tedious and messy option as each study would need 3600 trials and I would need a unique trial structure for each participant.
Are there any ways around this problem? Ideally I am able to import my information as a CSV or other table, to avoid the time cost by live pseudorandomization.
Thank you!!
Comments
Hi @henrietel ,
It depends on the kind of pseudorandomization that you need. If you have complex constraints, then your solution of copy-pasting very long loop tables would work, although it's clearly clunky. For simpler cases, you could use an
inline_javascriptitem.For example, the following script would create an array of conditions ('a' and 'b') with a maximum repetition of 1, so at most twice the same condition in a row. You could put something like this at the start of the experiment:
function shuffle(array) { array = array.slice() let counter = array.length while (counter > 0) { let index = Math.floor(Math.random() * counter) counter-- let temp = array[counter] array[counter] = array[index] array[index] = temp } return array } function max_rep(array) { let max_rep = 0 let n_rep = 0 for (let i = 0; i < array.length; i++) { if (i === 0) { continue } if (array[i] === array[i - 1]) { n_rep++ if (n_rep > max_rep) { max_rep = n_rep } } else { n_rep = 0 } } console.log(max_rep) return max_rep } vars.conditions = ['a', 'a', 'a', 'a', 'b', 'b', 'b', 'b'] while (true) { vars.conditions = shuffle(vars.conditions) if (max_rep(vars.conditions) <= 1) { break } } console.log(vars.conditions)And then in each trial, you would get one of the conditions from this array and assign it to the
conditionvariable:This may not be what you need exactly, but that's the general type of solution to this kind of issue.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi henriete,
What do you mean with Opensesame doesn't support pseudorandomization? Do you mean a specific type of randomization or just shuffling the trials? Because in the loop table, you can set the *order* field to random, which does randomization.
Does that help, or am I misunderstanding?
Eduard