| Reference | Downloads | Github

Pictures experiment - Problem with repetitions

Hello there!

We (students lost in PsychoPy) have problems concerning the repetition of our pictures…

Let’s start with the beginning:
We have to create an experiment in which we make 2 blocks of 5 trials. Each trial contains 4 pictures of 4 different categories. The first block should show us 20 different pictures , than there should be.a pause of 50 seconds and then a second block should show the last 20 pictures.
So we have created 1 instruction, then 1 trial with 4 components (Images) . This trial should be repeated 5 times so we get 20 pictures, then come to the pause and then come again to the trial and repeat it 5 times so that we get 20 pictures. (screenshot)

Now our problem is the following : the programm doesn’t execute the repetition as we indicate it to him. If I indicate just 2 repetitions , he shows me more than 30 pictures and doesn’t even stop there even though he should show me only 8 pictures (2x4pictures).

So does anybody know what we are doing wrong? Or how to get the programm to make the right number of repetitions?

Thank you for any answer!


Hello Lisa,

First off, congratulations on producing an almost perfect question, with a very precise description of what you are doing and a screenshot that confirms it. I think I might bookmark this as an example to show others when their questions are too vague or confusing to be answered.

The issue here is with the concept of what the repetition number in the loop dialog represents. An nReps value of 1 means that the loop will cycle through the rows in your conditions file exactly once. So the number of trials is equal to the number of rows in the conditions file. Only specify a larger nReps value if you want to present the conditions in your file more than once.

From what you describe, your conditions file should have four columns (one for each of your image components (i.e. categories)) and five rows (one for each trial), meaning that a total of 20 pictures will be presented if the nReps value is 1 for the inner loop.

Your outer loop (for the blocks) is different. It shouldn’t be connected to a conditions file and should have an nReps value of 2, so that the inner loop will run twice (once for each block).

Make sense?


PS Completely optional, but it can make it easier conceptually at the analysis stage if you rename the outer loop blocks. That way your data file will have a column explicitly named for the trial number as well as for the block number, without having to remember what trials_2 represents.

PPS one other suggestion: your pause routine will run after the second block, even though (I think) it isn’t needed again.
If you want to prevent it appearing the second time around, you can insert a code component on that routine. In the Begin routine tab of that component’s dialog, put code like this:

# check if we are on the second iteration of the outer loop:
if trials_2.thisN == 1: # NB the first block is repetition number 0
    continueRoutine = False # don't even start this routine
1 Like

Okay that makes sense! Thank you sooo much!!

However, there’s still one problem: you were right, I’ve four columns, but ten rows instead of five … My tutor wanted to do it that way. She wants 40 different images , and the first 20 randomized in the first block and the last 20 randomized in the second block…
So how am I going to make the programm do that? If 1 nReps value means that the loop will cycle through the rows in my conditions file exactly once, he’s going to show me the 40 pictures in the first block or am I getting something wrong? So I need half of them… the value 0.5 doesn’t work haha. Unfortunately I don’t understand what “random seed” means or does , and “selected rows” will take the number of rows I indicate , that would be a possibility but wouldn’t that destroy the randomization of the 40 pictures? I mean, if I indicate him the first 5 rows , he just randomizes between these 20 pictures and not the whole 40 (so I would still have an influence on the selection of the pictures (I hope you understand somehow what I mean :’) )

UPDATE: So I’ve been trying out a bit the possibilities. I have realized that the programm shows me 20 pictures in the first block and 20 pictures in the second block (One problem solved yey haha). BUT he shows me in the second block exactly the same pictures and the same order as in the first block. How can I change that? He has to use 20 randomized pictures of 40 and then 20 randomized pictures of the last 20 that weren’t used in the frist block.

  • I think he shows me in the first block only the pictures of the first 5 rows indicated instead of random 5 rows…

Here some screenshots to make it clear again

So I got the programm to make each time one block with 20 pictures. But first problem: he only switches randomly between the images of ligne 2 & 6 of my excel file (so he ignores line 7 to 11) and second problem: the 2. block is exactly the same thing as the first block.
What I need : that he chooses randomly 5 rows of these 10 or 20 pictures of the 40 pictures, and that he chooses in the second block the resting 5 rows or 20 pictures. The whole thing needs to be random… The program must at least switch randomly between the rows if he doesn’t want to give me 20 random pictures out of these 40… Hope I was clear enough for you.

Thank you very much & have a nice day!


OK, this can be done, and actually we’ll be making your experiment structure simpler.

First, delete the outer loop. The inner loop connects to your 10-row conditions file and has an nReps value of 1. Set it to random. Don’t select any specific rows.

This will give you 10 trials, showing all 40 pictures, in a random order which will vary across subjects.

How to separate the trials into two blocks of five trials? Move your pause routine inside the trials loop. Replace the suggested code above with this:

# Only run this routine once, to separate the blocks after the fifth trial:
if trials.thisN != 4: # NB the first block is repetition number 0
    continueRoutine = False # don't run this routine, except after the fifth trial
1 Like

Michael, you have no idea how much you are helping me!! Thank god! I’ll try it out tomorrow and recontact you if there should ba any issue , but I’m pretty sure it will work! Thanks alot!