| Reference | Downloads | Github

Counterbalancing in online experiments

I was wondering if there is any way I can use the same JS script for two different lists of stimuli (instead of creating two different scripts, and therefore two different projects on pavlovia).

With local PsychoPy, I would just create an item field in the diag box at the beginning of the experiment and then have the subject select it according to my needs, as shown here.

Given that my new experiment is going to be online, I would like to be in control of the two lists to feed the script with. What I was imagining is, for example, control the two lists by specifying the list within the URL of the experiment. From what I gathered in the PsychoPy webpage on online- participant recruitment, I can just use the URL address of my experiment with a specific query string, e.g.:

The variable list is then inserted as argument of the loop:

function loopTrialLoopBegin(thisScheduler) {
  // set up handler to look after randomisation of conditions etc
  loopTrial = new TrialHandler({
    psychoJS: psychoJS,
    nReps: 1, method: TrialHandler.Method.RANDOM,
    extraInfo: expInfo, originPath: undefined,
    trialList: list, // <----
    seed: undefined, name: 'loopTrial'});
  psychoJS.experiment.addLoop(loopTrial); // add the loop to the experiment
  currentLoop = loopTrial;  // we're now the current loop

Is that at all possible?

Yes, that’s exactly the idea.
A variable given to PsychoJS in the query string as you’ve done can be accessed during the experiment using


You probably need to manually add the csv file into your resources folder manually - PsychoPy probably won’t be able to work it out automatically from this method.

This also means that I will need to put the field list in my ExpInfo dictionary, which will appear in my diag box. I would rather not to have subjects mess with that…Could I just create a brand new dictionary just with list? e.g.,

let listInfo = {'list: ['list1', 'list2']};

and then refer to in both the URL and in the trialHandler object of my loop:

loopTrial = new TrialHandler({
 trialList: listInfo['list']+'.csv',

No. When you specify a value in the query string (whether or not it’s in the exp info dialog normally) it will then be excluded and the participants won’t see it.

For instance, ‘participant’ is in the dialog box, but if this is provided as a query string (e.g. by Prolific or Sona) then that entry in the dialog will not appear. So your experiment can allow self-assigned participants and auto-assigned participants with no change.

Clever huh?! :wink:

That’s actually pretty great, yes.