Elementary sensory-motor transformations underlying olfactory navigation in walking fruit-flies

Odor attraction in walking Drosophila melanogaster is commonly used to relate neural function to behavior, but the algorithms underlying attraction are unclear. Here, we develop a high-throughput assay to measure olfactory behavior in response to well-controlled sensory stimuli. We show that odor evokes two behaviors: an upwind run during odor (ON response), and a local search at odor offset (OFF response). Wind orientation requires antennal mechanoreceptors, but search is driven solely by odor. Using dynamic odor stimuli, we measure the dependence of these two behaviors on odor intensity and history. Based on these data, we develop a navigation model that recapitulates the behavior of flies in our apparatus, and generates realistic trajectories when run in a turbulent boundary layer plume. The ability to parse olfactory navigation into quantifiable elementary sensori-motor transformations provides a foundation for dissecting neural circuits that govern olfactory behavior.


Introduction
Fruit-flies, like many animals, are adept at using olfactory cues to navigate toward a source of food. Because of the genetic tools available in this organism, Drosophila melanogaster has emerged as a leading model for understanding how neural circuits generate behavior. Olfactory behaviors in walking flies lie at the heart of many studies of sensory processing (Root et al., 2008;Su et al., 2012), learning and memory (Aso et al., 2014;Owald et al., 2015), and the neural basis of hunger (Root et al., 2011;Tsao et al., 2018). However, the precise algorithms by which walking flies locate an odor source are not clear.
Algorithms for olfactory navigation have been studied in a number of species, and can be broadly divided into two classes, depending on whether the organisms typically search in a laminar environment or in a turbulent environment. In laminar environments, odor concentration provides a smooth directional cue that can be used to locate the odor source. Laminar navigators include bacteria (Brown and Berg, 1974), nematodes (Pierce-Shimomura et al., 1999), and Drosophila larvae (Gomez-Marin et al., 2011;Gershow et al., 2012). In each of these organisms, a key computation is detection of temporal changes in odor concentration, which drives changes in the probability of re-orientation behaviors. In turbulent environments, odors are transported by the instantaneous structure of air or water currents, forming plumes with complex spatial and temporal structure (Crimaldi and Koseff, 2001;Crimaldi et al., 2002;Webster and Weissburg, 2001). Within a turbulent plume, odor fluctuates continuously, meaning that instantaneous concentration gradients do not provide simple information about the direction of the source . Navigation in turbulent environments has been studied most extensively in moths (Kennedy and Marsh, 1974;David et al., 1983;Baker, 1990;Kuenen and Carde, 1994;Rutkowski et al., 2009) but has also been investigated in flying adult Drosophila (van Breugel and Dickinson, 2014) and marine plankton (Page et al., 2011). In these organisms, the onset or presence of odor drives upwind or upstream orientation, while loss of odor drives casting orthogonal to the direction of flow. An important distinction between laminar and turbulent navigation algorithms is that the former depend only on the dynamics of odor concentration, while the latter rely also on measurements of flow direction derived from mechanosensation or optic flow (Cardé and Willis, 2008). Also unclear is the role of temporal cues in turbulent navigation. Several studies have suggested that precise timing information about plume fluctuations might be important for navigation (Baker, 1990;Mafra-Neto and Cardé, 1994), or that algorithms keeping track of the detailed history of odor encounters may promote chemotaxis (Vergassola et al., 2007), but the relationship between odor dynamics and olfactory behaviors has been challenging to measure experimentally (Pang et al., 2018).
In comparison to these studies, olfactory navigation in walking flies has not been studied as quantitatively. A walking fly in nature will encounter an odor plume that is developing close to a solid boundary. Such plumes are broader, exhibit slower fluctuations, and allow odor to persist further downwind from the source, compared to the airborne plumes encountered by flying organisms (Crimaldi and Koseff, 2001;Crimaldi et al., 2002;Webster and Weissburg, 2001). Navigational strategies in these two environments might therefore be different. In laboratory studies, walking flies have been shown to turn upwind when encountering an attractive odor (Flügge, 1934;Steck et al., 2012), and downwind when odor is lost (Bell and Wilson, 2016). However, flies can also stay within an odorized region when wind cues provide no direction information, by modulating multiple parameters of their locomotion (Jung et al., 2015). Finally, walking flies have been shown to turn towards the antenna that receives a higher odor concentration (Borst and Heisenberg, 1982;Gaudry et al., eLife digest All kinds of animals use their sense of smell to find things. Doing this is difficult because odors in air travel as plumes, which meander downwind and break apart. Scientists are interested in learning the rules that animals use to decipher these odor signals and trace them back to their source. For example, do animals use patterns of timing in the odor, differences between smell at the two nostrils, or the direction of the wind? Scientists would also like to know how animal's brain circuits decipher this information.
Tiny fruit flies make a good model for studying the way animals detect odors because scientists have already learned a great deal about how their brains work. There are also many tools available to help scientists study the brain circuits of fruit flies. Now, Á lvarez-Salvado et al. show that fruit flies use multiple senses to track odors to their source. In the experiments, fruit flies that were blind and could not fly were placed in tiny wind tunnels and their behavior in response to a smell or no smell in the tunnel was carefully documented. When the flies detected an odor, they turned to face the wind using their antennae to detect wind direction and run toward it. When flies lost track of an odor they began to search for it at the spot where they last smelled it. Next, Á lvarez-Salvado et al. created a computer model that recreated the flies' behavior and was able to find the odor source as well as real flies. The model added together these basic behaviors to successfully recreate the flies' odor-search strategy.
Other animals are often better than humans at finding odor sources. As a result, people use pigs to find truffles and dogs to find lost hikers. The computer model Á lvarez-Salvado et al. developed might help design robots that can search for truffles, hikers, or landmines, without risking the lives of animals. It might also be useful for designing autonomous vehicles that must respond to many types of information in changing environments to make decisions. 2013). It is not clear how these diverse motor programs work together to promote navigation toward an attractive odor source in complex natural environments.
Here, we set out to define elementary sensory-motor transformations that underlie olfactory navigation in walking fruit flies. To this end, we designed a miniature wind-tunnel paradigm that allows us to precisely control the wind and odor stimuli delivered to freely walking flies. Using this paradigm, we show that flies, like other organisms, navigate through distinct behavioral responses to the presence and loss of odor. During odor, flies increase their ground speed and orient upwind. Following odor loss, they reduce their ground speed and increase their rate of turning. By blocking antennal wind sensation, we show that mechanosensation is required for the directional components of these behaviors, while olfaction is sufficient to induce changes in ground speed and turning. This implies that olfactory navigation is driven by both multi-modal and unimodal sensori-motor transformations. We next used an array of well-controlled dynamic stimuli to define the temporal features of odor stimuli that drive upwind orientation and turn probability. We find that behavioral responses to odor are significantly slower than peripheral sensory encoding, and are driven by an integration of odor information over several hundred milliseconds (for upwind orientation) and several seconds (for turn probability).
To understand how these elementary responses might promote navigation in a complex environment, we developed a simple computational model of how odor dynamics and wind direction influence changes in forward and angular velocity. We show that this model can recapitulate the mean behavior of flies responding to a pulse stimulus, as well as the variability in response types observed across flies. Finally, we examine the behavior of our model in a turbulent odor plume measured experimentally in air, finding that its performance is comparable to that of real flies in the same environment. These simulations suggest that integration over time may be a useful computational strategy for navigating in a boundary layer plume, allowing flies to head upwind more continuously in the face of odor fluctuations, and to generate re-orientations clustered at the plume edges. Moreover, they suggest that multiple independent forms of sensing -flow sensing, temporal sensing, and spatial sensing-can work cooperatively to promote attraction to an odor source. Our description of olfactory navigation algorithms in walking flies, and the resulting computational model, provide a quantitative framework for analyzing how specific sensory-motor transformations contribute to odor attraction in a complex environment, and will facilitate the dissection of neural circuits contributing to olfactory behavior.

ON and OFF responses to odor in a miniature wind-tunnel paradigm
To investigate the specific responses underlying olfactory navigation, we developed a miniature wind-tunnel apparatus in which we could present well-controlled wind and odor stimuli to walking flies ( Figure 1A and B and Materials and methods). Flies were placed in rectangular arenas, where they were exposed to a constant flow of filtered, humidified air, defining the wind direction. Into this airflow we injected pulses of odor with rapid onset and offset kinetics, producing a front of odor that was transported down the arena at 11.9 cm/s. The time courses of odor concentration and air speed inside the behavioral arena were measured using a photo-ionization detector (PID) and an anemometer ( Figure 1E ). Because flies were free to move about the chamber, and because the odor from takes about 1 s to advect down the arena, flies encountered and lost the odor at slightly different times. We therefore used PID measurements made a several locations in the arena to warp our behavior data to the exact times of odor onset and offset (see Materials and methods, Figure 1-figure supplement 1). We used genetically blind flies (norpA 36 mutants) in order to remove any possible contribution of visual responses. Flies were starved 5 hr prior to the experiment, and were tested for approximately 2 hr (from ZT 2-4), in a series of 70 second-long trials with blank (wind only) and odor trials randomly interleaved.
We observed that in the presence of 10% apple cider vinegar (ACV), flies oriented upwind, and moved faster and straighter ( Figure 1C, magenta traces). This 'ON' response peaked 4.4AE2.5 s after odor onset, but remained as long as odor was present. Following odor offset, flies exhibited more tortuous and localized trajectories ( Figure 1C, cyan traces). This 'OFF' response resembles local search behavior observed in other insects , and persisted for tens of seconds . Traces are color coded as in C. Gray-shaded area: odor stimulation period (ACV 10%). All traces warped to estimated time of odor encounter and loss prior to averaging. Small deflections in ground speed near the time of odor onset and offset represent a brief stop response to the click of the odor valves (see Figure 3-figure supplement 1). (G) Average values of motor parameters in F for each fly for periods before (À30 to 0 s), during (2 to 3 s) and after (11 to 13 s) the odor. Gray lines: data from individual flies. Black lines: group average. Horizontal lines with asterisk: Figure 1 continued on next page after odor offset. These two responses are usually readily perceptible and distinguishable by observing the movements of flies during an odor pulse ( Figure 1C, Video 1). On trials without odor, flies tended to aggregate at the downwind end of the arena ( Figure 1D).
To analyze these responses quantitatively, we first noted that flies alternated between periods of movement and periods of immobility ( Figure 3-figure supplement 1A-B). To focus on the active responses of flies, we considered in our analyses only those periods in which flies were moving, and we established a threshold of 1 mm/s below which flies were considered to be stationary (see Materials and methods). Then, we analyzed how flies' movements changed in response to an odor pulse by extracting a series of motor parameters ( Figure 1F, see Materials and methods). We computed each measure both as a function of time ( Figure 1F) and on a fly-by-fly basis for specific time intervals before, during, and after the odor presentation ( Figure 1G).
During odor presentation, upwind velocity (i.e. speed of flies along the longitudinal axis of the arenas) and ground speed both increased significantly, while angular velocity and curvature (i.e. ratio between angular velocity and ground speed) decreased after an initial peak. This resulted in the straighter trajectories observed during odor; the initial peak observed in angular velocity and curvature corresponds to big turns performed by flies to orient upwind after odor onset. Following odor offset, angular velocity increased, while ground speed decreased, resulting in the increased curvature characteristic of local search ( Figure 1F,G). Since an increase in probability of reorientation has been traditionally identified as a hallmark of localized search (Brown and Berg, 1974;Pierce-Shimomura et al., 1999;Gomez-Marin et al., 2011;Gershow et al., 2012), we calculated the turn probability of flies in our arena as a binarized version of curvature around a threshold of 20 deg/mm. Indeed, turn probability increased as well after odor offset ( Figure 1F,G). Upwind velocity also became negative after odor offset, although this response was weaker than the upwind orientation during odor, and peaked later than the changes in ground speed and curvature.
Although most of the flies we tested showed ON and OFF responses as described above, we observed considerable variability between individuals ( Figure 1-figure supplement 2). Individuals varied in the strength of their odor responses, with some flies exhibiting strong upwind orientation and search, while others showed little odor-evoked modulation of behavior (Figure 1-figure supplement 2A-C). Motor parameters from the same individual in different trials were correlated, whereas parameters randomly selected from different individuals were Video 1. Behavior of four flies in response to an ACV 10% pulse. The time of the odor stimulus is signaled by the green dot appearing at the top of the image. Flies start to move upwind shortly after the start of the stimulus (partly due to the time it takes for the odor front to reach their respective positions), and they stop advancing upwind after the odor is gone and engage in a more localized search behavior. Air and odor move from the top of the image towards the bottom at 11.9 cm/s. DOI: https://doi.org/10.7554/eLife.37815.007 not ( Figure 1-figure supplement 2D). Thus, the movement parameters of the 'average fly' depicted in Figure 1 underestimate the range of search behaviors shown by individuals, with particular flies exhibiting both much stronger and much weaker ON and OFF responses. There was a slight tendency for responses to be weaker during the first few trials; afterwards, this behavior was stable (on average) across the entire experimental session (Figure 1-figure supplement 2F). Sighted flies of the same genetic background also showed ON and OFF responses (Figure 1-figure supplement 3), with increases in upwind velocity and ground speed during odor, and increases in angular velocity and decreased ground speed after odor offset. However, the increase in angular velocity appeared to be weaker, on average, in these flies.
Together, these data indicate that apple cider vinegar drives two distinct behavioral responses: an ON response consisting of upwind orientation coupled with faster and straighter trajectories, and an OFF response consisting of slower and more curved trajectories.

