# Counterbalancing across participants

Hi!

I have a question about counterbalancing a stimuli position across participants. I found descriptions on how to counterbalance a stimuli position within participants. But between participants counterbalancing is not that clear.

In my task I need to demonstrate stimuli A on the left throughout the experiment for one participant, but for another participant I need to demonstrate stimuli A on the right throughout the experiment.

I tried to use the shuffle function. But it keeps changing positions within one experiment…

1 Like

Hey Marinalosifian,

I’m encountering the same problem, only that we have 200 conditions, one condition for each participant.

To counterbalance randomly this post gives a solution (Assigning participants randomly to a condition).

However I want to determine the condition for each participant in advance myself, not randomly. As the previous recommendation explains, it’s easy to turn the stimulus-input into a variable. But one needs an x value to compute the value of f(x), in my case I need the participants number and then I can automatically assign the condition, my individual excel sheet (‘participant 001’ gets ‘sequence001.xlsx’). The participant can type in a participants number, he or she thinks of himself, but how can he know, if he is 001, 004 or 199? This is my last piece of the puzzle, how to automatize this and I hope you maybe have an answer to that. Currently my strategies are:

a) is a participant recruiting platform like Prolific Academic or MTurk providing those chronicle ranks and can we links those ranks to our experiment either automatically or via the participant typing in his rank

b) to code a counter, that counts how many data sets have already been committed and then adding +1 to define the new participant number, which then can easily be related to the right excel sheet.

Clara

Well, for this I would honestly create two different excel sheets and upload them as two versions of the experiment, so half participants do version 1 and half participants do version 2.

In case, you want to have only one experiment, and need to assign a participant number, you can ask them to write their day (not the full date) of birth, and give a command so odd numbers would have certain condition and even number the other condition.

What I have previously done is to ask participants to message me so I assign them the participant number, but this is a little taxing and might slow data collection.

Thanks a lot! I am trying to use the solution from the post you cited. However I have troubles indicating several xlsx conditions files in the loop. Could you please advise what am I doing wrong?
In the “Conditions” section in my loop I write \$“Block” + condition + “.xlsx” (I have two conditions files: BlockA.xlsx and BlockB.xlsx). But Builder is unable to find my conditions files.

This is the strategy I am trying to use. But I am unable to indicate two xlsx files in “Conditions” in my loop.

I haven’t done this yet, but I know that when you have two files, you create a third one with a column with the names of the other two files, and upload this third file in your loop, and then give a command to look for the right file when a given criteria is met. I am pretty sure you can find something in the forum. Because what I do is I create to Psychopy experiments (one per list) but there must be a better way to do it for sure.

Hey!

I would keep the loop condition like this. Eventually you want to have the concrete file BlockA.xlsx or BlockB.xslx in your loop condition. Now you just decompose the name name as you did in constant parts and flexible parts. The constant parts are the strings “Block” and “.sxls”. The variable part is the condition variable and this should be filled out with the strings “A” or “B”. The question is where you introduce this variable and what determines the Value they have. In our experiment we inserted a participant counter that told us, which participants number the participant has without having the participant fill out anything. You could do the same and then make an assignement with code:

if participantsnumber <= x:
condition == ‘A’
else:
condition == ‘B’

Having defined the condition like this, your loop condition should be able to add the flexible and variable components together and search for either BlockA.xlsx or BlockB.xslx.

For the participants counter we created a python file with one value in it: 0. Then in the beginning of the experiment we read in the file, create a variable p_number and assign the last line of the python file to it. Then the number for the current participant is created by making a new variable p_number_pilot and assigning p_number and adding +1 to it. Finally we update the python folder with the current participants number by writing it back into the file. That’s the code:

``````# Read out participant number from a file
f = open('p_number_pilot.txt', 'r')