# Pictures experiment - Problem with repetitions

**URL:** <https://discourse.psychopy.org/t/pictures-experiment-problem-with-repetitions/3317>\
**Category:** Builder\
**Created:** [October 26, 2017, 12:22pm UTC](https://discourse.psychopy.org/t/pictures-experiment-problem-with-repetitions/3317 "2017-10-26T12:22:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Li\_Sa](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Li\_Sa](https://discourse.psychopy.org/u/Li_Sa)\
**Post date:** [October 26, 2017, 12:22pm UTC](https://discourse.psychopy.org/t/pictures-experiment-problem-with-repetitions/3317/1 "2017-10-26T12:22:03Z")

</div>

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!

Lisa

 ![Capture d’écran (226)](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/9/793db32560a6d7da2c1f12e22b5e6d82ede9875c.png)

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [October 26, 2017, 8:23pm UTC](https://discourse.psychopy.org/t/pictures-experiment-problem-with-repetitions/3317/2 "2017-10-26T20:23:25Z")

</div>

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?

Michael

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
```

---

<div class="post-metadata">

**Author:** ![Li\_Sa](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Li\_Sa](https://discourse.psychopy.org/u/Li_Sa)\
**Post date:** [October 26, 2017, 11:49pm UTC](https://discourse.psychopy.org/t/pictures-experiment-problem-with-repetitions/3317/3 "2017-10-26T23:49:44Z")

</div>

Okay that makes sense! Thank you sooo much!!

---

<div class="post-metadata">

**Author:** ![Li\_Sa](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Li\_Sa](https://discourse.psychopy.org/u/Li_Sa)\
**Post date:** [October 27, 2017, 12:13am UTC](https://discourse.psychopy.org/t/pictures-experiment-problem-with-repetitions/3317/4 "2017-10-27T00:13:02Z")

</div>

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 :’) )

---

<div class="post-metadata">

**Author:** ![Li\_Sa](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Li\_Sa](https://discourse.psychopy.org/u/Li_Sa)\
**Post date:** [October 27, 2017, 1:16am UTC](https://discourse.psychopy.org/t/pictures-experiment-problem-with-repetitions/3317/5 "2017-10-27T01:16:33Z")

</div>

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

 ![Capture d’écran (232)](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/b/ebbf1df70783cbac2c4bc1610f59fcce77f4b51c.png)  
 ![Capture d’écran (233)](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/c/6/c6b5e13df57069373225baef563290fd349d465a.png)  
 ![Capture d’écran (234)](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/6/0/605ed20ded878ed3caaf15b0a1846872c5afec65.png)

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!

Lisa

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [October 27, 2017, 1:32am UTC](https://discourse.psychopy.org/t/pictures-experiment-problem-with-repetitions/3317/6 "2017-10-27T01:32:23Z")

</div>

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:

```auto
# 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

```

---

<div class="post-metadata">

**Author:** ![Li\_Sa](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Li\_Sa](https://discourse.psychopy.org/u/Li_Sa)\
**Post date:** [October 27, 2017, 1:57am UTC](https://discourse.psychopy.org/t/pictures-experiment-problem-with-repetitions/3317/7 "2017-10-27T01:57:32Z")

</div>

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!
