I’ve been trying to write a simple script that generates an expanding circle that:
-
Expands from 2 to 20 degrees of visual angle over 250 ms.
-
Holds at 20 degrees for another 250 ms.
-
Repeats n number of times with 500 ms inter-stimulus interval (blank, grey screen).
I think I have the code working. However, 1) I think there must be a simpler/better way of doing this and 2) when I run the code, although no frame drops are reported, there appears to be some lag/variation in expansion between iterations.
If anyone could comment on either of these points I would appreciate it.
Code so far:
from psychopy import visual, core, event
# Define the background
win=visual.Window([800,600],monitor="testMonitor",units="deg")
# Number of epochs (repetitions)
EPOCH=15
# Duration of expansion
EXPANSION_MS=250
# Hold duration
HOLD_TIME_MS=250
# ISI duration
ISI_MS=500
# 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=1,edges=1000,fillColor='black',lineColor='black')
for e in range(EPOCH):
for f in range(FRAMES):
if circle.radius<10:
circle.radius+=1 # or should it be: 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
# Get keys to quit.
if len(event.getKeys())>0:
event.clearEvents()
win.close()