# Change Prevalence of Presented Stimuli over Blocks

Hello there,

I’m currently looking for an easy way to change the prevalence of stimuli in my experiment.

I have two stimulus sets, each set contains 60 different images. I want to change the prevalence of those two sets over the number of 8 blocks (each consists 50 images).

in block 1-3, 50% images from set 1 and 50% images from set 2 should be presented.
in block 4 the ratio should be 65 / 35
in block 5 the ratio should be 80 / 20
in block 6-8 the ratio should be 94 / 6

I’ve loaded up two different excel files, each containing the pathways to the images of one set.

``````list_T = pd.read_excel('images_T.xlsx')
shuffle(list_T)
shuffle(list_F)
``````

Than I wanted to use some code for the prevalence manipulation, something like this:

``````if blocks.thisN in [0, 1, 2]: # freq = 0.5
list_TF = [0] * 25 + [1] * 25
shuffle(list.TF)
elif blocks.thisN == 3: #freq = 0.65
list_TF = [0] * 17 + [1] * 33
shuffle(list_TF)
elif blocks.thisN == 4: #freq = 0.8
list_TF = [0] * 10 + [1] * 40
shuffle(list_TF)
elif blocks.thisN in [5, 6, 7]: #freq = 0.96
list_TF = [0] * 3 + [1] * 47
shuffle(list_TF)
``````

For every “0” a random image from set 1 should be presented, for every “1” a random image from set 2 should be presented:

``````for val in list_TF:
if val == 0:
selected_images.append(choice(list_T))  # Image set 1
else:
selected_images.append(choice(list_T))  # Image set 2
``````

Well, my genious plan is not working out so far… There a several errors, mostly psychopy is complaining, that it can’t find the images:

``````OSError: Couldn't find image ; check path? (tried: C:\Users\flori\Desktop\Onlinestudie)
``````

I double-checked everything. The path is correct, the excel files are correct… Maybe someone of you has an idea?

Also: Is this the best way for coding a change in prevalence or is there an easier / better way? Let me know!

Thank you very much!!!

Hello jtimmke

Are you planning to run the experiment online? I assume you are, given the folder name C:\Users\flori\Desktop\Onlinestudie. Note that you cannot import Python libraries for online experiments.

Use a print command to check the value of selected_images if you have not already done so.

Best wishes Jens

1 Like