Local search is driven purely by odor dynamics
We next asked whether any change in behavior could be produced by odor in the absence of wind information. Previous studies have found that optogenetic activation of orco + neurons did not elicit attraction (Suh et al., 2007), unless wind was present (Bell and Wilson, 2016). However, modulation of gait parameters by odor has also been observed when the wind is directed perpendicular to the plane of the arena (Jung et al., 2015). To ask whether walking flies could respond to odor in the absence of wind, we stabilized the third segment of the antennae using a small drop of UV glue. Fruit flies sense wind direction using stretch receptors that detect rotations of the third antennal segment (Yorozu et al., 2009). This manipulation therefore renders flies 'wind-blind' (Budick et al., 2007;Bhandawat et al., 2010).
We found that wind-blind flies showed severely impaired directional responses to odor and wind. Upwind velocity was not significantly modulated either during the odor or after (Figure 2A-B, top). Indeed, odor-induced runs in different directions (either up-or downwind or sideways) could be observed in individual trajectories ( Figure 2C). In addition, the downwind positional bias seen in the absence of odor was reduced ( Figure 2D). The average arena position of wind-blind flies on noodor trials was no different from that of intact flies in the absence of wind ( Figure 2D). Thus, antennal wind sensors are critical for the oriented components of olfactory search behavior.
However, wind-blind flies still responded to odor by modulating their ground speed and angular velocity. Wind-blind flies increased their curvature after odor offset and also increased their ground speed during odor ( Figure 2B). These changes can be seen in the examples shown in Figure 2C, where flies adopt somewhat straighter trajectories during odor, and exhibit local search behavior following odor offset. These results imply that odor can directly modulate gait parameters to influence navigation in the absence of wind. Together these experiments show that olfactory navigation depends both on multimodal processing (odor-gated upwind orientation), and on direct transformation of odor signals into changes in ground speed and curvature.

ON and OFF responses to dynamic stimuli
Because natural odor stimuli are highly dynamic, we next asked what features of the odor signal drive ON and OFF responses. To address this question, we presented flies with a variety of dynamically modulated stimuli. We focused our analysis on upwind velocity and turn probability, as measures of the ON and OFF response, respectively, as these parameters provided the highest signal-tonoise ratio.
We first looked at how ON and OFF behaviors depended on the concentration of the odor stimulus. In these experiments, different groups of flies were exposed to square pulses of apple cider vinegar at dilutions of 0.01%, 0.1%, 1% and 10% ( Figure 3A-B). We found that both upwind velocity during odor and turn probability after offset grew with increasing odor concentration between 0.01% and 1%, but saturated or even decreased at 10% ( Figure 3A-B). These responses were well fit by a Hill function with a dissociation constant k d of 0.072% (for ON) and and 0.127% (for OFF; Figure 3A and B, left and right insets). The fitted Hill coefficient was very close to 1 (1.03 for ON and 1.06 for OFF). A saturating Hill function nonlinearity is to be expected from odor transduction kinetics, and has been found to describe encoding of odor stimuli by peripheral olfactory receptor neurons (Kaissling et al., 1987;Nagel and Wilson, 2011;Gorur-Shandilya et al., 2017;Schulze et al., 2015), and central olfactory projection neurons (Olsen et al., 2010). A decrease in response at the highest intensities could arise from inhibitory glomeruli that are recruited at higher odor intensity, as has been described in Semmelhack and Wang, 2009).
We next wondered whether OFF behaviors could be elicited by gradual decreases in odor concentration, as turning behavior in gradient navigators is sensitive to the slope of odor concentration (Brown and Berg, 1974;Pierce-Shimomura et al., 1999). To perform this experiment, we used proportional valves to deliver a pulse of saturating concentration (10% ACV), that then decreased linearly over a period of 2.5, 5 or 10 s ( Figure 3C-D, Materials and methods). We observed that turn  Figure 1G). Gray lines: data from individual wind-blind flies. Orange lines: group average. Horizontal lines with asterisk: statistically significant changes in a Wilcoxon signed rank paired test after correction for multiple comparisons using the Bonferroni method (see Materials and methods for p values). n.s.: not significant. (C) Example trajectories of three different wind-blind flies before (black), during (magenta) and after (cyan) the odor pulse. Note different orientations relative to wind during the odor. (D) Antenna stabilization decreases preference for the downwind end of the arena on trials with wind and no odor. Blue: average (AESEM) arena position of sham-treated flies on trials with wind and no odor. Orange: average position of wind-blind flies in the same stimulus condition. Black: Average position of intact (not-treated) flies in the absence of both odor and wind (n = 23 flies, 1004 trials). The average arena position of wind-blind flies did not differ significantly from that of no-wind flies (p=0.93). Sham-treated flies spent significantly more time downwind than wind-blind (p=0.04) or intact flies in the absence of wind (p=0.0027). Horizontal lines with asterisk: statistically significant changes in a Wilcoxon rank sum test (alpha = 0.05). n.s.: non-significant. Black lines between C and D provided for reference of dimensions in D. DOI: https://doi.org/10.7554/eLife.37815.008 . Left-bottom traces show PID measurements using ethanol (max concentration 10%), normalized to maximal amplitude. Right inset: mean upwind velocity during odor (2 to 3 s) as a function of odor concentration (black; meanAESEM), and fitted Hill function (green; green dot: k d =0.072%). (B) Turn probability calculated from the same data. Right inset black traces: mean turn probability after odor (11 to 13 s). k d =0.127% for fitted Hill function (green). (C) Upwind velocity (averageAESEM) in response to stimuli with off-ramps of 2.5 (n = 38 flies, 528 trials), 5 (n = 38 flies, 567 trials) and 10 (n = 35 flies, 557 trials) seconds duration. Bottom traces: PID signals of the same stimuli using ethanol. (D) Same as C, showing turn probability from the same data sets. White arrows in C and D show elevated upwind velocity and turn probability that co-occur during a slow off-ramp. Black arrow in D: peak turn probability response at the foot of the off-ramp. (E) Upwind velocity (meanAESEM; n = 31 flies, 346 trials) in response to an ascending frequency sweep stimulus. Bottom trace: PID signal of the stimulus, measured using ethanol. Right inset: average (AESEM) modulation of upwind velocity as a function of frequency in each stimulus cycle (see Materials and methods). (F) Same as E for turn probability calculated from the same data. Right inset: modulation of turn probability as a function of frequency. (G) Equivalent to E, showing responses to a descending frequency Figure 3 continued on next page probability began to grow gradually as soon as the odor concentration started to decrease ( Figure 3D, white arrow), but peaked close to the point where the linear off ramp returned to baseline (black arrow). This result suggests some form of sensitivity adaptation, that allows the fly to respond to a small decrease from a saturating concentration of odor. We also noted that upwind velocity remained positive during these ramps ( Figure 3C, white arrow), suggesting that ON and OFF responses can be driven -at least partially-at the same time.
Finally, we wished to gauge the ability of flies to follow rapid fluctuations in odor concentration, as occurs in real odor plumes. Indeed, olfactory receptor neurons can follow odor fluctuations up to 10-20 Hz (Nagel and Wilson, 2011;Kim et al., 2011), and these rapid responses have been hypothesized to be critical for navigation in odor plumes (Nagel and Wilson, 2011;Gorur-Shandilya et al., 2017). To test the behavioral response of flies to rapid odor fluctuations, we used proportional valves to create ascending and descending frequency sweeps of 10% ACV between approximately 0.1 and 1 Hz ( Figure 3E-H). The peak frequency we could present was limited to 1 Hz, as we found that frequencies higher than this became attenuated at the downwind end of the arena, presumably because odor diffuses as it is transported downwind, blurring the differences between peaks and troughs in the stimulus (see Materials and methods). In addition, we presented a 'plume walk': an odor waveform created by taking an upwind trajectory at fly pace through a boundary layer plume measured using planar laser imaging fluorescence (PLIF; Figure 3I-J, see Materials and methods, Connor et al., 2018).
As in previous experiments, we warped all behavioral data to account for the fact that flies encounter the odor fluctuations at different times depending on their position in the arena (Figure 1-figure supplement 1 and Materials and methods). In addition, we excluded behavioral data points within 3 mm of the side walls, where boundary layer effects would cause slower propagation of the stimulus waveform. We also excluded responses occurring after each fly reached the upwind end of the arena, where arena geometry would constrain their direction of movement. The resulting traces represent our best estimate of the time courses of behavioral parameters (Figure 3-figure supplement 1), although we cannot completely rule out some contribution of odor diffusion or arena geometry.
We found that upwind velocity tracked odor fluctuations at the lowest frequencies, but that modulation became attenuated at higher frequencies (end of the ascending frequency sweep and start of the descending frequency sweep; Figure 3E and G), suggesting low-pass filtering of the odor signal. Similarly, upwind velocity peaked in response to nearly every fluctuation in the 'plume walk', but remained elevated during clusters of odor fluctuations ( Figure 3I). The frequency-dependent attenuation was seen in both ascending and descending frequency sweeps, arguing against it being an effect of position in the arena, or duration of exposure to odor. Attenuation was not due to the filter imposed on trajectories during processing, as it was visible also when this filtering step was omitted (Figure 3-figure supplement 1C-D). We think it is also unlikely to be due to a limit on our ability to measure fast behavior reactions. We observed rapid decreases in ground speed in response to click stimuli that did not attenuate at higher frequencies ( Figure 3-figure supplement 1C,F), arguing that the attenuation seen with odor does not reflect a limit on detecting rapid behavioral responses. Turn probability at offset showed even stronger evidence of low-pass filtering. Fluctuations in turn probability were attenuated during the higher frequencies of both frequency sweeps, and the strongest responses occurred at the end of the stimulus to the absence of odor ( Figure 3F, H,J). The initial peaks in turn probability most likely represent the initial upwind turn, rather than an OFF response. Together these experiments provide detailed measurements of the way that ON and OFF behaviors depend on the history of odor encounters. Moreover, they suggest that the two responses depend on odor history in different ways, with rapid fluctuations leading to elevated ON responses and suppressed OFF responses.

