[solved] Measuring accurate timing for moving stimuli (in a for loop)
Hi!
First of all, I must say that Opensesame is a fantastic platform and you guys are doing an amazing job in promoting better experiment building in the field of cognitive science.
As for my question:
I'm building an experiment in which participants see moving stimuli on the screen (on top of a constant background picture) and needs to respond to the direction of the movement. I'm presenting the stimuli in a for loop with an inline code i wrote. Before running the experiment I wanted to make sure that the measure of reaction times is as accurate as possible and wrote this small test to make sure that the timing of the loop is constant.
some info: both 'scatter' and 'arrow' pictures are .png files with transparent background; also i'm running on Legacy because the other back-ends seems to not work with this type of stimuli.
start_time = self.time()
for i in range(0,150):
my_canvas.clear()
my_canvas.image(scatter,x=x ,y=y)
my_canvas.image(arrow,x=x+0.3*i, y=y)
my_canvas.show()
end_time = self.time()
I ran this test for 2 types of stimuli, 4 times each and got these results for the (end_time - start_time)
stimuli 1:
1440
1438
1438
1435
stimuli 2:
1443
1427
1427
1425
As you can see, the results show that the timing is not that exact and i'm concerned that it will reflect on the measurement of the Reaction times in my actual experiment.
Any thoughts on how to improve this?
Thanks!
Yoni
Comments
Hi Yoni,
In principle, it should be feasible to have constant durations. To find out what's going on here, you could start by looking at the timestamps of each individual canvas presentation. This will tell you, for example, whether the problem is an occasional dropped frame, or that display presentation doesn't lock to the refresh (in which case you get frame durations that are impossible given your monitor's refresh rate), etc.
Something like this:
My guess is that OpenSesame just doesn't keep up, because you're not preparing anything, but redrawing each canvas on the fly. This can cause dropped frames and unpredictable jitter. There's a good chance that switching to the psycho back-end will solve the problem, because PsychoPy is a bit more efficient for these things. If not, you may have to optimize the script a bit.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thank you very much!
I used psychoPy (turns out I had to update my opensesame vervion) and it works perfectly.
Yoni