Counterbalancing for online experiments

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): win10
PsychoPy version (e.g. 1.84.x): 2021.1.2
Standard Standalone? (y/n) If not then what?:y
What are you trying to achieve?:
I am trying to counterbalance my experiment online. I have used the fantastic url on here ( to set participant numbers and then used the following code

if expInfo['participant'] % 2:
    group = 'A'
    group = 'B'

What did you try to make it work?:

I then in my conditions file put the following $"condition"+'group'+".xlsx"

What specifically went wrong when you tried that?:

I got the error message

Unfortunately we encountered the following error:

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

Which means I assume that i’m not defining the variable group at the right stage. Is anyone able to help with this. I’ve put the code component in the first “welcome” routine and put in the begin experiment tab. I have also tried putting it in the before experiment tab but it did not work.

my two condition files are conditionA.xlsx and conditionB.xlsx

Many thanks

You need to add your Excel files in the online tab of experiment settings.

Also, use int(expInfo…) to convert participant from string to an integer.

Thank you, that solved the integer problem, I also had put ’ ’ around the variable and it wasn’t reading group, works now I have removed them.

1 Like