Phenomenological models of ON and OFF responses
We next sought to develop computational models that could account for the behavioral dynamics described above. A challenge was that behavioral responses saturated at concentrations above 1% ACV, and they were also modulated by small decreases and fluctuations from a higher concentration (10%). This suggests some form of adaptation, in which the sensitivity of behavior to odorant shifts over time, allowing responses to occur near what was previously a saturating concentration. Sensitivity adaptation has been described at the level of olfactory receptor neuron transduction and can be implemented as a slow rightward shift in the Hill function that describes intensity encoding (Kaissling et al., 1987;Nagel and Wilson, 2011;Gorur-Shandilya et al., 2017). We therefore modeled adaptation by filtering the odor waveform with a long time constant t A and using the resulting signal to dynamically shift the midpoint of the Hill function to the right (see Materials and methods). The baseline k d of the Hill function was taken from the fits in Figure 3A and B. We call this process 'adaptive compression' ( Figure 4A) as it both compresses the dynamic range of the odor signal (from orders of magnitude to a linear scale), and adaptively moves the linear part of this function to the mean of the stimulus. We then tested four models for the ON response: one with adaptive compression followed by a low-pass filter ('ACF'), one with filtering followed by adaptive compression ('FAC'), and the same models without adaptation ('CF' and 'FC' respectively). We note that the FC model, with filtering followed by a fixed nonlinearity, is most similar to traditional linear-nonlinear models. For simplicity, we parameterized the low-pass filter by a single time constant t ON , that describes the amount of smoothing seen in the response (Materials and methods).
We first fit models of the ON response to all upwind velocities shown in Figure 3, omitting and reserving the 'plume walk' stimulus to use as a test. We found that both models with adaptation performed better than models without, and that the model with adaptive compression first ('ACF', Figure 4A) outperformed the adaptive model with filtering first ('FAC', Figure 4B). As shown in Figure 4C, model ACF correctly predicted saturation with increasing odor concentration, and also the fact that responses to high odor concentrations exhibit adaptation while those to low odor concentrations do not. This model also correctly predicted the attenuation seen during frequency sweeps ( Figure 4D and E), although some details of response timing early in the stimulus were not matched. We note that behavioral responses used for fitting were recorded in three different experiments with different sets of flies, and we used a single set of parameters to fit all responses; some differences between real and predicted response (for example the timing of response onset in Figure 3D and E vs C) may reflect differences in responses across experiments. The time constant of filtering was 0.72 s (see Table 1), significantly slower than encoding in peripheral ORNs (Kim et al., 2011;Nagel and Wilson, 2011). The time constant of adaptation was very slow (9.8 s). Models without adaptation (pink trace in Figure 4D-E) exhibited strong saturation during the frequency sweep, which was not observed experimentally.
We next fit the OFF response using four related models. In this case, the adaptive compression step was the same, but we used a differentiating filter instead of a low-pass filter, to generate responses when the odor concentration decreases from a previously high level. This filter was parameterized by two time constants, t OFF1 and t OFF2 , that describe the time intervals over which the current and past odor concentrations are measured ( Figure 4F, Materials and methods). Again we found that models with adaptation outperformed those without, and that the adaptive model with compression first very slightly outperformed the adaptive model with filtering first ( Figure 4G). This model reproduced reasonably well the responses of flies to odor ramps ( Figure 4H). The slow time constant of filtering was 4.84 s, accounting for the selectivity of the OFF response to low frequencies during frequency sweeps ( Figure 4I and J). The time constant of adaptation was of similar magnitude to that derived from fitting the ON response (10.62 s).
To further assess the best-performing ON and OFF models (those with adaptive compression followed by filtering), we tested the performance of these models on the 'plume walk' stimulus. We found that the ON model reproduced most major contours in the 'plume walk' response ( Figure 4K), although there was some discrepancy in the timing of peaks early in the response as for  Figure 3A) and predictions of the ACF ON model (top thicker traces) to square pulses of ACV at different concentrations. Bottom traces: stimuli, normalized to maximal amplitude. Note that adaptation appears only at higher concentrations and that responses saturate between 1% and 10% ACV. (D) Upwind velocity of real flies (top black trace; average; same data in Figure 3E), and predictions of ACF (red) and CF (pink) ON models to an ascending frequency sweep. Bottom trace: stimulus. Note that the model without adaptation (CF) exhibits saturation not seen in the data. (E) Same as D for a descending frequency sweep stimulus (same data in Figure 4 continued on next page the frequency sweeps ( Figure 4D). The OFF model also captured many of the major peaks in the behavioral response ( Figure 4L), as well as the time course of the slow offset response after the end of the stimulus. Overall, the RMSE errors between predictions and data for the plume walks were comparable to those for the stimuli we used for fitting. We conclude that models featuring adaptive compression followed by linear filtering provide a good fit to behavioral dynamics over a wide range of stimuli.

A model of olfactory navigation
To understand how the ON and OFF functions defined above might contribute to odor attraction, we incorporated our ON and OFF models into a simple model of navigation. In our model ( Figure 5A-C), we propose that odor dynamics directly influence ground speed and turn probability through the ON and OFF functions developed and fit above. Specifically, ONðtÞ drives an increase in ground speed and a decrease in turn rate, leading to straight trajectories, while OFFðtÞ drives a decrease in ground speed and an increase in turn rate, leading to local search ( Figure 5B). Ground speed (v) and turn probability (PðtÞ) of our model flies are then defined by (1) Figure 4 continued Figure 3G). (F) OFF model schematic featuring adaptive compression followed by differential filtering. (G) Root mean squared error between predictions of four OFF models and behavioral data. (H) Turn probability of real flies (top thiner traces; average; same data in Figure 3D) and predictions of the ACF OFF model (top thicker traces) to odor ramps of different durations. Bottom traces: stimuli. (I) Turn probability (top black trace; average; same data in Figure 3F), and predictions of ACF OFF model (top red trace) to an ascending frequency sweep. Bottom trace: stimulus. (J) Same as I for a descending frequency sweep stimulus (same data in Figure 3H). (K) Upwind velocity (top black trace; average; same data in Figure 3I), and predictions of ACF ON model to the 'plume walk' stimulus (see Results). Bottom trace: stimulus. RMSE = 1.355. (L) Same as K for the same stimulus, showing turning probability of real flies (top black trace; average; same data in Figure 3J) and predictions of the ACF OFF model (top red trace). Bottom trace: stimulus. RMSE = 0.038. Plume walk responses were not used to fit the models. DOI: https://doi.org/10.7554/eLife.37815.011 Table 1. Values of ON and OFF functions parameters.
Results of fitting the different ON and OFF functions to behavioral data by non-linear regression. Highlighted in green are the models of choice and the parameters that were used in the navigation model and the simulations shown in Figures 5 and 6. t x : different time constants of ON, OFF and adaptation filters. RMSE: root mean squared error between predictions of the models and the corresponding data they were fitted to. Corr.Coef.: Pearson's linear correlation coefficients between predictions of the models and the corresponding data they were fitted to.
where v 0 and P 0 are baseline values extracted from behaving flies ( Figure 1F).
Second, we propose that turning has both a probabilistic component, driven by odor, and a deterministic component, driven by wind. In the absence of any additional information about how these turn signals might be combined, we propose that they are simply summed. To model deterministic wind-guided turns, we constructed a sinusoidal desirability function or 'D-function' which drives right or leftward turning based on the current angle of the wind with respect to the fly. Such functions were originally proposed to explain orientation to visual stripes (Reichardt and Poggio, 1976). In an upwind D-function, wind on the left (denoted by negative values) drives turns to the left (denoted by negative _ values), and vice-versa ( Figure 5C, magenta trace). Conversely, in a downwind D-function, wind on the left drives turns to the right, and vice-versa (black trace). Supporting the notion of a wind direction-based D-function, we found that the average angular velocity as a function of wind direction in the period immediately after odor onset had a strong 'upwind' shape ( Figure 5D, magenta trace), while the angular velocity after odor offset had a weaker 'downwind' shape ( Figure 5D, black trace). In our navigation model, the angular velocity of the fly is then given by where ðtÞ is a binary Poisson variable with rate PðtÞ and G is the distribution of angular velocities drawn from when is 1 (see Materials and methods). This first term generates probabilistic turns whose rate depends on recent odor dynamics. The second term is an upwind D-function, gated by the ON function, that produces strong upwind orientation in the presence of odor. The final term is a constant weak downwind D-function that produces a downwind bias in the absence of odor. This navigation model is parameterized by six coefficients (k 1 -k 6 ) that determine the strength with which the ON and OFF functions modulate ground speed, turn probability, and the drive to turn upor downwind. For example, k 1 determines how much the forward velocity increases when the ON function increases by a specific amount. We first adjusted these parameters so that average motor   Table 2). Similar to real flies, this model produced upwind runs during the odor pulse and searching after odor offset ( Figure 5F). Average upwind velocity during the odor and turn probability after the odor were comparable to measurements from real flies (compare Figure 5G and Figure 1G). As a second test, we set the coefficients controlling wind orientation (k 5 and k 6 ) to zero, making the model fly indifferent to wind direction and mimicking a wind-blind real fly. In this case, the model produced undirected runs during odor and search behavior at odor offset, as in our data (compare Figure 5H-I and Figure 2A-B).
We also asked whether our model could account for variability in behavior seen across flies (Figure 1-figure supplement 2). To address this question, we asked whether differences in behavior could be accounted for by applying fly-specific scale factors to the ON and OFF functions of the model. To define these scale factors, we returned to our main data set ( Figure 1) and computed an ON scale value for each fly equal to its mean upwind velocity, divided by the mean upwind velocity across flies. An OFF scale value was computed similarly by taking the mean turn probability for a fly divided by the mean across flies. This procedure allowed us to express the behavior of each fly as a scaled version of the group average response. Next, keeping all other parameters in our navigation model fixed as previously fitted, we scaled the ON and OFF functions to match the value of individual flies. The trajectories produced by these scaled models resembled the behavior of individual flies both qualitatively and quantitatively. For example, scaling down the ON and OFF functions produced similar behavior to a weak searching fly ( Figure    behavior similar to a strongly-searching fly ( Figure 5K, compare directly to blue-highlighted examples in Figure 1-figure supplement 2A). Together, these results support the idea that our model captures essential features of how flies respond to odor and wind in miniature wind-tunnels, including the responses of intact and windblind flies, and variations in behavior across individuals. Thus, this model provides a basis for examining the predicted behavior of flies in more complex environments.
Behavior of real and model flies in a turbulent environment Finally, we sought to test whether our model could provide insight into the behavior of real flies in more complex odor environments. To that end we constructed two equivalent wind tunnels capable of delivering a turbulent odor plume ( Figure 6A; see Materials and methods). In one tunnel (New York), we incorporated IR lighting below the bed and cameras above it to image fly behavior in response to a turbulent odor plume. In the second tunnel (Colorado), we used a UV laser light sheet and acetone vapor to obtain to high-resolution movies of the plume for use in modeling ( Figure 6B, Connor et al., 2018). These two apparatuses had similar dimensions, and matched odor delivery systems and wind speeds. We used photoionization detector measurements to corroborate that the shape and dynamics of the plume in the New York tunnel was similar to the one measured in Colorado ( Figure 6B).
We next examined the behavior of walking flies in this wind tunnel. Flies were of the same genotype and were prepared for experiments in the same way as those used previously. They were constrained to walk by gluing their wings to their backs with a small drop of UV glue and by placing a 1cm-wide water-filled moat at the edge of the arena.
We first tested flies with wind only (no odor) at 10 cm/s. As in our miniature wind tunnels, we found that flies uniformly preferred the downwind end of the arena ( Figure 6C). In the absence of wind, this preference was reduced ( Figure 6D). We observed no preference for the upwind end of the tunnel (which received greater ambient light from the room) or for the odor tube, confirming that these norpA 36 flies lacked phototaxis and visual object attraction. Finally, we examined behavior in the presence of a plume of ACV 10%, and we observed diverse responses ( Figure 6E). Of 66 flies, 37 (56%) successfully located the odor source, walking upwind and lingering in a small region close to the odor tube ( Figure 6E, left trace). Other flies searched in the middle of the arena without getting close to the source ( Figure 6E, middle trace, 18%), while others headed downwind and remained at the downwind end of the arena ( Figure 6E, right trace, 15%). The rest of the flies (seven flies) either moved very little or moved mostly along the sides of the tunnel.
To compare the performance of our model to the behavior of the flies, we ran simulations with our model using the plume movie measured in the Colorado wind tunnel as a virtual Video 2. Behavior of a model fly navigating an odor plume. The video shows 3 min long trial, sped up four times. The background image represents the odor concentration of the plume (equivalent to Figure 6B) recorded by PLIF in the Colorado wind tunnel (see Materials and methods). The moving dot represents the position of the model fly, with changing colors depending on its current behavior. Magenta dot: ON response is larger than 0.1. Cyan dot: OFF response is larger than 0.05. White circle: no odor-evoked responses. DOI: https://doi.org/10.7554/eLife.37815.016 environment (Video 2). At each time step, we took the odor concentration at the location of the simulated fly and used this to iteratively compute ON and OFF functions and update the fly's position accordingly ( Figure 6F-H). We observed that model flies produced trajectories similar to those of real flies in the wind tunnel. For example, some flies responded to odor with general movement upwind interrupted by occasional excursions out of the plume ( Figure 6F); overall, 66% successfully came within 2 cm of the odor source. Other model flies searched but failed to locate the source (17% of trials; Figure 6H, left trace), while others 'missed' the plume and moved downwind (17% of trials; Figure 6H, right trace). Using a single set of model parameters fit to the mean behavioral responses in Figure 1F, we found that our model yielded a similar -although somewhat highersuccess rate than real flies ( Figure 6I, 66% versus 56% success rate).
Given the large degree of variability in behavior across individuals, we wondered if this variability could account for the difference in success rates between real and model flies. We therefore ran simulations incorporating variability in fly behavior. In each trial of this simulation, we randomly drew a pair of ON and OFF scale values (as described previously) and used it to scale the ON and OFF responses of the model for that trial. Introducing variability in the model decreased the success rate to 45% (Figure 6I), and made it slightly worse than that of real flies in the wind tunnel. This simulation produced 27% 'failed' searches and 28% trials in which flies 'missed' the plume and went downwind.
The simulations described above indicate that the trajectories produced by our model in a turbulent environment are qualitatively similar to those produced by real flies. To gain insight into the roles that ON and OFF behaviors play in this environment, we color-coded model trajectories according to the magnitude of the ON and OFF functions underlying them ( Figure 6F-G). We observed that the ON function was dominant throughout most of the odorized region, while excursions from the plume elicited strong OFF responses that frequently resulted in the model fly reentering the plume. OFF responses were also prominent near the odor source, where they contributed to the model fly lingering as observed in real flies. ON and OFF magnitudes varied over a much smaller range than the range of odor concentrations, suggesting that the adaptive compression we incorporated into the model helps flies to respond behaviorally over a greater distance downwind of the source. Plotting the strengths of both responses as a function of position in an odor plume supported this analysis of individual trajectories ( Figure 6J-K). This analysis showed ON being active in the area within the plume, and more active the closer to the center of the plume ( Figure 6J), where the concentration of odor is higher and intermittency is lower. This suggests that ON responses are responsible for making flies progress within the odor area, allowing them to eventually reach the odor source. The OFF function was most active in the area surrounding the odor plume ( Figure 6K), suggesting it plays a role in relocating the plume after flies walk outside of it and the odor signal is lost. OFF values were also high just upwind of the source. Notably, OFF values were generally low within the plume, even though large fluctuations do occur within this region. This suggests that the slow integration time of the OFF response may help it to detect the edges of the time-averaged plume, allowing flies to slow down and search only when the plume has genuinely been exited.
To assess the relative role of ON and OFF functions in promoting source localization, we ran a series of simulations in an odor plume (500 trials each), systematically changing the scaling factors of the ON and OFF functions ( Figure 6L). We observed that performance increased with both functions, but that ON was more critical for success in the plume, producing large improvements in performance as it increased. This is consistent with the idea that wind direction is a highly reliable cue in this environment (indeed, it is likely more reliable in our model than in reality, as we did not incorporate local variations in flow induced by turbulence into our model). To test the idea that ON and OFF might have different importance in a windless environment, we repeated the analysis just described in a simulated Gaussian odor gradient with no wind ( Figure 6M). In this environment, success rates were lower, but the contributions of ON and OFF were more similar, with higher success rates when the OFF function was the strongest for any given strength of the ON function. These results suggest that ON and OFF responses have different impact on success depending on the features of the environment.

Role of spatial comparisons in plume navigation
In addition to the ON and OFF functions described here, walking Drosophila have also been shown to perform spatial comparisons across their antennae, and to turn toward the antenna that receives a higher odor concentration (Borst and Heisenberg, 1982;Gaudry et al., 2013). Such turns can be produced using optogenetic activation of olfactory receptor neurons in one antenna, arguing that they are independent of wind sensing (Gaudry et al., 2013). Because the fly's antennae are located so close to one another, and because it has been unclear what kind of spatial information a plume provides, the role of these spatial comparisons in plume navigation has been questioned (Borst and Heisenberg, 1982). To ask whether such comparisons could contribute to source finding in the boundary layer plume that we measured, we incorporated a fourth term into the total angular velocity in our model: Here, C l and C r represent the odor concentrations at the left and right antennae, processed by the same adaptive compression function used previously (see Materials and methods). The left antenna was taken to be at the position of the fly, and the right antenna was taken to be one pixel (740 m) to the right. The results of these simulations depended heavily on the choice of gain k 7 . Based on the results of (Borst and Heisenberg, 1982) and (Gaudry et al., 2013), we estimated a gain of approximately 40 deg/s when the concentration difference between the two antennae is maximal. In this case, spatial comparisons did not contribute significantly to the probability of successfully finding the source ( Figure 7A-C). However, if we increased the gain to 300 deg/s, we found that performance of the model improved significantly, from 67% to 76%. Under these conditions, trajectories remained closer to the center of the plume and were less dispersed around the source ( Figure 7A-B, third column). We observed a contrary phenomenon when we switched the position of the antennae in the model, so that information from the right side was interpreted as left, and vice-versa. This made model flies more prone to leave the area of the plume and wander off, decreasing their success rate to 54% ( Figure 7A-C, fourth column). In the absence of wind sensation, flies performing a correct bilateral comparison were unable to locate the odor source ( Figure 7A-C, fifth column). These results argue that nearby locations in the plume contain information that can be used to aid navigation (if the gain is high enough), but that this information is insufficient to find the odor source in the absence of wind.
To explore how performance depended on the interaction of wind sensation and spatial sensing, we varied the strength of these two behavioral components ( Figure 7D). This analysis showed that some wind sensing is absolutely required to find the odor source, as almost no flies find the source when the wind coefficients are set to zero. However, in the presence of wind, bilateral sensing, controlled by k 7 , improves performance, with the greatest improvements coming at the highest gain. Thus, although the contributions of wind sensing and bilateral sensing sum linearly to control angular velocity in our model, their effects on finding the source are nonlinear, presumably because of the structure of the plume itself.
In addition, we asked whether both temporal sensing and spatial sensing contribute to performance in the plume. To do this, we varied the magnitude of the OFF response and the gain of bilateral sensing ( Figure 7E), while keeping the strength of wind sensation constant. In this case, we observed that both components contributed to increased performance. This is consistent with our observations of model trajectories, which suggest that the OFF response and bilateral sensing work together to help reorient model flies into the plume when they wander out of it.
Together these results suggest that three different forms of sensation-flow sensing (wind), temporal sensing (OFF response), and spatial sensing (bilateral comparisons)-can all contribute to finding an odor source, but that the precise contribution of each mechanism depends both on the environment and on the gain or sensitivity of the animal to each measurement. These data support the idea that olfactory navigation in complex environments can be decomposed into several largely independent sensori-motor transformations and provide a foundation for investigating the neural basis of these components.  Figure 6). In the second and third simulations, a bilateral component was added to total angular velocity with gain values ðk 7 Þ of 40 and 300 deg/s, respectively. In the fourth simulation, all components of the model were active, but the information from the antennae was swapped -left was interpreted as right, and vice-versa. In the fifth simulation, wind sensation was turned off. Trajectories' colors show times when ON > 0.1 (magenta) or OFF >0.05 (cyan). Dashed gray lines: area of odor plume data (outside this area odor concentration is zero). A larger area is shown to display the behavior more clearly. Green circle: area of 2 cm around the odor source, used to define success in trials.

