#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

# Counterbalance between 3-4 blocks

I have 4 different blocks in my experiment and I want to do a counterbalancing between blocks. I watched @sebastiaan 's tutorial (https://www.youtube.com/watch?v=zP8ucRtWU5g), and followed the steps there, but whenever I try to run the experiment I get a message saying b1 is not defined. How can I solve this? is there another way of having counterbalance between blocks?

• Hi Taa,

please provide more information on the problem. Share your experiment here, or at least some screenshots. Otherwise it is not really possible to see what is going wrong and help you.

Thanks,

Eduard

• So I tried something else for counterbalance between blocks, however, it doesn't work.

I am attaching screenshots of how the experiment looks like:

• Yeah, that doesn't really help. I still don't know what exactly it is that you want to accomplish.

I attach a demonstration of how counterbalancing can work based on the subject_nr (which is set in the beginning of the experiment.

Condition A is executed if the subject number is even, Condition B if it is uneven. This can easily be extended to 4 conditions. Things are slightly different if you dont want to counterbalance which conditions to run, but the order of running them. But even in this scenario the same logic applies.

Eduard

• Hello,

Thank you for your answer. However, now it runs one block for each subject. I wanted it to run all blocks in a different order each time. Moreover, I have 240-word pairs, each block randomly runs 60-word pairs out of the 240. When I did what you suggested, it suddenly started to run all 240 ( although I have defined in the block loop that I only want 60-word pairs.

• Hi Taa,

Sorry for the long delay.

As I mentioned before, the code was not meant to counterbalance order of all, but to counterbalance which blocks to run.

The attached experiment implements counterbalanced ordering. Is the logic of how it works clear?

When I did what you suggested, it suddenly started to run all 240 ( although I have defined in the block loop that I only want 60-word pairs.

Well, yeah, I haven't implemented anything with trials yet. So it is no surprise that it doesn't work like you expected. I think it is easiest if you implement a trial list before your enter the blocks (make a list of 240 stimuli), and before you enter a specific block, you select the 60 items from the full list of 240 items that you want to use for the upcoming block. For example like this:

```# a list with 240 stimuli. numbers in this case
var.stimuli = list(range(1, 241))
if var.block_no == 0:
var.cur_block_stim = var.stimuli[0:60]
elif var.block_no == 1:
var.cur_block_stim = var.stimuli[60:120]
elif var.block_no == 2:
var.cur_block_stim = var.stimuli[120:180]
```

Then you can select from that list the stimuli for a specific trial.

I hope this helps,

Eduard

• Hey, found your comments from the discussion thread. I am pretty much in the same situation. I have 7 loops and I want their presentation order to be different for every participant, but the situation with the subject's number doesn't quite work for me since the exp is already pretty heavy for my computer as it is. I was wondering if you have any code that could work for my case as well :))

Thank you in advance!

My best wishes,

Vasileia Christou

• Hi Vasileia.

You could create your experiment with all the loops and sequences, but set the runif field of them to `never` Instead you will have a single inline_script, in which you can determine the condition, based on subject number of whatever you need, and then start the loops in the correct order. Like this your computer should be able to handle the load.

See here for explanation on programmatically start an item. You wan to start the loop items one by one.

I hope it helps, if not let me know, then I might be able to provide a brief code example

Eduard