| Reference | Downloads | Github

Semi-random assignment to conditions

Hi everyone,

I’m trying to run my first Psychopy/Pavlovia experiment, but I am stuck with a semi-randomized assigment of each participant.

What I have: My experiment contains a total of 4 independent groups (planned are exactly 40 participants per group). Each condition contains videos that vary in frequencies (T vs. A) and one of two phase shift (i.e., in vs. out), leading to the conditions T_in, T_out, A_in, and A_out.
However, this is not enough… each condition will be presented in one of two sequence: Sequence 1 and Sequence 2, leading to a total of 8 groups already (T_in_seq1, T_out_seq1, T_in_seq2, T_out_seq2, A_in_seq1, A_out_seq1, A_in_seq2, A_out_seq2).
Again, not enough… My supervisor does not want a random assignment of our participant to one of those group. Instead, we need the same number of males and females within each of the 8 conditions and it is important that they are evenly distributed to each group to avoid something like one group is full but one didn’t even start, for example.

What did I try so far? I started by adding another “Experiment Info”, asking for the sex of each participant. I then thought I could assign Males and Females to one of two Excel-Sheets that contain the conditions. However, I really have no idea what I could do next to assign males/females to half of each condition (and sequence within the condition) and especially, how to make sure that it stops with one condition as soon as it has its max. number of participants.

Another idea was to give each male participant an ascending number from 1-80 (and females from 81-160) and previously pseudorandomize numbers 1-80 to each of the described conditions (same goes for females), but how does the program know which number is the next in line?

I am really desperate with this, since I am new to psychopy but especially to programming in general and I have no idea if this description makes kind of sense at all…
For a better visualization of all conditions, please see the list below. I really hope it helps!

Thank you so much in advance!! I appreciate every help!!!

For online counterbalanced assignment to groups you probably need Qualtrics or one of my online tools


You could use a different recruitment URL for men and women in order to ensure that both groups are separately counterbalanced.

Hi Wakecarter,

thank you for the quick reply! I will definitely try our advises and your idea to use different recruitments URLs sounds pretty good too!

I just look at the VESPR Study Portal and it is exactly what I was looking for! I just have to figure out how to combine the portal with my Pavlovia Study but the Video on youtube already helped a lot: VESPR Study Portal - YouTube
I might ask some other questions while testing everything :slight_smile:

PS: Your portal accidently also solved another issue I still had with the Online-Experiement: I wasn’t happy with asking for the E-Mail adress to send a voucher. It seems like this helps, too, so thanks sooo much!!

1 Like

It’s me again.

I just finished filling out each text field and pressed “Save as new experiment”.
However, when I press this, the only thing that happens is that the page refreshes and the examples page is shown again, i.e., my content is gone. Is there anything I need to do on Pavlovia first/ need the advanced version due to the groups? Do you have something like a step-by-step explanation? I also thought if there might be a word limit, since my PI Sheet is quite long…

Thanks again for your help, really appreciate it! :slight_smile:

Thanks for payment. I’ve upgraded your account.

I don’t think there’s a limit to the PI sheet. You should still see it when you save as new experiment. I’ll take a look but later. What did you see at the top of the page when you saved?

Thank you!

As soon as I click on Save as new Experiment, this is what the top page looks like:

Thanks…bug fixed, please try again.

PI sheet, Debrief and Inactive texts should be unrestricted in size.

It is working now, thanks! :slight_smile:

Sorry I have to bother you again, but I am stuck again.
I just don’t know how to connect the VESPR portal with my Experiment on Pavlovia…
My main questions:

  1. Do I have to define the groups in Psychopy with a code component in the beginning of the experiment in some way? (e.g., defined groups are connected with a condition csv. file?)
  2. How does VESPR know which group (so far 1-8) is connected to which condition?
  3. How can I define how many participants are needed in one group?
  4. To create seperate recruitment URLs for men and women, do I create two experiments in your app to get differnt links?

I am really grateful for you help! If there is any kind of “how to” somewhere else please let me know, but I couldn’t find anything yet.

  1. You need to set group in the expInfo dialogue box so it can receive the value of group sent my the study portal. Then use expInfo[‘group’] (which will be a string variable of ‘1’ to ‘8’ if you set 8 groups) to define the spreadsheet, e.g. conditionsFile = ‘group’+expInfo[‘group’]+’.xlsx’

  2. It doesn’t. You have to tell PsychoPy what to do with each value of group.

  3. The Study Portal will attempt to assign equal numbers to each group. I haven’t added a stopping condition at this stage.

  4. Yes, that would be the easiest way to do it. In the PI sheet you could add a link to the other PI sheet for people reading it of the wrong gender. A link in Markdown is created using [Duck Duck Go](

The video and this thread are the only documentation other than that you can see on the app itself.

Great, that helps alot!