Quantitative measurement of olfactory attraction behavior in adult fruit-flies
The ability to navigate toward attractive odors is widespread throughout the animal kingdom and is critical for locating both food and mates (Bell and Tobin, 1982). Taxis toward attractive odors is found even in organisms without brains, such as E. coli, and is achieved by using activation of a receptor complex to control the rate of random re-orientation events, called tumbles or twiddles (Falke et al., 1997). Precise quantification of the behavior elicited by controlled chemical stimuli has been critical to the dissection of neural circuits underlying navigation in gradient navigators such as C. elegans (Gray et al., 2005) and Drosophila larvae (Tastekin et al., 2015).
Larger organisms that navigate in air or water face fundamentally different problems in locating odor sources (Cardé and Willis, 2008;Murlis et al., 1992). Odors in open air are turbulent. Within a plume, odor concentration at a single location fluctuates over time, and local concentration gradients often do not point toward the odor source (Crimaldi and Koseff, 2001;Webster and Weissburg, 2001). To solve the problem of navigating in turbulence, many organisms have evolved strategies of combining odor information with flow information. For example, flying moths and flies orient upwind using optic flow cues during odor (Kennedy and Marsh, 1974;David et al., 1983;van Breugel and Dickinson, 2014). Marine invertebrates travel upstream when encountering an attractive odor (Page et al., 2011). Although neurons that carry signals appropriate for guiding these behaviors have been identified (Olberg, 1983;Namiki et al., 2014), a circuit-level understanding of these behaviors has been lacking. Obtaining such an understanding will require quantitative measurements of behavior coupled with techniques to precisely activate and inactivate populations of neurons.
In recent years, the fruit-fly D. melanogaster has emerged as a leading model for neural circuit dissection (Simpson, 2016). The widespread availability of neuron-specific driver lines, the ease of expressing optogenetic reagents, and the ability to perform experiments in a high-throughput manner have established the fruit-fly as a compelling experimental model. Here, we have developed a high-throughput behavioral paradigm for adult flies that allows for precise quantification of fly movement parameters as a function of well-controlled dynamic odor and wind stimuli. An important distinction between our paradigm, and others previously developed for flies (Jung et al., 2015;van Breugel and Dickinson, 2014;Bell and Wilson, 2016), is that it allows us to control the odor and wind stimuli experienced by the flies regardless of their movement. This 'open loop' stimulus presentation allowed us to measure the dependence of specific behaviors on odor dynamics and history. In addition, our paradigm allows for movement in two dimensions (in contrast to Steck et al., 2012;Bell and Wilson, 2016), which allowed us to observe and quantify search behavior elicited by odor offset. By combining this paradigm with techniques to activate and silence particular groups of neurons, it should be possible to dissect the circuits underlying these complex multi-modal forms of olfactory navigation.

