Counterbalance between the first and last block (with three blocks in total)

I am having trouble to counterbalance between two blocks. The basic structure of my current task is as follows:


Task A and Task C will have the same set of stimuli, but the setup of the loop will be different. For Task A, the loop will be random while for Task C, the loop will be sequential.
Screen Shot 2021-01-06 at 1.32.34 PM Screen Shot 2021-01-06 at 1.32.44 PM
I am trying to counterbalance the order Task A and Task C appears first such that some participants see Task A first and some see Task C first. I am getting a bit stuck here. I am wondering if there is any way to do it in the builder or if there is any code component I can insert. Or maybe a better way is to set up two different versions of the experiment and randomly assign participants to one of them. I am planning to run it online and so it would be nice if I can insert a code component to do the counterbalancing rather than creating two versions of the experiment. I am wondering if there is any idea as to how I tackle this. Thank you!

Hi There,

You need to set the nReps of each loop using an outer loop

One file will be for the group who has task A first and will look something like this:

nRepsA nRepsB nRepsC
1 0 0
0 1 0
0 0 1

The second group, who has task B first will look something like this:

nRepsA nRepsB nRepsC
0 0 1
0 1 0
1 0 0

Then you set the parameters of your outerloop to be ‘sequential’ and the conditions field as $'Group'+expInfo['group']+'.xlsx'
Here is a demo file that should do what you need. counterbalance-sandwich.psyexp (10.8 KB)

Hope this helps :slight_smile:
Becca

1 Like

Thank you so much for your help! It is amazing!

you are welcome! if this answered your question please could you tag the corresponding solution for future users?

Thanks :slight_smile:
becca

Thanks for the reminder, just did it.