Abstract
Neural circuits for behavior transform sensory inputs into motor outputs in patterns with strategic value. Determining how neurons along a sensorimotor circuit contribute to this transformation is central to understanding behavior. To do this, a quantitative framework to describe behavioral dynamics is needed. Here, we built a high-throughput optogenetic system for Drosophila larva to quantify the sensorimotor transformations underlying navigational behavior. We express CsChrimson, a red-shifted variant of Channelrhodopsin, in specific chemosensory neurons, and expose large numbers of freely moving animals to random optogenetic activation patterns. We quantify their behavioral responses and use reverse correlation analysis to uncover the linear and static nonlinear components of navigation dynamics as functions of optogenetic activation patterns of specific sensory neurons. We find that linear-nonlinear (LN) models accurately predict navigational decision-making for different optogenetic activation waveforms. We use our method to establish the valence and dynamics of navigation driven by optogenetic activation of different combinations of bitter sensing gustatory neurons. Our method captures the dynamics of optogenetically-induced behavior in compact, quantitative transformations that can be used to characterize circuits for sensorimotor processing and their contribution to navigational decision-making.
Introduction
To successfully navigate their environments, animals transform sensory inputs into motor outputs in patterns that strategically orient themselves towards improving conditions. The navigational strategies of insect larvae represent a long-standing paradigm for studying the mechanisms of animal orientation (1, 2). The small size and simple nervous system of the Drosophila larva, combined with its powerful genetic toolbox and recent advances in optical neurophysiology and anatomical reconstruction of circuit structure and connectivity, opens the possibility of understanding the neural encoding of animal navigation from sensory inputs to motor outputs without gaps (3). To accomplish this a quantitative framework to describe navigation decision-making is needed. Such a framework can then be used to dissect the function of the neurons and circuits in charge of processing sensory information.
Drosophila larva navigation involves the regulation of transitions between two basic motor states, runs during which the animal moves forward using rhythmic peristaltic waves and turns during which the larva sweeps its head back and forth until it selects the direction of a new run (4-6) (Fig 1A). Attractive and repulsive responses can be estimated by the tendency of the larva to aggregate near or avoid an environmental stimulus (7). Attractive and repulsive responses can also be observed in the movement patterns of individual larvae (4, 8, 9). When the larva encounters improving conditions over time, it lowers the likelihood of ending each run with a turn, thereby lengthening runs in favorable directions. When the larva encounters improving conditions during each head sweep of a turn, it increases the likelihood of starting a new run, thereby starting more runs in favorable directions. Thus, subjecting the larva to an attractant tends to suppress transitions from runs to turns and stimulate transitions from turns to runs; subjecting the larva to a repellant has the opposite effects.
Much progress has been made in understanding the molecular and cellular organization of the chemosensory system of the Drosophila larva, but how specific chemosensory neurons relay information to guide navigational movements remains poorly understood. (7, 10-12). One challenge of studying chemotaxis is that it is difficult to provide sensory input to behaving animals with the flexibility, receptor-specificity, and precision needed to build computational models of chemosensory-guided navigation. The recent development of a red-shifted version of Channelrhodopsin, CsChrimson, which is activated at wavelengths that are invisible to the larva’s phototaxis system, now allows us to specifically manipulate the activity of neurons in behaving animals with reliability and reproducibility (13).
Here, we sought a mathematical characterization of the navigation dynamics evoked by optogenetic activation of different sets of neurons. We focus on the navigation driven by chemosensory inputs. Although the organization of the chemosensory periphery is well defined, the quantitative mapping from sensory activity to behavioral dynamics has not yet been determined. To do this, we engineered a high throughput experimental setup capable of recording the run and turn movements of freely moving larvae subjected to defined optogenetic activation of selected chemosensory neurons. By measuring large numbers of animals responding to defined random patterns of optogenetic stimulation, we were able to collect enough data to use reverse-correlation analysis to connect optogenetic activation patterns of sensory neurons with motor patterns (14). We used this information to build linear-nonlinear (LN) models that accurately predict behavioral dynamics in response to diverse patterns of optogenetic activation of sensory neurons (15).
We used our method to study how the optogenetic activation of olfactory receptor neurons (ORNs) and different sets of gustatory receptor neurons (GRNs) map to navigational movements. Analysis of gustatory neurons allowed us to investigate the navigational responses evoked by individual GRNs and their combinations. We find that compact LN models that connect optogenetic activation to behavioral responses are nonetheless sufficient to describe or predict navigational behavior, and should facilitate future studies to elucidate the circuit mechanisms that shape sensorimotor transformations.
Results
Reverse-correlation analysis of navigation dynamics
We can characterize the navigation strategy of the Drosophila larva by identifying the mathematical functions that describe transitions between two basic motor states: running and turning (Fig 1A). We sought these functions (fr→t, ft→r) for defined patterns of chemosensory stimulation delivered via optogenetics. We used transgenic animals that express the red-shifted Channelrhodopsin CsChrimson in selected olfactory and gustatory neurons using the UAS-Gal4 system (16). In our setup, we followed the movements of large numbers of late second instar larvae navigating the surface of a 22 cm × 22 cm agar plate under dark-field illumination provided by infrared LEDs (Fig 1B). The entire plate was subjected to spatially uniform optogenetic illumination from above using a matrix of 625 nm red LEDs, a wavelength chosen to activate CsChrimson while invisible to the larva’s photosensory system (13, 17). We tuned our light intensity (1.9 W/m2) to a level where negligible behavioral response is detected in wild type animals crossed with UAS-CsChrimson fed with 0.5mM all-trans-retinal. We made sure that this light intensity is strong enough to activate CsChrimson by testing it with a well-studied motor neuron line (Fig 1-figure Supplement 1).
To obtain direct evidence that optogenetic illumination in our behavioral setup activates sensory neurons, we used electrophysiology. We made extracellular recordings of the dorsal organ of individual larvae expressing CsChrimson in specific olfactory receptor neurons, and recorded the responses to red light activation pulses of 0.2, 0.5 and 1 second of the same intensity used in the behavioral experiments. We found that optogenetic activation of the ORN expressing Or45a reliably and reproducibly induced spike trains during exposure to red light (Fig 1C). Similar results were obtained using larvae expressing CsChrimson in the ORN expressing Or42a (Fig 1D). These results confirm direct correspondence between ON/OFF pulses of CsChrimson activation and induced spiking in single sensory neurons.
To map the input-output relationships with optogenetic interrogation of chemosensory neurons, we used reverse-correlation methods viewing the whole animal as a transducer. We subjected larvae to random patterns of optogenetic stimulation, and collected the statistics of all behavioral responses exhibited by the freely moving larvae. We used the simplest white process for reverse-correlation, a Bernoulli process where we assigned -1 for lights OFF and +1 for lights ON, and calculated the mean stimulus history that preceded each run to turn or turn to run transition (Fig 1E, F). These event-triggered stimulus histories represent how the animal uses optogenetic activation patterns of specific neurons to regulate each motor state transition and are proportional to the linear filter components of fr→t and ft→r (see Materials and Methods and Supplemental Methods).
Linear filters of repellant and attractive responses
When freely crawling larvae encounter increasing chemoattractant concentrations during runs, they decrease the likelihood of initiating a turn. When they encounter increasing chemoattractant concentrations during the head sweep of a turn, they increase the likelihood of starting a new run. The Or42a receptor is activated by a number of volatile chemoattractants including ethyl butyrate and ethyl acetate (7, 8, 18). Genetically modified animals in which the Or42a expressing ORN is the only functional olfactory receptor neuron are capable of climbing olfactory gradients towards these attractants. These observations strongly suggest that the Or42a expressing ORN mediates attractant responses. To test our system, we subjected Or42a>CsChrimson larvae to random optogenetic stimulation. We found that run-to-turn transitions coincided with a decrease in the probability of optogenetic activation (Fig 2A, left), whereas turn-to-run transitions coincided with an increase (Fig 2A, right). These patterns are consistent with an attractive response to Or42a activation. Importantly, the full shape of the event-triggered stimulus histories informs us about how the temporal optogenetic activation patterns of Or42a regulate each type of navigational movement. Methods that measure the tendency of larvae to aggregate near chemoattractants or net movement up chemoattractant gradients provide information about the overall tendency to navigate but not about the discrete decision-making processes that drive navigation.
Random optogenetic activation of all the ORNs via expression of UAS-CsChrimson with the Orco olfactory-receptor-coreceptor driver (previously called Or83b) mediated an attractive response similar to the one shown with the Or42a driver alone (Fig 1E,F). This is consistent with most ORNs in the Drosophila larva being thought to mediate attractant responses (7, 19). One exception is the Or45a-expressing ORN, which has recently been shown to mediate an aversive response in an optogenetic setup; larvae that express Channelrhodopsin in Or45a-expressing neurons will avoid an illuminated region of an agar plate (20). A role for the Or45a-expressing neurons in repellency is also consistent with the observation that they are the only ORNs that detect octyl acetate, a chemical repellant (7, 21). We sought the linear filters of this olfactory repellant response in our setup by quantifying the movements of Or45a>CsChrimson larvae subjected to random optogenetic stimulation (Fig 2B). Run-to-turn transitions in Or45a>CsChrimson larvae coincided with an increase in the probability of optogenetic illumination and turn-to-run transitions coincided with a decrease, consistent with repellant behavior.
For comparison, we calculated event-triggered stimulus histories using larvae heterozygous for UAS-CsChrimson and with the same genetic background as our Gal4 lines (w1118 × UAS-CsChrimson) subjected to random illumination (Fig 2C). These control larvae were raised in the same conditions and fed the same food as larvae used for all other experiments (Materials and Methods). These larvae showed no correlations between the probability of illumination and motor state transitions. Their motor state transitions were random and spontaneous.
In our setup, we flag turn-to-run transitions by the resumption of peristaltic forward movement and run-to-turn transitions as the onset of head sweeping behavior. However, the decision to finish a run may begin at an earlier point, when the animal first begins to slow down. We measured the crawling speeds of larvae before flagged run-to-turn transitions, and found that runs decelerate ∼1s before the onset of head sweeping behavior (Fig 2A-C). For both repellant and attractants, an increase and decrease in the probability of optogenetic illumination, respectively, coincides with the beginning of run deceleration (Fig 2A, B). The average deceleration time was 1s for all experiments conducted in this study (Student’s t-test, p<0.01).
Linear-Nonlinear models of behavior
A satisfactory model of navigation should be able to predict behavioral responses to various stimulus waveforms. We asked whether we could use our measurements of event-triggered stimulus histories to build such a model. A simple and widely used formalism is the linear-nonlinear (LN) model. In LN models, the linear filter component is proportional to our measurement of the event-triggered stimulus history (15). First, the stimulus waveform is passed through this linear filter to make an initial prediction of the behavioral response. Linear estimates have common problems, such as taking negative values and failing to account for saturation. To correct these problems, the linear prediction is then scaled with a static nonlinear function. This static nonlinearity can be calculated by comparing a linear prediction with experimental measurements.
We used larvae with CsChrimson in Or45a expressing neurons to test an LN model in predicting behavior. We calculated the static nonlinearity for both run-to-turn and turn-to-run transitions by comparing linear predictions obtained with the event-triggered stimulus histories shown in Fig 2B with experimental measurements (Fig 3A). Next, we implemented the linear filter and static nonlinearity in an LN model (Fig 3B) to predict the behavioral response of these larvae to different inputs, using step increases in optogenetic illumination as well as defined trains of pulses of different widths. We found remarkably good agreement in these predictions to both stimulus types (Fig 3C). We note that the LN prediction begins to fail to account for the turn-to-run transitions at long times following a step increase in optogenetic illumination. Turns typically last <4 seconds, which limits the length of stimulus history that can be used in a linear filter, which thus puts a ∼4s upper bound on the length of stimulus response that can be predicted. Taken together, our results show that LN models governing stimulus-evoked transitions between motor states can be used to predict larval chemotaxis behavior with high accuracy (Fig. 3C). The LN model was also successful in predicting the behavior of Or42a-expressing neurons and other chemosensory neurons (Fig 3-figure supplement 1; Fig 3-figure supplement 2; detailed calculations are in Supplemental Methods).
Distinct temporal dynamics in optogenetically-induced chemotactic behavior
The dynamics of behavioral responses are shaped by the linear filter component of LN models while the static nonlinearity only provides saturation and instantaneous scaling. To test if optogenetic activation of different chemosensory neurons could produce behavioral responses with distinct dynamics we undertook a search for different linear filters measured by event-triggered stimulus histories using reverse-correlation.
The Gr21a receptor senses carbon dioxide, a powerful Drosophila repellant (9, 22). We measured the event-triggered stimulus histories of Gr21a>CsChrimson larvae subjected to random optogenetic stimulation. We found that run-to-turn transitions coincided with an increase in the probability of optogenetic illumination from baseline, whereas turn-to-run transitions coincided with a decrease (Fig 4A). These patterns are consistent with a repellant response. However, the linear filter associated with Gr21a for run-to-turn transition revealed important differences in shape and timing of stimulus history as compared with the filter for Or45a. The run-to-turn transition in both cases was preceded by a positive lobe in the probability of optogenetic activation lasting ∼2s. This positive lobe was itself preceded by a pronounced negative lobe lasting ∼1.5s for Gr21a but not for Or45a.
How do differences in the shape and timing of linear filters translate into behavioral responses with different dynamics? To explore this question, we compared the prediction and experimental measurement of stepwise activation of Or45a and Gr21a expressing neurons (Fig 4B). Biphasic linear filters – such as that associated with Gr21a and also seen in other sensory systems like the E. coli chemotactic response – contribute to adaptation following transient stimulation (23). A step increase in stimulation with repellants will cause a transient increase in the probability of run-to-turn transition. We predicted and confirmed differences in the adaptive return to baseline behavior for Gr21a and Or45a. The probability of run-to-turn transition returns to baseline faster in the case of Gr21a. Since each point represents a distribution of binary values (larvae transitioning from running to turning and larvae not transitioning), we used a z-test to identify regions where P(r→t) is significantly higher than baseline with p<0.05. We found that P(r→t) of Gr21a larvae reach values significantly higher than baseline at least 0.5s earlier than Or45a larvae. In addition, Or45a larvae stay at elevated values of P(r→t) for at least 0.75s longer than Gr21a larvae (Fig 4-figure supplement 1A).
We also asked whether differences in behavioral dynamics caused by different linear filters might be found in attractant responses. Gr2a is expressed in the A1 and A2 GRNs of the dorsal organ as well as in two unidentified neurons in the terminal organ (12). The role of the Gr2a receptor is not known, but it is part of the subfamily of Gr68a which has been identified as a pheromone receptor in the adult fly (24). We calculated the event-triggered stimulus histories of Gr2a>CsChrimson larvae, and found that run-to-turn transitions coincided with a decrease in optogenetic activation, consistent with an attractant response (Fig 4C). Interestingly, the linear filter associated with Gr2a was distinct from that of Or42a. In Or42a>CsChrimson, the run-to-turn transition was preceded by a single negative lobe lasting ∼2s. In Gr2a>CsChrimson larvae, the negative lobe was itself preceded by a positive lobe. As we did for repellants (Fig 4B), we asked whether the response dynamics to step decrease in optogenetic stimulation were distinct. We predicted and confirmed differences in behavioral dynamics. The most noticeable feature is that Or42a larvae reach different steady states of P(r→t) for lights ON or OFF; this creates differences in step response dynamics. We conducted a z-test to identify regions where P(r→t) is significantly higher than baseline with p<0.05. Since the steady state P(r→t) for Or42a larvae is different for lights ON and lights OFF, we conducted the z-test with both values (Fig 4-figure supplement 1B). Because Or42a larvae start at a lower P(r→t), they take at least 1.75s longer than Gr2a larvae for P(r→t) to become significantly higher than the lights OFF steady-state P(r→t). Comparison with the steady state P(r→t) for lights ON confirms that the steady state P(r→t) for lights OFF is significantly higher with p<0.05 (Fig 4-figure supplement 1B).
We note that unlike the linear filters for run-to-turn transitions, the linear filters for turn-to-run transitions showed a similar shape for all Gal4 drivers that we used in this study. These filters only showed some variation in amplitude (Figs 1, 2, 4, 5).
Navigational responses from bitter-sensing GRNs
The molecular and cellular organization of the chemosensory system of the Drosophila larva is numerically simple. The 21 olfactory receptor neurons (ORNs) contained in the larval dorsal organ (DO) together express 25 members of the Or family of odorant receptors and the Orco coreceptor (11, 25). In contrast, 10 gustatory receptor neurons (GRNs) distributed in the dorsal organ and terminal organ – named A1, A2, B1, B2, and C1-C6 – together express 28 members of the Gr family of gustatory receptors. Whereas most ORNs express a single Or, GRNs can express multiple Grs and each Gr can be expressed in multiple GRNs (12). Thus, using larvae expressing CsChrimson under the control of different Grx-Gal4 drivers enabled us to assess the contribution of selected GRNs to behavior.
The C1 neuron expresses 17 receptors, some of which are found in other neurons (e.g., Gr32a which is also found in B2) and some of which are specific to C1 (e.g., Gr9a). Most Grs are thought to respond to repulsive bitter compounds because they express the bitter markers Gr33a and Gr66a (12), suggesting that C1 is a broadly tuned mediator of repellant responses. Consistent with this hypothesis, optogenetic activation of C1 with random stimuli using Gr9a>CsChrimson larvae evoked a weak repellant response where the run-to-turn transition coincided with a slight increase in the probability of optogenetic illumination (Fig. 5A) (this response was significantly different than the control with p<0.05, see Fig5-Supplementary Fig1A). Optogenetic activation of C1 together with B2 using Gr32a>CsChrimson larvae evoked a much stronger repellant response (Fig. 5B). Optogenetic activation of specifically the B2 neuron using Gr10>CsChrimson larvae evoked a repellant response (Fig. 5C) Optogenetic activation of C1 together with C4 using Gr39a.b>CsChrimson larvae generated a strong repellant response (Fig. 5D). One possibility is that co-activation of narrowly tuned GRNs that express fewer Grs potentiates the repellant response of the broadly tuned C1 GRN; however, this interpretation should be taken with caution since different Gal4 drivers may induce different spiking rates upon optogenetic activation with CsChrimson.
We found that optogenetic activation of the C2 neuron alone using Gr94a>CsChrimson larvae evoked a weak attractive response (Fig 5E) (this response was significantly different than the control with p<0.05, see Fig5-Supplementary Fig1B). This is surprising because the C2 neuron also expresses the bitter receptors Gr33a and Gr66a, which should drive repellant responses, although these receptors are also found in other neurons. One possibility is that the attractant response driven by C2 is inverted when additional gustatory neurons are recruited. This hypothesis is supported by our observation that co-activation of C1 and C2 using Gr39a.a>CsChrimson larvae exhibited a much stronger repellant response than activation of C1 alone (Fig. 5F). Co-activation of C1, C2, and C4 using Gr59d>CsChrimson larvae also exhibited a strong repellant response (Fig. 5G). The strongest repellant response was observed by co-activating C1-C4, B1, and B2 using Gr66a>CsChrimson larvae (Fig. 5H).
Discussion
A fundamental step towards understanding how animal navigation is encoded in neural circuits is the development of a quantitative framework that accurately describes behavioral dynamics. To take this step with the Drosophila larva, we combined optogenetics with high-resolution behavioral analysis and reverse-correlation techniques to build linear-nonlinear models that provide an accurate estimate of the decision-making processes that guide navigation during optogenetically induced chemotaxis.
Linear-nonlinear models separate time-dependencies and instantaneous scaling into two modules, the linear filter and static nonlinearity, respectively. We find that the LN model is capable of accounting for diverse dynamics across attractant and repellant responses in both the gustatory and olfactory systems. For example, LN models accurately predicted the differences in response speed and adaptation when different GRNs and ORNs were activated. One reason for the diversity of dynamics is that the Drosophila larva chemosensory system, in addition to encoding attractant and repellant responses, is also capable of shaping the dynamics of behavioral responses in ecologically important ways. For example, the priorities given to specific chemicals encountered in the environment might not only be measured in terms of their relative degrees of attraction or repulsion, but also in the speed of the behavioral response that they trigger or the speed of adaptation. We note that some of the observed differences in behavioral dynamics might be caused by using different transgenic lines and different Gal4 drivers with different potencies. It would thus be useful to confirm the differences in behavioral dynamics that are suggested by our optogenetic manipulations with direct stimulation of each GRN and ORN and quantitative behavioral analysis in defined environments using cell-specific odorants and tastants.
Navigational dynamics evoked by specific sets of gustatory neurons have remained elusive because of the lack of chemicals that are specific to individual GRNs. Our reverse-correlation analysis using optogenetic activation with CsChrimson allowed us to determine not only the valence (attraction or repulsion) of navigation mediated by different combinations of GRNs, but also the dynamics of the evoked behavior. Although little is known about the circuits downstream of the GRNs, our analysis of sensorimotor transformations serves as a reference to determine how these circuits organize navigational decision-making.
Although chemotactic navigation behavior involves just two motor states (running and turning), it is possible, in principle, to extend reverse-correlation analysis to a larger number of possible behavioral states. Vogelstein et al presented recently a study where they used optogenetic pulses to trigger different subsets of neurons throughout the larval brain (26, 27). They identified 29 statistically different behavioral states, likely because they were able to interrogate circuits for a much wider variety of larval behaviors than navigation. It would be useful to apply reverse-correlation methods such as ours to examine transitions between this rich set of behavioral states to identify how specific neurons mediate a broader range of behavioral decisions than navigation up or down stimulus gradients.
The wiring diagram of the Drosophila larva nervous system is likely to be the next whole animal connectome that will be reconstructed (28). Powerful genetic tools are making it possible to target specific neurons throughout the Drosophila nervous system with cellular resolution (27). The new availability of powerful optogenetic tools for activating and inactivating neurons, particularly red-shifted molecules that are outside the spectrum of Drosophila vision, are making it possible to pinpoint the role of specific neurons in overall behavior (13, 29). An essential step in building whole nervous system models of behavior that incorporate wiring and dynamics is computational modeling. Bringing together computational modeling of behavior with new tools for behavioral and physiological analysis, such as those described here, should open the door to a thorough understanding of behavioral circuits from sensory input to motor output in the small but surprisingly sophisticated nervous system of the Drosophila larva.
Materials and Methods
Drosophila stocks
All larvae were raised in the dark at 22 °C and fed yeast with 0.5 mM all-trans-retinal (ATR). All GrX-Gal4 lines were previously described (30). The UAS-CsChrimson flies were a gift of Vivek Jayaraman. Other lines were provided by the Bloomington Stock Center: Or42a-Gal4 (BL#9970), Or45a-Gal4 (BL#9975), Orco-Gal4 (BL#23909), Gr21a-Gal4 (BL#23890), Gr66a-Gal4 (BL#28801), and w1118 (BL#5905).
Behavioral assays
Male Gal4 flies were crossed to UAS-CsChrimson virgins in small cages (Genesee Scientific) where eggs were laid on grape juice plates. Larvae were thoroughly washed in water, and late second instar larvae were selected under a dissecting microscope. For spatial navigation assays, groups of 20-30 larvae were placed in the center of a ∼5 mm thick 22×22 cm agar (Fisher Scientific) plate and allowed to freely move for 20 minutes. Animals were recorded with a CCD Mightex camera with a long pass (740nm) infrared filter at 4Hz.
Light stimulation was produced with a custom built LED matrix assembled with SMD 5050 flexible LED strip lights of 12V DC and 625nm wavelength (LEDlightninghut.com) and controlled with an H bridge driver and custom code written for a LabJack U3 controller. Random light sequences were synchronized with the acquisition of images of the camera. Illumination was at 850nm wavelength with custom built LED bars. Technical considerations for assembly of the experimental setup are explained in the Supplementary Methods.
Electrophysiology
We followed previously described methods (11). In brief, action potentials of the olfactory receptor neurons (ORNs) were extracellularly recorded by placing a custom made tungsten recording electrode (with a piezo manipulator) through the cuticle into the dome of the dorsal organ of third instar larvae. The larva was placed on its ventrum on a metal rod and immobilized by wrapping Parafilm around the rod and the body, exposing only the very anterior part of the larva containing the domes of the dorsal organs. A reference electrode, a drawn out Borosilicate glass capillary filled with Ephrussi and Beadle solution, was previously inserted through the Parafilm into the larva’s body. Light stimulation was generated with an LED at 627nm (Luxeonstar) driven by a buckpuck (LUXdrive LEDdynamics) and synchronized via a photocoupler relay (Toshiba TLP597A) with the data acquisition system (Syntech IDAC-4). The electrophysiological optogenetics experiments were conducted in a completely dark room, and the intensity of the light stimulus at the location of the larva’s dorsal organ was set to 1.9 W/m2.
Data analysis
The image stacks recorded were processed using MAGAT analyzer and analyzed using custom code written in MATLAB (9). To produce the random stimulus a Bernoulli process was used. This process is wide-sense stationary, produces independent binary values (Lights ON or OFF) at every instant, and its autocorrelation function is the Dirac delta function. The linear transformations for r→t and t→r transitions were estimated by the event-triggered averages multiplied by the mean t→r or r→t rates respectively (31, 32). The convolution of the filters with the stimulus was computed numerically without fitting any function to the filter. The number of larvae used in the experiments of each figure can be found in the respective legends. Details about the calculations, model construction and analysis of behavior can be found in the Supplementary Methods.
Acknowledgements
We thank Vivek Jayaraman for sharing fly stocks, Ni Ji for comments on the manuscript, and Vivek Venkatachalam, Christopher Tabone, Renaud Bastien, Matthew Berck and Jess Kanwal for useful discussions. This work was supported by grants from the NIH to JC and to ADTS (1P01GM103770 and 8DP1GM105383-05).