Search tips
Search criteria 


Logo of hhmipaabout author manuscriptssubmit a manuscriptHHMI Howard Hughes Medical Institute; Author Manuscript; Accepted for publication in peer reviewed journal
Nat Methods. Author manuscript; available in PMC 2011 January 1.
Published in final edited form as:
PMCID: PMC2945246

Two-photon calcium imaging from motion-sensitive neurons in head-fixed Drosophila during optomotor walking behavior


Drosophila melanogster is a model organism rich in genetic tools to manipulate and identify neural circuits involved in specific behaviors. Here we present a novel technique for two-photon calcium imaging in the central brain of head-fixed Drosophila walking on an air-supported ball. The ball’s motion is tracked at high resolution and can be treated as a proxy for the fly’s own movements. We used the genetically encoded calcium sensor, GCaMP3.0, to record from important elements of the motion-processing pathway, the horizontal-system (HS) lobula plate tangential cells (LPTCs) in the fly optic lobe. We presented motion stimuli to the tethered fly and found that calcium transients in HS-neurons correlated with robust optomotor behavior during walking. Our technique allows an entirely new set of questions to be addressed by monitoring behavior and physiology in identified neurons in a powerful genetic model organism with an extensive repertoire of walking behaviors.

Drosophila melanogaster has a brain of only ca. 100,000 neurons but displays a wide variety of behaviors1, ranging from innate behaviors like phototaxis and courtship, to adaptive behaviors such as remembering associations between sensory stimuli and conditional reward or punishment. Genetic tools to manipulate the activity of defined sub-populations of neurons in the fly brain have helped identify candidate neural substrates for many of these behaviors, but it has been harder to establish clear links between behavior and neural activity. Physiological recordings from the fly’s brain can provide such a link, but these recordings are made challenging in the fly because of its small size. Technical advances in the past decade have significantly improved the fly physiologist’s toolkit, making it possible to use powerful circuit-busting strategies that combine physiology with genetic and behavioral tools24.

Studies of adult fly brain function now routinely use either genetically encoded sensors and/or electrophysiology to record the activity of identified neural populations in a fixed fly. Electrophysiology provides high temporal resolution and, in the case of somatic whole-cell patch clamp recordings, a window into synaptic activity that is difficult to obtain using other methods. On the other hand, much of the processing in insect neurons is localized to arbors that are distant from the soma57 and difficult to target with patch clamp recordings. Increasingly powerful imaging techniques thus represent a complementary capability to monitor neural activity. In Drosophila, two-photon imaging8 with genetically encoded sensors provides a relatively non-invasive means of recording neural activity from identified neurons at high spatial resolution911.

However, recording in a completely immobilized preparation is not sufficient to make direct connections between neural activity and behavior. Recording neural activity while the animal is engaged in a particular task allows for a direct exploration of the functional properties of a circuit in the context of the behavior. Feedback from other brain areas is likely to play a particularly important role in neural circuit operation during behavior. Furthermore, such recordings enable investigations into the links between neural and behavioral variability during individual trials12. Recordings in head-fixed animals give a high degree of control over stimulus presentation, and have been used in the past in insects1315, primates16, 17, and rodents18, 19.

We have developed a head-fixed, behaving fly preparation and demonstrate its use by recording from motion-sensitive Lobula Plate Tangential Cells (LPTCs) of the optic lobe during walking behavior. The LPTCs have been the focus of numerous investigations in larger blowflies20, 21 and have recently been the target of physiological studies in Drosophila as well15, 22, 23. Here, we used two-photon imaging with GCaMP3.024 to record dendritic calcium responses of the Horizontal System (HS) neurons of the Lobula Plate in Drosophila. In stationary flies, HS neuron responses to optic flow were similar to those previously observed23, 2527(see also Chiappe et al., submitted). In walking flies, on average, optomotor responses to motion stimuli in the preferred direction of HS-neurons followed and were correlated with neuronal responses, as has only been predicted previously25. Our technique thus allows activity in genetically targeted cell populations to be measured during behavior and under sensory stimulation that is relevant to the neurons under study.


Fly holder

The fly’s small size poses the main challenge in performing physiology under conditions that permit behavior. In most in vivo Drosophila physiology experiments, flies are fixed in positions that prevent natural movement of their legs and wings. Our modified holder allows walking behavior under visual stimulation (Supplementary Movie 1). The holder also permits physiology experiments with comfortable access to the brain for dissection, and imaging under a water-immersion objective. A 0.001-inch thick stainless steel shim fly holder separates the dorsal side of the head, the neck and a part of the thorax from the rest of the fly. An opening that accommodates parts of the fly’s head and thorax is cut into the shim using a laser mill (Supplementary Fig. 1 and 2a). The fly holder is then glued with epoxy into a 3D-printer-constructed photopolymer resin chamber that forms the bottom of the liquid chamber, which provides a fluid volume for a water-immersion objective (Fig. 1a). The fly is mounted in the holder in a manner similar to that used in many tethered fly behavioral experiments28 (Supplementary Fig. 2b, see Online Methods). During dissection, we remove the cuticle and some of the fat tissue preventing optical access to the LPTCs.

Figure 1
Setup for two-photon imaging from the brain of head-fixed flies walking on a ball

Fly-on-a-ball setup

The fly chamber is placed inside a larger setup that allows the fly to stand on a small air-supported ball (Fig. 1b, Supplementary Fig. 2c, d). We used two cameras to watch the fly and position it centrally on the ball with micromanipulators. As a visual aid we used stills from high-speed video recordings of flies walking freely in a “ballscape” (Supplementary Fig. 2e). Behavioral experiments with Drosophila walking on an air-supported Styrofoam ball date back almost four decades29, 30. For our experiments we used a custom-made polyurethane foam ball (construction described in Online Methods) that had low inertia, a homogeneous distribution of mass, texture that allowed our sensors to detect small movements (see below) and a surface that flies walked smoothly on.

High-resolution ball tracker

