# Problem presenting stimuli in multiple blocks

**URL:** <https://discourse.psychopy.org/t/problem-presenting-stimuli-in-multiple-blocks/1428>\
**Category:** Builder\
**Created:** [November 8, 2016, 5:09pm UTC](https://discourse.psychopy.org/t/problem-presenting-stimuli-in-multiple-blocks/1428 "2016-11-08T17:09:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AmyWatts](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@AmyWatts](https://discourse.psychopy.org/u/AmyWatts)\
**Post date:** [November 8, 2016, 5:09pm UTC](https://discourse.psychopy.org/t/problem-presenting-stimuli-in-multiple-blocks/1428/1 "2016-11-08T17:09:49Z")

</div>

Hi,

I am trying to recreate a version of an implicit association test found on the open science framework. I would like to present 4 categories of images (attractive faces, unattractive faces, alcohol bottles and water bottles), each consisting of 5 images. The experiment consists of 7 blocks, each varying in length and showing different stimuli e.g.  
Block 1, 20 trials, alcohol and attractive pictures  
Block 2 20 trials, unattractive and attractive faces  
Block 3, 40 trials, all four categories (20 images in total, repeated twice each)  
and so on…

At the minute, psychopy is only showing images from 3 out of the 4 categories, but is not producing any error messages as to why one category is being ignored. Could anyone shed any light on why psychopy will not show images from all 4 categories?

So far, I have followed the template on OSF, using the following code components in the builder view to load the stimuli file and set the number of repeats:

```auto
# load stimuli file and set block length
exemplars_filename = 'stimuli.xlsx'
exemplars = data.importConditions(exemplars_filename)
n_exemplars = len(exemplars)
list_multiplier = int(math.ceil(10/n_exemplars))
def generate_trials(trial_type_column, multiplier):
    a = dict()
    for i in range(len(exemplars)):
       a[i] = [exemplars[i][trial_type_column]] * multiplier
    a = a.values()
    a = list(itertools.chain(*a))
    random.shuffle(a)
    return a

#set number of repeats
if blocks.thisN == 0:
    trial_rows = "0:2" 
    n_block_repeats = 10 #2*10 = 20 trials
    modified_list_multiplier = list_multiplier
elif blocks.thisN == 1:
    trial_rows = "2:4" 
    n_block_repeats = 10 #2*10 = 20 trials
    modified_list_multiplier = list_multiplier
elif blocks.thisN == 2:
    trial_rows = "0:4" 
    n_block_repeats = 5 #4*5 = 20 trials
    modified_list_multiplier = list_multiplier

# Generate list of stimuli for the block
img_trial_type_1_trials = generate_trials('img_trial_type_1_exemplars', modified_list_multiplier)
img_trial_type_2_trials = generate_trials('img_trial_type_2_exemplars', modified_list_multiplier)
img_trial_type_3_trials = generate_trials('img_trial_type_3_exemplars', modified_list_multiplier)
img_trial_type_4_trials = generate_trials('img_trial_type_4_exemplars', modified_list_multiplier)

```

I am quite new to psychopy and would appreciate any help!  
Thank you 🙂

---

<div class="post-metadata">

**Author:** ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)\
**Post date:** [November 11, 2016, 3:41pm UTC](https://discourse.psychopy.org/t/problem-presenting-stimuli-in-multiple-blocks/1428/2 "2016-11-11T15:41:57Z")

</div>

I imagine this isn’t PsychoPy issue per se btu to do with your code creating the images list. The code you’ve posted (I’ve added three ` symbols at start/end so it gets formatted properly) can’t be run without the conditions file attached, so we can’t test for you and work out what’s wrong.

Could you write a minimal example that we can actually run and see where the error is?

---

<div class="post-metadata">

**Author:** ![AmyWatts](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@AmyWatts](https://discourse.psychopy.org/u/AmyWatts)\
**Post date:** [November 14, 2016, 2:05pm UTC](https://discourse.psychopy.org/t/problem-presenting-stimuli-in-multiple-blocks/1428/3 "2016-11-14T14:05:06Z")

</div>

Hi,

Thanks a lot for your reply. I went back and redid the code and now it seems to work fine. Perhaps there was a typo somewhere I didn’t see.

Thanks for your time,  
Amy
