-
Notifications
You must be signed in to change notification settings - Fork 0
/
opto_vis_stim.py
75 lines (55 loc) · 1.78 KB
/
opto_vis_stim.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
from psychopy import visual, core, event
# Define the background
win=visual.Window([800,600],monitor="testMonitor",units="deg",fullscr=True)
# Number of epochs (repetitions)
EPOCH=15
# Duration of expansion
EXPANSION_MS=250
# Hold duration
HOLD_TIME_MS=250
# ISI duration
ISI_MS=500
# Start radius
START_RADIUS=1
# Time-to-frame conversion assuming a 60Hz FR and RR
FRAMES=int((60*EXPANSION_MS)/1000)
HOLD_FRAMES=int((60*HOLD_TIME_MS)/1000)
ISI_FRAMES=int((60*ISI_MS)/1000)
print(FRAMES)
# Define the stimulus
circle=visual.Circle(win,radius=START_RADIUS,edges=1000,fillColor='black',lineColor='black')
while EPOCH > 0:
#for e in range(EPOCH):
for f in range(FRAMES):
if circle.radius<10:
circle.radius=(circle.radius+(9/FRAMES))
circle.draw()
win.flip()
for f in range(HOLD_FRAMES):
circle.radius=10
circle.draw()
win.flip()
for f in range(ISI_FRAMES):
win.flip()
print(circle.radius)
circle.radius=1
EPOCH -= 1
# Get keys to quit.
if len(event.getKeys())>0:
event.clearEvents()
win.close()
'''
# For recording dropped frames
win.recordFrameIntervals=True
# By default, the threshold is set to 120% of the estimated refresh
# duration, but arbitrary values can be set.
#
# I've got 85Hz monitor and want to allow 4 ms tolerance; any refresh that
# takes longer than the specified period will be considered a "dropped"
# frame and increase the count of win.nDroppedFrames.
win.refreshThreshold = 1/85 + 0.004
# Set the log module to report warnings to the standard output window
# (default is errors only).
logging.console.setLevel(logging.WARNING)
print('Overall, %i frames were dropped.' % win.nDroppedFrames)
'''