The ball’s movements are tracked at high temporal resolution using a system based on a mass-produced sensor chip (ADNS-6090, Avago Technologies, San Jose, CA) that is commonly used to perform optical flow measurement in optical computer mouse devices. The sensor has been integrated into a custom-designed circuit that streams ball velocity data to a computer at 4 kHz (details provided in Online Methods). Such a real-time readout makes the tracker suitable for future closed loop experiments.

Optical mouse sensors have been used with success for larger insects31, but the small size of our ball limits how close to it we can place the sensors. We thus used lenses to project the images of small regions of the ball close to the equator onto two sensors placed 90 degrees apart from each other and behind the fly. Each camera provides local X/Y velocity information (Fig. 2a), but both together allow all velocity components of the ball to be tracked. The transformation from local displacements of an approximately flat patch of the ball, as measured by the camera sensors, to a global rotation of the ball can be made accurately because the high rate of motion measurements ensures only small displacements are captured. This allows us to make implicit use of the small angle approximation.

Figure 2
High-precision ball tracking system allows online measurement of fly’s virtual trajectory

It is straightforward to convert the ball velocities into rotational, forward and sideslip velocities for the fly (Fig. 2b-d and Online Methods). We can then plot trajectories that the fly would create if it were walking on flat ground (Fig. 2e-h, Online Methods and Supplementary Movies 2 and 3), with the limitation that the high local curvature of the ball we use makes strict equivalence impossible. Subtle biases in positioning of the fly on the ball are manifested as biases in spontaneous walking in one direction or the other (e.g., Fig. 2f). We can partially correct for these by repositioning the fly but for many tasks of interest, we use relative metrics (left versus right comparisons) that minimize these biases.

Visual stimulation of the fly

We used a modular LED arena to present visual stimuli to the fly32. To prevent light emitted by the display reaching the photomultiplier tubes of the microscope, we employed two sets of filters (Online Methods). The first set of filters is placed in front of the LED panels, while a bandpass filter is placed before the PMTs. Remaining bleed-through contributes a constant background (Supplementary Fig. 3) that we subtract from the fluorescence of the neuronal region of interest (see Online Methods).

Optomotor behavior of the fly during two-photon imaging

Performing physiology experiments necessitates placing several constraints on the flies. Flies in our holders have some of their cuticle removed and their brains exposed. Their visual field is also somewhat reduced (see Online Methods). The fly’s ability to perform the behavior of interest under these conditions is a critical test of the usefulness of this preparation. We presented the fly with horizontally rotating vertical grating pattern moving at a temporal frequency (ft) of 1 Hz (see Online Methods), a stimulus that is known to evoke stereotypical compensatory turning responses in freely walking33 and tethered walking flies29. We used two different motion-stimulus protocols to characterize the optomotor behavior in our rig. The protocols differed only in duration, with each featuring epochs of movement in the preferred (PD) and null (ND) directions of the recorded HS-neuron (see Online Methods). Trials lasted either 35 or 75 s depending on the protocol used, during which flies walked most of the time. Experiments lasted up to 4 hours. For analysis we rejected any trial in which the fly did not walk for more than 30% (mean percentage of rejected trials = 14%, number of imaged flies = 19, number of trials ranged from 5 to 100, Supplementary Fig. 4).

We defined an optomotor response index (O.I., see Online Methods) to quantify the optomotor response of the fly as the ratio between the difference of rotation velocities in PD and ND segments and the sum of the absolute value of rotation velocities in PD and ND segments. We ran several trials under dark and stationary stimulus conditions to test the motion-stimulus-dependence of the O.I. (Supplementary Fig. 5a, b). ). We present data from all individual flies tested. Flies 1–17 were presented with Protocol 1 and flies 18–29 were evaluated with Protocol 2 (see Online Methods). We found no difference in the behavior under the two different protocols (mean O.I. Protocol 1 = 0.48 ± 0.20, mean O.I. Protocol 2 = 0.45 ± 0.21, p = 0.6702, Mann-Whitney). We also compared the walking and optomotor performance of flies on the ball to flies allowed to walk freely in a visual arena. Freely walking flies show consistently higher forward velocities but lower rotational velocities (see Supplementary Fig. 6a-e and Online Methods), something that may be expected given that tethered flies walk on a curved surface. Since body turns are the dominant observable feature of orientation behavior, the high rotational velocities of tethered flies walking on the ball suggest that our system is well suited for studying fly navigation.

Most flies showed behavioral responses during imaging, switching from turning in one direction to the other as the stimulus direction changed (Fig. 3a-c, Supplementary Movies 2 and 3). Dissected flies showed optomotor responses that were comparable to non-dissected flies, as measured by O.I. (mean O.I. for non-dissected flies = 0.48 ± 0.19, mean O.I. for dissected flies = 0.46 ± 0.21, p = 0.74, Mann-Whitney, Fig. 3d). Moreover, in two flies we evaluated the optomotor behavior before and after dissection and found that their performance was not significantly different (fly 8: p= 0.93, fly 9: p= 0.41; Mann-Whitney). Thus, flies in our preparation can consistently turn in the direction of a motion stimulus, and the extent of their turning response in one direction versus the other is preserved in dissected, head-fixed configurations.

Figure 3
Optomotor behavior in tethered flies

Two-photon imaging of HS-neurons during optomotor behavior

To evaluate our preparation’s suitability for imaging neuronal activity during walking behavior, we chose to focus on the HS-neurons. There are three such neurons in each Drosophila optic lobe34, with receptive fields arranged along the dorsal-ventral axis (they are accordingly referred to as HS-North, HS-Equator and HS-South). Each neuron responds selectively to horizontal motion in its visual field and in its preferred direction, which is always the direction of expected optic flow for a forward-walking animal (so called progressive, or front-to-back, motion). Different experimental strategies have shown the involvement of these neurons in the optomotor responses of blowflies3537 and of Drosophila38. The HS-neurons have also been the subject of imaging39, 40 and electrophysiological26, 27, 41 studies in blowflies and, recently, in Drosophila23 as well, and their responses to motion stimuli have been thoroughly characterized.

