Simultaneous optogenetic manipulation and calcium imaging in freely moving C. elegans

A fundamental goal of systems neuroscience is to probe the dynamics of neural activity that drive behavior. Here we present an instrument to simultaneously manipulate neural activity via Channelrhodopsin, monitor neural response via GCaMP3, and observe behavior in freely moving C. elegans. We use the instrument to directly observe the relation between sensory stimuli, interneuron activity and locomotion in the mechanosensory circuit.

microns apart in a moving worm (see Supplementary Movie 2), and estimate our actual resolution to be ~30 microns. The system's effective resolution would be further improved using next generation red-shifted calcium indicators.
[6] Guo, Z.V., Hart, A.C., and Ramanathan, S. Nat. Methods 6, 891-896, (2009). a.) A digital micromirror device (DMD) reflects laser light onto only targeted neurons of a worm freely moving on a motorized stage. Real-time computer vision software monitors the worm's posture and location and controls the DMD, lasers and stage. b.) ChR2 is expressed in six soft-touch mechanosensory neurons, including ALM and AVM (dark blue). Calcium indicator GCaMP3 and fluorescent reference mCherry are expressed in command interneuron AVA (striped green and red). Light blue shaded regions indicate areas of illumination. "a" is anterior, "p" is posterior, "d" is dorsal and "v" is ventral. c.) Intracellular calcium dynamics of AVA (green line) are measured before during and after optogenetic stimulation of the ALM touch neuron (2.7 s stimulation, blue shaded region). The velocity of the worm's body bending waves is shown in gray. d.) Mean of activity and e.) velocity during a time window were shown (grey crosses) for worms that responded by reversing to optogenetic illumination of ALM (n=8 trials), AVM (n=6 trials) or both (n=9). Mean across trials is shown (red squares). Errorbars represent standard error of the mean. Dashed green line represents the mean plus standard deviation of fictive neural activity from a GFP control, which serves as a measure of noise in the instrument. f.) For each trial, mean AVA activity is plotted against mean velocity, (n=39 trials), including non-responders. g) The fraction, f, of responders are shown for each stimuli. Number, n, indicates total trials. Error bars are ! =

Supplementary Methods
The optogenetics portion of the instrument is based on the CoLBeRT system [1]. The calcium imaging portion builds upon concepts from an earlier imaging-only system, called DualMag [8,9].

Microscopy.
The optogenetic stimulation and calcium imaging system was built around a modified Nikon Eclipse Ti-U inverted microscope that contained two stacked filter cube turrets. All imaging was conducted using a 10x, numerical aperture (NA) 0.45, Plano Apo objective. Worms were imaged on 6cm NGM agarose plates on a Ludl BioPrecision2 XY motorized stage controlled by a MAC 6000 stage-controller. Custom real-time computer vision software kept the worm centered in the field of view via an automated feedback loop.

