-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgratings.py
More file actions
76 lines (64 loc) · 1.58 KB
/
gratings.py
File metadata and controls
76 lines (64 loc) · 1.58 KB
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
import numpy as np
import psychopy.visual
import psychopy.event
import psychopy.core
# Create Window
win = psychopy.visual.Window(
size=[400,400],
units="pix",
fullscr=True
)
# Create Horizontal grating (Cue_Period)
horizontal_grating = psychopy.visual.GratingStim(
win=win,
name="horizontal_grating",
units="pix",
size=[200,200],
sf=[3.0/150.0],
mask="gauss",
ori=90
)
# Create targetH_period
# Horizontal_grating
gratingH = psychopy.visual.GratingStim(
win=win,
name="gratingH",
units="pix",
size=[200,200],
sf=[3.0/150.0],
mask="gauss",
ori=90,
pos=[200,0]
)
# Vertical_grating
gratingV = psychopy.visual.GratingStim(
win=win,
name="gratingV",
units="pix",
size=[200,200],
sf=[3.0/150.0],
mask="gauss",
ori=0,
pos=[-200,0]
)
# Time & clock parameters
clock = psychopy.core.Clock()
n_trials = 2 # number of trials
pre_duration = 2 # duration without stimulus (seconds)
stim_duration = 3 # cueH_period (seconds)
target_duration = 8 # targetH_period (seconds)
for trial in range(n_trials):
clock.reset()
while clock.getTime() < pre_duration:
win.flip()
while clock.getTime() <= pre_duration + stim_duration:
horizontal_grating.draw()
horizontal_grating.phase = np.mod(clock.getTime() / 0.5, 1)
win.flip()
while clock.getTime() < stim_duration + target_duration:
gratingH.draw()
gratingV.draw()
gratingH.phase = np.mod(clock.getTime() / 0.5, 1)
gratingV.phase = np.mod(clock.getTime() / 0.5, 1)
win.flip()
win.close()