We performed two-photon calcium imaging from HS-neurons in Drosophila. We expressed the genetically encoded calcium indicator GCaMP3.024 selectively in HS-neurons using the R27B03-Gal4 driver from the Rubin Gal4 collection.

We presented the fly with vertical stripes rotating horizontally with ft = 1 Hz, and recorded HS-neuron calcium transients in the soma (Supplementary Movie 4) and dendrites (Fig. 4a, b and Supplementary Movie 5) simultaneously with the fly’s behavioral responses. We chose to look at dendritic arbors because LPTC calcium transients are thought to be greater there than in axonal arbors40. HS-neurons responded to motion in their PD with slow increases in fluorescence signals, in agreement with results using synthetic calcium indicators in the blowfly39. Calcium transients decayed slowly back to baseline levels after the PD stimulus was removed. Slight decreases in fluorescence signals were observed during ND stimulation when recording from the soma, but these were difficult to detect in the dendrites where the levels of fluorescence were lower (data not shown). The fly’s turning response to motion stimuli in the preferred direction of the recorded HS-neuron lagged behind the calcium responses. Fig. 4b-e (see also Supplementary Movie 4) shows behavioral traces recorded simultaneously with dendritic calcium transients. Direct correlations between the PD phase of fluorescence signals with behavioral responses revealed a mean lag of 4.37 ± 1.65 s for the turning responses relative to dendritic calcium transients as measured by significant deviations from baseline (see Online Methods). In all flies, we observe high correlations for most trials, as shown in Fig. 4f-h (see also Supplementary Information). Our results are consistent with the involvement of HS-neurons in the fly’s optomotor response25, 35, 36.

Figure 4
Optical imaging of dendrites of a motion-sensitive neuron during tethered walking

Fluorescence changes during walking and motion artifacts

A key concern when monitoring HS-neuron responses during walking is the possibility of the observed changes resulting from motion artifacts rather than neural activity. We verified our results using flies expressing GFP (Supplementary Fig. 5c). This allowed us to use activity-insensitive protein to monitor fluorescence changes due to any brain motion. We found that changes in fluorescence induced by brain motion artifacts cannot explain the fluorescent transients observed during visual stimulation.

We minimized brain movement by fixing the proboscis, and removing muscles that are known to cause brain motion10. This was sufficient to largely eliminate central brain motion, but additional muscles near the optic lobes appear to move the lateral parts of the brain, often during visual stimulation42 and these prevented complete brain stabilization. Many different algorithms have been proposed for motion compensation, but we found that translational compensation43 sufficed in our experiments, which typically featured single, spatially localized regions of interest. If motion appeared to be out-of-plane or to have shear that made analysis difficult, we did not use the data.


For spiking neurons in the fly, the correlation between spiking activity and genetically encoded calcium indicator signal can be problematic10, 44. Thus, results obtained with these indicators need to be interpreted with some caution. Importantly, the absence of a fluorescence signal does not necessarily imply absence of neural activity. In the blowfly, calcium dynamics of HS-neurons have been well-characterized using synthetic indicators which accurately track calcium dynamics40. Such experiments suggest that voltage-dependent channels contribute to the observed signals. Calcium dynamics are likely to be similar in Drosophila, but this has not yet been shown. Despite such complexities, two-photon imaging with genetically encoded calcium indicators offer the vital advantage of cell-specificity and high spatial resolution, providing a less invasive means of monitoring neural processing in arbors distant from the soma. Although electrophysiological techniques are irreplaceable for answering certain classes of questions, imaging provides the opportunity to monitor neuronal signals within different compartments of neurons and address questions related to single-cell signal processing. In addition, long-term electrophysiological recordings are difficult to achieve in small neurons deep inside the brain, something that two-photon imaging enables with high spatial resolution. Imaging also enables recording from populations of neurons and multiple dendritic arbors, something that is likely to be important for understanding neural circuit function. Continuing improvements in the development of genetically encoded indicators suggest that imaging will offer an increasingly powerful approach to investigating neural circuit dynamics in Drosophila in the future.

Flies display a wide range of behaviors while walking, many of which are significantly under-studied. Our setup allows both neural activity and the fly’s movements to be monitored at a high temporal resolution, with flies demonstrating robust optomotor behavior for several hours. The strong optomotor performance we see in flies on the rig suggests that we should also be able to reproduce more complex behaviors under the two-photon microscope. For example, both open- and closed-loop physiological experiments, with Drosophila performing adaptive behaviors in a precisely controlled sensory environment, now appear feasible. An ever-expanding set of tools allows genetically encoded sensors, activators, and repressors of neural activity to be expressed in selected subsets of neurons across the entire fly brain, and these targeted manipulations can be reliably reproduced across experimental animals. Going forward, the combination of such tools with targeted physiological recordings in behaving flies during both walking and flying15 (J. Seelig, M. Reiser and V. Jayaraman, unpub. data) should enable systematic, multi-scale investigations into questions about sensorimotor processing and learning and memory that are at present difficult to address mechanistically in other organisms.


Fly stocks

Flies were reared on standard cornmeal agar under a 12-hr light/12-hr dark cycle at 25° C. All experiments were performed on adult female flies, 2–4 days post-eclosion. Stocks were generously provided as follows: R27B03-Gal4 (Gerry Rubin, Aljoscha Nern), UAS-GCaMP3.0 (Loren Looger, Julie Simpson). Line R27B03 was constructed by the methods described in Pfeiffer et al. 200845 and identified as driving expression in the HS-neurons by A. Nern (unpublished).

Fly holder

The details of the holder geometry are shown in Supplementary Figs. 1 and 2a. The lower side of the fly holder is painted black using a metal staining opaque paint (Dykem opaque staining, ITW Dymon, KS) to avoid reflections of the visual stimulus on the shim surface that could affect the fly’s behavioral responses. This holder is robust and reusable.

Fly preparation and positioning on the ball

A female fly was anesthetized on ice and transferred onto a cold plate. We fixed the extended proboscis of the fly with a wax mixture (1:1 molten bee wax and colophony, Sigma Aldrich 60895) to minimize motion of the brain.

