Timing of canvas presentation in a loop
Hello,
I have an issue I really have troubles figuring out with timing.
A simplified version of what I try to do is:
- presenting a canvas;
- then wait for a keyboard answer (timeout 800 ms).
So I just have in a loop and inline calling the canvas, then the keyboard, like:
in prepare:
python my_keyboard = keyboard(keylist=['SPACE']) my_keyboard.flush()python
in run
python var.time_present = show_stim(var.trial_shape).show() var.practice_key_pressed_Trial, var.pattern_abs_time_response_Trial = my_keyboard.get_key(timeout=800)python
show_stim is just a little function with the name of the canvas to display.
Anyway so when I do that I log the time of canvas presentation in var.time_present. Issue I have is that when I substract the difference between two var.time_present is not equal to 800 ms (well or to something close depending the refresh rate) and constant.
So I wonder if my canvas are staying for a same amount of time on the display.
I join a code example to this maybe it will be more understanble.
Best,
Sylvain
Comments
Hi Sylvain,
some thoughts:
1. my_keyboard.flush() does not make sense in prepare phase
2. why do you insert a loop, and do not write it in python code? The rest is written in python code. Not sure whether this might fix your problem. But it's worth a try.