Optogenetics with Scanbox

The latest version of Scanbox includes a panel to allow uses to perform 1p optogenetics with 2p imaging.  The panel provides an interface to the ThorLabs DC2200 dual channel controller, but can also be used with the simpler T-cube driver.  You can use the LED of your preference.  We have been working both with mounted LEDs with T-cube driver, and mounted LEDs and the Solis LEDs wit the DC2200 controller. We use a gated PMT from Hamamatsu to protect the PMT during LED stimulation, and the timing diagram below shows its basic characteristics.


The first important note is that the maximum shutter time is 10ms.  The second is that a dead time is needed between the LED control signal turning off and the PMT shutter signal turning the PMT back on.  The reason is that the PMT shutter is extremely fast, with switching times less than 400ns.  On the other hand, it can a bit longer for the LED to completely turn off after the control signal to the driver is switched off.  Thus, in order to prevent damage to the PMT, we need to turn the LED off first and switch the PMT on some time later.  We call this dead time the margin.  We call the amount of time the LED is on the width of the stimulation pulse.  Because of the timing limitations we need to have margin+width<10ms.  The size of the margin can be determined experimentally: increase its value until you don’t see any saturated lines.

Scanbox generates a control signal for the LED and the PMT shutter that is synchronized to the beginning of a frame.  The signal that controls the LED goes to the LED driver used, while the signal that controls the shutter, must be connected to the PMT gate.  The signals are generated by means of an external Arduino pulse generator.  The board also receives a copy of the CAM0 signal, wihch indicates the begining of each frame.

The code for the Arduion can be found under Scanbox/optogenetics/.  Once the board is programmed it will show up as a COM port in the Device Manager.  The board and the instrument ID of the DC2200 controller can be specified in Scanbox configuration file:

%Optogenetic options 

sbconfig.optogenetics = true; % make optogenetic panel visible
sbconfig.led_id = 'USB0::0x1313::0x80C8::M00476084::INSTR'; % DC2020 ID
sbconfig.led_stim_com = 'COM8'; % Pulse generator COM port

Once the configuration file is ready, when you start Scanbox, an Optogenetics panel will be available with the following controls:optogenetics.pngThe fields at the bottom control the parameters for the pulse generator.  The are the width, margin, and number of pulses to be delivered (all positive integers).  Width and margin are in units of msec.  The settings shown above, for example, mean that every time an LED stimulus is requested, the software will generate 8ms of stimulation with 2ms deadtime, and the pulse will appear in 4 consecutive imaging frames.

The parameters within the blue box control the mode and settings of the DC2200 controller.  If you are using this controller you must set its mode to one that can be triggered externally and connect the LED signal to the SMA connector in the back of the unit. A full description of the parameters can be found in the DC2200 manual.  Each of the different lines provide the parameters for different modes (CC: Continuous Current, CB: Continuous Brightness, Pulse: Pulse mode, IMOD: Internal modulation, TTL: External TTL enable).

The Arduino stimulus generator can be triggered manually by hitting the “Trigger” button or, once the parameters are set, it can be triggered via a network command (“e”). I will also add network commands to change the parameters of the pulses and the DC2200 driver remotely soon.

If you want to keep a time-stamp of the times at which the pulses occured, you may want to connect the TTL signal controlling the LED to the TTL0 or TTL1 event lines. This is not entirely necessary, as it is clear on which frames the stimulus occured due to the blanking of PMT in these cases.  So the actual frames can be recovered from the imaging sequences as well.

When you use sbxaligntool for these experiments select a manual ROI and pick a region which does not overlap with the stimulation band.  I will add some automatic detection of this condition in the future.