Under a dissection microscope we glued a pin to the anterior third of the fly’s thorax at a 45–60° angle, and inserted the pin into a mount attached to a three-axis micromanipulator to position the fly’s head and thorax in the holder. This was done above a cold stage to minimize fly movement. The head of the fly was bent forward by about 70–80° to give access to its posterior surface, and glued to the holder with UV-activated glue (Fotoplast Gel, Dreve, part number 44691). The glue was spread along the head using a pulled glass capillary with a small glass ball of about 40 μm diameter at its end. The glue was cured after each step using UV light (LED-100 UV portable, Electro-lite Corp) for about 20 s. After gluing the head, the fly was lowered slightly using the micromanipulator and moved backwards to relax neck tension and give good optical access to the dorsal part of the head and the LPTCs (Supplementary Fig. 2b). Any uncured glue at the surface was removed using a paper tissue and extensive rinsing with saline.

Under saline solution46 with 2mM Ca2+, we used sharpened #5 forceps to carefully remove the cuticle and some of the fat tissue preventing optical access to the LPTCs (see Supplementary Fig. 2b). Calcium signals can easily be lost if the neural processes are damaged during the dissection. We also removed the muscle, M1610, to prevent brain motion. The procedure lasted about 40 minutes. Most flies that were fixed in the holder did not immediately show walking behavior after positioning on the ball. Consistent walking behavior (e.g., as shown in Supplementary Movie 1) developed soon after the fly adapted to the ball. The adaptation is mostly due to the positioning of the fly in the holder. If flies are adapted to the ball they quickly begin walking behavior after the dissection and can maintain it for up to 4 hours afterwards (e.g., see Supplementary Fig. 7).

Treadmill ball

Previous Drosophila walking experiments on an air-supported ball have used a Styrofoam ball with a diameter of 7–9 mm and a weight of 10 mg47,30. When testing a Styrofoam ball with these specifications we noticed that flies easily lifted the ball. We used a ball of 40 mg (6 mm diameter) manufactured out of polyurethane foam (Last-A-Foam, FR7120, General Plastics Manufacturing Company) using a bowl shaped file with an inner diameter of 6 mm (Supplementary Fig. 8a). The edge of the file is sharp and the radial surface is textured using electrical discharge machining (EDM). This results in a surface texture similar to a nail file. With the ball file inserted into a hand-held drill, a piece of polyurethane foam was slowly rotated against the ball file until it became a sphere with a diameter of 6 mm. The ball can be coated with polyurethane spray paint to prevent small dust particles from coming off the ball.

Ball holder, flow meter

The ball floats on a stream of air30. The ball holder has a hemispherical bowl for the ball, shown schematically in Supplementary Fig. 8b. The bowl is lightly smoothed using a glass bead abrasion machine. The airflow was adjusted using a flowmeter (correlated flowmeter, max. flow rate: 825 mL/min, Cole-Parmer, EW-3227-16).

High-resolution ball tracker

To track the movement of the air-supported ball, we developed a custom high-speed “optical flow camera” based on a commercially available motion sensing chip (Avago Technologies ADNS-6090). The ADNS-6090 measures optical flow based on sequential correlations of 30×30 pixel images, with a maximum frame rate of 7.2 kHz. The ADNS-6090 can acquire snapshot video frames of its visual field and stream the pixel data at video rates (20 Hz). Our camera system consists of three discrete units: Two cubical camera enclosures with c-mount lens threads, and a single MCU base unit to which the cameras are connected via 10 wire ribbon cables (Supplementary Fig. 9).

Tracker: Microcontroller core, signal conditioning, signal I/O, and power

The interface between the ADNS-6090 and the PC was mediated by a deterministic microcontroller with a 20 MHz quartz oscillator. The controller responds to commands from the PC user, acquires data at a fixed sample rate, and conditions data for return to the PC or to the real-time interface.

The Atmel ATMega644p is at the core of our system. Firmware was developed for the Atmel microcontroller in the CodeVisionAVR C development environment and programmed to the device via a USB in-system programmer (Atmel AVR ISP mkII).

The MCU was driven at 5 V, provided by the USB data cable, for TTL logic level compatibility through the real-time interface. Conversion to 3.3 V logic for communication with the ADNS sensor chip was accomplished with non-inverting precision Schmitt-triggers. The MCU communicates with the ADNS-6090 via a 6-line serial interface. This interface operates at 3.3 V, and is clocked in a custom serial “bit-banging” fashion in order to send identical data to both chips while reading responses from the cameras on separate parallel lines. The bit stream can be paused and continued during operation.

Serial port communication with a PC is accomplished via a UART to USB converter (FTDI FT232BL). In our implementation, the serial interface operates with a data rate of 1Mbit/sec. An analog representation of the motion signals (accumulated over a user-selectable fixed time interval) was generated on 4 external lines for each of the four principal axis velocities during operation. Four channels of analog output are provided by a 12-bit parallel 4-channel digital to analog converter. This parallel addressed device allows for simultaneous latching of output values to prevent sample phase lag across output channels.

Tracker: Firmware state machine and data packet format

The majority of the firmware code for the MCU consists of a user interface state machine that responds to multiple byte commands from the PC user. Fixed byte commands control the state of the system in either “Idle,” “Video Streaming,” or ”Motion Data Streaming” modes. Other commands allow for a communications bridge between the PC user and the internal configuration and status registers of the ADNS-6090.

Data streaming to a PC is timed by a dedicated interrupt service routine driven by the system quartz oscillator signal. During the data read from the cameras, the MCU services UART transmit interrupts so as to deliver data to the PC user while concurrently acquiring new data from the ADNS-6090 chips in an interleaved fashion.

The serial data stream consists of packets containing a header byte, a counter byte that loops over the 0–255 range, and a programmable number of bytes including X/Y velocity values from each camera or combined pitch/roll/yaw/blank values (4 bytes), camera surface quality values (2 bytes), and 16-bit shutter speed values (4 bytes). The overall system sample rate is primarily limited by the time to read values from the ADNS camera chips and may be increased by reducing the data packet size.

