Reuse one loop to generate different runs

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): v2020.2.10
Standard Standalone? (y/n) If not then what?:y
**What are you trying to achieve?:
I create 8 lists of stimuli, correct response, the location, attributes, trigger index of stimuli and so on, respectively. The reason why I create 8 lists is that I need to present 8 pictures in one trial in 8 different locations.
I want to reuse one loop to generate 8 runs instead of using 8 loops to achieve this.

What did you try to make it work?:
here is some of my code in the first routine of the whole experiment, which was used to assign stimuli (take the assignment of target images as an example):

# run1==================================

img_run1_o1 = img_o1[0:3]

img_run1_o2 = img_o2[0:3]

img_run1_o3 = img_o3[0:3]

img_run1_o4 = img_o4[0:3]

img_run1_o5 = img_o5[0:3]

img_run1_o6 = img_o6[0:3]

img_run1_o7 = img_o7[0:3]

img_run1_o8 = img_o8[0:3]

# run2==================================

img_run2_o1 = img_o1[3:6]

img_run2_o2 = img_o2[3:6]

img_run2_o3 = img_o3[3:6]

img_run2_o4 = img_o4[3:6]

img_run2_o5 = img_o5[3:6]

img_run2_o6 = img_o6[3:6]

img_run2_o7 = img_o7[3:6]

img_run2_o8 = img_o8[3:6]

# run3==================================

img_run3_o1 = img_o1[6:9]

img_run3_o2 = img_o2[6:9]

img_run3_o3 = img_o3[6:9]

img_run3_o4 = img_o4[6:9]

img_run3_o5 = img_o5[6:9]

img_run3_o6 = img_o6[6:9]

img_run3_o7 = img_o7[6:9]

img_run3_o8 = img_o8[6:9]

# run4==================================

img_run4_o1 = img_o1[9:12]

img_run4_o2 = img_o2[9:12]

img_run4_o3 = img_o3[9:12]

img_run4_o4 = img_o4[9:12]

img_run4_o5 = img_o5[9:12]

img_run4_o6 = img_o6[9:12]

img_run4_o7 = img_o7[9:12]

img_run4_o8 = img_o8[9:12]

# run5==================================

img_run5_o1 = img_o1[12:15]

img_run5_o2 = img_o2[12:15]

img_run5_o3 = img_o3[12:15]

img_run5_o4 = img_o4[12:15]

img_run5_o5 = img_o5[12:15]

img_run5_o6 = img_o6[12:15]

img_run5_o7 = img_o7[12:15]

img_run5_o8 = img_o8[12:15]

# run6==================================

img_run6_o1 = img_o1[15:18]

img_run6_o2 = img_o2[15:18]

img_run6_o3 = img_o3[15:18]

img_run6_o4 = img_o4[15:18]

img_run6_o5 = img_o5[15:18]

img_run6_o6 = img_o6[15:18]

img_run6_o7 = img_o7[15:18]

img_run6_o8 = img_o8[15:18]

# run7==================================

img_run7_o1 = img_o1[18:21]

img_run7_o2 = img_o2[18:21]

img_run7_o3 = img_o3[18:21]

img_run7_o4 = img_o4[18:21]

img_run7_o5 = img_o5[18:21]

img_run7_o6 = img_o6[18:21]

img_run7_o7 = img_o7[18:21]

img_run7_o8 = img_o8[18:21]

# run8==================================

img_run8_o1 = img_o1[21:24]

img_run8_o2 = img_o2[21:24]

img_run8_o3 = img_o3[21:24]

img_run8_o4 = img_o4[21:24]

img_run8_o5 = img_o5[21:24]

img_run8_o6 = img_o6[21:24]

img_run8_o7 = img_o7[21:24]

img_run8_o8 = img_o8[21:24]

**What specifically went wrong when you tried that?:
for now, I can only use 3 loops to generate 3 runs, because when I add the numer of runs to 4, the procedure won’t work and didn’t give any error report. here is part of my routines in run1 & run2 loop:



I don’t know how to reuse one loop to generate 8 runs using these stimuli I assigned. can anybody help me?

Hi,

for what I understood of your experiment I think you can manage with just one routine and some loops. You can specify the image file and location in a excel file and use it as a loop condition for trials, and you can use a second loop above the first one for different blocks.

tandy

Hi! tandy,

thank you so much for your reply, after I read the image files, I need to do some shuffle things, so the image components need to read image file through the image variables I create, like my code above.

what I’m confused is how can I use some sort of inner or outer loops to create 8 runs based on the stimuli stored in the variables, like the code I showed above, instead of the file paths stored in the excel file.

in other way, I may not need to split the stimuli into 8 sets, I just need to set a rest period after every 3 trials (24 trials in total), how can I achieve this purose?

I find the solution in this thread:

thank you very much!