Delay in sketchpad display in Loop
Hi,
I'm building an experiment with Open sesame. In this experiment, I would like to display one stimulus (a circle or a square) every 500ms. I would like display 20 stimuli. The participant have to determine if the stimulus is a circle (to press "S" key) or a square (to press "L" key).
The localization of the stimulus on the screen is random and the alternating between square and circle is also random. For this, I created a loop. Each row is the name of the stimulus (circle/square), a x position, and a y position. The order of the loop is "random".
Next, I added a sketchpad which displays the stimuli according to the values of variables in the loop. Finally, the function keyboard.get_key( ) to record the responses.
Because I would like to display 20 stimuli (one by one), my loop iterates 20 times (until the count_variable = 20). So, the total time of this display must be 10 s (20 stimuli * 500 ms). However, this display runs late (12s instead of 10s). I don't understand why. Can you help me to reduce this late?
You could find tattached this opensesame projet (Distracteur_display.osexp).
I tried to not use "sketchpad" but canvas or form (with inline script python) but the issue is the same.
I tried to use letter instead of square/circle but the issue is the same.
I verified to correctly use "prepare" for the keyboard.
Thanks you for your help!
NB: I'm using the backend "PsychoPy, powerful stimulusgeneration"
Comments
Hi,
Are you sure this has nothing to do with your machine? When I run your code, I get:
which is pretty accurate I guess?
Eduard
Hi,
Thanks for your answer.
Indeed, the time of each keyboard seems to be accurate. However, when I compute the total time for the display of all stimuli, I find a delay, namely :
I find this delay when I compute the total time with the clock.time( ) function in Opensesame and when I compute the total time with an external timer.
I'm adding a new opensesame file with the calculation of this time (which reveals this delay - var.total_time).
Inès
Hi Inès,
That's quite normal. Opensesame is optimized so that timing within a trial is as precise as possible, where "within" a trial is defined as the elements in the run phase of a sequence. It does so by sacrificing a bit of accuracy across trials, so between two iterations of a sequence. If you need more detail, you can read again the prepare-run-strategy part of the documentation.
So avoid the 2 or 6 seconds delay across trials, you can implement your own trial structure, based on inline_scripting. Attached you find an example that demonstrates the idea, the timing is much better already. There is of course still room for improvement (mostly due to the overhead of managing the different phases, which you can avoid, by not using loop-sequence in first place), but I wouldn't worry too much about that little delay.
Eduard
Hi,
Thank you very much for your help!
It was very usefull and it helped me to better understand!
Inès