Tracker: Camera housing, mounting frame, lenses, & illumination

The ADNS sensor is delivered with a bushing that is designed to direct light onto the chip from an integrated illumination source at a prescribed angle to the package in typical optical mouse applications. The bushing may be removed by releasing a set of plastic tabs at either end of the long axis of the package.

The plastic frame of the chip is soldered in place so as to be flush against the back surface of a circuit board (Supplementary Fig. 10a) mounted inside a custom anodized aluminum frame (Supplementary Fig. 10b). We visualized the moving surface through a 25 mm CCTV lens, a 2x lens extender, and a 1 inch extension tube.

Tracker: Calibration and optical alignment of the tracking system

To align the tracking cameras we used a cubical target that fits into the air support stand. We calibrated the tracking system and tested the linearity of the motion measurement by directly controlling the rotational velocity of the ball. The ball was attached to a servo motor (Compumotor SM161AE-NGSN, controlled by a Gemini GV Servo Drive, Parker Motion Control Systems, Rohnert Park, CA), which rotated at constant velocities for different durations. We derived a velocity calibration factor by comparing the velocities measured with the tracking system to known (command) ball velocities (Supplementary Fig. 11a). The calibration was well fit by a linear regression, with a coefficient of regression of 0.99 (clockwise rotations, n = 10; counterclockwise rotations, n=10). Moreover, the calibration factor was constant across all tested velocities. We examined the precision of the system by testing its performance during movement onsets and stops. The tracker responded reliably across all velocities tested with a tick for every 80 μms at the magnification used (Supplementary Fig. 11b). Further, simultaneous movement tracking with two cameras gave identical results in all trials (median difference across different displacements = 0, range form −1 to 1 arbitrary units, n = 40, Supplementary Fig. 11c).

Tracking performance depends on shutter speed and surface quality, which in turn depend on illumination conditions. We used 850-nm collimated IR LEDs with flexible arms (SLFA-850-12-2-SA-110, Illumination Control, Inc.) illuminating the ball from a distance of 1–2 cm roughly parallel to the optical axis of the tracking cameras without obstructing the field of view to achieve the highest surface quality and shutter speeds (see Supplementary Fig. 12). We ensured the consistency of tracking conditions by recording the ball’s movement at a frame rate of 480 Hz at the beginning of each experiment using a third camera (camera 3 in Fig. 1b). This camera was placed directly behind the fly and had a similar field of view as the tracking cameras, with a resolution set to 100×100 pixels. We compared the ball’s trajectory as determined by the tracking system to that obtained by the extra camera using offline MATLAB image processing code based on subimage cross-correlations. We found a linear relationship between calibration factors computed from ball tracker output and camera-measured translation (R2 = 0.99 ± 0.004, see Supplementary Fig. 11d). Given the close agreement between X and Y calibration factors (6.6 ± 0.6 and 6.1 ± 0.6 respectively), we used the average of the two for the rotational calibration factor.

Tracker: Reconstruction of the fly’s walking trajectories

We used two tracking cameras (Camera1 and Camera2 in Fig. 2a) to acquire the ball’s three rotational degrees of freedom, roll, pitch, and yaw. The cameras were positioned at the equator of the ball at a distance of 8 to 10 cm, and at 135° and −135° in the azimuth, with 0° degrees corresponding to the fly’s body axis (in the ideal alignment condition, brown arrow in Fig. 2a, b). Both cameras tracked motion of the ball using their local view, measuring movement in the x (X1 and X2) and y (Y1 and Y2,) directions. We then extracted yaw (pure rotation of the fly, referred to as rotational velocity or velocity_rotation), pitch (velocity_forward) and roll (velocity_side) velocities as follows:


Ball movement compensates for the fly’s walking motion, and ball velocities therefore translate directly to virtual velocities of the fly. Thus:


We defined translational velocities as the square root of the sum of the squares of forward and side velocities. To reconstruct the fly’s virtual 2-dimensional trajectory we used both position and gaze. Briefly, for a coordinate system centered on the fly with a y-axis along the fly’s body axis at its first position (0,0,0), if the fly’s current coordinates on a virtual flat plane are (flyx, flyy, θ), its new position is:


Tracker: MATLAB software user interface

The MATLAB-based interface software provides two functions: control/calibration, and data streaming/logging. One component is a visualization tool that streams the visual fields of the cameras (2×30×30 = 1800 pixels) at a 20 Hz frame rate. The tracker data are either displayed in a 2D field as independent points or applied as rotational transformations to a 3D ball. The data path to and from the PC is mediated either via a virtual serial COM port or direct access to the FTDI D2xx C based driver library.

Visual display arena and shielding

We used a modular LED arena to present visual stimuli to the fly32. The light of the blue LED arena (Bright LED Electronics Corp., emission maximum at 465 nm) had to be filtered to avoid interference with fluorescence detection during two-photon imaging. The arena was covered with four layers of Kodak color filters (Kodak Wratten No 47B). However, filtering was not complete and the remaining fluorescent background due to bleed-through-induced intensity, which peaked at 450 nm (FWHM = 45 nm), was typically 4 ± 2.8% ΔF/F (with respect to baseline fluorescence during arena–off conditions) for a PMT gain of 0.405 V. This offset was (Supplementary Fig. 3) subtracted for each trial (see Data Analysis in Online Methods). Moreover, in our calcium signal analysis, we defined the baseline during the segment of a stationary (not-moving) pattern (see below). The maximal luminance of the visual arena with the filter was 0.85 cd/m2.

