[solved] How to get around frame sync issues
Hi,
At the moment I'm trying to create rotating objects for a new paradigm. To avoid timing issues I used the number of frames instead of ms for stimulus presentation.
I wrote the following inline script (the 'run phase' part):
#presentation of stimuli in nr of frames
nrframes = 300
nrsteps = -nrframes /10
#speed at which rotation takes place
rate = 2
#autodraw fixation dot
fixdot.setAutoDraw(True)
#Show fixation + cue arrow for memorization
for frameN in range(30):
if self.get('memorize') == 'left':
ArrowL.draw()
self.experiment.window.flip()
else:
ArrowR.draw()
self.experiment.window.flip()
# Initial fixation
for frameN in range(15):
self.experiment.window.flip()
#Set autodraw for objects
ImLeft.setAutoDraw(True)
ImRight.setAutoDraw(True)
fixdot.setAutoDraw(True)
#array of points where rotation takes place
rotl = [x-((random.randrange(0, -nrsteps, 10) -(nrsteps/2))) for x in range(nrframes, 0, nrsteps)]
rotr = [x-((random.randrange(0, -nrsteps, 10) -(nrsteps/2))) for x in range(nrframes, 0, nrsteps)]
rots = [x-((random.randrange(0, -nrsteps, 10) -(nrsteps/2))) for x in range(nrframes, 0, nrsteps)]
#Starting point of rotation
r = 0
l = 0
#rotate forward or backward
randr = random.choice([-1, +1])
randl = random.choice([-1, +1])
#Rotating objects according to points in array + congruent/ incongruent sound
for frameN in range(nrframes):
if rotl.count(frameN):
randl = randl * -1
if self.get('congruent') == 'left':
tone.play()
if rotr.count(frameN):
randr = randr * -1
if self.get('congruent') == 'right':
tone.play()
if self.get('congruent') == 'none':
if rots.count(frameN):
tone.play()
r = r + (randr * rate)
l = l + (randl * rate)
ImRight.setOri(r)
ImLeft.setOri(l)
self.experiment.window.flip()
#stop autodraw to clear canvas
ImLeft.setAutoDraw(False)
ImRight.setAutoDraw(False)
#Retention interval
for frameN in range(120):
self.experiment.window.flip()
#Clear canvas
fixdot.setAutoDraw(False)
self.experiment.window.flip()
I created this on my home pc with a excellent graphics card and it worked great!
Unfortunately, the stimulus pcs in our labs only have onboard graphics cards and there this script doesn't work. I think it has to do with 'frame sync'. I checked the psychopy forum which says: "Some graphics cards, such as Intel GMA graphics chips under win32, don’t support frame sync. Avoid integrated graphics for experiment computers wherever possible." (pretty clear ), however it does not give any alternatives if you have no choice but to work with integrated graphics cards.
While it's going to be part of an EEG experiment in which I need the accurate timing, I do want to do some behavioral runs aswell where timing doesn't have to be as precise, so I could use, for example, the self.sleep()
command? However, I have no idea how to do the same thing I did with the frames if I can only use the self.sleep()
command.
for example the following part:
for frameN in range(nrframes):
if rotl.count(frameN):
randl = randl * -1
if self.get('congruent') == 'left':
tone.play()
Any help is appreciated!
Regards,
Michel
Comments
Hi Michel,
In what sense doesn't the script work? Does the experiment run way too slowly? In that case, as you already suggest, the problem is probably that your computer's video card isn't fast enough to generate the stimuli online. I'm not sure what you have in mind when you want to use
self.sleep()
, but at any rate: Sleeping will only slow things down even further, so it won't solve anything!I'm afraid that if the video card isn't fast enough, there isn't much that can be done about it. Do you preload a lot of stimuli, or do you have a lot of
sketchpad
s etc. in OpenSesame (these are implicitly preloaded)? If so, you could see if removing some things will speed up your experiment. And, if it does, you could try to come up with a more efficient experimental structure.Another option would be to reimplement the experiment using the legacy backend, which is generally faster on systems with poor video cards. But this clearly undesirable, because you will end up with two versions of the same experiment. And it will be a lot of extra work.
Or maybe convince @durk to buy some decent video cards!
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
Thank you for your quick reply!
So, yeah, my post wasn't really clear. The 'experiment' actually seems to run to fast on a pc with a onboard graphics card!
instead of taking around 16,7 ms for 1 frame (depending on refresh ofcourse), getting a smooth rotation of objects, it seems to rush through al commands in order getting a blur of pictures and beeps.
I don't really know how to make my problem clear in words, since I have no idea of what's going on, so maybe you can take a quick peek at the 'experiment'?
I posted a link with the experiment and some stimuli:
dropbox
You would probably need a pc with and a pc without a good graphics card to see what I mean
I did convince @Durk to buy some decent videocards, but it's the departement here that I have to convince, and that's not working so far
Michel
Hi Michel,
A right, I see. In that case, the blocking flip doesn't work, which means that the computer doesn't wait until a display is actually presented before
win.flip()
returns.And yes, you could just insert a
self.sleep()
command after everywin.flip()
call to slow presentation speed down. You'll have to manually tweak the amount of sleeping so that it appears to run at the correct pace. Probably something just short of 16 should do the trick. You're probably aware of this, but this is a hack to throttle presentation speed, and it will not make the blocking flip work again.Btw, are you running Windows 7 with graphical effects? If so, disabling these effects may resolve your issue. See also here (there's lots more info on that page):
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
I thought as much. The
self.sleep()
command works as expected, so I'll just use that.I have my windows 7 set on 'best performance', so no pesky visual glitter and glamour. Also it gave the same problem on the lab winXP pcees.
Thank you for your help!