psychopy.org | Reference | Downloads | Github

Problem presenting stimuli in multiple blocks

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:

# 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 :slight_smile:

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?

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