The semi-cylinder arena was constructed from 14 modular LED panel displays with a resolution of 16×56 pixels, with a height of 70 mm and a diameter of 123 mm. When the fly is positioned at the center, those dimensions span ~157° in azimuth and 45° in elevation with a maximum pixel subtense of 2.8°, all with respect to the fly’s visual field. However, because the fly was on the ball, the subtended angle of elevation was reduced to ~40°. Horizontal moving patterns were generated with vertical bars of constant spatial period (λ = 22.4°) moving at 22.4 °/s so that the temporal frequency (the angular velocity of the pattern divided by the spatial period) was 1Hz. Patterns were generated in which 3 consecutive frames with intermediate intensity levels at the edges of the bars were used to define one pixel displacement. Large-field sine gratings of maximal contrast were presented to the fly in two protocols, which differed only in trial length. The first protocol consisted of a 5-s stationary pattern segment after which the pattern moved in the preferred direction (PD) of the neuron for 10 s. Following PD stimulation, another 5-second stationary pattern segment preceded motion of the pattern in the anti-preferred or null direction (ND) of the neuron for 10 s. The trial ended with 5 s of the stationary pattern. In the second protocol both the stationary and moving segments lasted 15 s. Thus, trials run with Protocol 1 lasted 35 s, whereas trials run with Protocol 2 lasted 75 s.

Free walking behavior

Flies walked on a flat, round platform with a diameter of 95 mm surrounded by a cylindrical arena (360° in azimuth) that was constructed from panels identical to those used for tethered walking. However, the LED light was not filtered, which resulted in a slight green shift of the stimulus light and many times greater stimulus intensity. The walking platform was actively maintained at the same temperature as was used for the tethered experiments (21 °C). The flies were enclosed by a heated metal ring with a height of 3.8 mm that supported a glass plate coated with Sigmacote (Sigma-Aldrich; arena design: T. Ofstad & M. Reiser, unpublished). We placed three 2–4-day old flies at a time on the platform, and presented stationary, clockwise and counterclockwise stimulation with the same pattern used in the tethered walking experiments. Each stimulus condition lasted 15 s and the stimulus sequence was repeated for 20 minutes. We tracked the positions of walking flies at 15 fps with a camera (Basler 602f) from above. We obtained walking trajectories for each fly using Ctrax software48, and calculated the translational and rotational velocities based on the distance moved between subsequent frames (75 ms). For averaging, we excluded parts where the fly was stationary (< 1 mm/s translational velocity). Velocities of tethered flies were calculated as the change in position during 75 ms, and were smoothed using Savitzky-Golay filtering with a span of 150 ms.

Two-photon imaging

We imaged on a custom-built two-photon microscope using ScanImage 3.6 software49 and Olympus water immersion objectives (LUMPlanFl/IR, 60×, N.A. 0.9 and LUMPlanFl/IR, 40x, N.A. 0.8). A mode-locked Ti:Sapphire Chameleon Ultra II laser (Coherent, Santa Clara, CA) tuned to 920–930 nm was used as the excitation source. Fluorescence was collected using photomultiplier tubes (Hamamatsu, Hamamatsu City, Japan) after bandpass filtering using a BG22 emission filter (Chroma Technologies, Brattleboro, VT) and either an HQ615/70–2p filter (Chroma Technologies, Nrattleboro, VT) or FF01-680/SP-25 filter (Semrock). An additional filter was used to minimize bleed through of arena light (FF01-542/50–25, Semrock). Images were acquired in framescan mode (4–16Hz). We noticed that using laser intensity much beyond 20 mW (measured at the back aperture) produced behavioral responses in flies (presumably due to heating50), and subsequently restricted the laser intensity to below 15 mW.

We only imaged the left half of the fly brain. Therefore, data presented as HS always refers to the left HS neuron, for which PD corresponds to rotations in the counterclockwise direction.

Data analysis: Two-photon imaging

Image processing was performed using custom code written and run in MATLAB.

To correct motion artifacts during behavior, we implemented image registration of the raw image sequence by translational-compensation-based discrete Fourier analysis (efficient subpixel registration43). In most cases, we needed only minimal motion correction (see Supplementary Fig. 13). Regions of interest were selected manually. Peak responses were calculated as the difference between the mean of last second within the PD segment and the mean of the last second within the ND segment.

Data analysis: Optomotor behavior

We defined an optomotor response index to quantify the optomotor response of the fly as follows:


with Vcw representing rotational velocity signals obtained when the pattern moved clockwise. Similarly Vccw represents rotational velocity signals when the pattern moved counter-clockwise. When the fly “rotates” counterclockwise (i.e., when the ball rotates clockwise), the animal’s rotational velocity signals are positive. Conversely, when the fly “rotates” clockwise (i.e. the ball rotates counterclockwise), the rotational velocity signals are negative. The index ranges from 1 (pure optomotor response) to −1 (pure counter-optomotor response).

Data analysis: Correlations between neuronal and behavioral responses

After selecting trials in which flies showed positive O.I., cross-correlations were computed between behavioral responses (rotations) and fluorescence transients during PD stimulation. If zero-lag correlations were found to be negative, as was only rarely the case, we show cross-covariance minima in Fig. 4g (red trials, numbers of trials in Supplementary Information). Otherwise, we took the positive peak of cross-covariances. For computing lags, only trials showing positive cross-covariances were used. Lags were computed across trials and flies as the delay between the measured onset of fluorescence response (3 s.d.s greater than baseline) and the onset of behavioral response (angular rotation 3 s.d.s greater than baseline in the direction of motion stimulus). For behavioral responses, we numerically corrected any baseline bias (caused by the fly favoring rotation towards one side over another before a stimulus is presented due to minor imbalances in positioning). We first calculated a bias slope over the entire baseline period across trials, and then used it to compute linear corrections for the entire trace.

Supplementary Material


Supplementary Movie M1 Real-time movie shows multiple views of the fly walking in response to visual stimulation.

Supplementary Movie M2 Real-time movie shows fly-on-the-ball virtual 2D trajectory during 2-photon imaging trial in response to counterclockwise (blue) and then clockwise (red) global horizontal motion of vertical stripes (1 Hz spatial frequency). The frame rate is chosen to show fly’s movements in real time. Frame size in X: 30 mm; Y: 45 mm.

Supplementary Movie M3 Real-time movie shows a second example of fly-on-the-ball virtual 2D trajectory during 2-photon imaging trial in response to counterclockwise (blue) and then clockwise (red) global horizontal motion of vertical stripes (1 Hz spatial frequency). The frame rate is chosen to show fly’s movements in real time. Frame size in X: 35 mm; Y: 40 mm.

