Tommy Sprague
unread,Jul 10, 2009, 12:00:01 PM7/10/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to psychopy-users, eagl...@bcm.edu, eagle...@gmail.com
I am a new user of PsychoPy and have encountered an issue that I have
not found a way to resolve.
I have created a simple script to display a stimulus in which a square
and circle both flash on the screen for 60 ms, followed by a blank
screen for 1 s, followed by the circle presented for 60 ms at some
point during a 910 ms presentation of the square. This stimulus
involves only 3 frames (sq+circ, sq alone, blank screen), and so I
only need to make 6 frame changes over ~2 sec. I’ve done my best to
follow any and all coding practices used in the demos, and this works
great if I use a small window size (such as the 600x600 used in the
demos). However, when using a window size equivalent to my full
screen resolution (1680x1050), the stimulus slows significantly.
Recording the times of frame onsets/offsets in order to determine the
actual duration of each frame presented, I find that PsychoPy takes
about 40 ms to draw 1 frame (60 Hz) – again, this problem does not
occur when using sufficiently small window sizes.
Are there any potential causes of this problem, and if so, does anyone
know of any possible solutions?
I’ve attached the code I’m working with now, and below are some system
details that may be relevant:
IDE: I use EasyEclipse with the Endthought distribution of Python/
SciPy/NumPy/etc, along with Pygame and PsychoPy installed, however the
same issue occurs when using the PsychoPy IDE
Graphics: NVIDIA Quadro NVS 285 with driver version 6.14.10.9371 (64MB
onboard memory/64MB of system memory) – this works great with
Psychtoolbox 2.5/3.0
Processor: Intel Core 2 6400 @ 2.13 GHz
RAM: 2.00 GB
OS: Win XP SP3
The same problem occurs on my Late-2008 Macbook Pro running Win 7 RC1
(2.8 GHz dual-core, 4GB RAM, GeForce 9500M graphics w/ 256MB dedicated
memory, same IDE setup)
Also, I am completely new to Python, but have experience programming
in MATLAB and Java – if there is anything I’m doing inefficiently in
my code that could be the cause of this problem, I’d appreciate any
advice you might have to improve this.
code:
from psychopy import visual, core, event
import numpy as np
global_clock = core.Clock()
frame_outsize = 0.5
frame_width = 0.1
circle_size = .15
stim_color = [1.0,1.0,1.0]
bg_color = [-1.0,-1.0,-1.0]
context_dur = 0.91 # in seconds
test_dur = 0.06 # in seconds
#bgWin = visual.Window( size = (1680,1050),
# allowGUI = False,
# rgb = (-1.0,-1.0,-1.0))
myWin = visual.Window( size = (1680,1050),
rgb = bg_color,
allowGUI = False,
monitor = 'testMonitor',
units = 'norm') # [-1 to 1] on either
side
FPS = 60#round(myWin.fps())
context_fr = round(context_dur*FPS)
test_fr = round(test_dur*FPS)
frame_out = visual.ShapeStim( myWin,
units = 'norm',
lineRGB = stim_color,
lineWidth = 1.0,
fillRGB = stim_color,
vertices = [[-frame_outsize, -
frame_outsize],[ frame_outsize,-frame_outsize],
[ frame_outsize,
frame_outsize],[-frame_outsize, frame_outsize]])
frame_in= visual.ShapeStim( myWin,
units = 'norm',
lineRGB = bg_color,
lineWidth = 1.0,
fillRGB = bg_color,
vertices = [[-frame_outsize
+frame_width, -frame_outsize+frame_width],
[ frame_outsize-
frame_width, -frame_outsize+frame_width],
[ frame_outsize-
frame_width, frame_outsize-frame_width],
[-frame_outsize
+frame_width, frame_outsize-frame_width]])
circ = visual.PatchStim(myWin,
tex = 'none',
mask = 'circle',
units = 'norm',
pos = [0.0,0.0],
size = .15,
rgb = [1.0, 1.0, 1.0])
#frame_out.draw()
#frame_in.draw()
#circ.draw()
#myWin.flip()
frames = [3,2,1,3,1]
durs = [test_fr,1*FPS,0,test_fr,context_fr-test_fr]
actual_durs = []
mean_fr_dur = [[],[],[],[],[]]
blank = 2
def draw_TCE(fr_type):
"draws appropraite frame (given by fr_type) to the global window
and flips"
global_clock.reset()
if fr_type==1: # context only
frame_out.draw()
frame_in.draw()
myWin.flip()
elif fr_type==2: # blank screen
myWin.flip()
elif fr_type==3:
frame_out.draw()
frame_in.draw()
circ.draw()
myWin.flip()
elif fr_type==4:
circ.draw()
myWin.flip()
return global_clock.getTime()
stim_clock = core.Clock()
for i in range(len(frames)):
print "drawing frame " + str(frames[i]) + " for " + str(durs[i]) +
" frames"
for d in range(int(durs[i])):
mean_fr_dur[i].append(draw_TCE(frames[i]))
actual_durs.append(stim_clock.getTime())
stim_clock.reset(0)
draw_TCE(blank)
print actual_durs
print mean_fr_dur
m = np.mean(mean_fr_dur[1])
print m
print "FPS = " + str(myWin.fps())
event.waitKeys()
myWin.close()
core.quit()