Block designs and counterbalancing
A block design is where we have sets of similar trials organised into blocks rather than having trials interleaved.
- e.g.
- a block of faces to recognise or a block of houses
- a faces oriented correctly and faces inverted
- a block of Stroop task in English and a block in French
1
The natural error
The biggest error that people make with this is to create a Routine (and a loop) for each block of trials:
Then they ask on the forum, “How do I shuffle the blocks on my Flow?”
That is the wrong way to think about it.
2
The right way
Instead of a Routine for each block, create a Routine for all your trials and make it behave differently across the blocks:
Then you can set the conditions files in your blocks loop to control the block-level changes.
The outer “blocks” loop then takes a (meta) “conditions” file that specifies which of the conditions files will be loaded in each block.
3
The right way
Imagine we want to extend our Posner task to include a block where invalid trials occur on 80% or trials.
We need to create a total of 3 conditions files:
- conditions20.xlsx
- conditions80.xlsx
- blocks.xlsx
4
The right way
blocks.xlsx:
The label variable isn’t technically needed but it could be used to tell people what block they are about to enter. The point is that you can still use other variables here, defined at the block level of the program.
5
The right way
Now we need to set up the variables inside our experiment:
- the inner (trials) loop will have a conditions file = $conditions which is defined in the blocks.xlsx file
- the outer (blocks) loop will have conditions file = blocks.xlsx
6
The right way
7
Randomised block designs
Setting loopType to random means that currently we have a randomised block design. The condition files listed in blocks.xlsx will be presented in a random order.
8
Randomised block designs
We could also add a Routine called blockReady like an instructions Routine with:
9
Randomised block design complete!
You’ve sorted out block designs in a relatively neat fashion.
Just keep clear what differs from one block to the next (for a conditions file) and what stays the same (for the Routine definition).
10
Counterbalancing
Counterbalancing your blocks is really just an extension of the blocking scenario, except that you set the blocks to operate in a particular order rather than leaving PsychoPy to randomise them.
11
Setting the order
PsychoPy doesn’t handle the ordering for you - you need to decide how to create the orders and how to assign participants.
Now, rather than a single file to specify the blocks you need one for each order that you want the blocks to appear in (and then set the blocks loop to be sequential rather than random to preserve the order you set)
For instance, the Posner task you might have groupA with alternating invalid cue probability, beginning with high prob, and the groupB participants might have the same but starting with low prob.
12
How to assign participants to a group
Easiest way is by hand at the start of the run for the participant. The steps are:
- In Experiment Settings add a field for group (which will be A, B, C… for however many orders you need to create)
- For the block loop use that value by calling expInfo[‘group’] using one of the alternatives below:
- $”block” + expInfo[‘group’] + “.xlsx”
- $”block{}.xlsx”.format( expInfo[‘group’] )
13
All done
You can now create trials and blocks in any order, fixed or random.
You’re in complete control (but you need to understand what orders you want!)
For online use we could also use this handy tool for generating sequential participant IDs
14
Time permitting
You don’t need to know how to code in order to make an experiment in PsychoPy. But, as we have seen, understanding a few simple concepts can really help in making tasks more flexible (e.g. if statements) and PsychoPy allows us to inadvertently learn some coding principles.
Let’s practice using
Code Components
15