Dear all,
I am using PsychoPy3 in Mojave. I am trying to build an experiment, in which participants are asked 4 questions about a picture of a material sample. There are 71 material samples that consist of 2 groups (1 with 56 pictures, 1 with 15 pictures). The 2 groups in turn consist of 8 subsets(each contains 7 pictures) and 2 subsets(1 subset with 8 and 1 with 7 samples) respectively.
I want my experimental loop to select either of the 2 groups first. Then pseudorandomly select a picture from 1 of the 8 or 2 subsets and display the same picture for four questions. So far I have managed to randomly select a group (far outer loop, SelectGroup, in screenshot), then randomly select a picture (middle loop, AllImages, in screenshot) and ask 4 questions (inner loop, Q1toQ4). However, I am struggling to select the images pseudorandomly. That is, select an image from one subset (1, for example) and select the subsequent image from a different subset (2 to 8, for example).
What did you try to make it work?: I have tried to insert a code component (Blank1 in screenshot) following this post (Randomising types of trials so the same stimuli do not repeat one after the other - #2 by jonathan.kominsky). I first tried to input my excel file, but got the error: ‘trialList=data.importConditions(‘SelectImage.xlsx’, selection=Setno),
NameError: name ‘Setno’ is not defined’.
When I tried to manually define a variable equivalent to ‘Setno’, I got the following error: ‘subOrder.append([j,datStructure[j].pop()])
IndexError: pop from empty list’.
I used the following code:
Under ‘Begin Experiment’
‘’'import pandas as pd
‘’'dat = pd.read_excel("./SelectImage.xlsx")
Under ‘Begin Routine’:
‘’‘datStructure = [[1,2,3,4,5,6,7],[1,2,3,4,5,6,7],[1,2,3,4,5,6,7],[1,2,3,4,5,6,7],[1,2,3,4,5,6,7], ‘’’[1,2,3,4,5,6,7],[1,2,3,4,5,6,7],[1,2,3,4,5,6,7],[1,2,3,4,5,6,7,8],[1,2,3,4,5,6,7]]
‘’'blockOrder =
‘’'for i in range(0,10):
‘’'subOrder =
‘’'for j in range(0,len(datStructure)):
‘’'shuffle(datStructure[j])
‘’'subOrder.append([j,datStructure[j].pop()])
‘’'shuffle(subOrder)
‘’'if len(blockOrder) > 0:
‘’'while subOrder[0][0] == blockOrder[-1][0]:
‘’'shuffle(subOrder)
‘’'for k in range(0,len(subOrder)):
‘’'blockOrder.append(subOrder[k])
‘’'trailList = blockOrder
What specifically went wrong when you tried that?: It seems that in both cases the code I tried didn’t work, because it somehow fails to read in the data I need in the first place. I am not sure what goes wrong or whether my approach is correct.
I have been building with PsychoPy for just under 1 week, so I am a newby. Although I can do a little bit of matlab the code components and Python are new to me.
Let me know if you have any suggestions.
Thank you in advance.
Ellen