Supplementary Movie M4 Real-time movie shows (clockwise from top-left): GCaMP signal from R27B03-Gal4 HS-neuron soma (shown in false color, linear intensity scale, window size: X = 62 μm, Y = 67 μm); visual pattern presented to the fly (motion is first in the null direction for the HS-neuron, and then in the preferred direction); view of fly walking on ball from camera 3 (behind fly); traces of change in %ΔF/F (in green) and accumulated rotation (in black) as the motion stimuli are presented. Two-photon images are unfiltered (aside from xvid compression applied to entire movie) and not motion-corrected.

Supplementary Movie M5 Real-time movie shows (clockwise from top-left): GCaMP signal from R27B03-Gal4 HS-neuron dendrites (false color, linear intensity scale, window size: 43 μm); visual pattern presented to the fly (motion is first in the null direction for the HS-neuron, then in the preferred direction and this protocol is repeated); view of fly walking on ball from camera 3 (behind fly); traces of change in %ΔF/F (in green) and accumulated rotation (in black) as the motion stimuli are presented. Two-photon images are unfiltered (aside from xvid compression of the movie) and not motion- corrected.


We thank J. Simpson and S. Hampel for cloning GCaMPs into pMUH. pMUH was a generous gift from B. Pfeiffer and G. Rubin. R27B03-Gal4 was a generous gift of G. Rubin. For pilot experiments, DB331-Gal4 was kindly provided by D. Reiff and line 3A-Gal4 by L. Luo. We thank D. Hall and K. Hibbard for fly crossing and Janelia’s Fly Core and particularly G. Zhang for stock maintenance. We thank K. Svoboda for generous donations of equipment, and advice in setting up our two-photon microscopes, D. Flickinger, S. Bassin, T. Tabachnik, and C. Werner for contributions to the optical and mechanical design, and V. Iyer for new ScanImage features and support. We thank M. Ahrens for software contributions, and T. Ofstad and N. Kladt for generous assistance with the free-walking and calibration experiments respectively. We also received generous advice and support from others at Janelia, including members of the Svoboda lab. We thank P. Coen (Janelia Summer Undergraduate Scholar) for carrying out pilot experiments with the ball tracker. Support by the Howard Hughes Medical Institute.


Author contributions

Design of project: JS, EC, GL, MR, VJ. Behavior and imaging preparation: JS, with input from JO, EC, VJ. Mechanical setup: JS, EC, AD, JO, VJ. LED arena: MR, JS, EC. Ball tracker: GL with input from MR, VJ. Tracker calibration: EC, JS, MR, VJ. High-speed video experiments: VJ. Free walking behavior: JS. Behavior and physiology experiments: JS, EC. Data analysis: JS, EC, VJ. Fly crosses: EC. VJ, JS, EC, GL, and MR wrote the paper.

Competing interests statement

The authors declare no competing financial interests.


