Hi everyone,
I am trying to remove the randomization between participants for my task. We are designing an eye-tracking task where all participants should view the same sets/patterns in the routines in the same order. This is important in the context of eye-tracking. My task involves randomization of the positions of numerals 1-9 on screen for each trial. I want this randomization to be randomized in the same way across all participants. So if you do trial 1 with number 1 appearing at coordinates 0,1 for example I want this to be the exact same for trial 1 participants 1, 2, 3, and so on… My issue is that when I go and do the task online, it keeps randomizing between participants and that means I cannot compare their performance at all. My task is rather complex as trial 1 will have number 1 only at a latency of 1s then trial 2 will have number 1 at 0.6, then trial 3 numbers 1 and 2 at 1s, then at 0,6, and then there are more numbers and faster display latencies added gradually. The goal is to test memory capacity and visual encoding speed. Please note I do have a loop in builder outside for the routines. I am not sure if it has any effect as it is set to random (no idea how this loop works as I am a newbie).
Here is my code. Thanks for the help!
Begin Experiment
from psychopy import visual, event, core
np.random.seed(1)
# Initialize PsychoPy window
win = visual.Window([800, 600], color="white")
# Define positions for each set with a latency of 1
set_positions_1 = {
1: {'Number 1': [-0.4, 0.25]}, # Set 1, Number 1
2: {'Number 1': [-0.4, 0.25], 'Number 2': [-0.4, -0.25]}, # Set 2, Number 1 and Number 2
}
# Define positions for each set with a latency of 0.6
set_positions_0_6 = {
3: {'Number 1': [-0.4, 0.25], 'Number 2': [-0.4, -0.25], 'Number 3': [0.4, 0.25]}, # Set 3, Number 1-3
4: {'Number 1': [-0.4, 0.25], 'Number 2': [-0.4, -0.25], 'Number 3': [0.4, 0.25], 'Number 4': [0.4, -0.25]}, # Set 4, Number 1-4
5: {'Number 1': [-0.4, 0.25], 'Number 2': [-0.4, -0.25], 'Number 3': [0.4, 0.25], 'Number 4': [0.4, -0.25], 'Number 5': [-0.3, 0.25]}, # Set 5, Number 1-5
6: {'Number 1': [-0.4, 0.25], 'Number 2': [-0.4, -0.25], 'Number 3': [0.4, 0.25], 'Number 4': [0.4, -0.25], 'Number 5': [-0.3, 0.25], 'Number 6': [-0.3, -0.25]}, # Set 6, Number 1-6
7: {'Number 1': [-0.4, 0.25], 'Number 2': [-0.4, -0.25], 'Number 3': [0.4, 0.25], 'Number 4': [0.4, -0.25], 'Number 5': [-0.3, 0.25], 'Number 6': [-0.3, -0.25], 'Number 7': [-0.1, 0.25]}, # Set 7, Number 1-7
8: {'Number 1': [-0.4, 0.25], 'Number 2': [-0.4, -0.25], 'Number 3': [0.4, 0.25], 'Number 4': [0.4, -0.25], 'Number 5': [-0.3, 0.25], 'Number 6': [-0.3, -0.25], 'Number 7': [-0.1, 0.25], 'Number 8': [-0.1, -0.25]}, # Set 8, Number 1-8
9: {'Number 1': [-0.4, 0.25], 'Number 2': [-0.4, -0.25], 'Number 3': [0.4, 0.25], 'Number 4': [0.4, -0.25], 'Number 5': [-0.3, 0.25], 'Number 6': [-0.3, -0.25], 'Number 7': [-0.1, 0.25], 'Number 8': [-0.1, -0.25], 'Number 9': [0.2, -0.25]} # Set 9, Number 1-9
}
# Define positions for each set with a latency of 0.5
set_positions_0_5 = {
3: {'Number 1': [-0.3, 0.25], 'Number 2': [-0.3, -0.25], 'Number 3': [0.3, 0.25]}, # Set 3, Number 1-3
4: {'Number 1': [-0.3, 0.25], 'Number 2': [-0.3, -0.25], 'Number 3': [0.3, 0.25], 'Number 4': [0.3, -0.25]}, # Set 4, Number 1-4
5: {'Number 1': [-0.3, 0.25], 'Number 2': [-0.3, -0.25], 'Number 3': [0.3, 0.25], 'Number 4': [0.3, -0.25], 'Number 5': [-0.3, 0.25]}, # Set 5, Number 1-5
6: {'Number 1': [-0.3, 0.25], 'Number 2': [-0.3, -0.25], 'Number 3': [0.3, 0.25], 'Number 4': [0.3, -0.25], 'Number 5': [-0.3, 0.25], 'Number 6': [-0.3, -0.25]}, # Set 6, Number 1-6
7: {'Number 1': [-0.3, 0.25], 'Number 2': [-0.3, -0.25], 'Number 3': [0.3, 0.25], 'Number 4': [0.3, -0.25], 'Number 5': [-0.3, 0.25], 'Number 6': [-0.3, -0.25], 'Number 7': [-0.3, 0.25]}, # Set 7, Number 1-7
8: {'Number 1': [-0.3, 0.25], 'Number 2': [-0.3, -0.25], 'Number 3': [0.3, 0.25], 'Number 4': [0.3, -0.25], 'Number 5': [-0.3, 0.25], 'Number 6': [-0.3, -0.25], 'Number 7': [-0.3, 0.25], 'Number 8': [-0.3, -0.25]}, # Set 8, Number 1-8
9: {'Number 1': [-0.3, 0.25], 'Number 2': [-0.3, -0.25], 'Number 3': [0.3, 0.25], 'Number 4': [0.3, -0.25], 'Number 5': [-0.3, 0.25], 'Number 6': [-0.3, -0.25], 'Number 7': [-0.3, 0.25], 'Number 8': [-0.3, -0.25], 'Number 9': [0.3, -0.25]} # Set 9, Number 1-9
}
# Define positions for each set with a latency of 0.4
set_positions_0_4 = {
3: {'Number 1': [-0.2, 0.25], 'Number 2': [-0.2, -0.25], 'Number 3': [0.2, 0.25]}, # Set 3, Number 1-3
4: {'Number 1': [-0.2, 0.25], 'Number 2': [-0.2, -0.25], 'Number 3': [0.2, 0.25], 'Number 4': [0.2, -0.25]}, # Set 4, Number 1-4
5: {'Number 1': [-0.2, 0.25], 'Number 2': [-0.2, -0.25], 'Number 3': [0.2, 0.25], 'Number 4': [0.2, -0.25], 'Number 5': [-0.2, 0.25]}, # Set 5, Number 1-5
6: {'Number 1': [-0.2, 0.25], 'Number 2': [-0.2, -0.25], 'Number 3': [0.2, 0.25], 'Number 4': [0.2, -0.25], 'Number 5': [-0.2, 0.25], 'Number 6': [-0.2, -0.25]}, # Set 6, Number 1-6
7: {'Number 1': [-0.2, 0.25], 'Number 2': [-0.2, -0.25], 'Number 3': [0.2, 0.25], 'Number 4': [0.2, -0.25], 'Number 5': [-0.2, 0.25], 'Number 6': [-0.2, -0.25], 'Number 7': [-0.2, 0.25]}, # Set 7, Number 1-7
8: {'Number 1': [-0.2, 0.25], 'Number 2': [-0.2, -0.25], 'Number 3': [0.2, 0.25], 'Number 4': [0.2, -0.25], 'Number 5': [-0.2, 0.25], 'Number 6': [-0.2, -0.25], 'Number 7': [-0.2, 0.25], 'Number 8': [-0.2, -0.25]}, # Set 8, Number 1-8
9: {'Number 1': [-0.2, 0.25], 'Number 2': [-0.2, -0.25], 'Number 3': [0.2, 0.25], 'Number 4': [0.2, -0.25], 'Number 5': [-0.2, 0.25], 'Number 6': [-0.2, -0.25], 'Number 7': [-0.2, 0.25], 'Number 8': [-0.2, -0.25], 'Number 9': [0.2, -0.25]} # Set 9, Number 1-9
}
# Define positions for each set with a latency of 0.3
set_positions_0_3 = {
3: {'Number 1': [-0.1, 0.25], 'Number 2': [-0.1, -0.25], 'Number 3': [0.1, 0.25]}, # Set 3, Number 1-3
4: {'Number 1': [-0.1, 0.25], 'Number 2': [-0.1, -0.25], 'Number 3': [0.1, 0.25], 'Number 4': [0.1, -0.25]}, # Set 4, Number 1-4
5: {'Number 1': [-0.1, 0.25], 'Number 2': [-0.1, -0.25], 'Number 3': [0.1, 0.25], 'Number 4': [0.1, -0.25], 'Number 5': [-0.1, 0.25]}, # Set 5, Number 1-5
6: {'Number 1': [-0.1, 0.25], 'Number 2': [-0.1, -0.25], 'Number 3': [0.1, 0.25], 'Number 4': [0.1, -0.25], 'Number 5': [-0.1, 0.25], 'Number 6': [-0.1, -0.25]}, # Set 6, Number 1-6
7: {'Number 1': [-0.1, 0.25], 'Number 2': [-0.1, -0.25], 'Number 3': [0.1, 0.25], 'Number 4': [0.1, -0.25], 'Number 5': [-0.1, 0.25], 'Number 6': [-0.1, -0.25], 'Number 7': [-0.1, 0.25]}, # Set 7, Number 1-7
8: {'Number 1': [-0.1, 0.25], 'Number 2': [-0.1, -0.25], 'Number 3': [0.1, 0.25], 'Number 4': [0.1, -0.25], 'Number 5': [-0.1, 0.25], 'Number 6': [-0.1, -0.25], 'Number 7': [-0.1, 0.25], 'Number 8': [-0.1, -0.25]}, # Set 8, Number 1-8
9: {'Number 1': [-0.1, 0.25], 'Number 2': [-0.1, -0.25], 'Number 3': [0.1, 0.25], 'Number 4': [0.1, -0.25], 'Number 5': [-0.1, 0.25], 'Number 6': [-0.1, -0.25], 'Number 7': [-0.1, 0.25], 'Number 8': [-0.1, -0.25], 'Number 9': [0.1, -0.25]} # Set 9, Number 1-9
}
# Define positions for each set with a latency of 0.2
set_positions_0_2 = {
3: {'Number 1': [0, 0.25], 'Number 2': [0, -0.25], 'Number 3': [0, 0.25]}, # Set 3, Number 1-3
4: {'Number 1': [0, 0.25], 'Number 2': [0, -0.25], 'Number 3': [0, 0.25], 'Number 4': [0, -0.25]}, # Set 4, Number 1-4
5: {'Number 1': [0, 0.25], 'Number 2': [0, -0.25], 'Number 3': [0, 0.25], 'Number 4': [0, -0.25], 'Number 5': [0, 0.25]}, # Set 5, Number 1-5
6: {'Number 1': [0, 0.25], 'Number 2': [0, -0.25], 'Number 3': [0, 0.25], 'Number 4': [0, -0.25], 'Number 5': [0, 0.25], 'Number 6': [0, -0.25]}, # Set 6, Number 1-6
7: {'Number 1': [0, 0.25], 'Number 2': [0, -0.25], 'Number 3': [0, 0.25], 'Number 4': [0, -0.25], 'Number 5': [0, 0.25], 'Number 6': [0, -0.25], 'Number 7': [0, 0.25]}, # Set 7, Number 1-7
8: {'Number 1': [0, 0.25], 'Number 2': [0, -0.25], 'Number 3': [0, 0.25], 'Number 4': [0, -0.25], 'Number 5': [0, 0.25], 'Number 6': [0, -0.25], 'Number 7': [0, 0.25], 'Number 8': [0, -0.25]}, # Set 8, Number 1-8
9: {'Number 1': [0, 0.25], 'Number 2': [0, -0.25], 'Number 3': [0, 0.25], 'Number 4': [0, -0.25], 'Number 5': [0, 0.25], 'Number 6': [0, -0.25], 'Number 7': [0, 0.25], 'Number 8': [0, -0.25
# Define latencies for each set
set1_latencies = {
1: [1],
2: [1],
}
set2_latencies = {
1: [0.6],
2: [0.6],
}
# Define latencies for each set with a latency of 0.6
set_latencies_0_6 = {
3: [0.6],
4: [0.6],
5: [0.6],
6: [0.6],
7: [0.6],
8: [0.6],
9: [0.6],
}
# Define latencies for each set with a latency of 0.5
set_latencies_0_5 = {
3: [0.5],
4: [0.5],
5: [0.5],
6: [0.5],
7: [0.5],
8: [0.5],
9: [0.5],
}
# Define latencies for each set with a latency of 0.4
set_latencies_0_4 = {
3: [0.4],
4: [0.4],
5: [0.4],
6: [0.4],
7: [0.4],
8: [0.4],
9: [0.4],
}
# Define latencies for each set with a latency of 0.3
set_latencies_0_3 = {
3: [0.3],
4: [0.3],
5: [0.3],
6: [0.3],
7: [0.3],
8: [0.3],
9: [0.3],
}
# Define latencies for each set with a latency of 0.2
set_latencies_0_2 = {
3: [0.2],
4: [0.2],
5: [0.2],
6: [0.2],
7: [0.2],
8: [0.2],
9: [0.2],
}
# Main experiment loop for Sets 1 to 9
for set_num in range(1, 10):
positions = globals()[f'set_positions_{set_num}']
latencies = globals()[f'set_latencies_{set_num}']
for latency in latencies:
for i, position in positions.items():
number_text = visual.TextStim(win, text=i, pos=position, height=0.1, color="black")
number_text.draw()
win.flip()
core.wait(latency)
# Clean up and quit
win.close()
core.quit()
Begin Routine
import numpy as np
np.random.seed(1) # Set the fixed seed
# Reset all clicks to false
validClick1 = False
validClick2 = False
validClick3 = False
validClick4 = False
validClick5 = False
validClick6 = False
validClick7 = False
validClick8 = False
validClick9 = False
# Define a timer starting from the moment each trial starts
timer = core.Clock()
# Define at which levels each number and masks appears
show2 = True if arcd_lvl >= 2 else False
show3 = True if arcd_lvl >= 3 else False
show4 = True if arcd_lvl >= 4 else False
show5 = True if arcd_lvl >= 5 else False
show6 = True if arcd_lvl >= 6 else False
show7 = True if arcd_lvl >= 7 else False
show8 = True if arcd_lvl >= 8 else False
show9 = True if arcd_lvl >= 9 else False
# Reset answer variable
ans = False
Each Frame
import numpy as np
np.random.seed(1) # Set the fixed seed
#Conditions for hearts to show
if lives_a == 4:
life5_a = True
if lives_a == 3:
life4_a = True
if lives_a == 2:
life3_a = True
if lives_a == 1:
life2_a = True
#Conditions for stimuli clicks
if mouse_arcd.isPressedIn(mask_a1, [0]):
if timer.getTime() > lat_a:
validClick1 = True
if arcd_lvl < 3:
ans = True
arcd_lvl = arcd_lvl + 1
lat_a = arcd_lat.pop(0)
continueRoutine = False
if mouse_arcd.isPressedIn(mask_a2, buttons = [0]):
if timer.getTime() > lat_a:
if validClick1 == False:
lives_a = lives_a -1
continueRoutine = False
else:
validClick2 = True
if arcd_lvl < 5:
ans = True
arcd_lvl = arcd_lvl + 1
lat_a = arcd_lat.pop(0)
continueRoutine = False
if mouse_arcd.isPressedIn(mask_a3, buttons = [0]):
if timer.getTime() > lat_a:
if validClick2 == False:
lives_a = lives_a -1
continueRoutine = False
else:
validClick3 = True
if arcd_lvl < 10:
ans = True
arcd_lvl = arcd_lvl + 1
lat_a = arcd_lat.pop(0)
continueRoutine = False
if mouse_arcd.isPressedIn(mask_a4, buttons = [0]):
if timer.getTime() > lat_a:
if validClick3 == False:
lives_a = lives_a -1
continueRoutine = False
else:
validClick4 = True
if arcd_lvl < 15:
ans = True
arcd_lvl = arcd_lvl +1
lat_a = arcd_lat.pop(0)
continueRoutine = False
if mouse_arcd.isPressedIn(mask_a5, buttons = [0]):
if timer.getTime() > lat_a:
if validClick4 == False:
lives_a = lives_a -1
continueRoutine = False
else:
validClick5 = True
if arcd_lvl < 20:
ans = True
arcd_lvl = arcd_lvl + 1
lat_a = arcd_lat.pop(0)
continueRoutine = False
if mouse_arcd.isPressedIn(mask_a6, buttons = [0]):
if timer.getTime() > lat_a:
if validClick5 == False:
lives_a = lives_a -1
continueRoutine = False
else:
validClick6 = True
if arcd_lvl < 25:
ans = True
arcd_lvl = arcd_lvl + 1
lat_a = arcd_lat.pop(0)
continueRoutine = False
if mouse_arcd.isPressedIn(mask_a7, buttons = [0]):
if timer.getTime() > lat_a:
if validClick6 == False:
lives_a = lives_a -1
continueRoutine = False
else:
validClick7 = True
if arcd_lvl < 30:
ans = True
arcd_lvl = arcd_lvl + 1
lat_a = arcd_lat.pop(0)
continueRoutine = False
if mouse_arcd.isPressedIn(mask_a8, buttons = [0]):
if timer.getTime() > lat_a:
if validClick7 == False:
lives_a = lives_a -1
continueRoutine = False
else:
validClick8 = True
if arcd_lvl < 35:
ans = True
arcd_lvl = arcd_lvl +1
lat_a = arcd_lat.pop(0)
continueRoutine = False
if mouse_arcd.isPressedIn(mask_a9, buttons = [0]):
if timer.getTime() > lat_a:
if validClick8 == False:
lives_a = lives_a -1
continueRoutine = False
else:
validClick9 = True
if arcd_lvl < 40:
ans = True
arcd_lvl = arcd_lvl + 1
lat_a = arcd_lat.pop(0)
continueRoutine = False