| Reference | Downloads | Github

Between-subjects counterbalancing using Pavlovia (assigning different .xlsx conditions files to different participants)

Hi, I’ll be running an online psychopy experiment. I usually achieve between-subjects counterbalancing (of assigning stimuli to conditions, etc.) by loading a new excel conditions sheet for each participant. Presumably I can’t do this when I am running it online? Am I now forced to created different “versions” of my experiment for the different counterbalancing conditions? There must be a way around this, but I can’t seem to figure it out…

Thanks in advance!


This may help :slight_smile:

Hi Nicholas. In my case, I need to use a different conditions file for each participant (randomising the identity of the stimuli). Am I correct in assuming, that if I used your solution it may result in some condition files being selected more than once and others not being selected at all? Thanks!

I have a web app to help with this.



Hi, and thank you! Am I correct in understand that this requires me to ask the participant to enter an ID and/or link with Qualtrics? Is there a way to avoid both of those options?

They are designed to create a consecutive ID on the fly and do not need Qualtrics

Sorry for the silly question, but how do I label my condition files so that the ID generated matches a file? A related but somewhat similar question - have you seen the thread in Todd’s profile titled ‘personalising stimuli’? Out of curiosity, is that also a way to achieve the same end (randomise the identity of stimuli per participant, but in this case using one conditions file), and does it work online (the thread refers to builder). Thanks!

How many different conditions files do you have? I would label them something like condition0.xlsx, condition1.xlsx, etc. and then use

useFile = "condition"+str(expInfo['participant']%8)+".xlsx"

if you have 8 different files.

Thank you for the specific instruction! I’ll probably end up using 40 condition files. I will use your suggestion. The reason for my second question was just to understand different ways of doing things.

Any insight why I would receive the following message: ‘TypeError: not all arguments converted during string formatting’.

Please could you copy and paste (into preformatted text) the line that you think isn’t working?

The error referred to this line in the code: useFile = “condition”+str(expInfo[‘participant’]%2)+".xlsx"

I’m testing our discussed solution using 2 conditions files (condition0.xlxs; condition1.xlxs) and running it locally.

Also - when running it online through your app - the experiment opens and goes through the welcome page, but then gives the following error:

  • when importing condition: condition1.xlsx
  • when getting the value of resource: condition1.xlsx
  • unknown resource

Have you copied the Excel files to html/resources ?