New features for patterned photo-stimulation

Here is a description of some recent features added to facilitated patterned photo-stimulation experiments.

The first step, of course, is the definition of ROIs (or masks) to stimulate. After collecting some data from one field of view, you can either use the “Segment” button to have Suite2p detect the cells or manually draw them by clicking on the “Add” button. The Suite2p segmentation is saved automatically in the data folder with a *.s2p extension. If you are using manual segmentation and would like to save your final result, use the “Save” button.

If you are returning to this same field in multi-session experiments, you can use the “Load” button. The file selected can be either one you saved manually or the *.s2p file saved by Suite2p.

If you are returning to the same field in multi-session experiments, first you want to align the fields to be as close as possible using our population search tool or manually. In any case, once you load the previously saved masks, it is likely you will see some small offset. The ROI delta field allows you to rigidly translate the masks so they will maximally overlap with the population in the new experiment. Alternatively, you can collect some new data, run Suite2p again, and use the new masks. Alignment between the experiments can then be done post-hoc. Which method is preferable depends on your experiment. If you need to stimulate the same set of cells across sessions, the first method is better suited to your goals. Alternatively, instead of translating the masks you can also use knobby to move the field of view.

The second step consist in defining the regions we want to stimulate. In defining the ROIs, it helps to collect data when the brain is not moving much, during periods of rest. In the “PMT selection, gain and visualization” panel, you can now ask Scanbox to accumulate images only during periods of rest (this requires the quadrature encoder to be installed). The resulting average image will show the mean during rest. When hitting the Segment button, I am trying to get Suite2p to ignore frames during locomotion using the bad_frames configuration variable, but it does not seem to work for me as of today (if you know how to make it work, please let me know). Once this is solved, Suite2p would also calculate the masks during periods of rest. I will describe below how you can also stimulate during periods of rest to increase the chances you are hitting your cells and not off-target locations.

The “Label” checkbox (on the left side in the first image above) now allows you to show the masks and their numbers during and after scanning. This helps track any systematic changes in the mask locations with respect to the brain, and you can use the ROI Delta field to bring them back into alignment.

Some new features have been added to the galvo-galvo panel as well. The “Add” button used to simply add the next cell in the list. However, when segmenting hundreds of cells, one would like to directly add a cell by it’s ROI index. The field next to the button allows you to do just that. In the example above, the two cells defined correspond to the masks with ROI indices 2 and 4, as shown by the last column.

There is a new Async checkbox. Previously Scanbox only triggered a stimulation sequence at the beginning of each frame. This may be useful when stimulating a handful of cells with single pulses. If there is need for continuous pulses or repetitions of a sequence, the Async checkbox will allow you to proceed and stimulate asynchronously with the frames of the scan.

We also added more network commands that allow you to remotely control many of the stimulation parameters. For example, if you need an experiment to calibrate the stimulation of the cells as a function of laser power, you need to change the power of each ROI on the fly. The extended set of network commands below allows for such experiments.

gp cell power– Sets the power of a single cell of of all the cells simultaneously. cell is the index of the cell. If the index is -1, all the cells are set. The parameter power is in percent. Example: gp 2 44 will set the power of cell #2 to 44%. Power will automatically be updated on the Scanbox box. No need to execute an upload command (see below).

gt flag — Enables/disables the external triggering by a hardware signal. If flag is 1, triggering is enabled. If flag is 0, triggering is disabled.

gm mode — Selects stimulation mode (mode=1 is cell, mode=2 is group, and mode=3 is protocol). So, for example, gm 1, prepares for the stimulation of a single cell.

gs — Runs the selected stimulation. It is equivalent to hitting the “Stimulate” button in the Scanbox panel.

gC — Clears the tables (cell definition, gorup definition and protocol)

ga roi_index — Add a cell with roi_index as the next entry in the table. This, of course assumes ROIs have already been defined.

gA roi1 … roiN — Add a new group consisting of roi1, roi2, up to roiN. Example: gA 1 2 5 will add a new group [1 2 5] as the next entry in the group table.

gP g1 g2 … gN — Define the protocol as the sequence of groups g1, g2 up to gN. Example: gP 2 1 2 defines the protocol as the stimulation of group 1, then group 2 and then back to group 1.

gd dx dy — Shift the masks by (dx,dy). This is the same as changing the ROI Delta field remotely.

Finally, the firmware for the Arduino Due has been modified to allow the stimulation computer (in my case presents a visual stimulus) to know if we are in a state of locomotion or rest. The computer polls for the mean locomotion velocity and selects only periods of rest to stimulate with the expectation that such periods will be the ones when the masks and the cells will be most aligned.