regulatory basis of the transduction pathway underlying adaptive chemoreception in bacterial chemotaxis (Yi et al., 2000; Tu et al., 2008). For this motif, we assumed that the activity of the neuron had an excitatory effect on the intermediate variable u, which in turn has an inhibitory effect on the OSN activity. In a first approximation, the negative feedback was assumed to be linear. The difference between the IFF and IFB motifs lies in the production of the intermediate variable (u), which in the case of the IFB is proportional to the firing rate (y) and not the stimulus intensity (x). These considerations yielded the following system of ODEs:

$$ \frac{du}{dt} = \alpha_3 y - \alpha_2 u, $$

$$ \frac{dy}{dt} = \beta_1 \frac{x}{\beta_2 + x + \beta_3 u} - \beta_4 \frac{y^2}{y^2 + \theta^2} - \beta_5 y. \quad (3) $$

Using numerical simulations, we found that the IFB motif alone cannot account for the dynamics of the OSN activity. In contrast, we discovered that the combination of the IFF and IFB motifs leads to substantial improvements in the quality of the fit (Figure 4). For all simulations achieved in this work, the ODE equations were numerically integrated by the solver ode23s built in Matlab.

## Parameter fitting of the composite IFF+IFB and pure IFF models

To optimize the parameters of the model to the experimental data, a standard fitting procedure was applied. As outlined in Figure 4Bi, we considered three possible models: the motif IFF, the motif IFB, and a combination of the two motifs. The joint probability of the observations was maximized as a function of the internal parameters for the neural activity patterns elicited by a set of 6 linear ramps, 5 nonlinear ramps, (Figure 4—figure supplement 1) and a naturalistic stimulus (Figure 2D,E). For each stimulation protocol, the confidence interval of the OSN activity (PSTH) was used to achieve a robust fit of the free parameters of the model. This procedure was applied to each of the three models independently.

In the ODE systems presented in Figure 4Bii and Equations 2, 3, we observe that the time derivative of u can be multiplied by an arbitrary scaling factor reabsorbed by the fitting parameter $\beta_3$ in the time derivative of y. For this reason one is forced to fix one of the eight parameters to a constant value. For numerical convenience we chose to fix $\alpha_1 = 0.1$. To infer the actual value of this parameter, one would need to experimentally access the value of the intermediate variable u, whose molecular identity remains unknown. For the pure IFF model, the number of free parameters is therefore seven. In addition to these parameters, we considered the scaling of the firing rate y elicited by individual stimulation protocols via a multiplicative factor accounting for variability across experimental conditions (e.g., minute differences in the positions of the stimulation pipette).

The maximization of the likelihood function was achieved by means of the Nelder-Mead (NM) method (Nelder and Mead, 1965), which proved to be fast and reliable. The result of the NM optimization was then refined through a gradient search algorithm (Brun and Rademakers, 1997). For the dataset corresponding to the light stimulation, the fitting procedure led us to rule out the relevance of the IFB model alone with a probability of $\chi^2$ very close to zero. In contrast, the IFF was able to reproduce the experimental observation with good accuracy. On the other hand, in the case of the odor stimulation, we obtained a significant improvement of the model fit by adding an IFB component to the IFF motif (addition of the term $\alpha_3 y$ to the dynamics of u).

The fitted value of the composite IFF+IFB motif indicated that the IFB component was not negligible during the stimulation and accounted for about 30% of the final firing rate (Figure 4D). In contrast to the pure IFF model, variables u and y of the IFF+IFB model were entangled in the structure of the ODE resulting in a coupling that allowed us to fit the value of parameter $\alpha_1$. We also examined the effect of introducing additional terms in the denominator of the function defining y, such as the product $u \times y$. Besides the test of other circuit motifs, the introduction of additional free parameters represented a qualitative test against the possibility of over-fitting. The improvements in the fitting obtained in these cases were very marginal.

With regards to both light and odor stimulation protocols, the data comprised stimulation patterns on diverse timescales and with varying stimulus durations: 10 linear and nonlinear ramps lasting less than 25 s and one 'naturalistic' stimulus lasting more than 200 s. We found that the parameter set leading to a good fit during the first 30 s of the light or odor stimulation did not yield an accurate fit for longer durations. By fitting the activity at the beginning and the end of the naturalistic stimulation, we discovered that the discrepancy between both time ranges was mainly due to a change in the
threshold $\theta$ of the Hill term in the time derivative of y (Equation 2). We therefore allowed the threshold $\theta$ to change smoothly between the two different time ranges with the functional expression: $\theta' = \theta \times (\tau/t)^2$ for $t > \tau$ with $\tau = 30$ s. A third set of measurements of the firing rate at steady state (time interval 20–24 s in Figure 3—figure supplement 1) was used as an independent control of the parameter fit obtained from the fitting of the other stimulation protocols.

## Derivation of the mathematical solution of the IFF motif

As observed in Figure 4E,F, the pure IFF motif not only accounts for the response of the OSN stimulated by light, but it also represents a good approximation of the OSN dynamics stimulated by an odor (Figure 4E,F and Table 2). The general solution of Equation 2 is:

$$u(t) = \alpha_1 e^{-\alpha_2 t} \int_0^t e^{\alpha_2 t'} x(t') dt' + C^{\text{ste}} e^{-\alpha_2 t}.$$

For times $t$ larger than $\alpha_2$, the second term of the solution converges to zero, and we obtain the more compact form:

