Hi Chris -
Briefly - we’re having three key issues:
(1) It seems that the plug-in is taking about ~80ms to activate the laser
(2) It seems that changing the “gain” (or amplitude) term in the plug-in works for square wave modulation but not sine wave modulation.
(3) When we use a photodiode to detect a square stimulus drawn to the screen BEFORE we activate the plug-in, we notice that this photodiode detection event occurs ~20ms AFTER the laser is turned on.
Im attaching two things:
- The MWEL protocol we use to drive the laser (the relevant lines are 230-337)
* We are sending 3 codes to mark the beginning and end of the laser stimulation
* One code is related to drawing the photodiode square
* A random code (called “distractor color” or “distractor id”) flanks the start/stop of the laser plugin
* Another code is related to activating the laser plug-in
- A figure showing our reconstruction of these event times relative to the light sensor coming out of our laser box.
Thanks,
Yasmine
protocol_Laser.mwel (18.2 KB)
[//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/flex031/uploads/mworks/original/1X/7349ac241512df017a1f4ad54aef15b9892e8547.jpeg]
Hi Yasmine,
I’m missing some details in your experiment. For one, I see there’s a macro named photodiode_pixel_on
, but I don’t have a definition for it. Can you share the other MWEL files used with the code you sent? Also, I don’t see any code that looks like it’s sending a “distractor id”. Where exactly does that happen?
(1) It seems that the plug-in is taking about ~80ms to activate the laser
In the plot, is this 80ms the gap between “DistR (EC)” and “LaserOn (EC)”? If so, it’s hard to say what’s happening without knowing how and when “DistR (EC)” is sent to the Blackrock.
(2) It seems that changing the “gain” (or amplitude) term in the plug-in works for square wave modulation but not sine wave modulation.
I don’t see any attempt to change the amplitude in the code you sent. Can you share the experiment code that produced this issue (or otherwise explain how you observed it)?
(3) When we use a photodiode to detect a square stimulus drawn to the screen BEFORE we activate the plug-in, we notice that this photodiode detection event occurs ~20ms AFTER the laser is turned on.
Again, I can’t see the details of how you’re presenting the photodiode stimulus.
That said, we already discussed (in June 2022; the email thread subject was “Disparity in stimulus on/off times?”) a very similar issue, and I made specific recommendations for how to address it. Maybe your photodiode_pixel_on
macro makes use of these, but if not, that’s probably the issue.
Cheers,
Chris
Hi Yasmine,
Regarding display update timing, here’s what I said last June:
On the MWorks side, your experiment is deciding when to send the digital code signaling on/off. Most likely, you’re sending it immediately after an update_stimulus_display action. As noted in the docs, completion of this action indicates that the display update has been submitted, but not that it has completed. MWorks can’t know, via software means alone, when the display update has completed — that’s why you have a photodiode on your display. If you want your experiment to wait until when the OS expects the display update to complete, you can use the predicted_output_time parameter and explicitly wait until that time.
Also:
If you want there to be any consistent correlation between when you send an on/off signal to Blackrock and when a display update appears on screen, then you must use predicted_output_time. If you don’t, then your signals will be sent at arbitrary points in the display update cycle.
I recommended replacing all instances of update_display
with invocations of the macro update_display_and_wait
(included below), which executes update_display
then waits until the predicted output time:
var predicted_display_update_time = 0
%define update_display_and_wait ()
update_display (predicted_output_time = predicted_display_update_time)
assert (
condition = predicted_display_update_time > now()
message = 'Predicted display update time is in the past'
)
wait (duration = predicted_display_update_time - now())
%end
In your current experiment, if the goal is for the photodiode stimulus to appear on screen as close as possible to the time when the laser turns on, then you should turn the laser on immediately after executing update_display_and_wait
, e.g.
update_display_and_wait ()
vpixx_dout_laser_gate = true
Cheers,
Chris