WHAT ARE YOU TRYING TO ACHIEVE?
I’m setting up an experiment in psychopy in which pairs are formed between instruction (‘Visualizar’ or ‘Reavaliar’) and images (60 negative images, 30 neutral images). Note that in total I will have 90 trials, in which each image is shown once and randomly paired with one of the two instructions (‘Visualizar’ or ‘Reavaliar’).
I already have the code for this part and it’s working perfectly.
What i need to do now is to change the code in a way that a neutral image will never be presented with the instruction ‘Reavaliar’. So, everytime a neutral image appears, i want the instruction to be ‘Visualizar’.
Here’s the code i already have:
(Begin experiment tab):
#Instruction Code Part.1:
#Define lists block of instructions and shuffle:
blocklist_inst =
for idx in range(6):
blocklist_inst.append(‘Visualizar’)
for idx in range(3):
blocklist_inst.append(‘Reavaliar’)
shuffle(blocklist_inst)
#Image Code Part.2::
#Define lists of images and shuffle:
useRows =
neutral = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29]
shuffle(neutral)
negative = [30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89]
shuffle(negative)
#Image Code Part.2:
#Pseudorandomize images:
for block in range(10):
blocklist =
for idx in range(3):
blocklist.append(neutral.pop())
for idx in range(6):
blocklist.append(negative.pop())
shuffle(blocklist)
useRows.extend(blocklist)
(Begin routine tab):
#Instruction Code Part.2:
#Pick one instruction from list:
useRows_inst = blocklist_inst.pop()
if len(blocklist_inst) == 0:
for idx in range(6):
blocklist_inst.append(‘Visualizar’)
for idx in range(3):
blocklist_inst.append(‘Reavaliar’)
shuffle(blocklist_inst)
#Save data manually:
thisExp.addData(‘Instruction’, useRows_inst)
WHAT DID YOU TRY TO MAKE IT WORK?
I changed only this part:
#Image Code Part.2:
#Pseudorandomize images:
for block in range(10):
blocklist =
for idx in range(3):
if blocklist_inst[block] == ‘Visualizar’:
blocklist.append(neutral.pop())
else:
blocklist.append(negative.pop())
for idx in range(6):
blocklist.append(negative.pop())
shuffle(blocklist)
useRows.extend(blocklist)
WHAT SPECIFICALLY WENT WRONG WHEN YOU TRIED THAT?:
Index error: pop from empty list.