Some questions

Hi Taylor,

Does that mean if I command the queuing of all the stimuli at a non-time sensitive state, the actual update_display() should not take different amount of time for drawing different number of stimuli?

No. Like I said, update_display does some work for each stimulus, so if there are more stimuli, it will do more work. There’s no way to “pre-perform” that work.

FYI, queue_stimulus does almost nothing – it just adds the stimulus to the list of stimuli to draw. No actual drawing work takes place until update_display.

The issue I am having right now is that for two protocols, I turn the laser on before update_display_and_wait() with the expectation that the laser would be on about 16ms before the stimulus onset.

For the protocol with one stimulus (protocol_LaserAmplitudeWithStim), in the “Stimulus On” state, I turn the laser on, queue the stimulus, and then update_display_and_wait(). The laser onset is about 20ms before the stimulus onset.

For the protocol with two stimuli (protocol_2afcLaser), in the 'Stimulus On - Pre-Saccade’ state, I queue all the stimuli first, turn the laser on, and then update_display_and_wait(). However, the laser onset is about 30ms before the stimulus onset for this protocol.

I doubt the 10ms difference is all due to the additional stimuli. Even if you normally expect update_display_and_wait to take about 16ms, there’s no guarantee that it’s going to do so. It all depends on where update_display is invoked relative to the display’s refresh cycle, and you have no control over that. Sometimes the drawing will take place several frames ahead of the actual display update, so update_display_and_wait will wait for 32ms (with a 60Hz display) or longer. Other times, you’ll be drawing for the very next frame, so the wait may be less than a single refresh period. I suspect this variability is the main source of the timing differences you’re seeing.

As I’ve said previously, you’re going to have a hard time aligning the laser and stimulus timing with the technique you’re using. I think this issue is an example of that difficulty. I’d really recommend switching to the alternative technique that I’ve described elsewhere.

Cheers,
Chris