-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexperiment_v4_1.py
128 lines (109 loc) · 3.64 KB
/
experiment_v4_1.py
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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
########################################
########################################
#### ####
#### Posner task ####
#### ####
#### Experiment version 4.1 ####
#### ####
########################################
########################################
from constants_v4_1 import *
from conditions_decomposed_v4_1 import *
from conditions_loops_v4_1 import *
from psychopy.visual import Window, TextStim, Circle, Rect, ShapeStim
from psychopy.event import waitKeys, getKeys
from psychopy.core import wait
from psychopy.gui import DlgFromDict
from psychopy import core, data, logging
import time, random, os
x, y = 0, 0
os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (x,y)
########################################
# randomise the order of all trials
random.shuffle(all_trials)
random.shuffle(valid_car_trials)
random.shuffle(invalid_car_trials)
#present the first instructions
inst_Stim_1.draw()
disp.flip()
#wait for any keypress to advance past the instructions screen
waitKeys(maxWait = float('inf'), keyList = ['space'], timeStamped = False)
# present the practice loops
p_left = p_right = p_rounds/2
while p_left > 0 and p_right > 0:
if random.random() < 0.5: # left trials
if random.random() < 0.8: #valid targets
exp_VCL_prac()
p_left -= 1
else: # invalid trials
exp_VCR_prac()
p_right -= 1
else: # right trials
if random.random() < 0.8: # valid targets
exp_ICL_prac()
p_left -= 1
else: # invalid trials
exp_ICR_prac()
p_right -= 1
if p_left == 0 and p_right > 0: # if there has been more than 50% left targets
while p_right > 0:
if random.random() < 0.8:
exp_VCR_prac()
p_right -= 1
else:
exp_ICR_prac()
p_right -= 1
elif p_left > 0 and p_right == 0: # if there has been more than 50% right targets
while p_left > 0:
if random.random() < 0.8:
exp_VCL_prac()
p_left -= 1
else:
exp_ICL_prac()
p_left -= 1
# present the post practice screens
prac_Fin_win.draw()
disp.flip()
waitKeys(maxWait = float('inf'), keyList = ['space'], timeStamped=False)
# prepare the experimental loop
left = right = n_trials/2
while left > 0 and right > 0:
if random.random() < 0.5: # left trials
if random.random() < 0.8: #valid targets
exp_VCL_record()
left -= 1
else: # invalid trials
exp_VCR_record()
right -= 1
else: # right trials
if random.random() < 0.8: # valid targets
exp_ICL_record()
left -= 1
else: # invalid trials
exp_ICR_record()
right -= 1
if left == 0 and right > 0: # if there has been more than 50% left targets
while right > 0:
if random.random() < 0.8:
exp_VCR_record()
right -= 1
else:
exp_ICR_record()
right -= 1
elif left > 0 and right == 0: # if there has been more than 50% right targets
while left > 0:
if random.random() < 0.8:
exp_VCL_record()
left -= 1
else:
exp_ICL_record()
left -= 1
# finish the experiment
finished_win.draw()
disp.flip()
waitKeys(maxWait = float('inf'), keyList = ['escape'], timeStamped = False,\
clearEvents = False)
# close the display
disp.close()
# close the log
log.close()