1. Vosshall LB. Into the mind of a fly. Nature. 2007;450:193–197. [PubMed]
2. Olsen SR, Wilson RI. Cracking neural circuits in a tiny brain: new approaches for understanding the neural circuitry of Drosophila. Trends Neurosci. 2008;31:512–520. [PMC free article] [PubMed]
3. Borst A. Drosophila’s view on insect vision. Curr Biol. 2009;19:R36–47. [PubMed]
4. Simpson JH. Mapping and manipulating neural circuits in the fly brain. Adv Genet. 2009;65:79–143. [PubMed]
5. Gouwens NW, Wilson RI. Signal propagation in Drosophila central neurons. J Neurosci. 2009;29:6239–6249. [PMC free article] [PubMed]
6. Peron SP, Krapp HG, Gabbiani F. Influence of electrotonic structure and synaptic mapping on the receptive field properties of a collision-detecting neuron. J Neurophysiol. 2007;97:159–177. [PMC free article] [PubMed]
7. Haag J, Borst A. Neural mechanism underlying complex receptive field properties of motion-sensitive interneurons. Nat Neurosci. 2004;7:628–634. [PubMed]
8. Denk W, Strickler JH, Webb WW. Two-photon laser scanning fluorescence microscopy. Science. 1990;248:73–76. [PubMed]
9. Wang JW, Wong AM, Flores J, Vosshall LB, Axel R. Two-photon calcium imaging reveals an odor-evoked map of activity in the fly brain. Cell. 2003;112:271–282. [PubMed]
10. Jayaraman V, Laurent G. Evaluating a genetically encoded optical sensor of neural activity using electrophysiology in intact adult fruit flies. Front Neural Circuits. 2007;1:3. [PMC free article] [PubMed]
11. Ng M, et al. Transmission of olfactory information between three populations of neurons in the antennal lobe of the fly. Neuron. 2002;36:463–474. [PubMed]
12. Churchland MM, Afshar A, Shenoy KV. A central source of movement variability. Neuron. 2006;52:1085–1096. [PMC free article] [PubMed]
13. Bohm H, Schildberger K, Huber F. Visual and Acoustic Course Control in the Cricket Gryllus-Bimaculatus. Journal of Experimental Biology. 1991;159:235–248.
14. Mason AC, Oshinsky ML, Hoy RR. Hyperacute directional hearing in a microscale auditory system. Nature. 2001;410:686–690. [PubMed]
15. Maimon G, Straw AD, Dickinson MH. Active flight increases the gain of visual motion processing in Drosophila. Nat Neurosci. 2010;13:393–399. [PubMed]
16. Evarts EV. Relation of pyramidal tract activity to force exerted during voluntary movement. J Neurophysiol. 1968;31:14–27. [PubMed]
17. Wurtz RH. Visual cortex neurons: response to stimuli during rapid eye movements. Science. 1968;162:1148–1150. [PubMed]
18. Ono T, Nakamura K, Nishijo H, Fukuda M. Hypothalamic neuron involvement in integration of reward, aversion, and cue signals. J Neurophysiol. 1986;56:63–79. [PubMed]
19. Dombeck DA, Khabbaz AN, Collman F, Adelman TL, Tank DW. Imaging large-scale neural activity with cellular resolution in awake, mobile mice. Neuron. 2007;56:43–57. [PMC free article] [PubMed]
20. Egelhaaf M, et al. Neural encoding of behaviourally relevant visual-motion information in the fly. Trends in Neurosciences. 2002;25:96–102. [PubMed]
21. Borst A, Haag J. Neural networks in the cockpit of the fly. J Comp Physiol A Neuroethol Sens Neural Behav Physiol. 2002;188:419–437. [PubMed]
22. Joesch M, Plett J, Borst A, Reiff DF. Response properties of motion-sensitive visual interneurons in the lobula plate of Drosophila melanogaster. Curr Biol. 2008;18:368–374. [PubMed]
23. Schnell B, et al. Processing of Horizontal Optic Flow in Three Visual Interneurons of the Drosophila Brain. J Neurophysiol. 2010 [PubMed]
24. Tian L, et al. Imaging neural activity in worms, flies and mice with improved GCaMP calcium indicators. Nat Methods. 2009;6:875–881. [PMC free article] [PubMed]
25. Hausen K, Wehrhahn C. Neural circuits mediating visual flight control in flies. I. Quantitative comparison of neural and behavioral response characteristics. J Neurosci. 1989;9:3828–3836. [PubMed]
26. Hausen K. Motion Sensitive Interneurons in the Optomotor System of the Fly .1. The Horizontal Cells - Structure and Signals. Biological Cybernetics. 1982;45:143–156.
27. Hausen K. Motion Sensitive Interneurons in the Optomotor System of the Fly .2. The Horizontal Cells - Receptive-Field Organization and Response Characteristics. Biological Cybernetics. 1982;46:67–79.
28. Lehmann FO, Dickinson MH. The changes in power requirements and muscle efficiency during elevated force production in the fruit fly Drosophila melanogaster. J Exp Biol. 1997;200:1133–1143. [PubMed]
29. Gotz KG, Wenking H. Visual control of locomotion in the walking fruitfly Drosophila. J Comp Physiol A Neuroethol Sens Neural Behav Physiol. 1973;85:235–266.
30. Buchner E. Elementary Movement Detectors in an Insect Visual-System. Biol Cybern. 1976;24:85–101.
31. Lott GK, Rosen MJ, Hoy RR. An inexpensive sub-millisecond system for walking measurements of small animals based on optical computer mouse technology. J Neurosci Meth. 2007;161:55–61. [PubMed]
32. Reiser MB, Dickinson MH. A modular display system for insect behavioral neuroscience. J Neurosci Methods. 2008;167:127–139. [PubMed]
33. Strauss R, Schuster S, Gotz KG. Processing of artificial visual feedback in the walking fruit fly Drosophila melanogaster. J Exp Biol. 1997;200:1281–1296. [PubMed]
34. Scott EK, Raabe T, Luo L. Structure of the vertical and horizontal system neurons of the lobula plate in Drosophila. J Comp Neurol. 2002;454:470–481. [PubMed]
35. Hausen K, Wehrhahn C. Microsurgical Lesion of Horizontal Cells Changes Optomotor Yaw Responses in the Blowfly Calliphora-Erythrocephala. P Roy Soc Lond B Bio. 1983;219:211–216.
36. Geiger G, Nassel DR. Visual orientation behaviour of flies after selective laser beam ablation of interneurones. Nature. 1981;293:398–399. [PubMed]
37. Blondeau J. Electrically Evoked Course Control in the Fly Calliphora-Erythrocephala. Journal of Experimental Biology. 1981;92:143–153.
38. Heisenberg M, Wonneberger R, Wolf R. Optomotor-Blind - Drosophila Mutant of Lobula Plate Giant Neurons. J Comp Physiol. 1978;124:287–296.
39. Durr V, Egelhaaf M. In vivo calcium accumulation in presynaptic and postsynaptic dendrites of visual interneurons. Journal of Neurophysiology. 1999;82:3327–3338. [PubMed]
40. Haag J, Borst A. Spatial distribution and characteristics of voltage-gated calcium signals within visual interneurons. J Neurophysiol. 2000;83:1039–1051. [PubMed]
41. Haag J, Borst A. Active membrane properties and signal encoding in graded potential neurons. Journal of Neuroscience. 1998;18:7972–7986. [PubMed]
42. Strausfeld NJ. Chapter 6: The Head-Neck System of the Blowfly Calliphora. Oxford University Press; 1992.
43. Guizar-Sicairos M, Thurman ST, Fienup JR. Efficient subpixel image registration algorithms. Opt Lett. 2008;33:156–158. [PubMed]
44. Reiff DF, et al. In vivo performance of genetically encoded indicators of neural activity in flies. J Neurosci. 2005;25:4766–4778. [PMC free article] [PubMed]
45. Pfeiffer BD, et al. Tools for neuroanatomy and neurogenetics in Drosophila. Proc Natl Acad Sci U S A. 2008;105:9715–9720. [PubMed]
46. Olsen SR, Bhandawat V, Wilson RI. Excitatory interactions between olfactory processing channels in the Drosophila antennal lobe. Neuron. 2007;54:89–103. [PMC free article] [PubMed]
47. Bausenwein B, Muller NR, Heisenberg M. Behavior-Dependent Activity Labeling in the Central Complex, of Drosophila during Controlled Visual-Stimulation. J Comp Neurol. 1994;340:255–268. [PubMed]
48. Branson K, Robie AA, Bender J, Perona P, Dickinson MH. High-throughput ethomics in large groups of Drosophila. Nat Methods. 2009;6:451–457. [PMC free article] [PubMed]
49. Pologruto TA, Sabatini BL, Svoboda K. ScanImage: flexible software for operating laser scanning microscopes. Biomed Eng Online. 2003;2:13. [PMC free article] [PubMed]
50. Hopt A, Neher E. Highly nonlinear photodamage in two-photon fluorescence microscopy. Biophys J. 2001;80:2029–2036. [PubMed]