Unimodal and multimodal responses guide olfactory navigation in adult Drosophila
In our behavioral paradigm, we observed two distinct behavioral responses to a pulse of apple cider vinegar: an upwind run during odor, and a local search at odor offset. Previous studies have suggested that flies cannot navigate toward odor in the absence of wind (Bell and Wilson, 2016), while others have suggested that odor modulates multiple parameters of locomotion, resulting in an emergent attraction to odorized regions (Jung et al., 2015). Our findings suggest a synthesis of these two views. We find that upwind orientation requires wind cues transduced by antennal mechanoreceptors. In contrast, offset searching is driven purely by changes in odor concentration. In computational model simulations, we found that when wind provided a reliable cue about source direction, wind orientation was the major factor in the success of a model fly in finding the source. However, when wind cues were absent, ON and OFF behaviors both played equal roles. In real environments, wind direction is rarely completely reliable (Murlis et al., 2000), so both behaviors are likely to contribute to successful attraction.
The ON and OFF responses that we describe here have clear correlates in behaviors described in other organisms. The upwind run during odor has been described previously (Flügge, 1934;Steck et al., 2012) and seems to play a similar role to the upwind surge seen in flying insects (Vickers and Baker, 1994). Upwind orientation in walking flies appears to depend entirely on mechanical cues while upwind orientation during flight has been shown to be sensitive to visual cues (Kennedy, 1940;Kennedy et al., 1981;van Breugel and Dickinson, 2014). Searching responses after odor offset have been observed in walking cockroaches , and have been observed in adult flies following removal from food (Dethier, 1976;Kim and Dickinson, 2017) but have until recently not been reported in flies in response to odor (Sayin et al., 2018). The OFF response seems to play a role related to casting in flying insects, allowing the fly to relocate an odor plume once it has been lost, although the response we observed did not have any component of orientation orthogonal to the wind direction, as has been described in flight (Kennedy and Marsh, 1974;van Breugel and Dickinson, 2014). OFF responses were weaker in flies lacking the norpA 36 allele, suggesting that vision may be able to substitute to some degree for search behavior, or that the norpA 36 allele itself promotes more vigorous searching.

Temporal features of odor driving ON and OFF behaviors
A common feature of chemotaxis strategies across organisms is the use of temporal cues to guide behavior. In gradient navigators, the dependence of behavior on temporal features of odor is well established. Bacteria respond to decreases in attractants over an interval of about 2 s (Block et al., 1982). Pirouettes in C. elegans are driven by decreases in odor concentration over a window of 4-10 s (Pierce-Shimomura et al., 1999). The temporal features of odor that drive behavioral reactions in plume navigators are less clear. Studies of moth flight trajectories in a wind tunnel have suggested that moths respond to each filament of odor with a surge and cast (Baker, 1990;Vickers and Baker, 1994), and cease upwind flight in a continuous miasma of odor (Kennedy et al., 1981). These findings have led to the idea that the rapid fluctuations found in plume are critical for promoting upwind progress (Baker, 1990;Mafra-Neto and Cardé, 1994). In contrast, Drosophila have been observed to fly upwind in a continuous odor stream (Budick and Dickinson, 2006), suggesting that a fluctuating stimulus is not required to drive behavior in this species. Flight responses to odor have been described as fixed reflexes (van Breugel and Dickinson, 2014), although they have also been shown to depend on odor intensity and history (Pang et al., 2018). Measurement of these dependencies has been hampered by the inability to precisely control the stimulus encountered by behaving animals.
Here, we have used an open loop stimulus and a very large number of behavioral trials, to directly measure the dependence of odor-evoked behaviors on odor dynamics and history. We find that in walking Drosophila, ON behavior (upwind orientation) is continuously produced in the presence of odor. ON behavior exhibited a filter time constant of 0.72 s, significantly slower than encoding of odor by peripheral olfactory receptor neurons (Kim et al., 2011;Nagel and Wilson, 2011). We think it is unlikely that this represents a limit on our ability to measure behavioral reactions with high temporal fidelity, as we observed very rapid, short-latency freezing in response to valve clicks that were faster and more reliable than olfactory responses. One possible explanation for this difference is that olfactory information may be propagated through multiple synapses before driving changes in motor behavior, while the observed freezing may be a reflex, executed through a more direct coupling of mechanoreceptors and motor neurons.
OFF responses (increases in turn probability) were driven by differences between the current odor concentration, and an integrated odor history with a time constant of 4.8 s. This long integration time was evident in responses to frequency sweeps and to the 'plume walk', where increases in turn probability were only observed in response to relatively slow odor fluctuations, or to long pauses between clusters of odor peaks. This filtering mechanism may allow the fly to ignore turbulent fluctuations occurring within the plume, and to respond with search behavior only when the overall envelope of the plume is lost. The neural locus of this offset computation is unclear. Olfactory receptor neurons that are inhibited in the presence of odor can produce offset responses when odor is removed (Nagel and Wilson, 2011); such inhibitory responses are generally odorant specific (Hallem and Carlson, 2006). In addition, inhibition after odor offset is observed in many olfactory receptor neurons, and the dynamics of this inhibition have been shown to predict offset turning in Drosophila larvae (Schulze et al., 2015). Alternatively, the OFF response could be computed centrally in the brain. For example, many local interneurons of the antennal lobe are broadly inhibited by odors (Chou et al., 2010) and exhibit offset responses driven by post-inhibitory rebound (Nagel and Wilson, 2016). Rebound responses grow with the duration of inhibitory current (Nagel and Wilson, 2016), providing a potential mechanism for slow integration. Experiments testing the odor and glomerulus specificity of the OFF response could be used to distinguish between these possibilities, as ORN temporal responses are specific to particular odorants (Hallem and Carlson, 2006), while LN temporal responses are similar across odorants (Chou et al., 2010).
In addition to low-pass filtering, we found that behavioral responses to odor were best fit by models that included a compressive nonlinearity-in the form of a Hill function-whose sensitivity was slowly adjusted by adaptation. This type of adaptive compression has been observed in the transduction responses of Drosophila olfactory receptor neurons (Kaissling et al., 1987;Nagel and Wilson, 2011;Gorur-Shandilya et al., 2017). Additional adaptation has been observed at synapses between first and second order olfactory neurons (Nagel et al., 2015;Cafaro, 2016). Adaptation at multiple sites in the brain may contribute to the relatively slow adaptation time constants we measured for behavior (9.8 and 10 s for ON and OFF respectively.) Our adaptive compression model has some similarity to the quasi-steady state model of (Schulze et al., 2015), in which sensitivity to odor is dynamically adjusted to a running average of recent changes in odor history. Similar to that study in larvae, our study also suggests that events early in olfactory transduction can shape the time course of subsequent motor responses.
Why might olfactory behavior in walking flies reflect integration of olfactory information over time while upwind flight in moths appears to require a rapidly fluctuating stimulus? Several possibilities are worth considering. One is that the temporal demands of walking differ from those of flight. A flying moth travels at much faster speeds and over longer distances than a walking fly and will therefore traverse a plume in less time. Second, plumes developing near a boundary are broad and relatively continuous, while those in open air, particularly at the long distances covered by moths, are much more intermittent (Crimaldi and Koseff, 2001;Celani et al., 2014;Yee et al., 1993), again making detection of the plume edge potentially more important than responding rapidly to each plume encounter. Finally, receptor-odorant interactions can have different kinetics (Nagel and Wilson, 2011) and may induce differing amounts of adaptation (Cao et al., 2016). Differences in temporal processing of odors across species could also therefore reflect differences in the kinetics of individual odor-receptor interactions. Experiments expressing moth receptors in fly neurons, or comparing the history-dependence of flight vs walking reactions in the same species, may help resolve these differences. Rapid odor fluctuations have also been observed to impair upwind progress in some moth species (Riffell et al., 2014).

