# define a block counter that will start at zero.
= 0 block_count
First, download the Blocks.zip folder and unpack it, then open the folder and open the ‘Blocks.psyexp’ PsychoPy file.
Up till now we have had a strong focus on ‘trials’ - that is, one instance of one condition that a participant typically generates one response for (complicated experiments may vary slightly). A ‘block’ of trials is usually the repetition of multiple trials. Within a block each trial may vary based on its condition and the only reason you would ‘block’ trials would be to give participants a break. Sometimes, when cognition might be affected by adjacent trials, it might be better to separate conditions across blocks - this is typically referred to as a ‘blocked’ condition or paradigm.
In this experiment we will have a simple trial with two conditions - we will then try to set up the experiment so that we vary those conditions randomly, within a block, and take breaks. Then we will try to set up the experiment so that there is one condition in each block.
This task is a perceptual discrimination task - whilst fixating your gaze on the fixation cross participants are asked to judge if lines on either side of the cross are the same length or different. Currently the experiment runs through instructions, two trials (one in the ‘same’ condition, the other in the ‘different’ condition) a break screen and then ends.
What you’ll learn
- How to implement blocks.
- How to implement block designs and blocks for breaks.
- How to change the break message based on blocks.
- Become more comfortable with loops and code.
When attempting to make blocks a common mistake is to make separate trials with separate routines in them like the image below:
Instead use loops within loops to cause blocks - this means you can maintain trial consistency. See the below image:
Things to change
- Add another block, so that you are presented with one trial from each condition then a break before another block of the same.
Add another loop around the trials
loop that ends after the block_break
routine - call this loop block
.
Your flow should look like this:
- Modify your experiment so that you present two trials from the ‘same’ condition in one block, and two trials from the ‘different’ condition in another.
You will need to modify the Excel documents and create new ones for this to work. You’ll need three files in total.
You will need to create three Excel documents, one for the same
trials and one for the different
trials. In a third document - call it blocks.xlsx
, provide the names of the new Excel document in a column called conditions (remember to use .xlsx
in the name). In the trials
loop refernce the file names by entering $conditions
. Finally, in the block
loop load the file blocks
.
- For either block, format present a different message in the break for each block, for example ‘that was the first block, you have one more to go’ for the end of the first block but something different for the last block.
You will need to add some code for this. Add a code component to the block_break
routine. Check back to the feedback task and look at how you defined a message using code
You’ll need to define a block counter
this should equal to zero when the experiment starts but add one as each block passes.
Add a code component to the block_break
routine. In the Begin Experiment
tab and add the following code.
Still in the the block_break
routine, select the text_3
routine - delete the words in the Text
field and add a variable, we’ll call it $block_msg
. Also, change the properties of the Text
field so that it shows set every repeat
.
Then in the Begin Routine
tab add the following.
#add one to the block counter at the beginning of the routine.
= block_count + 1;
block_count
#add an if function that writes a messages based on the block.
if block_count == 1:
= 'That is one block complete, you have one more to go. \n \n Press space when you are ready to start'
block_msg
== 2:
elif block_count = 'Great - the experiment is over. \n \n Press space to end the experiment.' block_msg
Your block messaging should now work!
Test yourself
Question 1 | When coding a message to be displayed to participants, as in this experiment, what do you type to force a new line in the text?
Question 2 | What’s the name of the component where reaction times to same/different jusdgments are stored?
key_resp_2
Question 3 | Would the storage of RTs, accuracy or any participant data change as a function of which block is running?
This is the advantage of this method of creating blocks - because routines and components are identical - it’s easier to organise and analyse the data.