$$u(t) = \alpha_1 \int_0^t e^{-\alpha_2(t-t')} x(t') dt'. \quad (4)$$

By sequentially integrating (4) by parts, we obtain the following identities:

$$u(t) = \alpha_1 \langle x(t) \rangle_{\alpha_2} = \frac{\alpha_1}{\alpha_2} x(t) - \frac{\alpha_1}{\alpha_2} \left\langle \frac{dx}{dt}(t) \right\rangle_{\alpha_2}. \quad (5)$$

where the brackets $\langle \rangle$ denote the convolution introduced in relationship (4). While timescale of the dynamics of variable $u$ is given by $\alpha_2$, the time scale of the stimulus can be approximated as

$$\tau_x \approx \frac{x_{\text{max}} - x_{\text{min}}}{\left(\frac{dx}{dt}\right)_{\text{max}}}.$$

For the linear and nonlinear ramps tested in Figure 3, $\tau_x$ is typically 10 s. As the value of $\alpha_2$ is 0.88 s⁻¹ (Table 1), the variable $u$ evolves on a timescale approximately 10 times faster than the stimulus. Using relationship (4), Equation 2 can be rewritten as:

$$\frac{dy}{dt} = \beta_1 \frac{x}{\beta_2 + x + \beta_3 \alpha_1 \int e^{-\alpha_2(t-t')} x(t') dt'} - \beta_4 \frac{y^2}{y^2 + \theta^2} - \beta_5 y. \quad (6)$$

The function multiplying parameter $\beta_4$ is a steep sigmoid (or Hill function) whose value is close to 1 when $y$ is reasonably larger than 0. More formally, this approximation is valid for values of $y$ larger than the threshold $y$:

$$\frac{\tilde{y}^2}{\tilde{y}^2 + \theta^2} = (1 - \varepsilon) \rightarrow \tilde{y} = \sqrt{\frac{(1 - \varepsilon)}{\varepsilon}} \theta. \quad (7)$$

Given that the value of $\theta$ of 0.3, we see that the Hill term will be larger than 0.95 for values of $y$ larger than 1.3 Hz. For this range of values, Equation 6 can be rewritten as:

$$\frac{dy}{dt} = f(x(t), t) - \beta_5 y, \quad (8)$$

where $f(t)$ is a function independent of $y$. This function evolves on a timescale slower than $\alpha_2$. If we assume that the firing rate $y$ (0) is initially 0, the solution of (8) is:

$$y(t) = \int_{0}^{t} e^{-\beta_{5}(t-t')} f(x(t'), t') dt'. \quad (9)$$

Equation 9 shows that the dynamics of $y(t)$ obeys a characteristic time given by $\beta_5$. Since $\beta_5 = 13.03$ s⁻¹ (Table 1), variable $y$ evolves on a timescale more than 10 times faster than the stimulus. In view of this separation of the timescales, it is justified to assume that $y$ is at quasi-steady-state (QSSA, $dy/dt \approx 0$) during the evolution of the stimulus $x$ and variable $u$. By combining this assumption with (6), we find that:
$$y^{\text{QSSA}}(t) = \frac{\beta_1}{\beta_5} \left( \frac{x(t)}{\beta_2 + x(t) + \alpha_1 \beta_3 \int e^{-\alpha_2(t-t')} x(t') dt'} \right) - \frac{\beta_4}{\beta_5}, \quad (10)$$

Based on the values of the parameters of the original ODE system (Table 1), we obtain $\beta_1/\beta_5 = 132.9$ Hz, $\beta_2 = 1.27$ W/m², $\alpha_1\beta_3 = 0.25$ s⁻¹, and $\beta_4/\beta_5 = 93.17$ Hz. It is interesting to note that the convolution of x is necessarily smaller when x takes on larger values. Using the identities (5), we can rewrite (10) as:

$$y^{\text{QSSA}}(t) = \delta_1 \left( \frac{x(t)}{\delta_2 + x(t) - \delta_3 \int e^{-\alpha_2(t-t')} \frac{dx}{dt'}(t') dt'} \right) - \delta_4, \quad (11)$$

where

$$\delta_1 = \frac{\beta_1}{\beta_5} \frac{\alpha_2}{\alpha_2 + \alpha_1 \beta_3} = 103.66 \text{ Hz.}$$

$$\delta_2 = \beta_2 \frac{\alpha_2}{\alpha_2 + \alpha_1 \beta_3} = 0.99 \text{ W/m}^2.$$

$$\delta_3 = \frac{\alpha_1 \beta_3}{\alpha_2 + \alpha_1 \beta_3} = 0.22.$$

$$\delta_4 = \frac{\beta_4}{\beta_5} = 93.17 \text{ Hz.}$$

As expected, the QSSA solution is in excellent agreement with the results of the integration of the full ODE system (Figure 14). Given the values of the parameters (Table 1), the denominator of relationship (11) is mostly driven by the stimulus intensity for slowly evolving stimuli. The contribution of the convolution over the first derivative is significant for rapid and large changes of the stimulus intensity. In the limit where the stimulus is constant over time (dx/dt = 0), the scaling term S(x,t) is equal to zero and the QSSA predicts the dose-response function displayed in Figure 3—figure supplement 1C:

$$y^{\text{QSSA}} \propto \frac{x}{x + \delta_2} - C_1 \quad \frac{dx}{dt} = 0,$$

where $C_1$ is a constant. For stimulation patterns in which the intensity changes at a constant rate (linear ramps, Figure 4E and Figure 4—figure supplement 1A), the first derivative is constant with a positive or a negative sign.

$$y^{\text{QSSA}} \propto \frac{x}{x + \delta_2 - C_2} - C_1 \quad \text{constant } \frac{dx}{dt},$$

with $C_1$ and $C_2$ being constants. The sign of $C_2$ is determined by that of dx/dt. For constant stimulus gradients (linear increases in concentration), we predict that the firing rate also followed a hyperbolic function (dose-response) of the stimulus intensity (Figure 3—figure supplement 1). This time, however, the dose-response is expected to saturate at lower values of the stimulus intensity when the gradient is positive (rising phase of the linear ramps) and higher values of the stimulus intensity when the gradient is negative (falling phase of the linear ramps). These predictions are consistent with the firing patterns observed in Figure 4.

## Tracker

The tracker outlined in Figure 5 is presented in more detail in Figure 15. It was conceived and built at the Instrumentation Design and Fabrication Facility at the Janelia Research Campus. Part of the construction was carried out by KeyTech (Baltimore, USA). Unlike other tracking systems (Faumont et al., 2011; Leifer et al., 2011; Kocabas et al., 2012), our setup was designed to keep the stage on which the larva evolves fixed by mounting the camera and stimulation LEDs on a moving stage whose position was continuously updated to stay locked with the animal's position (Figure 15). The upper and lower moving stage were powered by a pair of stepper motors (T-LSR450B, Zaber Technologies, Canada). The blueprint of the tracker and list of parts are available from the following
<figure><img src="image_22.png" /><figcaption>**Figure 14.** Quasi-steady state approximation of the IFF model describing the spiking dynamics of a single OSN stimulated by light ramps. Comparisons of the analytical solution of the OSN activity upon numerical integration of the full ODE system (green line) with the solution obtained under the quasi-steady state approximation (QSSA, orange line) and the experimental PSTH (black line, shades denote standard deviation). The goodness of fit of the QSSA is remarkable for the linear and nonlinear ramps. As discussed in the 'Materials and methods', the QSSA holds for values of y such that the Hill term can be linearized (y >1.3 Hz). This domain of validity is depicted by the orange background.</figcaption></figure>

DOI: 10.7554/eLife.06694.036

link: https://github.com/LabLouis/eLife_2015/tree/master/Tracker%20Hardware. The light stimulation module consisted of three LEDs, connected in series (LCS-0470-03-22, Mightex Systems) to an LED controller (SLA-1200-2, Mightex Systems) whose output current limit was set to 750 mA. The angle and position of each LED was fixed to cover the camera's field of view with maximum light intensity. The controller's output current scaled proportionally to the analog voltage fed into the controller board. The light intensity reaching the arena was estimated by measuring the current emitted by a photodiode (SM05PD7A, Thorlabs) connected to a benchtop amplifier (PDA200C, Thorlabs). The tracker's video camera (A622f, Basler, Germany) was placed at the center of the three blue LEDs; it delivered images at a resolution of 800 × 800 pixels at a frame time interval of 23 ms. Combined with the time required to process the image and actuate the position of the stage, the effective frame rate was 30 Hz.

As summarized in **Figure 15C**, the larval tracker control unit (LTCU) formed the main hardware interface controlling the LEDs and acquiring images from the video camera. While the camera was controlled via a transistor-transistor logic pulse signal, a 12-bit digital-to-analog converter output was used to send the control signals (0–5 V analog signal) to the LED controller. An in-circuit debugging (ICD) Port was used to connect the LTCU to an ICD3 programmable interface controller via a registered jack (RJ11) connector interface, while an USB Port enabled the LTCU's communication to the PC. A customized program written in C was used to direct the function of the LTCU. This C program enabled the LTCU to respond to the commands issued by the PC. The software interface of the tracking and image analysis software interfacing the LTCU was written in JAVA. Both the C program and JAVA interface are available from the following links: https://github.com/LabLouis/eLife_2015/tree/master/Wormsign (tracker) and https://github.com/LabLouis/eLife_2015/tree/master/Venkman (JAVA controller interface).

## Update of light intensity

For closed-loop experiments described in **Figures 6, 7**, the light intensity was updated based on the position of the head of the larva mapped on a predefined light landscape. The light landscape was loaded and interpolated by the software controller environment from a matrix with a spatial resolution of 1 × 1 mm. Since the position of the larva was monitored at a higher resolution, the intensity of the spatial landscape was redefined by using a bi-linear interpolation along the x- and y-axis. The position of the center of the light gradient was automatically adjusted at the beginning of the experiment in such a way that every larva started in a direction facing the center of the gradient at a fixed distance of
<figure><img src="image_23.png" /><figcaption>**Figure 15.** Technical description of the closed-loop tracker for virtual olfactory realities. (A) Schematic drawing of the closed-loop tracker. The blue LEDs and the camera are mounted on a moving stage that follows the larva while it crawls on an agarose slab (40 × 40 cm or approximately 120 × 120 body lengths of the larva). (B) Depiction and description of the moving camera stage equipped with three LEDs. (C) Flow chart outlining the interaction of the core modules of the tracking software ('Materials and methods'). (D) Illustration of the spatial trajectory generated by an *Or42a>ChR2* larva undergoing closed-loop light stimulation in a virtual odor gradient. (Top-left) Predefined light Figure 15. continued on next page</figcaption></figure>
Figure 15. Continued

landscape with a geometry approximating the odor distribution produced by a point source. During the behavioral tests, the full gradient is not projected onto the arena: the larva is illuminated by the LEDs at an intensity determined by its position in the virtual light gradient. (Bottom) The light intensity is updated based on the motion of the larva, which forms the temporal evolution shown in the graph. (Top-right) The spatial trajectory described by an Or42a>ChR2 larva in the virtual light gradient. The orientation response faithfully reproduces chemotactic behavior. In closed-loop experiments, the LED intensity was updated according to the position of the head with respect to a predefined spatial landscape. In open-loop experiments, the LED intensity was determined by a predefined temporal profile implemented only when a larva was in a run mode (Figure 5B). During a run, the motion of the larva had no influence on the intensity of the stimulus. As soon as the larva interrupted a run, the light intensity returned to a baseline value (15 W/m²). (E) Abolishment of photophobic behavior in blind larvae. Stimulation of larvae with light flashes of 0.5 s (intensity: 207 W/m²). The flashes were interspaced by a time interval picked from a Poisson distribution with mean 7.7 s. To ensure that a larva had sufficient time to react to individual light pulses, the minimum inter-flash interval was set to 5 s. The behavior resulting from the flash was characterized by computing the flash-triggered averages of the amplitude of the absolute head angle and its time derivative. Wild-type larvae (black trace) display an increase in head motion following the flash (release of head cast). Blind GMR-hid;dTrpA1¹ larvae (red trace) were not affected by the light flashes. The graph represents the means of the kinematic variables computed across trajectories; error bars denote SEM.

DOI: 10.7554/eLife.06694.037

9.6 mm from the center for the exponential light gradient (Figure 6) and a distance of 17.1 mm for the family of light landscapes (Figure 7). The minority of trajectories from which larvae failed to detect the presence of the light gradient was discarded from the dataset.

For open-loop experiments described in Figure 5, the LED intensity was updated based on a predefined temporal function. This function was only implemented when the larva was classified in a run mode according to the rules described in Figure 16. Throughout the study, odor and light gradient landscapes were represented using brewermap (S. Cobeldick, MathWorks file exchange) with color schemes from http://colorbrewer2.org/.

## Computation and predictions of the turn probability

In the behavioral experiments of Figure 5, the probability of turning ('turn rate') was estimated from the relative number of turns that took place during a 1-s time window centered on the time point of interest. If we denote the number of runs observed at the beginning and the end of the ith time window as Nbᵢ and Neᵢ, respectively, Nb1 represents the total number of runs contained in the dataset. Over time, Nbᵢ decreases monotonically to 0. The turn probability associated with the ith time point was estimated as the fraction of runs that ended during the corresponding time window: (Nbᵢ - Neᵢ)/Nbᵢ. A sliding time window was then applied to estimate the turn probability corresponding to every time point of the experiment. The turn probability was thus defined as the likelihood of implementing a turn within a 1 s time window, resulting in values smaller than 1 (in the case of 1 all runs entering a given time window switch to a turn) and larger or equal to 0 (in the case of 0 no turn takes place during a given time window). While a short time window led to noisy turn probability estimates, long time windows led to undesirable averaging effects. We empirically found that a time window of 1 s (or 30 time points) offered a good tradeoff.

## Generalized linear model for turn predictions

As described in Figure 5, the predicted probability of turning was computed from a GLM based on a linear function of the firing rate of the OSN, y. To map the domain of definition of the firing rate ([0, ∞)) onto the domain of definition of the turn probability ([0, 1]), we applied a logit link function (Myers et al., 2002). This led to the following relationship:

$$ \ln\left(\frac{\lambda(t)}{1-\lambda(t)}\right) = \gamma_0 + \gamma_1 y(t). \qquad (13) $$

The two parameters of the model, γ₀ and γ₁, were trained on a set of 10 light ramps listed in Figure 5—figure supplement 1. Parameter γ₀ corresponds to a term related to the basal turn rate. The values of the parameters of the model are reported in Table 3.
<figure><img src="image_24.png" /><figcaption>**Figure 16.** Real-time classification of the locomotor behavior of the larva. (A) In the present study, the locomotor behavior of the larva is classified into two basic types of action: forward runs and non-runs. Non-run is a meta-state that includes stops, turns, casts, and backward runs. No distinction is made between non-run behaviors. To distinguish runs from non-runs, we defined empirical filters based on the following three sensorimotor features: (1) the head angle between the direction of the body axis (tail-midpoint) and the neck axis (head-midpoint); (2) the instantaneous velocity vector measured at the tail position (vector vtail) and (3) the angle α formed by tail velocity vector and the direction of the body axis (unitary vector 1m). (B) Transitions from a run to a non-run state take place as soon as (i) the head angle is larger than a threshold τ₁ or (ii) the dot product of the tail velocity vector and unitary vector corresponding to the direction of the body axis is smaller than τ₂ (condition C1). The first condition on the head angle identifies head casts while the second condition on the dot product identifies sequences of behavior associated with a stop or a backward run. Transitions from a non-run to a run take place when the following two conditions are verified: (iii) the head angle must be lower than the threshold value τ₃ and (iv) the dot product of the tail velocity and unitary vector along the body axis must be larger than τ₂ (condition C2). (C) The thresholds of conditions (i–iv) were set at a value that maximizes the difference in the cumulative distribution of the run and non-run states along the relevant sensorimotor feature (head angle or dot product) for the two possible types of behavioral state transitions (run → non-run or non-run → run). Distributions of the frame-by-frame sensorimotor features were constructed by pooling the annotated frames from four representative trajectories. Manual annotation was achieved by two trained experimenters. (Top) The values of the thresholds used in the analysis were: τ₁ = 18°, τ₂ = 0.0065, and τ₃ = 13°. (Bottom) Comparison of frame-by-frame manual classification of run/non-run behavior achieved by the two trained annotators (A1 and A2) vs the computational classification obtained by filters described in panel B. The table reports the percentage of true positives (frames classified as a run by both the annotator and the algorithm) and false negatives (frames classified as a run by the annotator and a non-run by the algorithm). This good match validates the use of the computational classifiers in real-time experiments.

DOI: 10.7554/eLife.06694.029</figcaption></figure>

As shown in **Figure 17**, the logit transform included in the GLM improved the accuracy of the fit without being essential. The predictive value of the model trained on open-loop behavior was then evaluated when applied to closed-loop experiments such as those described in **Figures 6–8**. The performance of the test model was compared to a control model devoid of sensory processing of the OSN. For the control model, relationship (13) became:

$$ \ln\left(\frac{\lambda(t)}{1-\lambda(t)}\right) = \gamma''_{0} + \gamma''_{1}x(t), \qquad (14) $$

where the parameters γ''₀ and γ''₁ were computed from a linear regression on the open-loop experiments listed in **Figure 5—figure supplement 1** (parameter values listed in **Table 3**).

Finally, the contribution of the first derivative of the stimulus intensity was assessed in the enhanced control model:

$$ \ln\left(\frac{\lambda(t)}{1-\lambda(t)}\right) = \gamma''_{0} + \gamma''_{1}x(t) + \gamma''_{2}\frac{dx}{dt}(t). \qquad (15) $$

The time derivative of the stimulus was defined by the change in stimulus intensity that occurred during the frame (33 ms) preceding the present time point t. The goodness of fit of the two control models can be compared to the test model in **Figure 5—figure supplement 3**.
<figure><img src="image_25.png" /><figcaption>**Figure 17.** Contribution of the logit transform to the predictions of the integrated stimulus-to-behavior generalized linear model (GLM). (A) Comparison of the behavioral outputs of the GLM with and without logit transformation for the run-to-turn transitions elicited by a 8-s linear light ramp. In the absence of logit transformation, the GLM is based on a linear combination $\lambda(t) = \gamma_0 + \gamma_1y(t)$. Negative values of the linear combination were rectified to be equal to 0. The parameters of the model were trained on the full set of ramps presented in **Figure 5—figure supplement 1** (derived parameter set: $\gamma_0 = 0.3762$, $\gamma_1 = -0.0198 \text{ Hz}^{-1}$). The result of the GLM without logit transformation is represented by a dashed line. The GLM model that includes the logit transformation is represented by a plain line (parameter set listed in **Table 3**). The correlation coefficients ($\rho$) and coefficients of variation of the RMSE computed on the outputs of the GLM with and without logit transformation differ by 12% and 10%, respectively. (B) Same as panel A for a sigmoid light ramp. The correlation coefficients and coefficients of variation of the RMSE computed on the outputs of the GLM with and without logit transformation differ by 5% and 22%, respectively.

DOI: 10.7554/eLife.06694.038</figcaption></figure>

## Statistical procedures and data analysis

This section summarizes the methods used for the quantification of physiological and behavioral data.

### Quantification of goodness of fit of the OSN and behavioral models (material pertaining to Tables 2, 4, Figures 13, 18)

For the firing rate of the OSN and the probability of turning, two metrics were used to quantify the goodness of fit of the models. First, we used Pearson's correlation coefficient. If we denote the experimental observations as $X_t$ and the output from the model as $Y_t$, the correlation coefficient was computed as:

$$r = \frac{\sum_{t=1}^{n} (X_t - \bar{X})(Y_t - \bar{Y})}{s_X s_Y},$$

where $s_X$ is the standard deviation of variable X and n represents the total number of time points in the dataset. The second metric used is the coefficient of variation (CV) of the root-mean-square error (RMSE) defined as:

$$CV(\text{RMSE}) = \frac{\sqrt{\frac{1}{n} \sum_{t=1}^{n} (X_t - Y_t)^2}}{X}.$$

### Error bars for the PSTHs (material pertaining to Figures 2–8)

Except for **Figure 13**, all PSTH were computed on a sliding time window of 50 ms (Dayan and Abbott, 2001). Throughout the manuscript, the error bars (shaded areas) associated with the firing rate of the Or42a>ChR2 OSN (PSTH) denote the standard deviation.
<figure><img src="image_26.png" /></figure>

**Figure 18.** Behavior of single functional Or42a>ChR2 OSN in the background of a silenced and an intact peripheral olfactory system (1 vs 21 functional OSNs). (A) Open-loop stimulation protocol with a 8-s linear light ramp (magenta line). Comparison of the behavior elicited by ChR2 in the Or42a OSN in the background of 20 silenced OSNs (1 functional OSN, black line) and 21 functional OSNs (green line). The genotype of larvae with only one functional OSN is: *w;Or42a-Gal4,GMR-hid;Orco²,dTrpA1¹* × *w;UAS-Orco,UAS-ChR2-H134R;Orco²,dTrpA1¹*. This genotype is used throughout the study. The genotype of control larvae with 21 functional OSNs is: *UAS-ChR2-H134R/Or42a-Gal4;gl⁶⁰,dTrpA1¹*. This genotype is only used in the present control. The modulation of the turn probability elicited by the stimulus is similar for both genotypes. Plain lines indicate the mean of the turn probability; shaded areas denote standard deviation (see 'Materials and methods'). (B) Closed-loop behavior in an exponential light gradient. The stimulus landscape is the same as that used in **Figure 6A**. Side-by-side comparison of 10 light-driven trajectories superimposed onto the gradient. The overall patterns of the trajectories indicate that light-driven chemotaxis can be mediated by a single OSN in the background of 21 functional OSNs.

DOI: 10.7554/eLife.06694.028

## Error bars for the turn probabilities estimated from open-loop behavioral experiments (material pertaining to **Figures 5, 17, 18**)

Error bars for the turn probability were estimated by resampling the initial distribution of runs 100 times without replacement and with a sample containing half of the original set of runs. The error bars reported in the figures (shaded areas) correspond to the standard deviations calculated on the resampled sets of runs.

## Cross-validation of the ODE model for the OSN spiking activity (material pertaining to **Figure 4—figure supplement 2**)

The composite IFF+IFB model developed to reproduce and predict the activity elicited by odor stimulation was trained on the full set of odor ramps listed in **Figure 4—figure supplement 1** together with the natural stimulus shown in **Figure 2D,E**. The parameters derived through this training procedure (**Table 1**) were used throughout the study. To validate the structure of the ODE model, we followed a cross-validation approach in which the IFF+IFB model was trained on the 4-s linear ramps listed in **Figure 4—figure supplement 1Ai–ii** and used to accurately predict the activity elicited by the 8-s ramps listed in **Figure 4—figure supplement 2B** (middle panel) as well as the naturalistic stimulus shown in **Figure 4—figure supplement 2C** (top panel). The same approach was followed to provide a successful validation of the IFF model to describe the spiking activity elicited by light stimulations (**Figure 4—figure supplement 2**, bottom panels).

## Controls for behavioral experiments: open-loop light stimulation (material pertaining to **Figure 5**)

In open-loop stimulation experiments (**Figure 5**), the output of the integrated stimulus-to-behavior GLM described in (13) was computed for each time point of the experiment. The performances of the test model were compared to a control GLM in which the turn probability was predicted from the stimulus intensity without any sensory processing from the OSN. For this control model, we independently fitted a GLM identical to that presented in **Figure 5D** after replacement of the firing rate by the stimulus intensity alone or a combination of the stimulus intensity and its first derivative (**Figure 5—figure supplement 3**). The goodness of fit of the test and control GLMs are reported in **Table 4**.
Controls for behavioral experiments: closed-loop light and odor stimulation (material pertaining to **Figures 6, 8**)

In closed-loop experiments conducted in light and odor gradients (Figures 6, 8), the predictions of the integrated stimulus-to-behavior GLM described in equation (13) were analyzed by computing the turn-triggered average of the turn probability. This average time course was compared to two controls. The first control consisted in achieving turn predictions based on a sensory experience whose relation to the corresponding behavior was uncoupled. To this end, we inverted the time course of the light (odor) intensity and associated it with the forward time course of the behavior. This first control preserved the statistics of the stimulus intensity experienced by the larva. The second control was based on the assumption that the OSN firing rate was constant over time and corresponded to the mean activity predicted by a typical trajectory. Given that each larva experienced a different time course of light intensity, the mean OSN firing rate was computed on a trajectory-by-trajectory basis. Note that the control GLM derived in equation (14) for the open-loop light ramps was deemed inadequate to predict closed-loop behaviors in odor gradients due to the mismatch between the dynamic range of the stimulus associated with the light ramps and that experienced in the odor gradient.

Cross-validation of the GLM for the turn probabilities (material pertaining to **Figure 5—figure supplement 2**)

The integrated stimulus-to-behavior GLM was trained on the full set of light ramps listed in Figure 5—figure supplement 1. To validate the structure of the GLM, we followed a cross-validation approach in which the GLM was trained on the 4-s linear ramps listed in Figure 5—figure supplement 2A and used to accurately predict the activity elicited by the 8-s ramps listed in Figure 5—figure supplement 2B-iii. Furthermore, we demonstrated that training the GLM on a single light ramp was sufficient to make accurate predictions on a different ramp (Figure 5—figure supplement 2C).

Likelihood analysis for behavioral predictions (material pertaining to **Figures 6, 8**)

To assess the quality of the behavioral predictions obtained from the stimulus-to-behavior GLM described in equation (13), we computed the likelihood associated with the observation of the entire set of runs obtained in the closed-loop light and odor gradients. Let us denote the total number of runs observed in a particular gradient as N. The likelihood of the ith run was computed based on the turn probability predicted on bins of 1 s. The probability of observing a turn between time t and (t +1 s) is: λᵢ(t) where the index i refers to the sensory experience associated with the ith run. The probability of not turning during a time interval (t, t +1) is: 1 - λᵢ(t). Thus, the probability of observing a given run lasting 5.6 s can be estimated as:

$$p_i = (1 - \lambda_i(0.6)).(1 - \lambda_i(1.6)).(1 - \lambda_i(2.6)).(1 - \lambda_i(3.6)).\lambda_i(4.6). \quad (16)$$

Using relationship (16), we calculated the likelihood of the entire set of runs as:

$$L = \prod_{i=1}^{N} p_i. \quad (17)$$

The log-likelihoods (logL) of the predictions associated with the test model and the two controls (see previous section) were computed. To evaluate the reliability of differences between the test model and controls, we applied a standard bootstrap approach (Martinez and Martinez, 2001). From the original collection of runs, we generated 10,000 independent new samples of runs based on random resampling with replacement. For each sample, we computed the logL of the test model and the controls. Next we considered the relative difference in logL between the model and the control defined as:

$$\frac{\Delta \log L}{\log L_{\text{test}}} = \frac{(\log L_{\text{test}} - \log L_{\text{control}})}{\log L_{\text{test}}}.$$

The distribution of this variable is reported in **Figure 6F** for the behavior elicited by the light gradient, and in **Figure 8D** for the behavior elicited by the odor gradient. Finally, we computed the number of instances where ΔlogL/logL<sub>test</sub> was lower than 0 (control outperforming the test model) and derived a p-value for the hypothesis that the test model yields a larger likelihood than the controls.
## Optogenetics-based chemotaxis in the background of a silenced and intact olfactory system

For optimal results, the spike-sorting method (OpSIN, Figure 11B) developed in this work required that the recordings of the odor-stimulated OSN activity be achieved in the background of a silenced olfactory system (Orco⁻/⁻). For this reason, the genotype of the larvae used throughout the study for physiological and behavioral quantification resulted from the cross: w;Or42a-Gal4, GMR-hid;Orco², dTrpA1¹ × w;UAS-Orco,UAS-ChR2-H134R;Orco²,dTrpA1¹. Given that interneurons of the larval antennal lobe clearly contribute to the neural representation of odors (Asahina et al., 2009; Larkin et al., 2010), it was important to determine whether the sensorimotor principles controlling chemotactic behavior in a silenced and intact olfactory system are the same. In this aim, we examined the behavior of larvae with ChR2 expressed in the Or42a OSN in the background of a fully functional olfactory system (21 intact OSNs): UAS-ChR2-H134R/Or42a-Gal4;gl⁶⁰,dTrpA1¹. Larvae bearing the double mutant alleles gl⁶⁰ and dTrpA1¹ were insensitive to light (data not shown). In closed-loop and open-loop conditions of light stimulation, we found a high similarity of the chemotactic responses observed in the background of 1 or 21 functional OSNs (Figure 18). This result corroborates the idea that the basic control principles learned from single functional OSN larvae are relevant to wild-type larvae.

## Scripts

All scripts described in the 'Materials and methods' as well as the blueprint of the larval tracker are available for download from the following website: https://github.com/LabLouis/eLife_2015.

## Acknowledgements

We thank A Leonardo, E Knoche, and the Louis lab for comments on the manuscript. The tracker was developed with the help of L Ramaswamy (ID&F at Janelia Research Campus). We are grateful to the following individuals for insightful discussions at different stages of the project: C Bargmann (molecular interpretation of the IFF motif), H Davidowitz and D Rinberg (design of olfactometer in gaseous phase), A Kim and A Lazar (comparison between transfer function adult and larval OSNs), A Leonardo (linear filter analysis and data interpretation), R Moreno (likelihood analysis), M Phillips (turn classifiers). We thank S Pulver and L Griffith for donating the UAS-ChR2-H134R transgenic stock. ML acknowledges funding from the Spanish Ministry of Science and Innovation (MICINN, BFU2008-00362, BFU2009-07757-E/BMC and BFU2011-26208). We are grateful to KeyTech (Baltimore, USA) for advising about the design of the tracker and for carrying out the assembly of the hardware. AS, AGM, VGR, MM, JS, JR, DJ, and ML were supported by the EMBL/CRG Systems Biology Program. JS was supported by ICREA. AD was funded by the European Commission FP7 Initial Training Network FLiACT (289941). MS was partially funded by the National Centre for Biological Sciences—Tata Institute of Fundamental Research. GL, PA, ETT, CW, SD, and VJ were supported by the Howard Hughes Medical Institute. This project received support from the HHMI Janelia Research Campus visitor program (AS, AGM, VGR, DJ, and ML).

## Additional information

### Funding

<table><thead><tr><td>Funder</td><td>Grant reference</td><td>Author</td></tr></thead><tbody><tr><td>Spanish Ministry of Science and Innovation</td><td>BFU2008-00362</td><td>Aljoscha Schulze, Alex Gomez-Marin, Vani G Rajendran, Julia Riedl, David Jarriault, Matthieu Louis</td></tr><tr><td>Centre for Genomic Regulation</td><td>EMBL/CRG</td><td>Aljoscha Schulze, Alex Gomez-Marin, Vani G Rajendran, Marco Musy, Ajinkya Deogade, James Sharpe, Julia Riedl, David Jarriault, Matthieu Louis</td></tr></tbody></table>
<table><thead><tr><th>Funder</th><th>Grant reference</th><th>Author</th></tr></thead><tbody><tr><td>Howard Hughes Medical Institute (HHMI)</td><td></td><td>Gus Lott, Parvez Ahammad, Eric T Trautman, Christopher Werner, Shaul Druckmann, Vivek Jayaraman</td></tr><tr><td>European Commission (EC)</td><td>FP7 Framework (Marie Curie ITN, FLiACT)</td><td>Ajinkya Deogade</td></tr><tr><td>Tata Insitute of Fundamental research (TIFR)</td><td>(NCBS)</td><td>Madhusudhan Venkadesan</td></tr><tr><td>Howard Hughes Medical Institute (HHMI)</td><td>Janelia visitor programme</td><td>Matthieu Louis</td></tr><tr><td>Spanish Ministry of Science and Innovation</td><td>BFU2011-26208</td><td>Aljoscha Schulze, Alex Gomez-Marin, Vani G Rajendran, Julia Riedl, David Jarriault, Matthieu Louis</td></tr><tr><td>Spanish Ministry of Science and Innovation</td><td>BFU2009-07757-E/BMC</td><td>Aljoscha Schulze, Alex Gomez-Marin, Vani G Rajendran, Julia Riedl, David Jarriault, Matthieu Louis</td></tr></tbody></table>

The funders had no role in study design, data collection and interpretation, or the decision to submit the work for publication.

## Author contributions

AS, Conception and design (electrophysiology and part of the behavioral experiments), Acquisition of all data included in the study (electrophysiology, IR spectroscopy and behavior), Development of the OSN recording technique, Analysis and interpretation of data (electrophysiology), Drafting or revising the article; AG-M, Conception and design (models for OSN activity and behavioral control, part of the behavioral experiments); Analysis and interpretation of data (analysis and modeling of the experimental data), Tracker development (machine vision algorithm), Drafting or revising the article; VGR, Conception and design (part of the behavioral experiments), Acquisition of data (early dataset for behavior), Tracker development (behavioral classifiers); GL, Tracker development (machine vision algorithm), Conception and design; MM, Tracker development (machine vision algorithm), Conception and design, Analysis and interpretation of data; PA, Spike-sorting method based on optogenetics (electrophysiology), Conception and design, Analysis and interpretation of data; AD, Conception and design (analysis of model predictions); JS, Design of Simplex parameter optimization (modeling), Drafting or revising the article; JR, Development of the OSN recording technique. Conception and design, Contributed unpublished essential data or reagents; DJ, Development of the OSN recording technique and spike-sorting algorithm, Conception and design, Analysis and interpretation of data, Contributed unpublished essential data or reagents; ETT, Tracker development (controller algorithm), Conception and design; CW, Tracker development (hardware), Conception and design; MV, Conception of model and analysis of data related to the PDE simulations of odor diffusion (modeling), Acquisition of data, Analysis and interpretation of data; SD, Conception of generalized linear model for behavior (modeling), Conception and design, Analysis and interpretation of data, Drafting or revising the article; VJ, Conception and design of the experiments, Spike-sorting method based on optogenetics (electrophysiology), Analysis and interpretation of data (electrophysiology), Drafting or revising the article; ML, Conception and design of the experiments and models, Tracker development; Analysis and interpretation of data (electrophysiology, behavior and modeling), Drafting or revising the article

## Author ORCIDs

Matthieu Louis, http://orcid.org/0000-0002-2267-0262

## References

Ackers GK, Johnson AD, Shea MA. 1982. Quantitative model for gene regulation by lambda phage repressor. Proceedings of the National Academy of Sciences of USA 79:1129-1133. doi: 10.1073/pnas.79.4.1129.
Alon U. 2007. An introduction to systems biology: design principles of biological circuits. Boca Raton, FL: Chapman & Hall/CRC.

Ando N, Emoto S, Kanzaki R. 2013. Odour-tracking capability of a silkmoth driving a mobile robot with turning bias and time delay. *Bioinspiration & Biomimetics* **8**:016008. doi: 10.1088/1748-3182/8/1/016008.

Asahina K, Louis M, Piccinotti S, Vosshall LB. 2009. A circuit supporting concentration-invariant odor perception in *Drosophila*. *Journal of Biology* **8**:9. doi: 10.1186/jbiol108.

Bargmann CI. 2006a. Chemosensation in C. elegans. *WormBook* **25**:1–29. doi: 10.1895/wormbook.1.123.1.

Bargmann CI. 2006b. Comparative chemosensation from receptors to ecology. *Nature* **444**:295–301. doi: 10.1038/nature05402.

Bellmann D, Richardt A, Freyberger R, Nuwal N, Schwarzel M, Fiala A, Stortkuhl KF. 2010. Optogenetically induced olfactory stimulation in *Drosophila* larvae reveals the neuronal basis of odor-aversion behavior. *Frontiers in Behavioral Neuroscience* **4**:27. doi: 10.3389/fnbeh.2010.00027.

Berg HC. 2004. *E. coli* in motion: Springer.

Berndt DJ, Clifford J. 1994. Using dynamic time warping to find patterns in time series. Seattle, WA: KDD workshop.

Bintu L, Buchler NE, Garcia HG, Gerland U, Hwa T, Kondev J, Phillips R. 2005. Transcriptional regulation by the numbers: models. *Current Opinion in Genetics & Development* **15**:116–124. doi: 10.1016/j.gde.2005.02.007.

Borst A, Heisenberg M. 1982. Osmotropotaxis in *Drosophila melanogaster*. *Journal of Comparative Physiology A* **147**:479–484. doi: 10.1007/BF00612013.

Brun R, Rademakers F. 1997. ROOT—an object oriented data analysis framework. *Nuclear Instruments and Methods in Physics Research Section A* **389**:81–86. doi: 10.1016/S0168-9002(97)00048-X.

Busto M, Iyengar B, Campos AR. 1999. Genetic dissection of behavior: modulation of locomotion by light in the *Drosophila melanogaster* larva requires genetically distinct visual system functions. *The Journal of Neuroscience* **19**:3337–3344.

Carandini M, Heeger DJ. 2012. Normalization as a canonical neural computation. *Nature Reviews. Neuroscience* **13**:51–62. doi: 10.1038/nrn3136.

Carde RT, Willis MA. 2008. Navigational strategies used by insects to find distant, wind-borne sources of odor. *Journal of Chemical Ecology* **34**:854–866. doi: 10.1007/s10886-008-9484-5.

Chalasani SH, Chronis N, Tsunozaki M, Gray JM, Ramot D, Goodman MB, Bargmann CI. 2007. Dissecting a circuit for olfactory behaviour in *Caenorhabditis elegans*. *Nature* **450**:63–70. doi: 10.1038/nature06292.

Chichilnisky EJ. 2001. A simple white noise analysis of neuronal light responses. *Network* **12**:199–213. doi: 10.1080/713663221.

Cobb M. 1999. What and how do maggots smell? *Biological Reviews* **74**:425–459. doi: 10.1017/S0006323199005393.

Das A, Gupta T, Davla S, Prieto-Godino LL, Diegelmann S, Reddy OV, Raghavan KV, Reichert H, Lovick J, Hartenstein V. 2013. Neuroblast lineage-specific origin of the neurons of the *Drosophila* larval olfactory system. *Developmental Biology* **373**:322–337. doi: 10.1016/j.ydbio.2012.11.003.

Dayan P, Abbott LF. 2001. *Theoretical neuroscience: computational and mathematical modeling of neural systems*. Cambridge, Mass: Massachusetts Institute of Technology Press.

de Bruyne M, Clyne PJ, Carlson JR. 1999. Odor coding in a model olfactory organ: the *Drosophila* maxillary palp. *The Journal of Neuroscience* **19**:4520–4532.

De Palo G, Boccaccio A, Miri A, Menini A, Altafini C. 2012. A dynamical feedback model for adaptation in the olfactory transduction pathway. *Biophysical Journal* **102**:2677–2686. doi: 10.1016/j.bpj.2012.04.040.

De Palo G, Facchetti G, Mazzolini M, Menini A, Torre V, Altafini C. 2013. Common dynamical features of sensory adaptation in photoreceptors and olfactory sensory neurons. *Scientific Reports* **3**:1251. doi: 10.1038/srep01251.

Faumont S, Rondeau G, Thiele TR, Lawton KJ, McCormick KE, Sottile M, Griesbeck O, Heckscher ES, Roberts WM, Doe CQ, Lockery SR. 2011. An image-free opto-mechanical system for creating virtual environments and imaging neuronal activity in freely moving *Caenorhabditis elegans*. *PLOS ONE* **6**:e24666. doi: 10.1371/journal.pone.0024666.

Fishilevich E, Domingos AI, Asahina K, Naef F, Vosshall LB, Louis M. 2005. Chemotaxis behavior mediated by single larval olfactory neurons in *Drosophila*. *Current Biology* **15**:2086–2096. doi: 10.1016/j.cub.2005.11.016.

Fraenkel GS, Gunn DL. 1961. *The orientation of animals*. New York: Dover Publications.

French AS, Korenberg MJ, Jarvilehto M, Kouvalainen E, Juusola M, Weckstrom M. 1993. The dynamic nonlinear behavior of fly photoreceptors evoked by a wide range of light intensities. *Biophysical Journal* **65**:832–839. doi: 10.1016/S0006-3495(93)81116-0.

Frey BJ, Dueck D. 2007. Clustering by passing messages between data points. *Science* **315**:972–976. doi: 10.1126/science.1136800.

Fujiwara T, Kazawa T, Sakurai T, Fukushima R, Uchino K, Yamagata T, Namiki S, Haupt SS, Kanzaki R. 2014. Odorant concentration differentiator for intermittent olfactory signals. *The Journal of Neuroscience* **34**:16581–16593. doi: 10.1523/JNEUROSCI.2319-14.2014.

Gaudry Q, Hong EJ, Kain J, de Bivort BL, Wilson RI. 2013. Asymmetric neurotransmitter release enables rapid odour lateralization in *Drosophila*. *Nature* **493**:424–428. doi: 10.1038/nature11747.

Geffen MN, Broome BM, Laurent G, Meister M. 2009. Neural encoding of rapidly fluctuating odors. *Neuron* **61**:570–586. doi: 10.1016/j.neuron.2009.01.021.

Gerber B, Stocker RF. 2007. The *Drosophila* larva as a model for studying chemosensation and chemosensory learning: a review. *Chemical Senses* **32**:65–89. doi: 10.1093/chemse/bjl030.

Gershow M, Berck M, Mathew D, Luo L, Kane EA, Carlson JR, Samuel AD. 2012. Controlling airborne cues to study small animal navigation. *Nature Methods* **9**:290–296. doi: 10.1038/nmeth.1853.
Goentoro L, Kirschner MW. 2009. Evidence that fold-change, and not absolute level, of beta-catenin dictates Wnt signaling. *Molecular Cell* **36**:872–884. doi: 10.1016/j.molcel.2009.11.017.

Gomez-Marin A, Louis M. 2012. Active sensation during orientation behavior in the *Drosophila* larva: more sense than luck. *Current Opinion in Neurobiology* **22**:208–215. doi: 10.1016/j.conb.2011.11.008.

Gomez-Marin A, Louis M. 2014. Multilevel control of run orientation in *Drosophila* larval chemotaxis. *Frontiers in Behavioral Neuroscience* **8**:38. doi: 10.3389/fnbeh.2014.00038.

Gomez-Marin A, Stephens GJ, Louis M. 2011. Active sampling and decision making in *Drosophila* chemotaxis. *Nature Communications* **2**:441. doi: 10.1038/ncomms1455.

Grasso FW, Consi TR, Mountain DC, Atema J. 2000. Biomimetic robot lobster performs chemo-orientation in turbulence using a pair of spatially separated sensors: progress and challenges. *Robotics and Autonomous Systems* **30**:115–131. doi: 10.1016/S0921-8890(99)00068-8.

Gu Y, Lucas P, Rospars JP. 2009. Computational model of the insect pheromone transduction cascade. *PLOS Computational Biology* **5**:e1000321. doi: 10.1371/journal.pcbi.1000321.

Hallem EA, Ho MG, Carlson JR. 2004. The molecular basis of odor coding in the *Drosophila* antenna. *Cell* **117**: 965–979. doi: 10.1016/j.cell.2004.05.012.

Hoare DJ, McCrohan CR, Cobb M. 2008. Precise and fuzzy coding by olfactory sensory neurons. *The Journal of Neuroscience* **28**:9710–9722. doi: 10.1523/JNEUROSCI.1955-08.2008.

lino Y, Yoshida K. 2009. Parallel use of two behavioral mechanisms for chemotaxis in *Caenorhabditis elegans*. *The Journal of Neuroscience* **29**:5370–5380. doi: 10.1523/JNEUROSCI.3633-08.2009.

Izquierdo EJ, Lockery SR. 2010. Evolution and analysis of minimal neural circuits for klinotaxis in *Caenorhabditis elegans*. *The Journal of Neuroscience* **30**:12908–12917. doi: 10.1523/JNEUROSCI.2606-10.2010.

Joesch M, Schnell B, Raghu SV, Reiff DF, Borst A. 2010. ON and OFF pathways in *Drosophila* motion vision. *Nature* **468**:300–304. doi: 10.1038/nature09545.

Kane EA, Gershow M, Afonso B, Larderet I, Klein M, Carter AR, de Bivort BL, Sprecher SG, Samuel AD. 2013. Sensorimotor structure of *Drosophila* larva phototaxis. *Proceedings of the National Academy of Sciences of USA* **110**:E3868–E3877. doi: 10.1073/pnas.1215295110.

Kato HE, Zhang F, Yizhar O, Ramakrishnan C, Nishizawa T, Hirata K, Ito J, Aita Y, Tsukazaki T, Hayashi S, Hegemann P, Maturana AD, Ishitani R, Deisseroth K, Nureki O. 2012. Crystal structure of the channelrhodopsin light-gated cation channel. *Nature* **482**:369–374. doi: 10.1038/nature10870.

Kato S, Xu Y, Cho CE, Abbott LF, Bargmann CI. 2014. Temporal responses of *C. elegans* chemosensory neurons are preserved in behavioral dynamics. *Neuron* **81**:616–628. doi: 10.1016/j.neuron.2013.11.020.

Kaupp UB. 2010. Olfactory signalling in vertebrates and insects: differences and commonalities. *Nature Reviews. Neuroscience* **11**:188–200. doi: 10.1038/nrn2789.

Kelly-Zion P, Pursell C, Vaidya S, Batra J. 2011. Evaporation of sessile drops under combined diffusion and natural convection. *Colloids and Surfaces A* **381**:31–36. doi: 10.1016/j.colsurfa.2011.03.020.

Kim AJ, Lazar AA, Slutskiy YB. 2011. System identification of *Drosophila* olfactory sensory neurons. *Journal of Computational Neuroscience* **30**:143–161. doi: 10.1007/s10827-010-0265-0.

Kim AJ, Lazar AA, Slutskiy YB. 2015. Projection neurons in *Drosophila* antennal lobes signal the acceleration of odor concentrations. *eLife* **4**:e06651. doi: 10.7554/eLife.06651.

Klein M, Afonso B, Vonner AJ, Hernandez-Nunez L, Berck M, Tabone CJ, Kane EA, Pieribone VA, Nitabach MN, Cardona A, Zlatic M, Sprecher SG, Gershow M, Garrity PA, Samuel AD. 2015. Sensory determinants of behavioral dynamics in *Drosophila* thermotaxis. *Proceedings of the National Academy of Sciences of USA* **112**:E220–E229. doi: 10.1073/pnas.1416212112.

Kocabas A, Shen CH, Guo ZV, Ramanathan S. 2012. Controlling interneuron activity in *Caenorhabditis elegans* to evoke chemotactic behaviour. *Nature* **490**:273–277. doi: 10.1038/nature11431.

Kreher SA, Kwon JY, Carlson JR. 2005. The molecular basis of odor coding in the *Drosophila* larva. *Neuron* **46**: 445–456. doi: 10.1016/j.neuron.2005.04.007.

Kreher SA, Mathew D, Kim J, Carlson JR. 2008. Translation of sensory input into behavioral output via an olfactory system. *Neuron* **59**:110–124. doi: 10.1016/j.neuron.2008.06.010.

Kwon Y, Shim HS, Wang X, Montell C. 2008. Control of thermotactic behavior via coupling of a TRP channel to a phospholipase C signaling cascade. *Nature Neuroscience* **11**:871–873. doi: 10.1038/nn.2170.

Larkin A, Karak S, Priya R, Das A, Ayyub C, Ito K, Rodrigues V, Ramaswami M. 2010. Central synaptic mechanisms underlie short-term olfactory habituation in *Drosophila* larvae. *Learning & Memory* **17**:645–653. doi: 10.1101/lm.1839010.

Leifer AM, Fang-Yen C, Gershow M, Alkema MJ, Samuel AD. 2011. Optogenetic manipulation of neural activity in freely moving *Caenorhabditis elegans*. *Nature Methods* **8**:147–152. doi: 10.1038/nmeth.1554.

Lim WA. Lee CM, Tang C. 2013. Design principles of regulatory networks: searching for the molecular algorithms of the cell. *Molecular Cell* **49**:202–212. doi: 10.1016/j.molcel.2012.12.020.

Lima SQ, Hromádka T, Znamenskiy P, Zador AM. 2009. PINP: a new method of tagging neuronal populations for identification during in vivo electrophysiological recording. *PLOS ONE* **4**:e6099. doi: 10.1371/journal.pone.0006099.

Liu WW, Mazor O, Wilson RI. 2015. Thermosensory processing in the *Drosophila* brain. *Nature* **519**:353–357. doi: 10.1038/nature14170.

Lockery SR. 2011. The computational worm: spatial orientation and its neuronal basis in *C. elegans*. *Current Opinion in Neurobiology* **21**:782–790. doi: 10.1016/j.conb.2011.06.009.

Lott GK III, Johnson BR, Bonow RH, Land BR, Hoy RR. 2009. G-prime: a free, windows based data acquisition and event analysis software package for physiology in classrooms and research labs. *Journal of Undergraduate Neuroscience Education* **8**:A50–A54.
Louis M, Huber T, Benton R, Sakmar TP, Vosshall LB. 2008. Bilateral olfactory sensory input enhances chemotaxis behavior. *Nature Neuroscience* **11**:187-199. doi: 10.1038/nn2031.

Luo L, Wen Q, Ren J, Hendricks M, Gershow M, Qin Y, Greenwood J, Soucy ER, Klein M, Smith-Parker HK, Calvo AC, Colon-Ramos DA, Samuel AD, Zhang Y. 2014. Dynamic encoding of perception, memory, and movement in a C. elegans chemotaxis circuit. *Neuron* **82**:1115-1128. doi: 10.1016/j.neuron.2014.05.010.

Mainland JD, Lundstrom JN, Reisert J, Lowe G. 2014. From molecule to mind: an integrative perspective on odor intensity. *Trends in Neurosciences* **37**:443-454. doi: 10.1016/j.tins.2014.05.005.

Marmarelis VZ, McCann GD. 1977. A family of quasi-white random signals and its optimal use in biological system identification. Part II: application to the photoreceptor of Calliphora erythrocephala. *Biological Cybernetics* **27**: 57-62. doi: 10.1007/BF00357711.

Martelli C, Carlson JR, Emonet T. 2013. Intensity invariant dynamics and odor-specific latencies in olfactory receptor neuron response. *The Journal of Neuroscience* **33**:6285-6297. doi: 10.1523/JNEUROSCI.0426-12.2013.

Martinez WL, Martinez AR. 2001. *Computational statistics handbook with MATLAB: CRC press.*

Masse NY, Turner GC, Jefferis GS. 2009. Olfactory information processing in *Drosophila*. *Current Biology* **19**: R700-R713. doi: 10.1016/j.cub.2009.06.026.

Masuda-Nakagawa LM, Gendre N, O'Kane CJ, Stocker RF. 2009. Localized olfactory representation in mushroom bodies of *Drosophila* larvae. *Proceedings of the National Academy of Sciences of USA* **106**:10314-10319. doi: 10.1073/pnas.0900178106.

Mathew D, Martelli C, Kelley-Swift E, Brusalis C, Gershow M, Samuel AD, Emonet T, Carlson JR. 2013. Functional diversity among sensory receptors in a *Drosophila* olfactory circuit. *Proceedings of the National Academy of Sciences of USA* **110**:E2134-E2143. doi: 10.1073/pnas.1306976110.

Moses K, Ellis MC, Rubin GM. 1989. The glass gene encodes a zinc-finger protein required by *Drosophila* photoreceptor cells. *Nature* **340**:531-536. doi: 10.1038/340531a0.

Myers RH, Montgomery DC, Vining GG. 2002. *Generalized linear models: with applications in engineering and the sciences*. New York: J. Wiley.

Nagel KI, Wilson RI. 2011. Biophysical mechanisms underlying olfactory receptor neuron dynamics. *Nature Neuroscience* **14**:208-216. doi: 10.1038/nn.2725.

Nelder JA, Mead R. 1965. A simplex method for function minimization. *The Computer Journal* **7**:308-313. doi: 10.1093/comjnl/7.4.308.

Ohyama T, Jovanic T, Denisov G, Dang TC, Hoffmann D, Kerr RA, Zlatic M. 2013. High-throughput analysis of stimulus-evoked behaviors in *Drosophila* larva reveals multiple modality-specific escape strategies. *PLOS ONE* **8**: e71706. doi: 10.1371/journal.pone.0071706.

Ohyama T, Schneider-Mizell CM, Fetter RD, Aleman JV, Franconville R, Rivera-Alba M, Mensh BD, Branson KM, Simpson JH, Truman JW, Cardona A, Zlatic M. 2015. A multilevel multimodal circuit enhances action selection in *Drosophila*. *Nature* **520**:633-639. doi: 10.1038/nature14297.

Olsen SR, Bhandawat V, Wilson RI. 2010. Divisive normalization in olfactory population codes. *Neuron* **66**:287-299. doi: 10.1016/j.neuron.2010.04.009.

Oppliger FY, M Guerin P, Vlimant M. 2000. Neurophysiological and behavioural evidence for an olfactory function for the dorsal organ and a gustatory one for the terminal organ in *Drosophila melanogaster* larvae. *Journal of Insect Physiology* **46**:135-144. doi: 10.1016/S0022-1910(99)00109-2.

Pifferi S, Menini A, Kurahashi T. 2010. Signal transduction in vertebrate olfactory cilia. In: Menini A, editor. *The neurobiology of olfaction*. Boca Raton (FL).

Pulver SR, Pashkovski SL, Hornstein NJ, Garrity PA, Griffith LC. 2009. Temporal dynamics of neuronal activation by Channelrhodopsin-2 and TRPA1 determine behavioral output in *Drosophila* larvae. *Journal of Neurophysiology* **101**:3075-3088. doi: 10.1152/jn.00071.2009.

Ramaekers A, Magnenat E, Marin EC, Gendre N, Jefferis GS, Luo L, Stocker RF. 2005. Glomerular maps without cellular redundancy at successive levels of the *Drosophila* larval olfactory circuit. *Current Biology* **15**:982-992. doi: 10.1016/j.cub.2005.04.032.

Rieke F. 1997. *Spikes: exploring the neural code*. Cambridge, Mass: MIT Press.

Sawin-McCormack EP, Sokolowski MB, Campos AR. 1995. Characterization and genetic analysis of *Drosophila melanogaster* photobehavior during larval development. *Journal of Neurogenetics* **10**:119-135. doi: 10.3109/01677069509083459.

Schöne H. 1984. *Spatial orientation: the spatial control of behavior in animals and man*. Princeton, NJ: Princeton University Press.

Singer A, Schuss Z, Osipov A, Holcman D. 2008. Partially reflected diffusion. *SIAM Journal on Applied Mathematics* **68**:844-868. doi: 10.1137/060663258.

Singleton K, Woodruff RI. 1994. The osmolarity of adult Drosophila hemolymph and its effect on oocyte-nurse cell electrical polarity. *Developmental biology* **161.1**:154-167. doi: 10.1006/dbio.1994.1017.

Smear M, Shusterman R, O'Connor R, Bozza T, Rinberg D. 2011. Perception of sniff phase in mouse olfaction. *Nature* **479**:397-400. doi: 10.1038/nature10521.

Song Z, Postma M, Billings SA, Coca D, Hardie RC, Juusola M. 2012. Stochastic, adaptive sampling of information by microvilli in fly photoreceptors. *Current Biology* **22**:1371-1380. doi: 10.1016/j.cub.2012.05.047.

Suh GS, Ben-Tabou de Leon S, Tanimoto H, Fiala A, Benzer S, Anderson DJ. 2007. Light activation of an innate olfactory avoidance response in *Drosophila*. *Current Biology* **17**:905-908. doi: 10.1016/j.cub.2007.04.046.

Suzuki H, Thiele TR, Faumont S, Ezcurra M, Lockery SR, Schafer WR. 2008. Functional asymmetry in *Caenorhabditis elegans* taste neurons and its computational role in chemotaxis. *Nature* **454**:114-117. doi: 10.1038/nature06927.
Szyszka P, Gerkin RC, Galizia CG, Smith BH. 2014. High-speed odor transduction and pulse tracking by insect olfactory receptor neurons. *Proceedings of the National Academy of Sciences of USA* **111**:16925-16930. doi: 10.1073/pnas.1412051111.

Tichy H, Hinterwirth A, Gingl E. 2005. Olfactory receptors on the cockroach antenna signal odour ON and odour OFF by excitation. *The European Journal of Neuroscience* **22**:3147-3160. doi: 10.1111/j.1460-9568.2005.04501.x.

Tu Y, Shimizu TS, Berg HC. 2008. Modeling the chemotactic response of *Escherichia coli* to time-varying stimuli. *Proceedings of the National Academy of Sciences of USA* **105**:14855-14860. doi: 10.1073/pnas.0807569105.

Uchida N, Poo C, Haddad R. 2014. Coding and transformations in the olfactory system. *Annual Review of Neuroscience* **37**:363-385. doi: 10.1146/annurev-neuro-071013-013941.

van Breugel F, Dickinson MH. 2014. Plume-tracking behavior of flying *Drosophila* emerges from a set of distinct sensory-motor reflexes. *Current Biology* **24**:274-286. doi: 10.1016/j.cub.2013.12.023.

Vosshall LB, Stocker RF. 2007. Molecular architecture of smell and taste in *Drosophila*. *Annual Review of Neuroscience* **30**:505-533. doi: 10.1146/annurev.neuro.30.051606.094306.

Webb B. 2002. Robots in invertebrate neuroscience. *Nature* **417**:359-363. doi: 10.1038/417359a.

Wilson RI. 2013. Early olfactory processing in *Drosophila*: mechanisms and principles. *Annual Review of Neuroscience* **36**:217-241. doi: 10.1146/annurev-neuro-062111-150533.

Wilson RI, Mainen ZF. 2006. Early events in olfactory processing. *Annual Review of Neuroscience* **29**:163-201. doi: 10.1146/annurev.neuro.29.051605.112950.

Xiang Y, Yuan Q, Vogt N, Looger LL, Jan LY, Jan YN. 2010. Light-avoidance-mediating photoreceptors tile the *Drosophila* larval body wall. *Nature* **468**:921-926. doi: 10.1038/nature09576.

Yao Z, Macara AM, Lelito KR, Minosyan TY, Shafer OT. 2012. Analysis of functional neuronal connectivity in the *Drosophila* brain. *Journal of Neurophysiology* **108**:684-696. doi: 10.1152/jn.00110.2012.

Yi TM, Huang Y, Simon MI, Doyle J. 2000. Robust perfect adaptation in bacterial chemotaxis through integral feedback control. *Proceedings of the National Academy of Sciences of USA* **97**:4649-4653. doi: 10.1073/pnas.97.9.4649.