Sync stimuli display with output pulse (electrical stimulation)

Hi Chris

I am setting up an experiment where two response objects appear in the screen while at the same time delivering electrical stimulation. The stimulation and the stimuli should appear at the same time or as close in time as possible

If I implement this:

live_queue_stimulus (stim1)
live_queue_stimulus (stim2)
pulse(variable = EP_Stimulation_flag; duration = 3 * 1000)

The pulse will likely be delivered before the screen will get refreshed. I did a quick test and the pulse is arriving 50 ms before the refresh the screen.

Then my question is: do you have any sugestions?

Have a nice day


Hi Jaime,

Try waiting until the predicted output time of the display update:

var pulse_start_time = 0
live_queue_stimulus (stim1)
live_queue_stimulus (stim2)
update_stimulus_display (predicted_output_time = pulse_start_time)
wait (pulse_start_time - now())
pulse (variable = EP_Stimulation_flag; duration = 3 * 1000)


Thanks a lot