Modeling olfactory search behavior
To relate elementary sensory-motor transformations to behavior in complex odor environments, we developed a simple model of olfactory navigation. In our model, different forms of sensation, such as flow sensing (wind), temporal sensing (offset response) and spatial sensing (comparisons across the antennae) each produce distinct changes in forward and in angular velocity. The contributions of each form of sensing are summed to generate total turning behavior. Our model differs from previous models of turbulent navigation (Pyk et al., 2006;Balkovsky and Shraiman, 2002;van Breugel and Dickinson, 2014) in that it does not specify any distinct behavioral states such as 'upwind orientation' or 'casting.' This is consistent with the observation that intermediate behavior, in which a positive upwind velocity overlaps with an increase in angular velocity, can be observed during decreasing odor ramps. Our model also differs from those requiring the animal to derive and maintain an estimate of the source position (Vergassola et al., 2007;Masson, 2013). The only 'memory' required by our model is a slow adaptation and an offset response with a long integration time. Slow adaptation has been observed in the responses of olfactory receptor neurons and projection neurons (Kaissling et al., 1987;Nagel and Wilson, 2011;Nagel et al., 2015;Cafaro, 2016;Gorur-Shandilya et al., 2017), while offset responses with long integration times have been observed in antennal lobe interneurons (Nagel and Wilson, 2016). Thus, both these types of history-dependence have been experimentally demonstrated.
To validate our model, we showed that it can reproduce several features of experimentally observed fly behavior. First, the model can produce the upwind run during odor and the local search at offset that we observe in response to odor pulses in our miniature wind-tunnels. Second, it can produce straighter trajectories during odor and local search in the absence of wind information. Third, variation in the scale of the ON and OFF functions can generate the type of variability we observe in behavior across flies. Finally, the model produces a distribution of behaviors (source finding, intermediate search, and downwind orientation) similar to that of real flies when tested in a turbulent odor plume. Despite these similarities, there are aspects of fly behavior that our model does not capture. For example, we were unable to precisely match the distribution of angular velocities observed in our data and still produce realistic trajectories. This suggests that there is additional temporal structure in real fly behavior that our model lacks. There are also discrepancies between our model predictions and the timing of responses near odor onset (particularly in the frequency sweep responses) that might reflect the simplicity of the filter model used, or might reflect real variability in the latency of flies to respond to odor. Nevertheless, our model provides a relatively straightforward way to understand the relationship between temporal filtering of odors, sensorymotor coupling, and behavior in various odor environments. It should thus facilitate studies relating changes in neural processing to olfactory behavior.
A question left open by our model is the role of spatial sensing (bilateral comparisons) in guiding navigation. We found that if the gain was set high enough, this form of sampling could significantly improve the model's performance (unrealistic gain values, of 1500 deg/s, could produce performance rates of over 95% success). This result is surprising, as previous studies have concluded that nearby samples taken in turbulent plume do not contain usable information (Borst and Heisenberg, 1982). However, recent studies have suggested that plumes may contain more usable spatial information than previously thought (Boie et al., 2018), particularly when the plume forms near a solid boundary (Gire et al., 2016). Using average gain values estimated from studies in tethered flies on a trackball (Borst and Heisenberg, 1982;Gaudry et al., 2013) we found that bilateral sampling contributed fairly little to performance, because the concentration differences across the antennae were typically quite small. In previous studies, bilateral sampling has been investigated largely using longlasting odor stimuli of fixed concentration. It would be interesting in the future to ask whether flies can respond more strongly to small concentration differences when they are embedded in a fluctuating environment like the one measured here.