Behavioral imaging.
Worm behavior was imaged on a CMOS camera (Basler aca2000-300km) under darkfield illumination in the near-infrared (NIR). Dark-field illumination was chosen to provide high contrast between the worm and the agarose plate. NIR illumination was chosen to avoid cross talk with simultaneous fluorescence imaging and also to minimized inadvertent ChR2 activation. An NIR filter, Semrock #FF01-795/150, was mounted in the illumination path of a Nikon halogen lamp. Dark-field illumination was obtained by using a Ph3 phase ring to create an annular pattern of illumination. A custom filter cube (Semrock #FF670-SDi01) in the microscope's upper filter cube turret reflected the behavior imaging path out of the microscope through what would normally be its epifluorescence illumination pathway. From there, a telescope composed of two achromat doublet plano-convex lenses was used to form an image on the camera. A long-pass filter, Omega Optical #3RD710LP, prevented stray light from entering the camera. The Basler camera transferred images to a desktop computer via a BitFlow Karbon PCI Express x8 10-tap Full Camera Link framegrabber. Images were recorded via the MindControl software discussed below.
The beams from the 473-nm and 561-nm lasers were first aligned to a common beam path by a series of mirrors and a dichroic mirror (Semrock #FF518-Di01). The combined beam path was then expanded using a telescope of two plano-convex achromat doublet lenses and reflected by a 2-inch diameter mirror onto a 1,024 x 768 element digital micromirror device (Texas Instruments DLP, Discovery 4100 BD VIS 0.7-inch XGA, Digital Light Innovations). The patterned light from the digital micromirror device was imaged onto the sample via an achromat doublet that served as a tube lens, and a custom filter cube (Chroma #59022bs dichroic, Semrock #FF01-523/610 emission filter) in the microscope's lower filter cube turret. Light intensity measured at the sample was 2 mW * mm^-2 of 473-nm light and 1 mW * mm^-2 of 561-nm light.

Fluorescence imaging.
Red and green channel fluorescent images were recorded simultaneously with a Hamamatsu Orca Flash 4.0 siCMOS camera at 30 fps, with 33 ms exposure on a second Dell Precision T7600 desktop computer. To simultaneously image mCherry and GCaMP3 side-by-side we used a DV2 two-channel imager from Photometrics containing a custom filter set (Chroma #565dcxr dichroic, Semrock #FF01-609/54-25 red emission filter, Semrock #FF01-520/32-25 green emission filter). Fluorescent images were captured using HCImage software (Hamamatsu) running on a dedicated Dell Precision T7600 computer running Windows 7 with two Intel Xeon Quad Core 3.3 GHz processors and 49 GB of RAM.

Real-Time computer vision software
An improved version of the MindControl software [1], written in C, was used to generate patterned illumination and perform real-time feedback of the stage. The software was rewritten for 64-bit Windows 7. Additionally new features were added to give the user more options for performing timed stimulations and to give the user more control over stage feedback parameters. The overall stability of the software was also improved. The MindControl software was run on a Dell Precision T7600 computer running Windows 7 with two Intel Xeon Quad Core 3.3 GHz processors and 16 GB of RAM. Source code is released under the GNU General Public License and is available for download on GitHub at https://github.com/leiferlab/mindcontrol .

Fluorescence imaging analysis
Neural activity is reported as normalized deviations from baseline of the ratio between GCaMP3 and mCherry fluorescence, We have chosen to report fluorescence intensity of GCaMP3 as a ratio to the calcium insensitive mCherry so as to better account for artifacts from the animal's motion. The baseline R 0 is defined as the mean of R from trial onset to stimulus onset. The intensities !"#$%! and !"!!""# were measured as the median pixel intensity in the green and red channels, respectively, of the 40% brightest pixels of a circular region of interest (ROI) centered on the maximal intensity of a Gaussian smoothed image of the neuron AVA. The ROI was selected in each frame by custom MATLAB scripts and confirmed by the user. The local background, background green and background red in the green and red channels, respectively, were measured as the median pixel intensity in an annulus around the neuron. 2048 x 2048 pixel images were binned to 1024 x 1024 pixels. The ROI for each neuron was a circle of radius 8 pixels and the background was an annulus of inner radius 20 pixels and an outer radius of 22 pixels. At our magnification the scale was 0.62 μm / pixel. Custom MATLAB scripts were used to calculate the Δ! ! ! for each frame, and smoothed with a low-pass Gaussian filter (σ = 5 frames).
Transgenic animals expressing GFP instead of GCaMP3 were used as a control for motion artifacts and instrument noise. These animals were imaged under the same conditions as the GCaMP3 animals, however their reversals were spontaneous rather than induced.

Optogenetic-induced behavior experiments
Worms were grown on NGM agar plates seeded with 250μL of OP50 E. Coli mixed with 1μL of 1mM all-trans retinal in ethanol solution. Plates were seeded on day 0, worms were transferred to seeded plates on day 1 and imaging was performed on day 2.
Spatially distinct regions of the worm's body were defined to illuminate the cell bodies of selected neurons. The AVA region corresponded to 90% of the body width and 10% of the body length, centered 10% of the way from the anterior tip of the worm. The AVM region corresponded to 50% of the body width and 13% of the body length, centered 35.5% from the anterior tip, and 35% from the ventral edge. The ALM region was the same size, but centered 42.5% of the way from the anterior tip, and 35% from the lateral edge. Regions were selected to avoid overlap of processes, however the illumination region of AVA includes a small portion (estimated to be less then 20%) of the ALM process.
To mitigate suspected worm-to-worm variability in ChR2 expression and retinal uptake, we selected worms for our experiment that reversed in response to whole head illumination but did not reverse or pause in response to illuminating the small portion of the ALM process near AVA. Previously we had observed that illuminating small areas of neuronal processes alone usually caused little effect [1]. Approximately three quarters of worms tested responded with reversals to a brief whole head illumination, and of those, 39 of 53 worms had no noticeable response to the onset of process illumination and were thus deemed suitable for experimentation. Whole head illumination was performed manually on a fluorescent dissection scope (Nikon SMZ-1500) while process illumination was performed on the main instrument by illuminating the AVA region.
For imaging, worms were washed in M9, transferred to approximately 1.5-mm thick NGM agarose plates and covered with mineral oil to improve contrast under dark-field illumination. Imaging began after allowing animals to acclimate for 5 minutes. After >15 seconds of AVA imaging, either AVM, ALM or both, were illuminated for 2.7 seconds. AVA imaging continued for >15 seconds. Worms underwent up to two stimulations, with 3 minutes rest in between, before being discarded. Trials where the worm underwent spontaneous reversals prior to stimuli, or prolonged bouts of multiple distinct reversals in response to the stimuli were excluded.

Data Analysis
Behavioral data and calcium activity data were analyzed using custom MATLAB scripts, available at http:://github.com/leiferlab/dualmag-analysis. An empirical model of AVA activity was fit to each calcium trace to find the mean velocity and amplitude of neural activity for each trial. Calcium levels in AVA were assumed to increase and then decrease in a similar manner to an RC circuit in response to a voltage square wave, where stimulus onset occurs at t=0, A is the amplitude of neural activity and ! and ! are the timescales for calcium increase and decrease. Mean velocity was calculated over the time window from stimulus onset (t=0) to ! . The parameters A, ! and ! were fit for each trace using least-mean squared and the Nelder-Mead method.