Simple Randomization of Loop Order

Hi,
I am having trouble randomizing the presentation of two loops.

For some background, I want to present witnesses with 8 different video recordings and answer the same questions for each video. I have two loops, each representing the two within subjects conditions (“TA” loop presenting inaccurate videos, and “TP” loop presenting accurate videos) Within each loop, I have a separate stimuli excel file listing all of the videos included in that pool (TA/TP) that I want to randomly sample from. I then have some code that randomly selects 4 videos from the TA condition’s video pool and 4 videos from the TP condition’s video pool. Hence, my within-subjects condition is working OK.

What I am now having trouble with is trying to randomize the presentation of the accurate and inaccurate videos. Right now, 4 accurate videos are presented followed by 4 inaccurate videos. Is there any way I can present these two loops randomly over 8 trials?

Thanks so much!









Personally I would use one loop for accurate and inaccurate videos and one spreadsheet containing all 16 videos (with an additional column for Condition). To sample 4 of each video you can set up selected rows in Begin Experiment:

rows1 = [0,1,2,3,4,5,6,7]
shuffle(rows1)
rows2 = [8,9,10,11,12,13,14,15]
shuffle(rows2)
useRows = []
for Idx in range (4):
     useRows.append(rows1[Idx])
     useRows.append(rows2[Idx])

Then put $useRows as your selected rows for the loop.

Thank you! After adding shuffle (useRows) to the end of the code you provided, it worked exactly as I wanted.

One last thing, I plan to include quite a few videos, which means there will be quite a few rows in the excel sheet. Is there a way to edit the rows1 = [0,1,2,3,4,5,6,7] and rows2 = [8,9,10,11,12,13,14,15] to be a range of rows? I have tried it a few different ways and can’t get it to work. Thank you so much!

Hello

you could use the Python-function extend and range or a for-loop using append to fill a list. See below. The print-commands are included only for demonstration purposes. range allows you to define a start, a stop and a step.

range1 = []
range2 = []

range1.extend(range(10))

for i in range(10):
    range2.append(i)

print(range1)
print(range2)

Best wishes Jens

1 Like