Fly strains
We used genetically blind norpA 36 mutants, (Ostroy and Pak, 1974;Pearn et al., 1996) to avoid visual contributions to behavior. The norpA 36 allele was backcrossed for seven generations to an isogenic w 1118 stock (Bloomington 5905, also known as iso31 as described in (Ryder et al., 2004) that exhibits robust walking behavior (Stavropoulos and Young, 2011), using PCR to follow the allele through backcrossing. norpA 36 males were crossed to w 1118 virgins and virgin female norpA 36 /+ progeny were backcrossed to w 1118 males. In each subsequent generation, 15 to 20 virgin females were backcrossed singly to w 1118 males and genomic DNA was extracted from each female after several days of mating. PCR amplification was performed with primers flanking the norpA 36 deletion (oNS659 AAACCGGATTTCATGCGTCG and oNS660 TGTCCGAGGGCAATCCAAAC; 95C 2 min, 30x(95C 20 s, 60C 10 s, 72C 15 s, 72C 10 min) to identify heterozygous norpA 36 /+ mothers giving rise to wild-type (172 bp) and mutant (144 bp) products. After seven generations of backcrossing, single males were crossed to an isogenic FM7 stock to generate homozygous stocks, and those bearing norpA 36 were identified with PCR. Both w 1118 norpA 36 and w + norpA 36 stocks were generated during backcrossing. We used only w 1118 norpA 36 flies for behavior. For this reason, we used w 1118 flies as 'sighted' controls, although the w 1118 allele does affect vision as well. All flies were collected at least 1 day post-eclosion. After collection, flies were housed in custommade cardboard boxes at room temperature (21.5-23.5C), with a light cycle of 12 hr, for at least 3 days prior to experiments to allow habituation. Different boxes were shifted by two hours relative to the others to allow us to perform several experiments with the same conditions in the same day. At the time of the experiments, flies were 5 to 14 days old (average age was 7.1AE1.8 days). Prior to the experiments, flies were starved for 5 hr in an empty transparent polystyrene vial with a small piece of paper soaked in distilled water to humidify the air. Experiments were performed between 2-4 hr after lights on (ZT 2-ZT 4).

Behavioral apparatus
Our behavioral apparatus (Alvarez-Salvado and Nagel, 2018) was modified from the design of Bell and Wilson (2016) and was designed to allow us to monitor the position and orientation of flies walking freely in two dimensions while tightly controlling the odor and wind stimuli they experienced. The behavioral arena was composed of several layers of laser-cut plastic, all 30 by 30 cm in size with varying thicknesses (detailed below), in which different shapes were cut to create an internal air circuit and four individual behavioral chambers that measured 14 by 4 by 0.17 cm each. The arena was designed using Adobe Illustrator ( The ceiling was held in place with seven set screws; combined with the fluorosilicone rubber layer this ensured that air did not escape from the chambers and produced more uniform odor concentrations throughout the arena. Each behavioral chamber had a separate air inlet through which charcoal-filtered air was supplied, and an outlet at the opposite end. A series of baffles in the PETG layer, as well as the short vertical extent of the chambers (1.7 mm) ensured laminar flow of air through our chambers (calculated Reynolds number 11.5). Total airflow through the arena, as measured by anemometer, was 11.9cm/s. The arena was placed in an imaging chamber constructed from a breadboard (Thorlabs) and 80/ 20 posts (McMaster: 47065T101) held in place with brackets (McMaster: 47065T236). Illumination was provided by an LED panel composed of an aluminum sheet (McMaster: 88835K15 ) covered with infrared (IR) LED strips (Environmental lights, irrf850-5050-60-reel). A diffuser (Acrylite: WD008) was placed between the LED panel and the arena to provide uniform lighting. Flies were imaged from below the arena using a monochrome USB 3.0 camera (Basler: acA1920-155um) and a 12 mm 2/3'' lens (Computar: M1214-MP2). An IR filter (Eplastics: ACRY31430.125PM) was placed between the camera and the arena. LEDs were controlled using buckblock drivers (Digikey). An Arduino microprocessor (teensy 2.0, PJRC) was used to strobe the IR LEDs at 50 Hz and to synchronize them with each camera frame.
Imaging and stimulus delivery were controlled by custom software written in Labview (National Instruments, Austin, TX). Timing of odor was controlled by a National Instruments board (PCIe-6321). Flies were tracked by comparing the camera image at each time point to a background image taken prior to the experiment. Background-subtracted images were thresholded and binarized; a region of interest per chamber was then taken for further processing. Particle filtering functions were applied to each region of interest to remove particles less than 3 pixels (0.4 mm) long or greater than 50 pixels (6.8 mm) long. A particle analysis function was used to identify the fly in each chamber and to compute its center of mass and orientation.
Since the particle analysis function could only determine the fly's orientation up to 180 (i.e. it cannot distinguish the front and back of the fly), we used a second algorithm to uniquely determine the animal's orientation. Each background-subtracted image was passed through a second thresholding operation with a lower threshold intended to include the translucent wings. The center of mass of this larger particle was compared to the center of mass of the smaller wingless particle to determine the orientation of the fly in 360. Orientation measurements were strongly correlated with movement direction, but provided a smoother readout of heading direction when its velocity was low. Position (X and Y coordinates) and orientation were computed in real time during data collection and saved to disk.

Stimulus delivery
Wind and odor stimuli were delivered through inlets at the upwind end of the arena. Each arena was supplied with a main air line that provided charcoal-filtered wind. Wind flow rate was set to 1 L/min by a flowmeter (Cole-Parmer, Vernon Hills, IL). This line could be shut off by a three-way solenoid valve (Cole Parmer, SK-01540-11) in order to measure behavior in the absence of wind (Figure 2). To measure air flow, we used an anemometer (miniCTA 54T30, Dantec Dynamics, Skovlunde, Denmark), inserting the probe into the chambers through holes on a special ceiling made for this purpose. The anemometer was calibrated by measuring the outlet of a single 25 mm diameter tube (filled with straws to laminarize flow) connected directly to a flow meter. The measured air velocity was 11.9 cm/s.
Odor was delivered via rapidly switching three-way solenoid valves (LHDA1233115H, The Lee Company, Westbrook, CT) located just below the arena, that directed odorized air either to the chambers or to a vacuum. Each chamber had its own valve, and odor was injected just downstream of the main air inlet, 1.7 cm upstream of the baffle region of the chamber. Charcoal-filtered air was odorized by passing it through a scintillation vial filled with 20 ml of odorant solution (apple cider vinegar or ethanol), then directed through a manifold (McMaster: 4839K721) to each of the four valves. Importantly, the vials containing the odor solution were almost full, creating a relatively small head space where odor could readily accumulate. Odorized air flow rate was set to 0.4 l/min using flowmeters. During non-odor periods, odorized air was directed into a vacuum manifold and away from the apparatus. Flow rates in the arena and vacuum manifold were matched to eliminate transients in odor concentration during switching. An equal volume of 'balancing' air was injected into the arena during these periods to maintain a constant air flow rate throughout the experiment. Balancing air was humidified by passing over an identical scintillation vial filled with water and was delivered by an identical three-way valve. Odor and balancing valves fed into a small t-connector, that was suspended from the arena using » 1 cm of tygon tubing (0.8 mm inner diameter, E-3603). This design, in which odor flowed continuously and was switched close to the arena, produced rapid odor dynamics with few concentration artifacts, but also a small mechanical stimulus when the valve was switched. This odor delivery system was using for experiments in Figures 1 and 2, and for intensity experiments in Figure 3A-B.
To produce analog odor stimuli including ramps, frequency sweeps, and the plume walk stimulus, we added two-way proportional valves (EVP series, EV-P-05-0905; Clippard Instrument Laboratory, Inc., Cincinnati, Ohio) 20 cm upstream of the odor and balancing scintillation vials. Proportional valves were driven indepentendly by valve drivers (EVPD-2; Clippard) and were calibrated so that their maximal opening would produce the same flow rate as in experiments using three-way valves. (three-way valves were held open during experiments with analog stimuli.) Proportional valves produce increasing airflow with applied current; however, they exhibit both nonlinearity and histeresis, in which the effect of a driving current depends on the past and current state of the valve. To generate our desired stimulus waveforms, we first provided an ascending and descending ramp stimulus to the valves and measured the subsequent odor waveform in the behavioral chambers using a PID (see below). We used the results of that measurement as a lookup table to create a driving current command that produced the desired odor waveforms. Lookup tables for odor and balancing valves were measured separately. We used PID measurements at several locations in the arena to verify that the delivered odor waveform matched our desired odor waveform. We used an anemometer (see below) to verify that the total flow rate during the stimulus (in which odor and balancer valves were run together) did not vary by more than 1%.
To measure odor concentration in our arenas we used a photo-ionization detector (miniPID, Aurora Systems, Aurora, Canada) inserted into the arena, again using a special ceiling. All calibration measurements were made using 10% ethanol, which provided higher signal to noise than ACV. Measurements at the top of the arenas revealed an average rise time of » 180 ms and a fall time of » 220 ms for square pulses delivered using three-way valves. The latency of the measured odor onset from nominal odor onset increased linearly with distance from the odor source (up to 900-1000 ms at the downwind end of the arena), consistent with our measurement of air velocity (Figure 1-figure supplement 1). For frequency sweep stimuli, we observed some widening of peaks with distance down the arena, consistent with the effects of diffusion (Figure 1-figure supplement  1). Diffusion thus set the upper limit on the frequency of stimuli that we could reliably deliver within our arena (about 1Hz). Presenting higher frequency stimuli would require higher wind speeds, but we found that higher wind speeds caused flies to stop moving, as previously observed (Yorozu et al., 2009).

Experimental protocol
Each experiment lasted approximately 2 hr, during which flies performed an average of 86.7AE7.7 trials. (Some trials were discarded due to tracking problems, as described below, and not all experiments lasted exactly the same amount of time). Each trial lasted 70 s, and was followed by a gap of » 6 seconds while the computer switched to the next trial. There were three to four types of trials that were randomly interleaved during the experiment. One of those types was always a blank trial, in which flies only experienced clean air flow. The other types corresponded to different types of odor stimuli, that were dependent on the experiment: namely, square odor pulses for experiments in Figures 1, 2 and 3A-B; odor ramps in Figure 3C-D; frequency sweeps and plume data in Figure 3E-J. To ensure repeatability, data for all experiments was collected over several different days (5 to 9, often non-consecutive). For Figure 1, we used data from experiments performed over a period of 7 months.
For experiments in Figure 2, we rendered flies 'wind-blind' by anesthetizing them on a cold plate and cutting their aristae and stabilizing their antennae. We cut the aristae by clipping them with fine forceps at the lowest possible level without touching the antennae. Then, we put a very small drop of ultra-violet (UV) glue on the anterior side of the antennae, falling between the second and third segments, as well as touching the rest of the clipped aristae. We then used a pen-sized ultra-violet light to cure the glue, and made sure it was solid before putting the flies back to their home vials to recover for 24 hr. The whole procedure took approximately 5 min, and never longer than 10. We did this procedure in a pair of flies at a time, stabilizing the antenna of one and using the other as shamtreated (it was placed on the cold plate and under the UV light exactly like the treated fly was).
For experiments in Figure 6, approximately 48 hr before the experiment, we applied a drop of UV glue connecting both wings of the fly or to each wing hinge. This prevented flies from flying while allowing us to still use the wings to detect heading.

Analysis of behavioral data
All analyses were performed in Matlab (Mathworks, Natick, MA) (Alvarez-Salvado and Nagel, 2018; copy archived at https://github.com/elifesciences-publications/AlvarezSalvado_ElementaryTransformations). X and Y coordinates and orientation information were extracted from the data files, and any trials with tracking errors (i.e. flies' position was missed at some point) were discarded (this occurred rarely). In some trials, we observed orientation errors in the form of sudden changes of approximately 180. In these cases, orientation was corrected by calculating the heading of the flies using X and Y coordinates, and filling in the gaps in orientation using the orientation that best correlated with that information, producing coherent and continuous orientation vectors. Coordinates and orientations were low-pass filtered at 2.5 Hz using a two-pole Butterworth filter to remove tracking noise that was produced especially when flies were not moving. X and Y coordinates were then converted to mm, and trials in which flies moved less than a total of 25 mm were discarded. Distance moved was calculated as the length of the hypotenuse between two subsequent pairs of coordinates.
We next calculated a series of gait parameters from each trial's data. Ground speed was obtained by dividing the distance moved by the time interval of each frame (20 ms). Upwind velocity was calculated using the derivative of the filtered Y coordinates divided by the time interval of 20 ms. Angular velocity was calculated as the absolute value of the derivative of the filtered unwrapped orientation (i.e. orientation with phases corrected to be continuous beyond 0˚or 360˚) divided by the time interval of 20 ms. For all gait parameters shown (ground speed, upwind velocity, angular velocity), we excluded data points in which ground speed was less than 1 mm. This was necessary because flies spend a large amount of time standing still. Distributions of gait parameters are therefore highly non-Gaussian, with large peaks at 0 (Figure 3-figure supplement 1A), and parameter means are highly influenced by the number of zeros. In addition, the probability of moving (obtained by binarizing the ground speed with a threshold of 1 mm/s) changes dramatically in response to odor, and remains high for tens of second after odor offset (Figure 3-figure supplement 1B). Exclusion of the large number of zeros from average gait parameters produced more reliable estimates of these parameters. Curvature was calculated by dividing angular velocity by ground speed (excluding any points where ground speed was less than 1 mm/s). Turn probability was calculated binarizing curvature with a threshold of 20 deg/mm.
Because it takes a little over a second for the odor waveform to advect down the arena, the exact time of odor encounter and loss depends on the position of the fly within the arena. This advection delay has a strong effect on our estimates of gait parameter dynamics, particularly for fluctuating sinusoidal stimuli. We therefore developed a warping procedure to align behavioral responses to the actual time at which each fly encountered the odor on each trial. To implement this procedure, we first recorded the PID response to each stimulus at three different points along the arena (Figure 1-figure supplement 1). We then calculated the delay for the odor to reach the position of the fly for each time frame during the odor stimulus, and shifted all the data points back by this amount. The periods before and after the odor stimulation are also shifted according to the initial position of flies in the odor period. This method can skip a data point when the fly moves upwind or can repeat a data point when the fly moves downwind, but the majority of the data are conserved and the resulting waveforms resemble very much the initial ones. After warping, all trials from all flies can be equally compared to a standard PID measurement done at the top of the arenas (i.e. the odor source). Warping was applied to all data shown in Figures 1-3. Note that in experiments using three-way valves (Figure 1), the click of the valve produced a brief freezing responses that was visible as a dip in ground speed. However, because of the warping, the time of the valve click is distributed across flies, as their ground speeds have been aligned to the time of odor encounter rather than the time of valve opening. This results in a smeared dip in the ground speed trace near the beginning and end of the odor stimulus.
For experiments using frequency sweeps and plume walks, we additionally excluded data obtained after the fly reached the top end of the chamber, as well as data from within 3 mm of the side walls. These exclusions were made to minimize the effect of arena geometry on gait parameter estimates, and to exclude regions where boundary layer effects would cause the odor waveform to advect more slowly. To calculate the data shown in the insets of Figure 3E-H, and in Figure 3-figure supplement 1F, we used a jackknife procedure to resample the responses of flies to frequency sweep stimuli. We made 10 estimates of the mean, excluding 34 trials from each estimate. To estimate the modulation of upwind velocity and ground speed in response to each cycle of the stimuli, we took the times between minima of the stimulus waveform as the limits for each cycle of the ascending frequency sweep; for the descending frequency sweep we used the intervals between maxima of the odor waveform. Within those limits, we calculated the minimum-to-maximum amplitude for each of the 10 different mean responses. The results shown in the figures are the mean of these estimates as a function of frequency of the corresponding stimulus cycles. The frequency of the cycles was estimated as 1 over the duration of the cycle. Error bars in the figure insets represent the standard error (SE) across estimates, calculated as where x i is each of the peak-to-peak estimates excluding one fly, x the estimate including all flies, and n the number of data subsets used (10).

Statistical analysis
In Figure 1G, Figure 2B and Figure 5G, we compared the mean values of different motor parameters from the same fly in three different periods of time in the trials, namely: 'before odor' from À30 to 0 s before the odor, 'during odor' from 2 to 3 seconds during the odor, and 'after odor' from 1 to 3 s after odor offset. We performed a Wilcoxon signed rank paired test for each of those comparisons and corrected the threshold for statistical significance alpha using the Bonferroni method. All significant comparisons were marked with asterisks in the figures, and the exact p values obtained are presented in the following tables. p values for comparisons made in Figure 1G. The alpha value after correcting for multiple comparisons was 0.0167.

Comparison
Upwind velocity Ground speed Curvature p values for comparisons made in Figure 2B. The alpha value after correcting for multiple comparisons was 0.0167.
To estimate the Standard Error of the proportion of successful trials shown in Figure 6I and in Figure 7C, we used the formula where p was the proportion of successful trials and n the number of trials.
To test for statistical differences in Figure 7C, we calculated a z statistic by normal approximation of the corresponding binomial distributions according to: where p 1 and p 2 are the probabilities of success in the two distributions being compared, p is the probability of both distributions combined, and n 1 and n 2 are the number of trials in the two distributions. We then estimated the p values by evaluating a normal cumulative distribution function of a standard normal distribution for the resulting z values. This analysis yielded the following results: z statistic p value z statistics and p values for comparisons made in Figure 7C. The alpha level used was 0.05.

Computational modeling
Our computational model was composed of two parts (Alvarez-Salvado and Nagel, 2018). In the first, we asked whether simple phenomenological models, comprised of a linear filtering step, and a nonlinear adaptive compression function, were capable of capturing the dynamics of upwind velocity and turn probability in response to a wide array of odor waveforms. We compared fits of four model versions to our behavioral data, and tested the resulting best fit model by predicting responses to the plume walk stimulus. These fits comprise the two temporal functions which we call ON and OFF.
In the second part, we asked whether a simple navigational model, based on the ON and OFF functions fit to the data and described in Figure 5, was capable of reproducing the types of trajectories we observed experimentally and of locating the source of a real odor plume. In addition, this model allowed us to test the contribution of each of its components to successful odor localization. In the model, we first compute two temporal functions of the odor stimulus, ON and OFF. These two signals are then used to modulate ongoing behavioral components (angular velocity and ground speed) which iteratively update the fly's position. The model can be run in open loop, as in our behavioral expeirments, by providing an odor input as a function of time, or in closed loop, where the odor concentration at any point in time depends on the fly's position in a real or virtual space. All computational modelings were performed in Matlab. Differential equations were simulated using the Euler method with a time step of 20 ms.

Odor ON and OFF functions
The ON function was composed of an adaptive compression step and a linear filtering step (model ACF in Figure 4). Adaptation was driven by an adaptation factor A(t) that accumulated slowly in the presence of odor: Compression was modeled using a Hill equation with a baseline k d of 0.01 (expressed as a fraction of our highest odor concentration: 10% apple cider vinegar). This baseline value was taken from our fits of responses to square pulses of different concentration (Figure 3). Adaptation slowly increased the effective k d , reducing the sensitivity of behavior to odorant, and maintaining responses of about the same size over a wide concentration range: The filtering step was given by For the OFF model, adaptation and compression were modeled in the same way, but filtering was performed by applying two filters, one fast and one slow, and then taking the difference between the slow and the fast filter output, thresholded at 0: OFF ¼ maxð0; R2 À R1Þ Model parameters used in Figure 4 are shown in Table 1. These same model parameters were used for all remaining simulations. We also considered three additional models. In the FAC model, the order of operations was inverted, so the odor was first filtered, then adaptively compressed. In the CF and FC models, we omitted the adaptation step, and again tried both orders of operation (compression first and filtering first): We found that models lacking adaptation performed significantly worse for both ON and OFF. All fits were made using the function nlintfit in Matlab. Fit parameters and RMSE values are given in Table 1.

Modulation of behavioral components
The temporal functions described above were used to modulate the ground speed of the fly v and its heading H, from which the XY coordinates of the position of the fly at each point in time could be calculated.
The ground speed at each time step was give by: where v 0 is the baseline speed, set at 6 mm/s based in our behavioral data. k 1 and k 2 determine the influence of ON and OFF functions on the final speed. The heading at each time step (Dt of 20 ms) was computed by adding the instantaneous angular velocity to the current heading: The angular velocity at each time step _ ðtÞ is a linear sum of several components driven by different sensory stimuli: a random component, driven by odor dynamics, and two deterministic components, driven by wind: _ ðtÞ ¼ ðtÞGð0; sÞ 2 þ k 5 ONðtÞD u ð Þ þ k 6 D d ð Þ The first term represents probabilistic turning whose rate is modulated by the dynamics of odor. ðtÞ is a binary Poisson variable that generates a draw from a Gaussian distribution with mean 0 and standard deviation s when it is equal to 1. The value drawn from this distribution was squared to yield a distribution of angular velocities with higher kurtosis, as observed in the distribution of real flies' angular velocities. However, we did not attempt to directly match the distribution of angular velocities found in our data. (Indeed, we found that matching this distribution produced trajectories that were far too jagged, suggesting that one of the assumptions of the model, for example that angular velocities are independent of one another, or that angular velocity is independent of forward velocity, must be incorrect.) The rate of ðtÞ is given by Thus, the rate of random turns has a baseline of P 0 , decreases in the presence of odor (when ON (t) is positive) and increases after odor offset (when OFF(t) is positive).
The second and third terms represent deterministic turns driven by wind. To model these turns, we defined two sinusoidal functions -D u for upwind orientation and D d for downwind orientationgiven by the equations: where is the direction of the wind relative to the fly. A negative value of indicates wind coming from the fly's left, and a positive value of _ ðtÞ indicates a turn to the left, so D u produces a turn to the left when wind is sensed on the left and vice-versa, leading to upwind orientation. The function D d produces a turn to the right when wind is sensed on the left resulting in downwind orientation. The downwind function D d is always on but has a small coefficient, resulting in a mild downwind bias when combined with baseline random turning driven by the first term ðtÞGð0; sÞ. The upwind function D u is gated by the ON function and has a larger coefficient. This means that in the presence of odor, this term comes to dominate turning, driving strong upwind orientation.
To estimate values for the coefficients k 1 to k 6 we ran simulations of the model using a 10 s odor pulse and adjusted parameters sequentially so that analysis of the model outputs matched as closely as possible the response of real flies shown in Figure 5E. We first adjusted k 1 and k 2 to match the ground speed. Next, we adjusted k 5 and k 6 to match the upwind velocity. Finally, we adjusted k 3 and k 4 to match turn probability. We matched the theoretical turn probability on the model (the rate governing the Poisson variable ðtÞ rather than the turn probability extracted from the model trajectories.
To generate trajectories with this model, the X and Y coordinates were calculated from vðtÞ and HðtÞ, according to: Xðt þ DtÞ ¼ XðtÞ þ Dt Á vðtÞ cos ðHðtÞÞ (21) Yðt þ DtÞ ¼ YðtÞ þ Dt Á vðtÞ sin ðHðtÞÞ Simulations in the turbulent plume were run at 15 Hz rather than 50 Hz to match the sample rate of the plume measurements. All rate constants (including turn probability per sample) were converted accordingly. Video 2 shows an example of the model navigating a real odor plume.
To add bilateral sensing to our navigation model in Figure 7, we made two measurements of odor concentration at each point in time. Odor L was the odor concentration at the location of the fly in the plume movie, while odor R was the concentration one pixel (740 m) to the right. This spacing is perhaps twice the distance between a fruit fly's antennae, but represents the closest sampling we could perform using our current imaging system. We then applied the adaptive compression given by Equations 17 and 18 to each odor measurement separately: C L ðtÞ ¼ odor L ðtÞ odor L ðtÞ þ k d þ AðtÞ (23) C R ðtÞ ¼ odor R ðtÞ odor R ðtÞ þ k d þ AðtÞ The bilateral contribution to angular velocity was computed as the difference between the two compressed odor signals, multiplied by a coefficient k 7 that determines how strongly the fly turns when it detects a concentration difference. We estimated k 7 from the literature (Borst and Heisenberg, 1982;Cardé and Willis, 2008) by examining the turn rates produced when a maximal concentration difference ðC L À C R ¼ 1Þ was applied across the antennae. The bilateral contribution was added as a fourth component to the equation governing total angular velocity (Equation 17):

Turbulent wind tunnel construction
We generated a turbulent odor plume in a low-speed bench-top wind tunnel with a flow-through design. Two wind tunnels were built, one in Colorado (for plume measurements) and one in New York (for behavioral measurements). In the Colorado wind tunnel, air entered the tunnel through a bell-shaped contraction (4:1 ratio) and passed through a turbulence grid (6.4 mm diameter rods with a 25.5 mm mesh spacing) prior to the test section. The test section was 30 cm wide, 30 cm tall, and extended 100 cm in the direction of the flow. Air exited the test section through a 15 cm long honeycomb section used to isolate the test section from a fan located in the downstream contraction. The fan generated a mean flow of air through the tunnel at 10 cm/s. Acetone was released isokinetically into the center of the test section through a 0.9 cm diameter tube aligned with the flow. The tube opening was located 10 cm downstream of the turbulence grid and 6 mm above a false floor spanning the length and width of the test section. The New York tunnel was designed similarly, except that test section measured 38 cm by 38 cm by 92 cm, the honeycomb was 5 cm long, and odor was released from a 1cm diameter tube at floor level. Air flow was 10cm/s and odor release was isokinetic as in the Colorado wind tunnel. The New York tunnel was fitted with an aluminum IR light panel (Environmental lights, irrf850-5050-60-reel) 2.5 cm below a diffuser (Acrylite: WD008) and a 1 cm thick acrylic layer that acted as the arena floor. A channel 1 cm wide and 0.4 cm deep was milled into this arena and filled with water to constrain flies to walk within the imaging area, 31 cm wide and 87 cm long. Two cameras (Point Grey: 2.3MP Mono Grasshopper3 USB 3.0) with 12 mm 2/ 3' lenses (Computar: M1214-MP2) were suspended approximately 45 cm above the arena to image fly movement. Tracking code was written in Labview and used the same algorithms as described above to extract position and heading at 50Hz.

Plume measurements in air
To measure plume structure and dynamics in air, we used a planar laser-induced fluorescence (PLIF) system (Lozano et al., 1992) to image a plume of acetone vapor . A UV laser light sheet entered the test section of the tunnel through a slit along the length of the test section to excite acetone vapor. A camera imaged the resulting acetone fluorescence in the test section through a glass window. The imaging area covered up to 30 cm downwind from the odor source and up to 8 cm to both sides. The plume was imaged in the 1-mm-thick laser sheet centered on the tube 6 mm above the bed. A total of 4 min were recorded. Images were then post-processed into calibrated matrices of normalized concentrations. We produced acetone vapor by bubbling an air and helium gas mixture through flasks partially filled with liquid acetone. To reduce fluctuations in concentration, a water bath maintained flask temperature at 19 deg C which was approximately 2 degrees cooler than ambient air temperature to prevent condensation. To account for the density of acetone, we blended air (59% v/v) and helium (41% v/v) for the carrier gas. Assuming 95% saturation after contact with the liquid acetone, the gas mixture was approximately 25% acetone by volume and neutrally buoyant.
An Nd:YAG pulsed laser emitted light at a wavelength of 266 nm and a frequency of 15 Hz to illuminate the acetone plume. After excitation at that wavelength, acetone vapor fluoresces with an intensity proportional to its concentration. A high-quantum efficiency sCMOS camera imaged the acetone plume fluorescence at 15 Hz. To enhance signal and minimize noise, we collected data in a dark environment, used a lens with high light-gathering capabilities (f/0.95), and binned the pixels from 2048x2048 native resolution to 512x512 resolution (0.74 mm/pixel).
Images were post-processed using an algorithm adapted from (Crimaldi, 2008) to correct for variations in laser sheet intensity, lens vignette, and pixel-to-pixel gain variation. The correction used a spatial map of the image system response by imaging the test section while it was filled with a constant and uniform distribution of acetone. Signal intensities were normalized by the intensity at the tube exit such that concentrations have average values between 0 and 1.
The 'plume walk' stimulus was generated by taking the time course of odor concentration along a linear trajectory going upwind through a plume movie at 6 mm/s (the average ground speed of our flies), starting 8.9 cm laterally from the midline and 30 cm downwind from the source.
The following dataset was generated: