Introduction

Neural adaptation, the process of adjusting a neuron’s dynamic range to match the statistics of the sensory environment1,2, is ubiquitous throughout the nervous system and across species. Adaptation allows our visual systems to recognize a familiar face whether in the daytime or nighttime and our auditory systems to parse a sentence whether it is whispered or shouted. In general, adaptation corrects a neural representation for irrelevant aspects of the stimulus, such as fluctuations in stimulus mean or variance2,3,4. To ensure that the stimulus is efficiently encoded, adaptation should be both sufficiently fast and implemented as early as possible in the sensory pathway.

Accordingly, many sensory systems perform mean and variance adaptation within sensory receptor neurons. The nature of the physical stimulus transformed by receptor neurons into electrical activity dictates how they should implement adaptation. For auditory receptor neurons, the physical stimulus corresponds to the mechanical displacement of the receiver (for example, the stereocilia of cochlear hair cells). Receiver displacement has two, typically independent components: a fluctuating mean or baseline5,6 superimposed on sound-induced receiver oscillations, the standard deviation of which corresponds to the sound intensity. To faithfully encode the fine temporal features of sound, auditory receptor neurons should correct for both fluctuations in the mean and variance of receiver movements, without mean adaptation affecting sound sensitivity. Indeed, cochlear hair cells correct subtractively for stereocilia offsets (what we term here “mean adaptation”) and divisively for changes in intensity (what we term here “variance adaptation”)7,8, but how these forms of adaptation interact within hair cells has not yet been characterized. Studying these forms of adaptation in the more accessible auditory system of Drosophila melanogaster presents an opportunity to investigate their implementation.

Flies use sound for communication during their mating ritual. During courtship, males chase females and produce dynamically patterned song in bouts—females evaluate this acoustic signal and ultimately arbitrate the mating decision9,10. Song bouts typically comprise two modes—“sine” and “pulse.” To detect conspecifics and assess mate quality, the female’s auditory system must reliably encode the spectral and temporal properties of song, but several idiosyncrasies of both fly ears and fly courtship behavior can interfere with a faithful representation of song. The courtship song vibrates the arista (a feathery extension of the Drosophila antenna that serves as the sound receiver)—this causes rotation of the antenna and thereby opens mechanosensitive channels housed within antennal neurons, so-called Johnston’s organ (JO) neurons (JONs)11,12 (Fig. 1a, top). The male and the female constantly move during the courtship interaction10 and this induces strong fluctuations in the variance of sound-induced antennal movement (corresponding to the sound intensity; Fig. 1a, bottom) for two reasons: (i) fly ears are sensitive to the particle velocity component of sound (measured in mm s−1), which falls off strongly as the cube of the distance13, and (ii) fly ears are sensitive to sound direction since the particle velocity is a directional quantity and the sound receiver is maximally vibrated only by sound coming from a direction orthogonal to the arista14. While males dynamically adjust how loudly they sing based on their distance to the female15, this adaptation on the sender side is likely insufficient to avoid saturation of the auditory receptors during courtship. The reported dynamic range of Drosophila auditory receptor neurons is between 0.1 and 1 mm s−116, but song can be as loud as 4 mm s−1 when the male is close to the female17. In addition to intensity fluctuations, the baseline position of the antenna constantly shifts because of changes in air flow and gravity11,12. This baseline corresponds to the mean of the distribution of antennal displacements (Fig. 1a, bottom) and can saturate the responses to sound since mechanotransduction works only over a limited displacement range18.

Fig. 1
figure 1

Sound intensity (variance) adaptation in JO neurons. a (top) Frontal view of the fly brain (left half) with schematic of the antenna. Sound-induced antennal vibrations activate antennal mechanosensitive neurons within the Johnston’s organ (JO)—a subpopulation of JO neurons (JONs) serves as the auditory receptor neurons. JON spikes travel down the antennal nerve to the antennal mechanosensory and motor center (AMMC, green) for central processing of acoustic stimuli. The compound spiking activity (CAP or compound action potential) of the JONs can be recorded extracellularly from the antennal nerve. (bottom) The mean (thick black line) of antennal displacements corresponds to a slowly changing offset; the variance (thin black lines) to the magnitude of sound-induced vibrations (sound intensity). b CAP recording (bottom, gray, averaged over 20 trials, see Supplementary Fig. 1b for single trial CAPs) in response to a noise stimulus (top) switching intensity every 100 ms. The CAP amplitude (bottom, black) was calculated using the Hilbert transform and exhibits transients after each intensity switch (vertical black lines). c CAP amplitude traces for all step sizes (color coded) aligned to step onset (vertical black line), for one fly. While the onset response strongly depends on step sign and magnitude, the steady-state response is relatively independent of step size. d Peak of onset and steady-state responses (blue and black, respectively) as a function of step size (N = 5 flies). Normalized for each fly such that the average steady-state response across step sizes is 1.0. e Timescale of adaptation τ obtained by fitting an exponential to the transients in the CAP amplitude (N = 5 flies). f Responses of wild-type, iav1 mutants and Iav-rescues in different JON subsets to steps in noise intensity (from 1 to 2 mm s−1 (brown) and from 2 to 1 mm s−1 (blue), example data from one fly each, see also Supplementary Fig. 1d, e). CAP signals are abolished in iav1 flies but can be rescued by expressing functional Iav in specific JON subsets. CAP transients for all rescues resemble those seen in wild type. All CAPs averaged over 20 trials. Brain surface model (a) from ref 83

Thus, the Drosophila auditory system requires a neuronal mechanism for adaptation to both fluctuations in the baseline of antennal displacements and the intensity of the acoustic signal. While a subtractive mean adaptation mechanism corrects for the displacement baseline18,19, no studies have yet examined variance adaptation in Drosophila. Here, using neural recordings combined with computational modeling, we find that mean and variance adaptation co-occur within JONs and both do not require spiking or synaptic transmission. Despite the compact implementation of these two forms of adaptation within JONs, we find that mean adaptation does not affect sound sensitivity. This separation is not achieved by a separation of timescales since both forms of adaptation are equally fast. Rather, using a computational model, we show that the separation of mean and variance adaptation can be achieved with a simple sequence of computations: first, subtractive adaptation to correct for antennal offset, followed by rectification for encoding sound intensity, and finally divisive adaptation to correct for sound intensity. We find that the placement of rectification after mean adaptation in the model is essential for maintaining sound sensitivity for different levels of mean adaptation. While mean adaptation first occurs during mechanotransduction itself18,19, our data suggest that rectification and variance adaptation arise in subsequent steps. Our analysis of the organization of adaptation in Drosophila auditory receptor neurons should now facilitate the genetic dissection of these conserved operations, especially given the extensive parallels between fly and vertebrate hearing18,20,21,22.

Results

Variance adaptation in Drosophila auditory receptor neurons

The Drosophila sound receiver, its arista, is moved by sound and by slower, quasi-static stimuli, such as gravity or wind—these stimuli push and pull on the antenna, activating mechanosensory neurons (Johnston’s organ neurons or JONs) in its second segment (Fig. 1a). Antennal movement is actively amplified and produces a transduction or generator current in JON dendrites18,19. These currents are converted into action potentials that propagate along the antennal nerve to the antennal mechanosensory and motor center (AMMC), the first relay for auditory processing in the fly brain11. While type CE JONs encode slow antennal movements by responding tonically to static displacement of the antenna11,12,23, type AB JONs rapidly and completely adapt their responses to these static displacements and produce sustained responses primarily for fast, sound-induced antennal vibrations in the frequency range of courtship song (100–350 Hz18. They hence act as the auditory receptor neurons11,12. However, it is unknown whether type AB JONs also adapt to sound intensity, corresponding to the variance of the sound-induced antennal vibrations superimposed on the quasi-static deflections caused by wind or gravity.

We first examined neural responses to band-limited Gaussian white noise stimuli (termed “noise” from here on) of fluctuating intensities. Since recording intracellularly from individual JONs with patch electrodes interferes with the natural movement of the antenna and with mechanotransduction (Supplementary Fig. 1a), we first probed for variance adaptation by recording population activity extracellularly from the antennal nerve (Fig. 1a). The compound action potential (CAP) reflects the bulk spiking activity of sound-responsive JONs with sub-millisecond resolution (Supplementary Fig. 1b)11,24, and recordings are stable over hours. We presented a noise stimulus at intensities ranging from 0.25 to 2 mm s−1, with switches in intensity every 100 ms (Fig. 1b). Sound intensity is measured as particle velocity in mm s−1, since in the near field, bulk air movement, not changes in sound pressure, induce vibrations of the receiver (for Drosophila courtship, communication distance is much less than the wavelength of sound). The chosen intensity range corresponds to that which females naturally hear during courtship17. Noise exhibits a richly patterned fine structure that evokes reproducible, temporally structured responses in the JONs and has been shown to reduce desynchronization in other systems25 (Supplementary Figs. 1b and 2a).

We found that CAP responses exhibit transients at each switch in noise intensity: decreases in intensity produce negative transients while increases in intensity produce positive transients (Fig. 1c). After a few milliseconds, the responses settle to a steady state that is relatively independent of sound intensity, suggesting the presence of variance adaptation. To quantify these dynamic changes in sensitivity, we compared CAP amplitudes at the onset of an intensity switch and at steady state—we did this for all intensity steps tested and for different instantiations of the white noise stimulus (see “Methods” section for details). The resulting tuning curves reveal that the CAP amplitude strongly scales with step size at the time of a switch but is nearly intensity invariant at steady state (Fig. 1d). Adaptation is fast, on the order of 5–20 ms, and its speed depends on the size of the intensity step, with positive steps producing the fastest and negative steps producing the slowest transients (Fig. 1e). Adaptation dynamics are asymmetrical likely because the amplitude of negative transients is limited from below since CAP amplitudes and the firing rates they represent cannot decrease to below 0 Hz.

Since our extracellular recordings represent JON population activity, we ran several control experiments to determine that adaptive CAP dynamics specifically reflect adaptation of the firing rate within sound-sensitive JO–AB neurons. First, we recorded the CAP in flies carrying the iav1 mutation, which disrupts mechanotransduction and spiking in all JONs, and then rescued iav either in all JON, type AB or type B JONs19,26 (Supplementary Fig. 1d). The adaptation dynamics in these rescues are virtually indistinguishable from those of wild-type flies (Fig. 1f and Supplementary Fig. 1e), suggesting the recorded CAP is dominated by activity from type AB JONs and that adaptation is a property of this subpopulation. This result is consistent with previous reports that show that the activity of type AB JONs, but not of type CE JONs, is visible in the CAP for the frequency and intensity range of stimuli used in our study11,21,24. Second, extracellular signals, such as cortical LFPs, can be sensitive to the synchrony among neurons in the population27. The noise stimuli we used should avoid desynchronization25, as can be shown using a simple model of a population of leaky integrate and fire (LIF) neurons (Supplementary Fig. 2). Only adding a positive offset to the stimulus would drive LIF neurons in a way that induces desynchronization, but this alone is not sufficient to produce transient changes in synchrony upon steps in noise intensity (Supplementary Fig. 3), further supporting the idea that desynchronization does not explain the CAP dynamics. Finally, we recorded calcium signals via GCaMP6f28 from type A and B JON projections into the AMMC (Supplementary Fig. 4a). Calcium responses disappear when blocking JON spiking through bath application of TTX (Supplementary Fig. 4b), indicating that they represent the spiking activity of JONs. While the temporal resolution of GCaMP6f is impoverished compared with the CAP, calcium signals are not known to be sensitive to fine-scale neuronal synchrony and thus these recordings provide a more direct, albeit slow, readout of JON spiking. The calcium responses of both type A and B JONs for noise stimuli confirm the results obtained from CAP recordings (Supplementary Fig. 4c, d): responses saturate in the range of intensities tested (see also ref. 16) and exhibit both positive and negative transients immediately after steps. While adaptation appears to be weaker than that measured with the CAP likely due to the slow dynamics of the calcium indicator (Supplementary Fig. 4e), it is present nonetheless.

We also built simple, proof-of-principle models to demonstrate that alternative explanations of the adaptation dynamics in the CAP based on response heterogeneity—differences in frequency or intensity tuning—within type AB JONs are inconsistent with our data, in particular with the negative transients observed for negative steps in intensity (see Supplementary Figs. 5 and 6 for details). Nonetheless, in the absence of recordings from individual type AB JONs, these models cannot rule out a contribution of desynchronization, intensity range fractionation, or other forms of response heterogeneity to our observation of variance adaptation. However, our models show that doing so will require auxiliary assumptions, and that changes in firing rate within individual type AB JONs is a more parsimonious explanation of all of our data.

The above experiments and analyses provide strong evidence that type AB JONs adapt their firing rates to changes in sound intensity (variance), but by what arithmetic operation do they do so? Since sound intensity scales the distribution of antennal displacements, variance adaptation should be divisive, not subtractive, and result in a change of the slope of the intensity tuning curve. We therefore measured JON responses to short, intermittent probe stimuli interleaved within background noise stimuli of a particular intensity (Fig. 2a, bottom). The resulting family of intensity tuning curves—one for each background intensity—describes how JON sensitivity changes for different adaptation states (Fig. 2a, top). On a linear intensity scale, the slope of the tuning curves decreases with background intensity, indicating that variance adaptation is indeed divisive. A logarithmic intensity scale, which transforms this division to a rightward shift of the tuning curves, reveals (a) that tuning curve shape is invariant to intensity (Fig. 2b, c) and (b) that the shift is proportional to the background intensity (Fig. 2d). Variance adaptation in JON thus completely corrects for intensity across the dynamic range tested—in both male and female flies (Supplementary Fig. 7). Regardless of the shift, the tuning curve’s steepest part is always centered around the background level. Accordingly, stimulus discriminability—quantified using Fisher information29—also shifts dynamically and is always maximal around the background level (Fig. 2e–g). Thus, adaptation enhances the resolution with which changes from the background level are encoded. More broadly, JONs do not encode absolute stimulus intensity, but intensity relative to the background, as is the case for many other sensory systems30,31.

Fig. 2
figure 2

Variance adaptation in JON is divisive and corrects for background noise. a Intensity tuning curves for JONs adapted to different background stimuli (top, color coded by background intensity; vertical lines mark the background intensity; 40 trials for each background and probe combination). JONs were adapted using a white noise background sound and sound sensitivity was measured using brief, interleaved probe stimuli (amplitude profile of the noise stimulus shown in bottom). On a linear intensity scale, the slope of the tuning curves decreases with background—variance adaptation is thus divisive. Error bars show mean ±95% CI. b Same as a, but plotted on a logarithmic intensity scale, which transforms the change in slope into a tuning curve shift. Dots correspond to data (error bars omitted for clarity), lines show fit of sigmoidal curves (see “Methods” section for details). c Sigmoidal fits from b plotted on a log intensity scale relative to background intensity. Tuning curves overlap, demonstrating that the tuning curve shift is proportional to the background intensity. d Shift of the tuning curves is proportional to background intensity for all N = 5 flies (r2 = 0.95). The diagonal line corresponds to a perfect match between the tuning curve position and background. All JON tuning curves largely match the diagonal’s slope with a weak positive offset. e, f Fisher information curves for the tuning curves in b (normalized to max) show that the discriminability of intensities shifts in proportion to the background intensity (e—absolute log intensity, f—background-relative log intensity). g The peak intensities for the Fisher information curves shift with background for all N = 5 flies (r2 = 0.97). Panels ac and e, f show data from one fly

Variance adaptation for song stimuli

We next examined the properties of variance adaptation for naturalistic stimuli. Drosophila courtship song comprises bouts consisting of rapid alternations between two modes—sine and pulse (Fig. 3a). Sound can be decomposed into two components: fast fluctuations of the raw waveform (the carrier), and an envelope, which corresponds to amplitude changes of the carrier on a slower timescale (Fig. 3b). Sine song and pulse song have different, species-specific, sinusoidal carriers of ~150 and 250–300 Hz, respectively32,33. But song modes also differ in their envelope dynamics: pulse song’s envelope is highly transient, with a species-specific interval between pulses in a pulse train (inter-pulse interval) of ~36 ms for melanogaster. In contrast, the envelope of sine song is only weakly modulated and hence resembles the steady envelope of noise stimuli (Fig. 3b).

Fig. 3
figure 3

Variance adaptation and courtship song signals. a Courtship song is produced in bouts and consists of two modes: sine (blue) and pulse (red). b Sine song (blue) exhibits a relatively constant amplitude profile, while pulse song (red) consists of trains of transient pulses with interleaved pauses. c, d Artificial sine song and pulse song presented at a range of different intensities (color coded, see legend in e). e CAP (top—raw CAP, bottom—CAP amplitude) from one fly for 300 Hz sinusoids of different intensities (c). Intensity is color coded (see legend). After a strong onset transient (left), the CAP amplitude drops rapidly (right—steady-state response after 500 ms). Inset shows the frequency doubling of the CAP (top—stimulus at 4 mm s−1, bottom—CAP response oscillates at twice the stimulus frequency, or 600 Hz). f CAP (top—raw CAP, bottom—CAP amplitude) from one fly for synthetic pulse trains with different intensities (d pulse interval 36 ms, intensity color coded, see legend in e). While there is a weak decrease of response amplitude across pulses in a train, responses still scale with intensity (see also Supplementary Fig. 8c–e). g, h Onset and steady-state intensity tuning for sine stimuli (g) and pulse stimuli (h) (see also Supplementary Fig. 8); N = 6 flies, 20 trials each. Error bars correspond to mean ±95% CI across flies. i Asymmetrical responses to pulses (inset—CAP from one fly) betray adaptation. Thin black lines show CAP amplitude vs. stimulus amplitude for the first six pulses in a train (pulse peak intensity 2 mm s−1). N = 6 flies. Responses to pulse onset have a much larger slope than those to pulse offset (see diagonal lines). j Peak responses at steady state (after 1.4 s into pulse train) for pulse trains with different inter-pulse intervals (pulse duration 16 ms, intensity 4 mm s−1, gray lines show response of individual flies (N = 4), normalized to the max response; thick black lines correspond to mean ± s.e.m.). Responses are weak for short inter-pulse intervals due to stronger adaptation. Inset shows CAP amplitude traces for pulse trains with IPIs of 8 ms (blue), 24 ms (red) and 72 ms (orange). All CAP traces averaged over 20 trials

We examined neural responses for song-like stimuli across a range of intensities (0.06–4 mm s−1, Fig. 3c, d). Consistent with our expectation, adaptation to sinusoidals resembles that of adaptation to noise (compare with Fig. 1b, c), with onset transients that scale with intensity and weaker, saturating steady-state responses (Fig. 3e, g, compare with Fig. 1d). This adaptation is not confined to the melanogaster sine song frequencies but occurs at all frequencies tested (from 100 to 900 Hz, Supplementary Fig. 8a, b). Adaptation was much weaker for pulse song (Fig. 3d), and intensity tuning resembled that of sine song onsets throughout the pulse train, with a near-linear relation between intensity and response (Fig. 3f, h). Nonetheless, other features of the responses to pulse trains betrayed a dynamic adjustment of response gain. First, pulse response amplitude weakly decreased across pulses in a train particularly at high intensities (Supplementary Fig. 8c–e). Second, responses to symmetrical pulses were asymmetrical, with strong responses during pulse onset and shallower responses during pulse offset (Fig. 3i). Asymmetry of responses for on and off ramps is a signature of gain control in other systems, such as the olfactory receptor neurons of Drosophila larvae34. Additionally, when we tested stimuli of different inter-pulse intervals, we found that the responses to individual pulses depended on the interval between pulses, with short intervals inducing weaker responses during the pulse train, due to stronger adaptation (Fig. 3j). We also observed a small reduction of responses for the longest IPIs tested, which cannot be explained by adaptation: CAP responses recover from adaptation within ~30 ms and hence adaptation does not affect responses to pulses that are spaced further apart in time (Fig. 1d). Overall, although variance adaptation is too slow to correct for the amplitude of individual pulses at the melanogaster-typical pulse interval, it acts as a high-pass filter for this species-specific song feature (reducing responses to songs with shorter IPIs), and thereby could contribute to song evaluation.

Cellular origins of variance adaptation in the antenna

Since there are no synapses between individual JONs (with the possible exception of gap junctions between JON axons35) nor feedback to the JON from the brain or other sensory structures36, variance adaptation is likely to arise within individual JONs, at one of the following levels (Fig. 4a): (i) the movements of the antenna, (ii) the subthreshold mechanosensitive generator currents19,21, or (iii) the generation of spikes.

Fig. 4
figure 4

Cellular basis of variance adaptation in JO neurons. a Sound-induced antennal movement was measured using laser vibrometry (b). Generator (c) and spike-driven (d) currents were read out via patch clamp recordings of the giant fiber neuron (GFN), after bath application of TTX (c) or with normal saline (d). be Amplitude profile of the noise steps used to probe adaptation in different processing stages in JONs (top). Step size is color coded (see legend in d). Magnitude of antennal movement (b), generator current (c), spike-driven currents (d), and CAP (e) to the intensity steps. Adaptation transients first arise in the generator current (c). All panels show one fly with 20 trials per step (c—100 trials per step). f Time constant of adaptation at different stages within JON processing obtained by fitting exponentials to the transients in be (time constant averaged across all step sizes). The lack of adaptation in the antennal movements prevented estimation of time constants for the antenna. P values indicate the results of two-tailed tests (sign test for paired data (generator vs. spike), rank sum for unpaired data (LDV (laser Doppler vibrometry) vs. generator, spike vs. CAP)). N = 7 flies for generator/spike, N = 4 for LDV, N = 5 for CAP (number of trials as in be). g Strength of adaptation for the signals in be was obtained by comparing the responses to the different intensities at step onset vs. steady state. Adaptation values of 1.0 indicate complete adaptation (values can be greater than 1 or smaller than 0 due to noise in the CAP responses). Statistical procedures and N as in f. Error bars in f and g show mean ± standard deviation over flies. h Adaptation in flies mutant for the TRP channel nompC (green, blue, wild-type flies shown in gray for comparison). All mutants adapt for background intensity by shifting their tuning curve. The black diagonal line corresponds to perfect adaptation, complete absence of adaptation would lead to horizontal trends. Adaptation is reduced for soft backgrounds (1/4–1 mm s−1) in the nompC double mutants due to their reduced sound sensitivity. Mean ± s.d. over flies (see Supplementary Fig. 9 for N)

Like cochlear hair cells, the JO neurons are not passive transducers of mechanical stimuli but actively amplify antennal movement for soft sounds and partly reset antennal position after a static deflection through mean adaptation16,18,21,22,37. If the variance adaptation reported here was part of the same process underlying amplification and mean adaptation, then it should reduce the gain of antennal movement. This should decrease sound-induced antennal vibrations following a rapid increase in sound intensity and create adaptation transients in antennal position. We measured arista movement using laser Doppler vibrometry and found that the amplitude of antennal vibrations faithfully followed changes in stimulus intensity (Fig. 4b), lacking the adaptation transients seen in the CAP (Fig. 4e). We also tested nompC mutants that lack active amplification37. These mutants have diminished sound sensitivity16, but nonetheless we found that for stimuli that evoked strong responses (>1 mm s−1), variance adaptation was still present (Fig. 4h and Supplementary Fig. 9). That is, JON intensity tuning shifted with background intensity in the nompC background, just as for wild type. These results suggest that variance adaptation in the JONs is independent of active antennal mechanics and amplification.

Following mechanical amplification, sound-induced antennal vibrations open stretch-sensitive ion channels in the JON’s dendritic tips and produce a transduction or generator current19. This subthreshold current could adapt either directly, as part of the mechanotransduction machinery, or indirectly, on its way to the spike-initiating zone (Fig. 4a). While the generator currents are too small to be recorded extracellularly, a subset of type A JONs form gap junction-only synapses with the giant fiber neuron (GFN)38,39,40 and recording the GFN in voltage-clamp mode reveals the synaptic currents induced by the spikes of type A JONs19. These spike-induced currents in the GFN provide an alternative readout of JON spiking activity and exhibit adaptation similar to that of the CAP, confirming that the CAP is an appropriate readout of JON spiking (Fig. 4d, compare with CAP in Fig. 4e). Bath application of TTX during these GFN recordings abolishes the spike-driven input current from the JONs and unmasks the generator current19, which exhibits transients upon stimulation with noise steps, demonstrating that adaptation is present in the subthreshold currents (Fig. 4c).

The adaptation transients recorded from the GFN are slower than those in the CAP (Fig. 4f) and adaptation appears less complete (Fig. 4g). This may be because the generator current travels passively along the axons of type A JONs and through the gap junction to the recording site at the GFN soma; this pathway likely acts as a low-pass filter. Alternatively, subsequent spike-frequency adaptation with JONs could further accelerate and complete variance adaptation. Nonetheless, the existence of transients demonstrates that variance adaptation arises in the generator current and does not require spiking. Because adaptation in many sensory neurons involves the calcium-sensitive molecule Calmodulin7,41,42,43, we also tested adaptation in calmodulin mutants20. However, these flies exhibited normal adaptation (Supplementary Fig. 9), suggesting that variance adaptation in JONs either operates via a calcium-independent mechanism or another calcium-sensitive molecule44. So far, we have shown that physiologically separable computations in Drosophila auditory receptor neurons appear prior to spiking within individual JONs: active amplification37, mean adaptation18,19,22, and now variance adaptation. This raises the question of how these two forms of adaptation interact, given that sound sensitivity should be independent of the slow antennal offset induced by wind or gravity.

Interaction between mean and variance adaptation

To explore the interaction between mean and variance adaptation, we controlled the antennal offset (or mean position of the antenna) and the magnitude (or variance) of antennal vibrations independently using a piezoelectric actuator. Piezoelectric actuation reproduced previous results regarding mean adaptation studied using electrostatic forces to deflect the antenna18 (Supplementary Fig. 10). We first engaged mean adaptation by statically deflecting the antenna (to ±0.22 or ±0.44 μm) and tested whether this affected tuning for intensity by probing with sinusoidal motion of different magnitudes (300 Hz, 0.1–1.1 mm s−1; Fig. 5a). We found that intensity tuning remained the same for all offsets, demonstrating that mean adaptation does not affect sensitivity to sound (Fig. 5b, c). On the other hand, when we engaged variance adaptation via sinusoidal modulations (300 Hz, 0.07–0.63 mm s−1) and subsequently measured responses to superimposed steps (±0.01–0.78 μm; Fig. 5d), sensitivity to step stimuli decreased (Fig. 5e, f). Thus, the interaction between mean and variance adaptation in JONs is unidirectional—variance adaptation affects responses to displacement but mean adaptation does not affect responses to sound. This suggests that the majority of variance adaptation occurs downstream of mean adaptation, consistent with the fact that mean adaptation is already visible at the level of antennal movement18, but variance adaptation is not (Fig. 4b). The independence of mean and variance adaptation could be achieved through a separation of timescales, but we find that both forms of adaptation are similarly fast18 (Fig. 1e and Supplementary Fig. 10). To gain insight into the computations underlying the independence of sound sensitivity from mean adaptation, and to test the hypothesis of a serial implementation of first mean and then variance adaptation, we built a phenomenological model of adaptation in the JO.

Fig. 5
figure 5

Interaction between offset (mean) and intensity (variance) adaptation in JO neurons. a Stimuli for probing the impact of offset (mean) adaptation on intensity tuning (top)—a piezoelectric actuator was used to step deflect the antenna to induce mean adaptation (see Supplementary Fig. 10). Sensitivity to sound intensity was estimated by measuring the responses (bottom) to sinusoidal antennal deflection superimposed on the steps of different size (color coded—see insert in b). b Intensity tuning curves (dots) and sigmoidal fits (lines) for different levels of mean adaptation (color coded, see legend). c Tuning curve shifts with offset extracted from the sigmoidal fits (see b) for N = 4 flies. No significant correlation with the adaptation step was observed for any fly (p > 0.14). d Impact of variance adaptation on step responses was probed by superimposing step deflections onto sinusoidal antennal modulation of different magnitudes, again via piezoelectric actuator, and measuring responses (color coded—see insert in d). e Step tuning curves (dots) and sigmoidal fits (lines) for different levels of variance adaptation (color coded, see legend). Since step tuning curves are symmetrical, responses to positive and negative steps were averaged. f Tuning curve shifts with intensity extracted from the sigmoidal fits (see e) for N = 7 flies. Significant correlation with adaptation step was observed in all flies (p < 0.01). a, b, d, e show responses from one fly, each averaged over 20 trials

A sequential network motif for mean and variance adaptation

We started by defining a set of elementary computations we deemed necessary for reproducing our experimental findings. Mean and variance adaptation in our model are implemented using incoherent feedforward loops34,45: The loop’s input is low-pass filtered to an adaptation signal, which is either subtracted from the input (subtractive adaptation) or used to divide the input (divisive adaptation). We also included a rectifying nonlinearity in our model, since rectification is known to be necessary for variance adaptation46.

To explore the constraints underlying the organization of the two types of adaptation we consider here, we tested all possible sequential or parallel arrangements of these three elementary computations in our model (Supplementary Fig. 11a). Consistent with our hypothesis, only a sequential arrangement of (1) subtractive adaptation, (2) rectification, and (3) divisive adaptation reproduced our experimental observations (Fig. 6a). This sequence corresponds to the solution engineers would choose if they wanted to correct a signal for its mean and variance: first subtract the mean, estimate the signal’s intensity through rectification, and then divide by the intensity. The model’s qualitative behavior was robust to changes in model parameters (e.g., adaptation time constants or adaptation strength, Supplementary Fig. 11b, c). In particular, the independence of sound sensitivity from mean adaptation does not require a separation of timescales—it persists even when mean adaptation is faster than variance adaptation (Supplementary Fig. 11b). The resulting pattern of adaptation is thus a general property of this arrangement of computations, not of the specific parameters chosen. The first stage of the network motif involves low-pass filtering the stimulus to produce an adaptation signal that represents the slowly varying stimulus mean, which is then subtracted from the stimulus (Fig. 6b, c). For step stimuli, this adaptation signal corresponds to a smoothed version of the stimulus (Fig. 6b). For sound stimuli, however, with their symmetrical and fast fluctuations, this signal is nearly flat, since the positive and negative deflections cancel each other during the low-pass filtering (Fig. 6c). This first stage thus only adapts to quasi-static stimulus components (Fig. 6f, compare Supplementary Fig. 10) but does not alter responses to the sound (Fig. 6c). This is why mean adaptation does not affect sound sensitivity in the model (compare Fig. 6g with Fig. 5b).

Fig. 6
figure 6

Computational model of adaptation in the JO. a A sequence of subtractive adaptation, rectification, and divisive adaptation reproduces our experimental data (see also Supplementary Fig. 11a). b–e Signals from different stages of the model in a for step (b, d 10 ms) and sinusoidal (c, e 400 Hz) displacement. Adaptation signals and adapted signals are colored red and blue, respectively. Shown are the stimulus (black in b and c), the linear adaptation signals (red in b and c), the output of the mean adaptation stage (blue in b and c), the rectified form of this output (black in d and e), the rectified adaptation signal (red in d and e), and the output of the variance adaptation stage corresponding to the overall output of the system (blue in d and e). f Step tuning curves of the model for different antennal baseline positions (adaptation steps, color coded, see legend) on an absolute scale (left panel) and relative to the baseline (right panel) (compare with data in Supplementary Fig. 10). The model qualitatively reproduces subtractive mean adaptation, which corrects for antennal baseline. g Intensity tuning curves of the model for different noise backgrounds (adaptation intensities, color coded, see legend) on an absolute intensity scale (left panel) and relative to the background intensity (right panel) (compare with data in Fig. 2b, c). Variance adaptation is divisive and compensates for sound intensity. h Intensity tuning of the model for different antennal baseline positions (color coded, see legend in d) corresponding to different levels of mean adaptation (compare with data in Fig. 5b). Intensity tuning is independent of mean adaptation. i Step responses of the model for different noise backgrounds (color coded, see legend in e) corresponding to different levels of variance adaptation (compare with data in Fig. 5e). Responses to steps are reduced with variance adaptation. The curves for different background noises or steps in d (right panel), e (right panel), and f are near-identical and hence appear as single curves

The output of the mean adaptation stage is then rectified (Fig. 6d, e), either through half-wave rectification (setting the negative parts of the signal to zero) or full-wave rectification (inverting the sign of negative signal parts) (Supplementary Fig. 12, left). Rectification transforms the standard deviation of the input (sound intensity) to the mean of the rectified output (Supplementary Fig. 12, right). This enables encoding of—and subsequently adaptation to—signal intensity by simple low-pass filtering. Two features of the CAP responses suggest that JONs implement full-wave rectification: (i) responses to step deflections are identical for positive and negative steps (Supplementary Fig. 10) and (ii) responses to sinusoidals display frequency doubling (Fig. 3c, inset, compare Supplementary Fig. 12, bottom left). However, the specific form of rectification does not crucially affect adaptation in the model.

In the divisive adaptation stage (Fig. 6d, e), the adaptation signal now encodes stimulus intensity and divides the rectified signal to implement variance adaptation (Fig. 6h, compare Fig. 2b, c). Since the responses to steps have non-zero mean at the input of this stage (Fig. 6d), they also induce divisive adaptation, just as in our data, in which variance adaptation reduced step responses (Fig. 6i, compare Fig. 5e).

The model thus explains the unidirectional interaction between mean and variance adaptation in JONs: mean adaptation does not affect sound responses (Fig. 6g), since the first, subtractive adaptation stage is basically blind to sound (Fig. 6c). By contrast, variance adaptation does affect step responses (Fig. 6i), since the adaptation signal in the second, divisive adaptation stage is non-zero for sounds and for steps (Fig. 6b, d). Overall, starting from our experimental findings on the interaction between mean and variance adaptation in the JO, our model proposes how efficient sensory adaptation to both mean and variance can be implemented.

Discussion

Our analysis of adaptation in the Drosophila auditory system reveals that the receptor neurons subtract away changes in the physical stimulus mean, which corresponds to the baseline displacement of the sound receiver, and normalize for the variance of the stimulus, which corresponds to the sound intensity (Figs. 13). Both forms of adaptation first arise in JON subthreshold currents, before spiking (Fig. 4). Even though these two computations are implemented within a single neuron, they are partly independent: mean adaptation does not affect intensity tuning, but variance adaptation reduces responses to static receiver displacements (Fig. 5). A computational model suggests that this compartmentalization of mean and variance adaptation in JONs can be achieved by first subtracting the raw physical stimulus, then rectifying the mean-subtracted stimulus, and finally dividing by the rectified signal to correct for intensity (Fig. 6).

The two forms of adaptation studied here underlie an efficient representation of courtship song. As the female moves, her antenna is deflected by wind or gravity, while rapid changes in her position relative to the male singer induce fluctuations in song intensity at her ear. Mean adaptation has been shown to be subtractive and to render the auditory JONs largely insensitive to static or slow deflections18,19. Here we show that variance adaptation is divisive and induces intensity invariant responses after ~40 ms. This contrasts with variance adaptation in the vertebrate ear, where the tuning curves of individual auditory nerve fibers do not shift sufficiently to correct for background intensity47,48.

Variance adaptation in the auditory receptor neurons, while fast enough to correct for the weakly amplitude modulated sine song, does not correct for the intensity of individual pulses within the pulse song (Fig. 3d, f, h). However, it still improves the representation of pulses, as it corrects for background sound levels (Fig. 2). In addition, variance adaptation underlies a high-pass filter for the inter-pulse interval (Fig. 3j), indicating that tuning for conspecific song features begins to arise at the level of the receptor neurons. Behavioral tuning for inter-pulse interval is a band-pass centered around values found in the conspecific song (35–40 ms)49,50,51 and auditory neurons in the fly brain (AMMC-B1 neurons)52,53 already exhibit weak band-pass tuning for inter-pulse interval. Our results suggest that this tuning may in part be inherited from the JON inputs52. The incomplete adaptation to pulse trains containing melanogaster-specific inter-pulse intervals may be useful for encoding absolute pulse intensity, and this may facilitate orientation behaviors54. In addition, first-order auditory neurons in the fly brain (AMMC neurons) show adaptation across pulses in a train9, thereby further correcting for pulse intensity variation.

Information about antennal position in the sound-responsive type AB JONs is ambiguous since onset responses for step deflections depend on the intensity of the superimposed sound (Fig. 5e). However, type CE JONs do not adapt to antennal offsets and hence encode absolute antennal position11,12,23. Thus, just like in the mammalian somatosensory system, where different neurons adapt differentially to encode different aspects of touch55, distinct sensory channels in the Drosophila antenna differ in their adaptation properties to encode distinct aspects of antennal displacement.

Our data strongly suggest that adaptation is not a population-level phenomenon, but arises within individual type AB JONs. We recorded CAP signals from only type AB or B JONs (Fig. 1f), and recorded spiking and subthreshold activity from a subpopulation of type A JONs (Fig. 4d)—for both experiments, we observed adaptation transients. We also recorded calcium signals from type A or B JONs (Supplementary Fig. 4)—unlike the CAP signal, calcium signals recorded via GCaMP6f are a measure of population firing rate not sensitive to spike timing; the existence of adaptation transients in the calcium signals further indicates that changes in JON sensitivity—not in population synchrony—underlie adaptation. Finally, simple models revealed that explanations for adaptation based on response inhomogeneity within the type AB JONs are unlikely to explain the observed adaptive CAP dynamics (Supplementary Figs. 3, 5 and 6). These experiments and models do not rule out alternative explanations of adaptation in the CAP—however, they demonstrate that adaptation within individual type AB JON is the most parsimonious explanation of all of our data combined.

While the molecular bases for mean and variance adaptation in the JONs are still unknown, our data and model constrain hypotheses about their biophysical implementations. Mean and variance adaptation in JONs interact unidirectionally—mean adaptation does not affect sensitivity to stimulus variance but variance adaptation does affect responses to offsets (Fig. 5). Our model suggests that this can be implemented by a serial arrangement of two adaptation stages with an interleaved rectification step. The first adaptation stage subtracts the stimulus mean. After an interleaved rectification step, the second adaptation stage is divisive and corrects for intensity (Fig. 6). The partial compartmentalization of the two adaptation forms within JONs can be achieved by implementing mean adaptation at the mechanotransduction step. This is supported by mean adaptation affecting the mechanical sensitivity of the antenna and thus being visible in the antennal movement18,21. Mean adaptation is thought to occur via a stiffening of the gating springs that transform the antennal movement into opening and closing of mechanosensitive channels in JONs18,55. For mean adaptation to not affect sound sensitivity, the underlying adaptation signal must not be rectified, but must be a linear representation of the symmetrical antennal vibrations (Supplementary Fig. 11a).

Since variance adaptation is not visible in the antennal movement, it likely arises downstream of the gating of mechanotransduction channels. We find that rectification compartmentalizes mean and variance adaptation in JONs, not a separation of timescales, since mean or variance adaptation are equally fast18 (Fig. 1e and Supplementary Fig. 10). Rather, the separation arises because (i) the mean of the raw stimulus—prior to rectification—is independent of the variance and (ii) rectification after mean subtraction transforms the stimulus variance to the mean of the rectified signal (Supplementary Fig. 12). Thus, simply dividing by the rectified, mean-subtracted stimulus implements variance adaptation46. The same principle holds for retinal adaptation to visual contrast55 and for intensity adaptation in hair cells57. Rectification may be implemented in JON dendrites via voltage-sensitive channels whose activation curve exhibits a hard or soft threshold20,58,59. Intriguingly, the frequency doubling in the CAP—a 300 Hz tone induces 600 Hz CAP oscillations (Fig. 3c)—could be the result of full-wave rectification that transforms a sinusoidal’s negative lobes into positive ones (Supplementary Fig. 12). However, in the absence of single-neuron recordings of JONs, it is unclear whether this frequency doubling arises within single neurons or whether it is the outcome of recording from a population of neurons that respond at different phases of the sinusoidal19. Nevertheless, it is tempting to speculate that the frequency doubling in the CAP is a correlate of rectification for variance adaptation in single JONs.

Which molecules mediate variance adaptation? One possibility includes low threshold, voltage-sensitive potassium channels that open in response to subthreshold depolarizations with a delay and can thus dynamically reduce the amplitude of the generator currents (e.g., ref. 60). Adaptation channels can operate in a calcium-dependent manner, but we found that variance adaptation in calmodulin mutants appeared normal (Supplementary Fig. 9). Alternatively, the TRP channels nompC, nanchung, and inactive have been shown to adjust the gain of mechanotransduction in the JO37. They could hence also play a role in variance adaptation, which corresponds to a dynamical gain adjustment. However, we also found that nompC mutants display normal variance adaptation within their dynamic range (Fig. 4h and Supplementary Fig. 9). This is consistent with the observation that NompC mainly affects antennal gain and thus presumably acts upstream of variance adaptation37 (Fig. 4b). One major difficulty in discovering the molecules that mediate variance adaptation is that these molecules may also be involved in establishing the generator currents themselves (for example, nanchung and inactive mutants abolish the generator current19)—disentangling the two requires a way to measure adaptation and mechanotransduction independently.

How different forms of adaptation are organized in sensory receptor neurons fundamentally depends on the properties of the physical quantity they process. For the visual system, the mean and variance of a luminance pattern are both scaled by changes in illumination and hence can be corrected for in a single divisive step within photoreceptors46,61. Receptor neurons processing physical quantities that obey a similar scaling law between mean and variance—for instance, those that correspond to a count or a rate—should organize adaptation in this way. The olfactory sensory neurons process the molecule count or odorant concentration, the mean and variance of which are similarly scaled by diffusion. Accordingly, olfactory receptor neurons have been shown to implement divisive—not subtractive—adaptation to concentration62,63,64,65. This also applies to adaptation in higher-order neurons, e.g., adaptation to visual or acoustic contrast30,46,65.

By contrast, the mean and variance of the physical quantity processed by auditory receptor neurons do not obey the same scaling law since they are typically affected by independent processes: the additive mean corresponds to a baseline displacement of the mechanical receiver, while the multiplicative variance corresponds to fluctuations in intensity of the actual sound stimulus, which is superimposed on the time-varying baseline. Adaptation in cochlear hair cells and now in JO neurons is organized accordingly, first subtracting the mean and then dividing by the variance7,47. All receptor neurons that process physical quantities with an additive mean and a multiplicative variance—e.g., quantities that can have both positive and negative values—should follow this pattern. While the existence of adaptation has been reported for virtually all sensory systems, the computations and interactions of various forms of adaptation are rarely studied. For instance, mechanosensory bristles in Drosophila implement subtractive adaptation to step deflections67, but to the best of our knowledge neither variance adaptation nor its interaction with mean adaptation have been studied. Likewise, primary sensory afferents of the whisker system adapt to different degrees of whisker deflection, but the computations underlying adaptation are unknown68. Strikingly, different afferents encode different aspects of whisker motion, like position or velocity69, and this diversity could be explained through the diversity of adaptation—e.g., strong mean adaptation supports encoding of velocity and prevents encoding of whisker position. Our combined experimental and modeling strategy for studying the conserved processes of mean and variance adaptation, and their interactions, can now be used to facilitate a genetic dissection of the molecules that underlie both forms of adaptation in the Drosophila model system.

Methods

Flies

Group housed, virgin females were used for all recordings unless noted otherwise. Extracellular recordings were performed 2–5 days post eclosion. The wild-type strain used was Canton S (CS). Since homozygous nompC mutants are lethal, we used transheterozygous mutants for two different nompC null alleles (nompC1/nompC3 and nompC3/nompC1, depending on whether the nompC1 allele was inherited from the mother or the father) as in ref. 19. Similarly, we generated transheterozygotes for the cam locus (camn339/cam5)20. We recorded CAPs from genetically identified subsets of JONs using flies mutant for iav (iav1/iav1) and we rescued the mutation by expressing wild-type Iav under the control of JO1 (JON-ABCDE), JO2 (JON-B), or JO15 (JON-AB)19,70. Calcium signals of JON-AB were recorded using GCaMP6f under the control of JO15-Gal4. Patch clamp recordings from the GFN were performed in flies expressing eGFP in C17-GAL4. Since the generator currents were stronger in younger flies19, we recorded at days 1–2 post eclosion. All flies were raised on a 12:12 dark–light cycle. All fly strains were ordered from the Bloomington or Kyoto stock centers, with the exception of UAS-iav, which was kindly supplied by Rachel Wilson. The original citations for the fly strains are as follows: iav126, UAS-iav71, JO1 (NP0761), JO2 (NP1046), and JO1570, c17-Gal472, UAS-eGFP73, nompC1 and nompC382, cam[n339]74, cam[5]82, and UAS-GCaMP6f28

Detailed genotypes used

Figures 1b–e, 2, 3, and 5 and Supplementary Figs. 1b–c, 7, 8, and 10, Canton S

Figure 1f and Supplementary Figs. 1d–e, Canton S (wild type) and iav1/iav1 (iav1) and iav1/iav1;UAS-HM-iav/+;JO1-Gal4/+ (JON-ABCDE) and iav1/iav1;UAS-HM-iav/+;JO15-Gal4/+ (JON-AB), and iav1,JO2-Gal4/iav1, JO2-Gal4;UAS-HM-iav/+;+ (JON-B)

Figure 4b–g, Canton S (antenna, CAP),+; UASeGFP2x/C17-Gal4 (generator, spike)

Figure 4h and Supplementary Fig. 9, Canton S (wild type) and+;nompC1,cn,bw/cyo (nompC1/cyo),+;nompC3,cn,bw/cyo (nompC3/cyo) and +;nompC1,cn,bw/nompC3,cn,bw (nompC1/nompC3 (maternal/paternal) and nompC3/nompC1 (maternal/paternal) and camn339/cam5 (Supplementary Fig. 9 only)

Supplementary Fig. 1a +;JO15-Gal4/UASeGFP2x (patch clamp)

Supplementary Fig. 4, +;UAS20x-GCaMP-6f-UAS-Tom/cyo; JO15-Gal4/Tm6,tb (Calcium imaging)

Stimulus design and presentation

Stimuli were generated at a sampling frequency of 10 kHz. Band-limited Gaussian noise (from now on termed “noise”) was produced from a sequence of normally distributed random values by band-pass filtering using a linear-phase FIR filter with a pass band between 80 and 1000 Hz. For probing adaptation, we switched the intensity of the noise every 100 ms (or 1000 ms for Ca++ imaging) in a sequence that contained all transitions between ¼, ½, 1, and 2 mm s−1 (Fig. 1b). The effect of adaptation on intensity tuning was assessed using a noise stimulus at intensities ¼, ½, 1, 2, and 4 mm s−1 (adaptation background) whose intensity was switched every 120 ms for 20 ms to a probe intensity of 1/16, 1/8, ¼, ½, 1, 2, 4, and 8 mm s−1 (e.g., Fig. 1f). To minimize artifacts from abrupt changes in sound intensity, each intensity switch had a duration of 1 ms during which the intensity was linearly interpolated to the new value.

Artificial pulse song (Fig. 3d) was generated as a train of Gabor wavelets: sin(x*2πfc + ϕ) exp(−(x/σ)2 with carrier frequency fc of 250 Hz, phase ϕ of 0π, standard deviation σ of 4.6 ms and an inter-pulse interval of 36 ms. These parameters were chosen to mimic the shape of song pulses produced by Drosophila melanogaster males during natural courtship33. For Fig. 3j, the inter-pulse interval was varied between 8 and 72 ms.

Sound

The sound delivery system consisted of (i) analog output of a DAQ card (PCI-5251, National Instruments), (ii) a two-channel amplifier (Crown D-75A), (iii) a headphone speaker (KOSS, 16 Ω impedance; sensitivity, 112 dB SPL/1 mW), and (iv) a coupling tube (12 cm, diameter 1 mm).

The stimulus presentation setup was calibrated as in ref. 9. Briefly, the amplitude of pure tones of all frequencies used (100–1000 Hz) was set using a frequency-specific attenuation value measured with a calibrated pressure gradient microphone (NR23159, Knowles Electronics Inc., Itasca, IL, USA). To ensure that the temporal pattern of the noise stimuli was reproduced faithfully, we corrected the presented noise patterns by the inverse of the system’s transfer function, measured using a pressure microphone (4190-L-001, Brüel & Kjaer). During experiments, the sound tube was positioned behind the fly at a distance of 2 mm and an angle or 90° to the right (extracellular recordings and laser Doppler vibrometry) or left (Calcium imaging) arista.

Piezoelectric actuation

Piezoelectric actuation was performed using a single channel piezo driver (MDT694, Thorlabs) and actuator (A186). The piezo actuation was calibrated using laser Doppler vibrometry (see below) by measuring displacement and velocity of the piezo tip for all driving voltages used in the experiments (steps and 300 Hz sinusoidals). Step stimuli for piezoelectric actuation were low-pass filtered using a 1 ms Gaussian window to stay within the operating limits of the piezo driver.

Electrophysiology

Extracellular recordings were performed using glass electrodes (1.5OD/2.12ID, WPI) pulled with a micropipette puller (Model P-100, Sutter Instruments). The fly’s wings and legs were removed under cold anesthesia and the abdomen was subsequently fixed using low-temperature melting wax. The head was fixed by extending and waxing the proboscis’ tip. The preparation was further stabilized by applying wax or small drops of UV-curable glue to the neck and the proboscis. The recording electrode was placed in the joint between the second and third antennal segment and the reference electrode was placed in the eye. Both electrodes were filled with external saline76.

The recorded signal was amplified and band-pass filtered between 5 and 5000 Hz to reduce high-frequency noise and slow baseline fluctuations induced by spontaneous movement of the antenna (Model 440 Instrumentation Amplifier, Brownlee Precision). We ensured that the band-pass filter did not distort the recorded signal, e.g., introduce artefactual response transients. We subsequently digitized at 10 kHz with the same DAQ card used for stimulus presentation (PCI-5251, National Instruments).

Patch clamp recordings from the giant fiber neuron were performed as described in refs.70,19. After obtaining access to the membrane voltage (input resistance between 70 and 400 MΩ), we recorded in voltage-clamp mode the spike-induced current, or—after bath application of TTX (Tocris, UK) to 6 μM final concentration—the generator current.

Calcium imaging

Calcium signals were recorded from flies expressing GCaMP6f28 under the control of JO15-Gal4, which expresses in the majority of JON-AB69. Flies were anesthetized on ice and gently waxed into the hole of a perfusion chamber with the proboscis facing upward, such that both antennae were free to move on the underside of the chamber. The antennal nerves and the AMMC were exposed by removing the proboscis and surrounding tissue. Sound stimuli were presented using sound delivery tubes as described above.

Two-photon imaging was performed using a custom microscope controlled by Scanimage software (Vidrio Technologies). The calcium indicator was excited at 940 nm using a TiSa Laser (Coherent). GCaMP emission was detected using a resonant scanner at a frame rate of ~60 Hz. ROIs were drawn manually around the projections of type A and type B JONs in AMMC69 (Supplementary Fig. 4a). Calcium responses from both JON populations were similar (Supplementary Fig. 4c) and we pooled data from both populations for each fly for all analyses (Supplementary Fig. 4d, e). ΔF/F values were obtained by subtracting the average fluorescence in the second immediately prior to sound stimulus onset.

Laser Doppler vibrometry

Arista movement was measured using laser Doppler vibrometry (LDV) (Polytec OFV534 laser unit, OFV-5000 vibrometer controller, Physik Instrumente, low-pass 5 kHz). Flies were fixed and the arista was stimulated with sound using the same protocol as for recording CAP responses. The fly was mounted on a micromanipulator and visualized using a CCD imaging system (Polytec OFV-534, Mitutoyo MP20× objective). The fly was moved using the micromanipulator such that the laser was pointed at the distal part of the arista

Data analysis

Pre-processing: CAP/LDV instantaneous amplitude was estimated as the magnitude of the Hilbert transform. This method is preferable over “root mean square” like algorithms77 since it allows estimating the amplitude without imposing a timescale through the duration of the smoothing time window.

Adaptation timescale and strength: The adaptation timescale was estimated by fitting an exponential function r(t) = r0 + rmax exp(−t/τ) to the falling/rising phases of positive/negative transients (Figs. 1c and 3f). Adaptation strength (Fig. 3g) was estimated based on the slopes son and sss of the onset and steady-state intensity tuning curves (e.g., Fig. 1d), e.g., <son> = < Δron(x)/Δx > x , where <.> x denotes the average over intensities. 1−son/sss is a measure of adaptation strength that is independent of response magnitude: It is 0 for no adaptation (son = sss), approaches 1 for complete adaptation (sssson), and can exceed either of these values in the presence of noise.

Sigmoidal fits of the tuning curves: Onset and steady responses for the intensity-step stimuli (Fig. 1b–d) and for the background-adaptation stimulus (Fig. 1f, onset only) were obtained by averaging the CAP amplitude over the first 8 ms and last 10 ms of a step/probe, respectively. The tuning curve shapes did not depend crucially on the specific method chosen—results were similar when using different averaging time windows or when taking the CAP amplitude extrema instead.

Sigmoidal fits to the resulting curves were obtained using the least squares method. We extracted the slope α and offset or shift β of the tuning curves from these fits: r(x) = r0 + rmax/(1 + exp(−α(x−β)), where x is the sound intensity on a logarithmic scale and r(x) is the CAP amplitude. Fits were excellent throughout (r2 > 0.9).

Fisher information: Fisher information (Ifisher) is a local measure of stimulus (intensity) discriminability that can be estimated from the tuning curves. Ifisher increases with the magnitude of the local slope of tuning curve (Δrx)2—steeper slopes produce larger response changes for a given stimulus change and hence facilitate stimulus discrimination. Ifisher decreases with the local variance of tuning curve σ2(x) since variability adds uncertainty to stimulus-induced response differences29. Tuning curve slope as a function of intensity was estimated by taking the derivative of sigmoidal fits to the experimental tuning curves (see above). Since in our data, the response variance is proportional to mean (r2 = 0.98), Fisher information is proportional to Ifisher(x)r(x)/Δx)2/r(x)71.

Statistical methods: In all figures, error bars depict mean ± s.d. over animals. For the statistical tests in Fig. 3f, g, we chose a nonparametric test (sign test for paired, rank sum for unpaired data), since data points were not normally distributed (based on a Jarque–Bera test for normality). Z-scores for the tests are 2.27, 0.65 in Fig. 3g and −2.45, −2.04, and −2.65 in Fig. 3f (left to right). P values in Fig. 4c, f derive from the significance of the r2 value of a linear fit to the values for each fly (per fly p values and t-statistics (in parentheses) for Fig. 4c: 0.693 (−0.44), 0.139 (1.99), 0.769 (−0.32), 0.158 (−1.86), Fig. 4f: 0.0091 (10.41), 0.0096 (10.16), 0.0003 (57.59), 0.0066 (12.29), 0.0065 (12.30), 0.0050 (14.04), 0.0085 (10.80)). 95% confidence intervals (CIs) in Figs. 1f and 2g, h were estimated as two times the standard error of the mean over trials or animals, respectively.

Proof-of-principle models

To explore different explanations for the adaptive dynamics in the CAP, we employed regular and adaptive leaky integrate and fire (LIF) model neurons72.

The subthreshold dynamics of the membrane voltage (Vm) in a LIF is given by: τVd/dt Vm(t) = Iin(t)−Ileak(t)−Iadapt(t), with input current Iin = σstimIstim(t) + σnoiseInoise(t) and additive noise Inoise. The leak current Ileak with membrane resistance Rm follows Ileak(t) = Vm(t)−Vrest. The dynamics of the adaptation current Iadapt evolve according to τadapt d/dt Iadapt(t) = Iadapt(t). A spike is elicited when Vm reaches the threshold Vthres after which it is reset to Vres. Iadapt increments by ΔA upon each spike and is 0 for a regular LIF. For all simulations τV = 4 ms, Vthres = 1 mV, and Vrest = −65 mV, except for Supplementary Fig. 3c, for which the tv was chosen randomly from the interval 2 and 8 ms. The time constant of the adaptation current τadapt is 25 ms for Supplementary Figs. 2d and 3d, and 100 ms for Supplementary Fig. 5e, f. The latter time constant is much longer than observed in the CAP. This value was chosen to be able to observe an effect of adaptation for this stimulation paradigm by enabling adaptation to carry across subsequent steps in intensity. For the regular LIF models (Supplementary Figs. 2b, c, 3b, c, and 5c, d), the adaptation strength ΔA is 0 mV. For adaptive LIF models, ΔA is 1 mV for Supplementary Figs. 2d and 5e, f, and 1.5 mV for Supplementary Fig. 3d.

Stimuli were defined in terms of sound intensity (mm s−1) and then scaled to an input current Istim to obtain firing rates that were comparable across conditions (regular vs. adaptive LIF models) and physiologically plausible. Noise stimuli were low-pass filtered white noise (cutoff 1000 Hz) with step changes in intensity (standard deviation of the white noise) as describe in the figure legends. For Supplementary Fig. 3, the noise had a mean of 2 mm s−1 to induce constant depolarization and to promote spike time jitter to accumulate over time. For Supplementary Fig. 2b, the noise stimulus was identical for all neurons and independent white noise was added for each neuron to introduce spike time jitter. For all other simulations, the stimulus was a different realization of the noise since we were interested in observing changes in spike timing and firing rate associated with the steps in intensity, not with the temporal pattern of the white noise. For the range fractionation model (Supplementary Fig. 5), the low intensity population (blue) was fed the noise stimulus only while the noise was at low intensity (1 mm s−1) and the high-intensity population (orange) only received input during the high-intensity period (2 mm s−1). LIF models were numerically simulated using Euler’s method with a step size dt = 1/20 ms.

Model of JON adaptation

Subtractive and divisive adaptation were modeled as an incoherent feedforward loop45, which consists of two steps: First, leaky integration low-pass filters the signal to an adaptation signal xada = ∫xin exp(−t/τ)dt. The integration time constant τ controls how fast the adaptation signal is updated and hence determines the effective speed of adaptation. Second, the adaptation signal then either subtracts or divides the input: xout = xinxada or xout = xin/(1/σdiv + xada). 1/σdiv is added to the adaptation signal in the divisive case to avoid division by zero in the absence of stimulation and to control completeness of adaptation.

Generally, xada ≈ 0 for stimulus symmetrical fluctuations much faster than τ. Hence, there is no adaptation for rapidly fluctuating and symmetrical stimulus components, i.e., sound-induced vibrations, and adaptation acts as a high-pass filter. Note that this model can in principle also account for power law dynamics in adaptation73,74, by replacing the exponential integration kernel with a power law kernel75. This does not affect the qualitative model behavior we were interested in here. Rectification in the model was implemented as either full-wave rectification y = |x| or half-wave rectification y = Θ(x), where Θ(x) = 0 for x < 0 and Θ(x) = x for x ≥ 0 (Supplementary Fig. 12).

We systematically explored the adaptation properties of all serial and parallel arrangements of the three elementary computations: subtractive adaptation (S), divisive adaptation (D), rectification (R). To that end, we generated computational networks using the following rules: For serial networks, the root node could have either R or Ø (“Ø” stands for an empty computational node) followed by an adaptation node containing S or D or Ø, followed by R or Ø, followed by another adaptation node containing S or D or Ø, followed by R or Ø. More compactly, R/Ø → S/D/Ø → R/Ø → S/D/Ø → R/Ø (“/” stands for “or”). These rules yielded 22 unique serial networks. Parallel networks contained two branches (rules for each branch: → R/Ø → S/D/Ø → R/Ø →) and an input and an output node (rules for each: → R/Ø →). This resulted in 100 parallel networks. The parameters for testing all 122 computational network motifs were: τsub = 30 ms, τdiv = 50 ms, σdiv = 10−4.

We tested for robustness of the qualitative model behavior to changes in model parameters by running the selected network motif (Fig. 6a, subtractive adaptation → rectification → divisive adaptation) for combinations of τsub and τdiv on a grid (10 ≤ τ ≤ 100, 20 × 20 values, linearly spaced, σdiv = 10−4; Supplementary Fig. 11b) and different values of σdiv (10−8 ≤ σdiv ≤ 100, 20 values, logarithmic spacing, τsub = 30 ms, τdiv = 50 ms; Supplementary Fig. 11c). The resulting tuning curves (compare Fig. 6f–i) were fitted to sigmoidal functions (see above) to extract the change in slope and position with adaptation (top and bottom panels, respectively, in Supplementary Fig. 11b–c). We then used the coefficient of variation (CV) across adaptation stimuli of the tuning curves’ shift and slope to quantify adaptation for each parameter combination and for the four adaptation paradigms employed in the paper. A model qualitatively matching our data should have the following properties: due to mean and variance adaptation, steps and intensity are encoded relative to an adaptation step/intensity. For mean adaptation, tuning curve offset and slope are identical for different offsets if plotted in a x-scale relative to the adaptation step (Supplementary Fig. 10c). Hence, the CV across adaptation parameters should be close to zero. The same holds for intensity adaptation—tuning curves are virtually identical on a log intensity scale relative to the adaptation intensity (Fig. 2c). Accordingly, CV of tuning curve offset and slope should be small. For the impact of intensity adaptation on step responses, we assessed tuning curve parameters on an absolute probe scale—in our data, only the slope, but not the offset of the curves changes with different adaptation intensities (Fig. 5e) and hence the CV of offsets should be small and that of slope should be high. For the impact of mean adaptation in intensity tuning, we observed no change in intensity tuning for different adaptation step sizes (Fig. 5b)—accordingly, CV of tuning curve offset and slope should be near zero for a model that matches our data. The chosen network motif (Fig. 6a) matches these expectations (Fig. 6f–i). Moreover, model behavior is robust to changes in all three parameters (see Supplementary Fig. 11b, c), except for small σdiv, simply because this parameter controls adaptation strength and when adaptation is weak, tuning curves do not change much.

Data availability

All data and source code are available from the authors on request.