Hi Chris,
Thank you for the Nightly Built. It solved the conflicting timing of two event codes being sent at the same time.
Now we’ve encountered a similar problem with turn_laser_on() and update_display(). This will be our priority for next week since we will be recording very soon. We would appreciate it if you could help us with this.
For this particular protocol, we would like to have the laser on while presenting a stimulus on the screen. Ideally, we would like the laser to be turned on and off at the same time as the stimulus (and laser_on_duration is the same as the stimulus_on_duration which is 300ms). Since both turning on the laser and the photodiode takes time, we tried two ways of positioning turn_laser_on() and update_display() in our protocol as following to see if laser duration can cover the entire stimulus presentation time:
- turn_laser_on() before photodiode_pixel_on() and update_display()
report('Laser On’)
turn_laser_on(laser_on_duration)
report('Stim On’)
queue_stimulus(target_stimulus[stimulus_type])
photodiode_pixel_on()
update_display()
vpixx_send_blackrock_sync_word(e_stimulus_on) //Stim on
vpixx_send_blackrock_sync_word(e_photodiode_on)
It turned out that the laser was turned on and off about 30ms before the photodiode was on and off. But both were indeed turned on for 300ms. I’ve attached a matlab figure if it helps. The blue trace is the laser detection trace, the pink trace is photodiode, the blue dot is the e_laser_on, and the pink dot is the e_stimulus_on.
- photodiode_pixel_on() and update_display()before turn_laser_on()
We recalled that there is an about 16 to 17ms delay between e_stimulus_on and photodiode on (due to the refresh rate of the monitor). Therefore, we tried to draw the stimulus first before turning the laser on, thinking that the time it took the laser to be turned on would overlap with this 16 to 17ms delay to make the two events happening closer in time.
report('Stim On’)
queue_stimulus(target_stimulus[stimulus_type])
photodiode_pixel_on()
update_display()
turn_laser_on(laser_on_duration)
report('Laser On’)
vpixx_send_blackrock_sync_word(e_stimulus_on) //Stim on
vpixx_send_blackrock_sync_word(e_photodiode_on)
However, the stimulus was still presented before the laser was turned on. There was an about 45ms difference between photodiode on and laser on. The laser was on for 300ms but the stimulus was on for over 300ms even though the stimulus_on_duration was 300ms. It seems like it was waiting for the stimulus drawing to be completed before turning the laser on. I’ve also attached a figure of what the traces look like this time.
We ran a few controls to troubleshoot this problem. We silenced either the turn_laser_on() or the update_display() in the protocol. When there was only turn_laser_on() command in a protocol, the e_laser_on and actual laser onset took place with a time difference of just around 2ms. When there was only update_display() and no turn_laser_on() command in a protocol, there is an about 16 to 17ms delay between e_stimulus_on and photodiode on time. The two commands alone worked as expected but there seems to be a problem when both commands are cued at the same time. In order to make sure that the laser covers the stimulus presentation, we tried to make the laser on duration 30ms longer than the stimulus on duration. It is not ideal but it solved the problem for now. Is this the only solution?
I’ve also attached the config_Laser file and a protocol where we cued both a stimulus and turn_laser_on() in the “Stimulus On” state.
Thank you again for helping!
Best,
Taylor
laserAmpStim_laserThenStim.fig (388 KB)
laserAmpStim_stimThenLaser.fig (369 KB)
config_Laser.mwel (5.28 KB)
protocol_LaserAmplitude_wStim.mwel (16.9 KB)