# Sensory fusion in the hoverfly righting reflex

Anna Verbe, Dominique Martinez, Stéphane Viollet

► To cite this version:

Anna Verbe, Dominique Martinez, Stéphane Viollet. Sensory fusion in the hoverfly righting reflex. Scientific Reports, 2023, 13 (1), pp.6138. 10.1038/s41598-023-33302-z. http://dx.doi.org/10.1038/s41598-023-33302-z

HAL Id: hal-04191334

https://amu.hal.science/hal-04191334v1

Submitted on 30 Aug 2023

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
# Sensory fusion in the hoverfly righting reflex

Anna Verbe<sup>a,c</sup>, Dominique Martinez<sup>a,b</sup>, and Stéphane Viollet<sup>a,*</sup>

<sup>a</sup>Aix-Marseille Université, CNRS, ISM, 13009, Marseille, France.

<sup>b</sup>Université de Lorraine, CNRS, LORIA, 54000 Nancy, France.

<sup>c</sup>PNI, Princeton University, Washington Road, Princeton, NJ 08540, USA.

*corresponding: stephane.viollet@univ-amu.fr

## ABSTRACT

We study how falling hoverflies use sensory cues to trigger appropriate roll righting behavior. Before being released in a free fall, flies were placed upside-down with their legs contacting the substrate. The prior leg proprioceptive information about their initial orientation sufficed for the flies to right themselves properly. However, flies also use visual and antennal cues to recover faster and disambiguate sensory conflicts. Surprisingly, in one of the experimental conditions tested, hoverflies flew upside-down while still actively flapping their wings. In all the other conditions, flies were able to right themselves using two roll dynamics: fast (~50ms) and slow (~110ms) in the presence of consistent and conflicting cues, respectively. These findings suggest that a nonlinear sensory integration of the three types of sensory cues occurred. A ring attractor model was developed and discussed to account for this cue integration process.

## Introduction

In the righting reflex, animals have to reorient themselves to reach an upright position. This is an example of goal-directed behavior<sup>1,2</sup> in which a goal signal (in this case, the right-side up orientation) is compared with an estimate of the current state (the body roll movement). The animal eventually reaches the goal position by canceling any closed-loop errors (i.e., any differences between targeted and current states). In the framework of control theory, many kinds of behavior can be said to function like feedback control systems on the basis of responses to disturbances or perturbations<sup>3–7</sup>. Electromagnetic pulses applied to a metallic pin attached to a fruitfly's body have shown, for example, that these insects are able to completely reject disturbances in their roll<sup>8</sup>, pitch<sup>9</sup>, and yaw movements<sup>10</sup> within a few milliseconds. Feedback control systems provide insects with a highly efficient means of ensuring stable locomotion, compensating for morphological variability<sup>11</sup> and even rejecting perturbations, for example, in order to maintain the appropriate heading<sup>12</sup>. Goal-directed behavior raises the question, however, as to how internal goal signals are generated on the basis of sensory cues.

We addressed this question by investigating the multisensory integration process at work in the hoverfly righting reflex. When falling upside-down, hoverflies trigger their wingbeats in order to rotate and regain the right-side up position within a short lapse of time (mean value: 48.8ms, see<sup>2</sup>). During the righting, hoverflies may produce the goal roll via three main sensory pathways: visual, leg proprioceptive, and antennal airflow sensing. The dorsal light response (DLR), a visual reflex, enables flies to determine their orientation, since the brightest part of the environment is presumably located above them<sup>13–17</sup>. Leg proprioceptive cues might also be used via the tarsal reflex to measure the angle of the surface on which flies are standing<sup>13–18</sup>. The fly's antennae may also play the role of mechanoreceptors during flight<sup>19–21</sup> by detecting the direction of the airflow and its changes<sup>22–24</sup>.

Our working hypothesis was therefore that the goal roll signal triggered during the righting reflex is based on the sensory integration of antennal, visual, and leg proprioceptive cues. Our experiments combined with computational modeling show that hoverflies integrate antennal, visual, and leg proprioceptive cues and trigger a goal roll signal. Interestingly, the righting was two times slower when the sensory cues disagreed, or in the experiments performed in the dark. One particular sensory conflict even led to an unexpected stable inverted flight with no righting. These results suggest that a nonlinear sensory integration occurs in the hoverfly righting reflex. We further developed a ring attractor model accounting for these nonlinear dynamics. A ring attractor network is a biologically plausible neural network underlying sensory cue integration<sup>25</sup>. It can be useful to combine conflicting cues of various strengths<sup>26</sup> can even perform Bayesian inference<sup>27</sup>. Our model is based on a ring attractor network with a global inhibitory neuron<sup>28,29</sup> extended with sigma-pi neurons accounting for the nonlinear response of the hoverfly.
# Results

## The roll righting reflex has a multi-sensory basis

Flies were placed in a free fall situation by releasing them upside-down from a suction-based custom-built device² (Figure 1A). Their body roll orientation was analyzed closely versus time, using two fast cameras (Supplementary Table S1). Flies were exposed to various sensory conditions during the free fall (Supplementary Movies S1 to S5). Their righting reflex was expected to depend on the integration of three sensory inputs: leg proprioceptive cues (P), dorsal light responses involving vision (V), and airflow cues involving the antennae (A). The flies had prior knowledge of their orientation with respect to gravity, as they were always in contact with the ceiling before being released (P). As a fly deprived of proprioception before being released crashes irremediably onto the ground³⁰,¹⁶, we did not include any condition without proprioception. Sensory conflicts were introduced by varying the visual inputs (lighting from above or below) and the state of the antennae (glued or intact). The various combinations of stimuli used either triggered righting behavior or not. As shown in Figure 1B, the following five conditions based on sensory cues were therefore tested: with proprioception P, with the antennae A either intact ($A_+$) or glued ($A_-$) and under three visual conditions V (with lighting from above $V_t$, or below $V_b$ or in the dark $V_{dark}$).

<figure><img src="image_2.png" /></figure>

**Figure 1.** Experiments A. The experimental set-up used here to analyze the hoverfly aerial righting reflex. The observation cage consisted of a transparent 40x40x40cm PVC box, all the sides of which were covered with a white diffuser. Illumination was provided from above or below by a halogen light. The fly was held upside-down on the ceiling of this box using a vacuum set-up². When the vacuum source was turned off, the fly was released and started falling. The fall was recorded with two high-speed video cameras facing two adjacent sides of the box at a rate of 1690 fps in full resolution (1280x800 pixels). B. Plot of the body roll angle versus time ($\theta_{TR}$) in the following five conditions: $PA_+V_t$ (in blue, with the antennae intact and lit from the top), $PA_+V_b$ (in green, with the antennae intact and lit from below), $PA_+V_{dark}$ (in grey, with the antennae intact and placed in the dark), $PA_-V_b$ (in red, with the antennae blocked and lit from below), $PA_-V_{dark}$ (in orange, with the antennae blocked and placed in the dark). Right-side up and upside-down orientations correspond to roll angles of 0° and 180°, respectively. We did not observe any noticeable righting maneuvers involving body pitch or yaw rotations (Supplementary Movies S1 to S5). Thick lines are means and error bars are SDs.

## Depending on the sensory cues available flies performed either proper righting maneuvers or inverted flight

Proper righting occurred in the three visual conditions involving intact antennae (Figure 1B) with the setup lit from above ($PA_+V_t$, Supplementary Movie S1), below ($PA_+V_b$, Supplementary Movie S3) and in the dark ($PA_+V_{dark}$, Supplementary Movie S4). Flies were able to right themselves in the condition $PA_-V_{dark}$, which means that the presence of proprioceptive cues alone sufficed to trigger the righting reflex. However, Campaniform sensilla located along the body and legs might also contribute, but this hypothesis was not tested here. Complete righting was always observed with intact antennae ($A_+$), regardless of the visual conditions. When the condition $A_-$ was combined with either one of the two visual conditions ($V_b$ or $V_{dark}$), opposite responses were observed: either complete righting ($PA_-V_{dark}$, Supplementary Movie S5) or sustained inverted flight ($PA_-V_b$, Supplementary Movie S2).

As a stable inverted flight was observed in the condition $PA_-V_b$, we analyzed the transient roll dynamics leading the fly to trigger wingbeats while maintaining an upside-down position. In this condition, the righting process started normally as in the
three conditions $PA_+V_b$, $PA_+V_{dark}$ and $PA_-V_{dark}$, but was reversed at 90.79±46.80° and 60.39±27.60ms (means ±SDs, red curve in Figure 1B). A final roll orientation of 158.2±20.89° (mean ±SD) with respect to the initial upside-down position was reached within 99.53±46.16ms (mean ±SD, Supplementary Movie S6).

Depending on the sensory cues available flies performed either fast or slow righting reflex

Apart from the condition $PA_-V_b$, proper righting of the fly was consistently observed. We then examined whether various sensory combinations had any effect on the righting reflex. In the condition $PA_+V_t$, flies righted themselves within 48.8±10.9ms (mean ±SD, blue curve in Figure 1B) of the first wingbeat. In addition, their roll responses featured a fast transient phase followed by a steady-state phase corresponding to a body roll of 0° (right-side up). In the condition $PA_+V_b$, flies righted themselves within a longer time of 83.03±17.58ms (mean ±SD, green curve in Figure 1B). These results are similar to those previously reported in². In the condition $PA_+V_{dark}$, flies also righted themselves, but within 107.4±29.39ms (mean ±SD), which is 58.64 ms longer than in the condition $PA_+V_t$ (mean, gray curve in Figure 1B). In the dark without the use of their antennae ($PA_-V_{dark}$), flies took 142.8±38.7ms to right themselves (mean ±SD, yellow curve in Figure 1B). To summarize, in the presence of a sensory conflict or in the absence of some sensory cues, the righting behavior was always slower than in the condition $PA_+V_t$ (~110ms vs ~50ms).

A ring attractor model accounts for the slow/fast righting dynamics

The tentative model developed here (Figure 2, see details in Supplementary Section 1.1) integrates sensory information accounting for the various righting speeds (fast and slow) observed. Each neuron in the ring had a preferred orientation. A rotational symmetry was assumed to exist around the ring so that the preferred orientations were evenly distributed around (0°, 360°), with the same neuron encoding for 0° and 360°. Simulations were performed with 100 neurons so as to ensure a sufficiently high level of angular precision, but the results obtained with this model are robust to the choice of ring attractor size. The ring attractor was initialized with a wide Gaussian bump at 0°, corresponding to the proprioceptive cues (P) sensed by the insect's legs prior to the fall. The other two sensory pathways were simulated in the form of Gaussian inputs, $X_A$ and $X_V$ (antennae and vision), to the ring attractor (see figure 3). Both vision and leg proprioception were established before the free fall. However, we assumed that leg proprioception initialized the ring attractor as this was the only cue no longer available during the free fall. This assumption requires further experiments in order to understand the role of leg proprioception and vision prior to the free fall more clearly.

We first dealt with the linear neurons in the ring, to which the total input was the sum of the two sensory inputs $X_A + X_V$. With linear neurons, however, we did not completely succeed in modeling the change in dynamics between consistent and conflicting cues (Supplementary Figure S6B). We, therefore, used high-order sigma-pi units³¹,³² to which the total input was computed by taking the weighted sum of the product of two individual inputs $X_A + X_V + \omega X_A X_V$, where $\omega$ is a weighting factor. As a result, when the two sensory cues are in conflict, the Gaussians are far from each other (e.g. with $X_A$ and $X_V$ centered at 0° and 180°) and the product $X_A X_V \approx 0$. The sigma-pi unit then behaves like a linear neuron with the input $X_A + X_V$. By contrast, when the two sensory cues are in agreement, the Gaussians are close to each other and the product $X_A X_V$ is large, resulting in a nonlinear amplification of the input.

The output of the ring attractor over time (Figure 3 and Supplementary Figure S4) is encoded as the winner-take-all solution, that is, at each time step, the winning neuron is that showing the highest level of activation (Supplementary Figures S7 and S8). The goal roll signal is obtained by filtering the winner angle with a time constant $\tau_f \propto 1/K$, where K is the amplitude of the winner activation (filter implementation in Supplementary Figures S3 and S8). The role of the filter is to introduce some dynamics in the goal roll signal so that a weakly activated winner would produce the slow dynamics observed in the presence of sensory conflicts. The roll control was modeled in the form of a closed-loop system (Figure 2): The goal roll signal $\theta_{goal}$ is compared with the fly's body roll $\theta_{roll}$ estimated from the roll rate sensed by the halteres. A complete block diagram of the fly's roll feedback control system is presented in Supplementary Figure S2.

Figure 4A and Supplementary Movies S1 to S3 show the responses of the model versus the roll responses of the fly in the three experimental conditions $PA_+V_t$, $PA_+V_b$, and $PA_-V_b$. The model was also tested in the two conditions in the dark $PA_+V_{dark}$ and $PA_-V_{dark}$ (Supplementary Figures S4 and S5, and Movies S4 to S5). The goal roll signal $\theta_{goal}$ featured a fast transient when the sensory cues were consistent and a slower transient when the sensory cues were in conflict or in the dark. The results of the simulations, therefore, matched the fast and slow dynamics observed in the fly's body roll. In addition, the simulated response corresponding to the condition $PA_-V_b$ featured a similar back-and-forth rolling maneuver. In line with the experimental findings, the simulated roll righting stopped suddenly 60ms after its onset, at a roll of 118°, before rotating back to a similar upside-down position to its initial position(164°).
<figure><img src="image_3.png" /><figcaption>**Figure 2.** Tentative model for the roll righting reflex in flies. By merging the three parallel sensory pathways (the antennal, leg proprioceptive and visual pathways), the ring attractor delivers a goal roll signal $\theta_{goal}$ to the closed-loop controlling the insects' body roll movements. The controller drives the fly's body roll $\theta_{roll}$ so as to follow $\theta_{goal}$ by canceling the closed-loop error $\varepsilon_{roll}$. The $\theta_{roll}$ signal results from the integration of the roll rate sensed by the fly's halteres.</figcaption></figure>

The fastest righting response (50ms) was observed and simulated in the condition $PA_+V_t$. It took only 15ms for the simulated roll rate to reach a maximum speed of 6061°/s, which is similar to that observed in the experiments (6490±1111 °/s at 15.14±5.73ms, means ±SDs, Figure 4B). Slower righting responses were also obtained in the simulations in the three conditions $PA_+V_b$ (Figure 4B), $PA_+V_{dark}$ and $PA_-V_{dark}$ (Supplementary Figure S5B). In these three conditions, the righting lasted for about ~100ms with an angular speed of around 944°/s (mean value recorded during the first 50ms, which was similar to the slower roll rate observed experimentally in the hoverfly, see Figure 4B). In both experiments and simulation, an increase in the roll angular speed was also observed after 50ms in the two conditions $PA_+V_b$ (Figure 4B, green curve) and $PA_+V_{dark}$ (Supplementary Figure S5B, grey curve).

## Discussion and Conclusion

**A closed-loop roll control based on the halteres.** To control its body roll during the righting process, the fly has to estimate the current roll on the time scale of a single wingbeat. In this context, vision is probably not fast enough. Hoverfly righting is entirely achieved within 6 wingbeats, i.e., 50ms², and the processing time of the visual system in hoverflies is probably of the order of that measured in blowfly *Calliphora* (± 20ms),³³,³⁴ even if this latency depends strongly on the experimental conditions (lighting intensity, contrast amplitude, temperature...). Therefore, roll control on the timescale of a single wingbeat is not compatible with visual processing, whereas the halteres are fast sensors for measuring the roll rate¹⁰,³⁵. It was therefore assumed that the body roll is estimated by integrating the roll rate given by the halteres (Figure 2 and Supplementary Figure S2). In line with the results obtained with our model, it is worth noting that modifying the halteres, e.g. by adding mass, drastically affected the flight dynamics²,³⁶. Neither vision nor antennae are required for body roll stabilization to occur, as hoverflies with blocked antennae placed in the dark are able to right themselves correctly ($PA_-V_{dark}$, Figure 1 and Supplementary Movie S5)).

**A goal roll signal based on three types of external cues.** Contrary to what was reported in a previous study suggesting that vision is necessary to the righting reflex in dragonflies³⁷, complete righting of hoverflies was observed here in the dark ($PA_+V_{dark}$, $PA_-V_{dark}$). This discrepancy between dragonflies' and flies' performances may be attributable to the differences between the initial conditions prior to the free fall, i.e., no leg proprioception was present in Wang et al, 2022³⁷ whereas leg proprioception was present via the substrate (P) in the present study. We previously reported that a fly deprived of leg proprioception before being released in the dark crashes irremediably onto the ground³⁰, but it has emerged that flies right themselves correctly when their legs are in contact with a substrate before being released. In the present experimental setup,
<figure><img src="image_4.png" /><figcaption>**Figure 3.** Ring attractor responses in the three conditions $PA_+V_t$, $PA_+V_b$ and $PA_-V_b$. The output from the ring with time is expressed as the winner-take-all (winner angle) function, that is, at each time step, the winning neuron is that featuring the highest level of activation. The winner angle codes for the roll state value targeted $\theta_{goal}$ (Figure 2), whereas the K value is equal to the amplitude of the winning neuron's activation (Supplementary Figure S2). The initialization of the ring attractor is affected by the leg proprioceptive signal in the three conditions and the integration of the orientation cues (antennal and visual). In the case of $PA_+V_t$, the antennal and visual cues both give the same information corresponding to an upside-down position (0°), while in the condition $PA_+V_b$, the information conveyed by the antennal cues corresponds to an upside-down position (0°) and that conveyed by the visual cues corresponds to a right side up position (180°). In the last condition tested, $PA_-V_b$, the antennae were blocked, which meant that only the visual cues were integrated resulting in a right-side-up position (180°). Initialization at $t = 0$ is the same in all three conditions: K = 0.45, Winner angle = 0°. The final state at $t = 0.14$ s was K = 178, Winner angle = 0° (panel A), K=3.21, Winner angle = 0° (panel B) and K=1.64, Winner angle = 180° (panel C). Color code in right column is defined as follows: blue=low activation, green=medium activation, yellow=high activation.</figcaption></figure>
<figure><img src="image_5.png" /><figcaption>**Figure 4. Model vs Experiments.** Response of the righting reflex model (dotted line) versus the experimental data (solid line) in terms of the roll angle (A) and the angular speed (B) in three of the main conditions tested: with the antennae intact, lit from above, $PA_+V_t$ in blue, and from below, $PA_-V_b$ in green. With the antennae glued, lit from below, $PA_-V_b$ in red. Thick lines are means and error bars are SDs. See Supplementary Section 1.1.</figcaption></figure>

there were no moving parts or possible leg kicks that might have introduced any marked variability in the initial conditions. As shown in the movies (Supplementary Movies S1 to S5), our device based on a vacuum source² always gave the flies a smooth take-off. Leg proprioceptive cues may therefore have provided sufficient prior knowledge of the initial roll orientation for the flies to be able to recover their position during the free fall.

To support this idea, upon running our ring attractor with leg proprioceptive cues alone ($PA_-V_{dark}$, Supplementary Figure S4, and S5), we noted that these cues sufficed to generate an effective internal goal roll signal driving the righting sequence. Leg chordotonal organs are known to sense the changes in load which occur with respect to gravity and the distribution of weight relative to the substrate³⁻⁴⁰. In addition, in the fruitfly, three kinds of mechanosensory neurons have been found to code for the angular rate and the orientation of the leg joints⁴¹. Secondly, contrary to the prevailing belief that the halteres are involved in gravity perception⁴²,⁴³, the possible involvement of these organs to generate the goal roll signal $\theta_{goal}$ was unlikely in this study, as no righting (but inverted flight) was observed in the condition $PA_-V_b$ where the fly triggered the wingbeat and thus the halteres' vibration. Note that in this condition, in which the antennae were glued, the inverted flapping flight was stable, unlike the unstable flight observed in hawkmoths with clipped-off antennae⁴⁴,⁴⁵. This discrepancy is probably due to the fact that Dipterans, unlike hawkmoths, have halteres which contribute greatly to stabilizing the insects' flight by acting like rate gyros³⁵,⁴⁶,⁴⁷. The fact that different behavior was observed here in the condition $PA_+V_b$ vs $PA_-V_b$ suggests that antennae are involved in producing the goal roll signal with respect to either the airflow direction or gravity. Antennal mechanosensors have been found to contribute to sensing the airflow⁴⁸⁻⁵⁰ and maintaining the headwind orientation⁵¹. Another recent study on Drosophila has shown that wind-induced antennal displacements affect the compass of the fly's brain²³. In insects, antennal mechanosensory mediation takes place in the Johnston's organ, which is a highly sensitive mechanosensory structure located in the antennal pedicel-flagellar joint²²,⁵². However, the possible involvement of the hoverfly's antennae in gravity perception requires further experiments to assess its role in the absence of leg proprioception and vision. The stable inverted flight ($PA_-V_b$) and the difference in the roll dynamics observed in condition $PA_+V_b$ vs $PA_+V_t$ provide additional evidence that visual cues mediated via the DLR play a key role in measuring the fly's absolute body orientation¹⁶.

**Linear vs nonlinear cue integration.** How may leg proprioceptive, visual, and antennal cues be integrated to provide a reliable goal roll signal? Let us assume that the antennae and vision yield individual noisy goals with means $\mu_A$, $\mu_V$, and variances of $\sigma_A^2$ and $\sigma_V^2$; respectively (Supplementary Section 1.1). According to the minimum variance estimation rule⁵³, the appropriate roll movement is given by a linear combination of the means weighted by their inverse variances; that is, $\omega \mu_A + (1-\omega) \mu_V$, where $\omega = \sigma_A^{-2}/(\sigma_A^{-2} + \sigma_V^{-2})$. Applying this formula to the condition $PA_+V_b$ gives 36° so that the fly can be expected to turn only partially. However, this situation was not observed in the present experiments as the flies always performed either right-side up (0°) or upside-down (180°) rotations. We nevertheless simulated a linear cue integration model and show that this cannot account for the experimental data (Supplementary Figure S6). These results, therefore, suggest that flies do not perform linear cue integration as stated by the minimum variance estimation rule.
In addition, the nonlinear nature of the righting is confirmed by the differences in response time, depending on whether the sensory cues are in conflict or in agreement. This result is in contradiction with linear cue integration models on hawkmoths<sup>54</sup> and humans<sup>55</sup> based on experiments involving small amplitude variations in sensory conflicts. However, nonlinear sensory cue integration has been found to occur in previous studies<sup>56,57</sup>. In addition, since the sensory conflicts ($A_+ \ vs \ A_-$, $V_t$ vs $V_b$) and roll amplitudes (0-180°) were too large in the present experiments, linear modeling approximation is not applicable here. We, therefore, modeled the righting reflex in the form of a closed-loop control system in which the goal roll angle is provided by a ring attractor network (Figure 2). The present model performs nonlinear cue selection in the presence of large sensory conflicts, where the strongest cue predominates over the others<sup>26</sup>. It also includes internal dynamics accounting for the slow versus fast righting responses observed in the experiments. When the sensory cues available are in conflict, the sigma-pi units<sup>31,32</sup> of the ring attractor model behave like linear neurons, resulting in a small winner activation and a slow righting process. When the sensory cues are in agreement, the multiplication of the inputs induced by the sigma-pi units generates a large winner activation and a fast righting (Figure 4). Here, the multiplication of sensory cues rather than linear integration accounts for the change in dynamics. Yet, our ring attractor model remains tentative in regards to the lack of knowledge in the neuronal processing of hoverflies and we cannot rule out the possibility that other nonlinear models might explain the data equally well.

**Biological plausibility of the ring attractor model.** In line with Touretzky's network<sup>28</sup> (Supplementary Figure S1), which was simulated with large sensory conflicts<sup>26</sup>, the present ring attractor model acts like a winner-take-all network by selecting the strongest cue. The main difference here in comparison with the previous ring attractor models on rodents<sup>58</sup> and fruitflies<sup>59</sup> is the use of sigma-pi neurons accounting for the nonlinear response (much faster response with consistent cues). It is worth noting that there exists evidence that individual neurons in the fruitfly can perform multiplications of their inputs<sup>60,61</sup>. The results obtained in this study correlate well with the key features of ring attractors<sup>62</sup>, namely: their responsiveness to the position of external stimuli, the persistence in the absence of external stimuli ($PA_+V_{dark}$ and $PA_-V_{dark}$), locking onto a single external stimulus when presented with two competitors ($PA_+V_b$ and $PA_-V_b$) and sliding between positions ($PA_-V_b$). What might the neural basis of the ring attractor model be in the fly brain? The central complex (CX) in insects is a key brain area involved in the performance of spatial orientation and navigation tasks. The CX neural circuit's activity has been found to track the insect's current heading relative to its environment. Recent studies have shown that part of the CX network can be modeled in the form of a ring attractor<sup>63</sup>. In addition, it has been established that in various insect species<sup>64</sup> for a review), many neurons in the central complex integrate multisensory information by responding to various (mechanical, visual, and olfactory) stimuli. However, even if the layout of the CX is conserved among species, the idea that the CX is the substrate of nonlinear multisensory fusion cannot be generalized because it depends on whether the stimuli involved generate nonlinear responses, i.e., large sensory conflicts. The fact that the initial bump of activity due to the onset of leg proprioception (P) in our ring attractor model is present even in the absence of sensory inputs during the righting response ($PA_-V_{dark}$, Supplementary Figure S5) suggests that the ring attractor may play the role of a working memory. In line with the model presented here, there exists experimental evidence that ring attractor networks maintain persistent activity for several seconds in *Drosophila*<sup>59</sup>.

**Conclusion** Voluntary movements in animals depend on their ability to generate internal goal signals controlling the value of current states. The present study focuses on the generation of the goal signal used to control the hoverfly's roll in closed-loop. Here we have presented a ring-attractor model of how this signal may be obtained based on a nonlinear multisensory integration. We have stressed the key role played by sensory redundancy in the righting reflex, as flies can experience various conflicting sensory situations in real life, e.g., when the ground is not always darker than the sky or the antennae are affected mechanically by dust or pollen. The ring attractor mechanism present in the brain of vertebrates and invertebrates has been shown to carry an estimate of the current heading. However, the neural substrate of a goal roll signal has not been identified so far. The findings in this study shed a new light on the role of ring attractors in the robust coding of goal orientation.

## Methods

### Biological material

*Episyrphus balteatus* pupae were purchased from Katz Biotech AG, Baruth, Germany. They were fed *ad libitum* with pollen and honey. Flies were released using a custom-built suction-based device, as in a previous study (See Verbe et al (2020)<sup>2</sup> for further information). The following changes were made to the previous set-up: a white optical diffuser was added to the sides of the box and two apertures were made on adjacent sides in order to be able to film the falling flies with two fast cameras (Figure 1A).

### Experimental set-up and procedure

In the conditions $PA_-V_b$, the flies' aerial righting performances were recorded with two high-speed video cameras (Phantom VEO E310 and Phantom Miro M110) at a rate of 1690 frames per second (resolution: 1280x800 pixels). The two cameras were positioned at an angle of 90° pointing towards the box in order to obtain 2D and 3D views of part of the fall. The two
lenses used (a Nikon Micro-Nikkor AF-S DX Micro 40mm f/2.8 G and a Nikon Micro-Nikkor AF-S N 60mm f/2,8) gave a good compromise between the size of the fly, the resolution, and the visual field (the fly-to-camera distance was ~20cm).

In the other four conditions ($PA_+V_t, PA_+V_b, PA_+V_{dark}$ and $PA_-V_{dark}$), the same experimental set-up was used as that described in Verbe et al., 2020² (Supplementary Table S1). In the condition with antennae blocked, a small drop of glue (fifty percent of rosin and bee wax) was deposited at the basis of each antenna so as to block any deflection due to the airflow. The experimental arena was covered at the top and on the sides with white diffusers (PMMA WH02, 3mm thick) and illuminated from above and below by a halogen light (Kaiser Studiolight H = $5.6 \times 10^{-13} W.m^{-2}$ and $1.76 \times 10^{-11} W.m^{-2}$, respectively). When the experimental arena was placed in the dark, infrared light projectors (BLANKO, wavelength 850 nm) were used to film the flies' behavior. The VEO camera was triggered automatically as soon as the insect entered the camera's field of view, which started the miro camera. To synchronize the two cameras exactly, infrared LEDs placed in both cameras' fields of view were switched on automatically whenever the VEO camera was triggered.

In conditions $PA_+V_t, PA_+V_b, PA_+V_{dark}, PA_-V_b$ and $PA_-V_{dark}$, a total number of 13 drops (4 males and 6 females), 13 drops (3 males and 1 female), 3 drops (1 male and 2 females), 13 drops (4 males and 3 females) and 11 drops (5 males and 3 females) were recorded. Note that at each drop, each fly experienced a single experimental condition.

**Image processing and analysis.** The same method as that described in² with a Tracker Video Analysis and Modeling Tool was used here (Copyright (c) 2018 Douglas Brown). The other analyses were performed with MATLAB (R2018a, MathWorks, Natick, MA, USA).

## References

1. Green, J., Vijayan, V., Pires, P. M., Adachi, A. & Maimon, G. Walking Drosophila aim to maintain a neural heading estimate at an internal goal angle, DOI: 10.1101/315796 (2018). Pages: 315796 Section: New Results.

2. Verbe, A., Varennes, L. P., Vercher, J.-L. & Viollet, S. How do hoverflies use their righting reflex? *J. Exp. Biol.* **223**, DOI: 10.1242/jeb.215327 (2020). Publisher: The Company of Biologists Ltd Section: Research Article.

3. Cowan, N. J. et al. Feedback Control as a Framework for Understanding Tradeoffs in Biology. *Integr. Comp. Biol.* **54**, 223–237, DOI: 10.1093/icb/icu050 (2014).

4. Mongeau, J.-M., Sponberg, S. N., Miller, J. P. & Full, R. J. Sensory processing within cockroach antenna enables rapid implementation of feedback control for high-speed running maneuvers. *J. Exp. Biol.* **218**, 2344–2354, DOI: 10.1242/jeb.118604 (2015).

5. Mountcastle, A. M., Ravi, S. & Combes, S. A. Nectar vs. pollen loading affects the tradeoff between flight stability and maneuverability in bumblebees. *Proc. Natl. Acad. Sci.* **112**, 10527–10532, DOI: 10.1073/pnas.1506126112 (2015). Publisher: Proceedings of the National Academy of Sciences.

6. Sponberg, S., Dyhr, J. P., Hall, R. W. & Daniel, T. L. Luminance-dependent visual processing enables moth flight in low light. *Science* **348**, 1245–1248, DOI: 10.1126/science.aaa3042 (2015). Publisher: American Association for the Advancement of Science.

7. Stamper, S. A., Madhav, M. S., Cowan, N. J. & Fortune, E. S. Beyond the Jamming Avoidance Response: weakly electric fish respond to the envelope of social electrosensory signals. *J. Exp. Biol.* **215**, 4196–4207, DOI: 10.1242/jeb.076513 (2012).

8. Beatus, T., Guckenheimer, J. M. & Cohen, I. Controlling roll perturbations in fruit flies. *J. The Royal Soc. Interface* **12** (2015).

9. Whitehead, S. C., Beatus, T., Canale, L. & Cohen, I. Pitch perfect: how fruit flies control their body pitch angle. *The J. Exp. Biol.* **218**, 3508–3519, DOI: 10.1242/jeb.122622 (2015).

10. Ristroph, L. et al. Discovering the flight autostabilizer of fruit flies by inducing aerial stumbles. *Proc. Natl. Acad. Sci. United States Am.* **107**, 4820–4824, DOI: 10.1073/pnas.1000615107 (2010).

11. Uyanik, I. et al. Variability in locomotor dynamics reveals the critical role of feedback in task control, DOI: 10.7554/eLife.51219 (2020). Publisher: eLife Sciences Publications Limited.

12. Heisenberg, M. & Wolf, R. *Vision in Drosophila: Genetics of Microbehavior* (Springer Berlin Heidelberg, 1984). Google-Books-ID: Exr1rQEACAAJ.

13. Mittelstaedt, H. Physiologie des Gleichgewichtssinnes bei fliegenden Libellen. *Zeitschrift fur vergleichende Physiol.* **32**, 422–463 (1950).
271

14. Hengstenberg, R. Multisensory control in insect oculomotor systems. In Visual Motion and its Role in the Stabilization of Gaze, 285–297 (Elsevier Science Ltd, 1993).

272

273

15. Goulard, R., Julien Laferriere, A., Fleuriet, J., Vercher, J.-L. & Viollet, S. Behavioural evidence for a visual and proprioceptive control of head roll in hoverflies (Episyrphus balteatus). *J. Exp. Biol.* **218**, 3777–3787 (2015).

274

275

16. Goulard, R., Verbe, A., Vercher, J.-L. & Viollet, S. Role of the light source position in freely falling hoverflies’ stabilization performances. *Biol. Lett.* **14**, 20180051, DOI: 10.1098/rsbl.2018.0051 (2018). Publisher: Royal Society.

276

277

17. Schuppe, H. & Hengstenberg, R. Optical properties of the ocelli of Calliphora erythrocephala and their role in the dorsal light response. *J. Comp. Physiol. A* **173**, 143–149 (1993).

278

279

18. Meyer, D. L. & Bullock, T. H. The hypothesis of sense-organ-dependent tonus mechanisms : history of a concept. *Annals New York Acad. Sci.* **290**, 3–17 (1977).

280

281

19. Schneider, D. Insect Antennae. *Annu. Rev. Entomol.* **9**, 103–122, DOI: 10.1146/annurev.en.09.010164.000535 (1964).
*eprint: https://doi.org/10.1146/annurev.en.09.010164.000535*.

282

283

20. Hollick, F. S. J. & Gray, J. The flight of the dipterous fly Muscina stabulans Fallén. *Philos. Transactions Royal Soc. London. Ser. B, Biol. Sci.* **230**, 357–390, DOI: 10.1098/rstb.1940.0003 (1940).
Publisher: Royal Society.

284

285

286

21. Krishnan, A. & Sane, S. P. Antennal Mechanosensors and Their Evolutionary Antecedents. In *Advances in Insect Physiology*, vol. 49, 59–99, DOI: 10.1016/bs.aiip.2015.06.003 (Elsevier, 2015).

287

288

22. Gewecke, M. The Antennae of Insects as Air-Current Sense Organs and their Relationship to the Control of Flight. In Barton Browne, L. (ed.) *Experimental Analysis of Insect Behaviour*, 100–113, DOI: 10.1007/978-3-642-86666-1_8 (Springer, Berlin, Heidelberg, 1974).

289

290

291

23. Okubo, T. S., Patella, P., D’Alessandro, I. & Wilson, R. I. A Neural Network for Wind-Guided Compass Navigation. *Neuron* **107**, 924–940.e18, DOI: 10.1016/j.neuron.2020.06.022 (2020).

292

293

24. Suver, M. P. et al. Encoding of Wind Direction by Central Neurons in Drosophila. *Neuron* **102**, 828–842.e7, DOI: 10.1016/j.neuron.2019.03.012 (2019). Publisher: Elsevier.

294

295

25. Esnaola-Acebes, J. M., Roxin, A. & Wimmer, K. Flexible integration of continuous sensory evidence in perceptual estimation tasks. *Proc. Natl. Acad. Sci.* **119**, e2214441119, DOI: 10.1073/pnas.2214441119 (2022). Publisher: Proceedings of the National Academy of Sciences.

296

297

298

26. Sun, X., Mangan, M. & Yue, S. An analysis of a ring attractor model for cue integration. In *Conference on Biomimetic and Biohybrid Systems*, 459–470 (Springer, 2018).

299

300

27. Kutschreiter, A., Basnak, M. A., Wilson, R. I. & Drugowitsch, J. Bayesian inference in ring attractor networks. *Proc. Natl. Acad. Sci.* **120**, e2210622120, DOI: 10.1073/pnas.2210622120 (2023). Publisher: Proceedings of the National Academy of Sciences.

301

302

303

28. Touretzky, D. S. Attractor network models of head direction cells. *Head direction cells neural mechanisms spatial orientation* **1**, 411–432 (2005). Publisher: MIT Press Cambridge, MA.

304

305

29. Touretzky, D. S. Attractor bump simulation. https://www.cs.cmu.edu/dst/Matlab/bump/ (2005).

306

307

30. Goulard, R., Vercher, J.-L. & Viollet, S. To crash or not to crash: how do hoverflies cope with free-fall situations and weightlessness? *The J. Exp. Biol.* **219**, 2497–2503 (2016).

308

31. Durbin, R. & Rumelhart, D. E. Product Units: A Computationally Powerful and Biologically Plausible Extension to Backpropagation Networks. *Neural Comput.* **1**, 133–142, DOI: 10.1162/neco.1989.1.1.133 (1989).

309

310

32. Rumelhart, D. E., Hinton, G. E., McClelland, J. L. & others. A general framework for parallel distributed processing. *Parallel distributed processing: Explor. microstructure cognition* **1**, 26 (1986). Publisher: Cambridge, MA: MIT Press.

311

312

33. Parsons, M. M., Krapp, H. G. & Laughlin, S. B. A motion-sensitive neurone responds to signals from the two visual systems of the blowfly, the compound eyes and ocelli. *J. Exp. Biol.* **209**, 4464–4474, DOI: 10.1242/jeb.02560 (2006).

313

314

34. Warzecha, A.-K. & Egelhaaf, M. Response latency of a motion-sensitive neuron in the fly visual system: dependence on stimulus parameters and physiological conditions. *Vis. Res.* **40**, 2973–2983, DOI: 10.1016/S0042-6989(00)00147-4 (2000).

315

316

317

35. Yarger, A. M. & Fox, J. L. Dipteran Halteres: Perspectives on Function and Integration for a Unique Sensory Organ. *Integr. Comp. Biol.* **56**, 865–876, DOI: 10.1093/icb/icw086 (2016). Publisher: Oxford Academic.

318
319

320

36. Dickerson, A. K., Shankles, P. G., Berry, B. E. & Hu, D. L. Fog and dense gas disrupt mosquito flight due to increased aerodynamic drag on halteres. *J. Fluids Struct.* **55**, 451–462 (2015).

321

322

37. Wang, Z. J., Melfi, J. & Leonardo, A. Recovery mechanisms in the dragonfly righting reflex. *Science* **376**, 754–758, DOI: 10.1126/science.abg0946 (2022). Publisher: American Association for the Advancement of Science.

323

324

38. Horn, E. & Lang, H. G. Positional head reflexes and the role of the prosternal organ in the walking fly, Calliphora erythrocephala. *J. comparative physiology* **126**, 137–146 (1978).

325

326

39. Kress, D. & Egelhaaf, M. Head and body stabilization in blowflies walking on differently structured substrates. *J. Exp. Biol.* **215**, 1523–1532 (2012).

327

328

40. Horn, E. Gravity reception in the walking fly, Calliphora erythrocephala: Tonic and modulatory influences of leg afferents on the head position. *J. Insect Physiol.* **28**, 713–721 (1982).

329

330

41. Agrawal, S. et al. Central processing of leg proprioception in Drosophila. *eLife* **9**, e60299, DOI: 10.7554/eLife.60299 (2020). Publisher: eLife Sciences Publications, Ltd.

331

332

42. Daltorio, K. A. & Fox, J. L. Haltere removal alters responses to gravity in standing flies. *The J. Exp. Biol.* **221**, jeb181719, DOI: 10.1242/jeb.181719 (2018).

333

334

43. Bender, J. & Frye, M. Invertebrate solutions for sensing gravity. *Curr. Biol.* **19**, 186–190, DOI: 10.1016/j.cub.2008.12.024 (2009).

335

336

44. Sane, S. P., Dieudonné, A., Willis, M. A. & Daniel, T. L. Antennal mechanosensors mediate flight control in moths. *Sci. (New York, N.Y.)* **315**, 863–866, DOI: 10.1126/science.1133598 (2007).

337

338

45. Dahake, A., Stöckl, A. L., Foster, J. J., Sane, S. P. & Kelber, A. The roles of vision and antennal mechanoreception in hawkmoth flight control. *eLife* **7**, e37606, DOI: 10.7554/eLife.37606 (2018). Publisher: eLife Sciences Publications, Ltd.

339

340

46. Nalbach, G. & Hengstenberg, R. The halteres of the blowfly Calliphora. *J. Comp. Physiol. A* **175**, 695–708, DOI: 10.1007/BF00191842 (1994).

341

342

47. Dickinson, M. Haltere-mediated equilibrium reflexes of the fruit fly, Drosophila melanogaster. *Philos. Transactions Royal Soc. London. Ser. B: Biol. Sci.* **354**, 903–916 (1999).

343

344

48. Khurana, T. R. & Sane, S. P. Airflow and optic flow mediate antennal positioning in flying honeybees. *eLife* **5**, e14449, DOI: 10.7554/eLife.14449 (2016). Publisher: eLife Sciences Publications, Ltd.

345

346

49. Natesan, D., Saxena, N., Ekeberg, O. & Sane, S. P. Tuneable reflexes control antennal positioning in flying hawkmoths. *Nat. Commun.* **10**, 5593, DOI: 10.1038/s41467-019-13595-3 (2019). Number: 1 Publisher: Nature Publishing Group.

347

348

349

50. Taylor, G. K. & Krapp, H. G. Sensory Systems and Flight Stability: What do Insects Measure and Why? In *Casas, J. & Simpson, S. J.* (eds.) *Advances in Insect Physiology*, vol. 34 of *Insect Mechanics and Control*, 231–316, DOI: 10.1016/S0065-2806(07)34005-8 (Academic Press, 2007).

350

351

352

51. Fuller, S., Straw, A., Peek, M., Murray, R. & Dickinson, M. Flying Drosophila stabilize their vision-based velocity controller by sensing wind with their antennae. *Proc. Natl. Acad. Sci.* **111**, 1182–1191, DOI: 10.1073/pnas.1323529111 (2014).

353

354

52. Sant, H. H. & Sane, S. P. The mechanosensory-motor apparatus of antennae in the Oleander hawk moth (Daphnis nerii, Lepidoptera). *The J. Comp. Neurol.* **526**, 2215–2230, DOI: 10.1002/cne.24477 (2018).

355

356

357

53. Ghahramani, Z., Wolpert, D. M. & Jordan, M. I. Computational models of sensorimotor integration. In *Morasso, P. & Sanguineti, V.* (eds.) *Advances in Psychology*, vol. 119 of *Self-Organization, Computational Maps, and Motor Control*, 117–147, DOI: 10.1016/S0166-4115(97)80006-4 (North-Holland, 1997).

358

359

360

54. Roth, E., Hall, R. W., Daniel, T. L. & Sponberg, S. Integration of parallel mechanosensory and visual pathways resolved through sensory conflict. *Proc. Natl. Acad. Sci.* **113**, 12832–12837, DOI: 10.1073/pnas.1522419113 (2016). Publisher: National Academy of Sciences Section: Biological Sciences.

361

362

55. Ernst, M. O. & Banks, M. S. Humans integrate visual and haptic information in a statistically optimal fashion. *Nature* **415**, 429–433, DOI: 10.1038/415429a (2002). Number: 6870 Publisher: Nature Publishing Group.

363

364

56. Taylor, G. J., Luu, T., Ball, D. & Srinivasan, M. V. Vision and air flow combine to streamline flying honeybees. *Sci. reports* **3**, 1–11 (2013).

365

366

57. Fetsch, C. R., DeAngelis, G. C. & Angelaki, D. E. Bridging the gap between theories of sensory cue integration and the physiology of multisensory neurons. *Nat. Rev. Neurosci.* **14**, 429–442 (2013).
58. Knight, R. et al. Weighted cue integration in the rodent head direction system. *Philos. Transactions Royal Soc. B: Biol. Sci.* **369**, 20120512, DOI: 10.1098/rstb.2012.0512 (2014). Publisher: Royal Society.

59. Kim, S. S., Rouault, H., Druckmann, S. & Jayaraman, V. Ring attractor dynamics in the Drosophila central brain. *Science* DOI: 10.1126/science.aal4835 (2017). Publisher: American Association for the Advancement of Science.

60. Groschner, L. N., Malis, J. G., Zuidinga, B. & Borst, A. A biophysical account of multiplication by a single neuron. *Nature* **603**, 119–123, DOI: 10.1038/s41586-022-04428-3 (2022). Number: 7899 Publisher: Nature Publishing Group.

61. Silver, R. A. Neuronal arithmetic. *Nat. Rev. Neurosci.* **11**, 474–489, DOI: 10.1038/nrn2864 (2010). Number: 7 Publisher: Nature Publishing Group.

62. Kakaria, K. S. & de Bivort, B. L. Ring Attractor Dynamics Emerge from a Spiking Model of the Entire Protocerebral Bridge. *Front. Behav. Neurosci.* **11** (2017).

63. Adden, A., Stewart, T. C., Webb, B. & Heinze, S. A neural model for insect steering applied to olfaction and path integration. *bioRxiv* 2020.08.25.266247, DOI: 10.1101/2020.08.25.266247 (2020). Section: New Results Type: article.

64. Pfeiffer, K. & Homberg, U. Organization and Functional Roles of the Central Complex in the In- sect Brain. *Annu. Rev. Entomol.* **59**, 165–184, DOI: 10.1146/annurev-ento-011613-162031 (2014). _eprint: https://doi.org/10.1146/annurev-ento-011613-162031.

## Acknowledgements

We are most grateful to Julien Diperi for his contribution to building the experimental set-up and to Marc Boyron and Jean-Marc Ingargiola for developing the electronics: all the research presented in this paper was based on their work. We would also like to thank Jessica Blanc for correcting and improving the English manuscript.

## Author contributions statement

A.V. and S.V. drew up the research project; A.V. performed the experiments and analyzed the data; D.M. and S.V. performed the simulations and A.V., D.M., and S.V. wrote the paper.

## Data availability:

Source code of the ring-attractor model as well as data from this study have been deposited in GitHub (https://github.com/AnnaVerbe/Sensory_ring).

## Additional information

**Competing interests** The authors have no competing interests to declare.

**Ethics** No ethical authorization for animal research or permission to carry out fieldwork was required for this study.

**Funding** We acknowledge the support received from the Centre National de la Recherche Scientifique (CNRS), Aix-Marseille University and the Agence Nationale de la Recherche (ANR) (in the framework of the IRIS (Intelligent Retina for Innovative Sensing) project ANR-12-INSE-0009 and the OrigaBot project ANR-18-CE33-0008-01).
# Supplementary document - Sensory fusion in the hoverfly righting reflex

Anna Verbe<sup>a,c</sup>, Dominique Martinez<sup>a,b</sup>, and Stéphane Viollet<sup>a,*</sup>

## ABSTRACT

### 1 Material and methods

<table><caption>Supplementary Table S 1. Camera configurations depending on the condition tested.</caption><thead><tr><td>Experiment</td><td>Number of cameras</td><td>Frames per second</td><td>Linked article</td></tr></thead><tbody><tr><td>PA<sub>+</sub>V<sub>t</sub></td><td>1</td><td>1600</td><td>1</td></tr><tr><td>PA<sub>+</sub>V<sub>b</sub></td><td>1</td><td>3200</td><td>1</td></tr><tr><td>PA<sub>-</sub>V<sub>b</sub></td><td>2</td><td>1690</td><td>/</td></tr><tr><td>PA<sub>+</sub>V<sub>dark</sub></td><td>1</td><td>3200</td><td>/</td></tr><tr><td>PA<sub>-</sub>V<sub>dark</sub></td><td>1</td><td>1690</td><td>/</td></tr></tbody></table>

#### 1.1 Ring attractor network

Here we describe the ring attractor model based on the experimental data. Each neuron *i* in the ring had a preferred orientation $\theta_i$, $i = 1 \cdots n$. Rotational symmetry was assumed to exist around the ring so that the preferred orientations were evenly distributed around (0°, 360°), with the same neuron encoding for 0 and 360°. Simulations were performed with $n = 100$ neurons in order to ensure a sufficiently high level of angular precision, but in any case, the results are robust to the choice of ring size. As in (2,3, Supplementary Figure 1), a rate model was adopted for the neurons in line with the following first-order ordinary differential equations:

$$ \tau_E \frac{dc_i}{dt} = -c_i + g(\gamma_E + W^{I \to E} u + \sum_{j=1}^{n} W_{ji}^{E \to E} c_j + I_i) \quad (1) $$

where $c_i$ is the activation of the *i*-th neuron in the ring, $g(x) = \max(0, x)$ is a rectified activation function, $\tau_E = 42.5$ ms is the time constant, $\gamma_E = -1.5$ is the activation threshold and $I_i$ is the sensory input. The network comprises a single inhibitory neuron, which inhibits the neurons in the ring proportionally to its level of activation $u$ with the weight $W^{I \to E} = -6$. Pairs of neurons (*i*, *j*) in the ring have symmetric excitatory connections and weights decreasing with the distance $d_{ij}$ as follows:

$$ W_{ji}^{E \to E} = \alpha \exp(-d_{ij}^2 / 2\sigma^2) \quad (2) $$

where $\alpha = 45/n$, $\sigma = 120°$ and $d_{ij} = |\theta_i - \theta_j|$. The temporal evolution of the inhibitory neuron is given by

$$ \tau_I \frac{du}{dt} = -u + g(\gamma_I + W^{I \to I} u + W^{E \to I} \sum_{k=1}^{n} c_k) \quad (3) $$

where $\tau_I = 2.125$ ms, $\gamma_I = -7.5$, $W^{I \to I} = -1$ and $W^{E \to I} = 60/n$ are the weight exerted by the inhibitory neuron on itself and that exerted by the whole population of excitatory neurons, respectively.

<footnote><sup>a</sup>Aix-Marseille Université, CNRS, ISM, 13009, Marseille, France.</footnote>

<footnote><sup>b</sup>Université de Lorraine, CNRS, LORIA, 54000 Nancy, France.</footnote>

<footnote><sup>c</sup>PNI, Princeton University, Washington Road, Princeton, NJ 08540, USA.</footnote>

<footnote>*corresponding: stephane.viollet@univ-amu.fr</footnote>
<figure><img src="image_6.png" /><figcaption>A.</figcaption></figure>

Touretzky Ring Attractor

<figure><img src="image_7.png" /><figcaption>B.</figcaption></figure>

**Supplementary Figure S 1.** A and B adapted from², showing the Touretzky ring attractor network implemented here. A. Green circles stand for excitatory neurons, and the blue circle indicates the global inhibitory neuron. The orange arrows point to recurrent excitatory interneurons. The strength of the activation decreases with the distance between neurons. Excitatory and inhibitory connections between the global inhibitory neurons are shown in blue and green, respectively. B. The whole integration network is shown in unwrapped form (minus recurrent connections for the sake of simplification) with examples of inputs and optimal outputs superimposed. n = 100 neurons.
The model defined by Eq. (1) and (2) is known to give bell-shaped activation profiles$^{2,3}$. The output of the ring is obtained over time as the winner-takes-all solution, that is, at each time step $t$, the winning neuron $i^*(t)$ is that receiving the highest level of activation $c_{i^*}(t) > c_i(t) \forall i$. Its preferred orientation gives the goal roll and its activation gives a scaling factor, computed as $K = 30 c_{i^*}(t)$, accounting for the roll dynamics.

Simulations were performed based on Euler integration, taking the step size $dt = 0.01$ ms. For the sake of simplicity, the inhibitory neuron was initialized at $u(t = 0) = 1$, and the excitatory neurons were initialized with a bump at 0° corresponding to the proprioceptive cues sensed by the insect's legs prior to the experiments, that is $c_i(t = 0) = W_{ji}^{E \to E}$ given by Eq. 2, where $j = 0$. During the fall, the leg proprioception was no longer taken into account as the legs were not in contact with a surface, whereas when $t > 0$, sensory cues of two other kinds, namely those provided by the visual system and the antennae, were taken into account. The visual input to neuron $i$ was computed as follows:

$$X_{Vi} = \frac{k_V}{\sqrt{2\pi}\sigma_V} \exp(-|\theta_i - \mu_V|^2/2\sigma_V^2) \quad (5)$$

where $k_V = 40$, $\sigma_V = 10$ and $\mu_V = 0$ or $180^\circ$, depending on whether the light originated from above or below, respectively. The antennal input to neuron $i$ was computed as follows:

$$X_{Ai} = \frac{k_A}{\sqrt{2\pi}\sigma_A} \exp(-|\theta_i - \mu_A|^2/2\sigma_A^2) \quad (6)$$

where $\sigma_A = 5$, $\mu_A = 0^\circ$ and $k_A = 40$ or 0, depending on whether the antennae were intact or blocked with glue, respectively.

We first dealt with the classical linear neurons in the ring, to which the total input was the sum of the two sensory inputs, i.e. $I_i = X_{Ai} + X_{Vi}$. We did not completely succeed here, however, in simulating the experimental data because the difference in the roll rates observed between consistent and conflicting cues (the righting response was much faster with consistent cues) cannot be modeled by performing a simple summation of the sensory inputs, but requires some non-linear amplification. For this purpose, we used high-order, sigma-pi units$^{4,5}$ to which the total input was computed as follows:

$$I_i = X_{Ai} + X_{Vi} + \omega X_{Ai} X_{Vi} \quad (7)$$

where $\omega = 100$. When the two sensory cues disagree, the product $X_{Ai} X_{Vi} \approx 0$ and the sigma-pi unit behaves like a linear neuron with $I_i \approx X_{Ai} + X_{Vi}$, but when the two sensory cues are in agreement, a large product $X_{Ai} X_{Vi}$ is obtained, resulting in a non-linear amplification of the input $I_i$.

## 1.2 Closed-loop control of roll

We previously modeled the fly roll dynamics in the form of a purely second-order system (a double integrator, see Supplementary Figure 1 and$^1$) receiving a torque $U_{roll}$ as its input control signal and yielding a thorax roll speed $\Omega_{roll}$ and a thorax roll angle as its outputs, via the moment of inertia $I_{roll}$. As shown in Figure 1B, flies were able to reach the steady-state 0° position (right-side up) reliably. As described in Verbe et al., 2020$^1$, we modeled the exact closed-loop control of the roll by means of two nested feedback loops controlling the roll rate and the roll angle.
<figure><img src="image_8.png" /><figcaption>**Supplementary Figure S 2.** Dynamic model of hoverflies' righting reflex. Control block diagram including two nested feedback-loops: the fast feedback-loop controls the roll's angular speed measured by the halteres, and the slow loop controls the roll angle based on the estimated roll angle provided by a neural integrator. The goal roll signal ($\theta_{goal}$) controls the amplitude of the body roll. $\epsilon_{roll}$ and $\epsilon_{speed}$ are error signals, $K_{roll}$ is a gain, and $U_{roll}$ is the torque roll. The multiplicative factor $K_i$ (180/pi) serves merely to convert the estimated roll from radians to degrees. A simple integrator in the closed-loop mode (not shown here) is used to implement a low-pass filter with a variable time constant imposed by the K value. $K_{roll} = 1.22e-9$, $I_{roll} = 9.76e-12 \text{kg} \cdot \text{m}^2$, $H(s) = \frac{1}{0.0035s+1}$.</figcaption></figure>

<figure><img src="image_9.png" /><figcaption>**Supplementary Figure S 3.** Implementation of the variable time constant low pass filter as classically done in analog computing⁶. A pure integrator (1/s with s the Laplace variable) is placed in closed-loop to adapt the time constant by multiplying the error between the input signal (winner angle) and the output signal ($\theta_{goal}$) with the winner activation $K$. As a result, the closed-loop transfer function corresponds to a first order low-pass filter with time constant $\tau_f = 1/K$.</figcaption></figure>
<figure><img src="image_10.png" /><figcaption>**Supplementary Figure S 4.** Ring attractor simulated responses in the two experimental conditions $PA_+V_{dark}$ and $PA_-V_{dark}$. The output from the ring is obtained over time as the winner-take-all function, that is, at each time step, the winning neuron is that featuring the greatest activation. Winner angle codes for the goal roll value (Figure 2), whereas the value of K is equal to the amplitude of the winning neuron's activation. The initialization of the ring attractor is done by the leg's proprioceptive signal in the three conditions, and the integration of the orientation cues (Antenna and Light). In the case of $PA_+V_{dark}$, vision is absent and the antennae give the information corresponding to an upside-down position (0°), while in conditions $PA_-V_{dark}$, vision and the antennae are silent and only the leg proprioception generates information corresponding to an upside-down position (0°). The activation initiated at $t=0$ is similar in both conditions: $K=0.45$, winner angle = 0°. The final state at $t=0.14$ s is $K=178$, winner angle = 0° (panel A) and $K=0.61$, winner angle = 0° (panel B).</figcaption></figure>
<figure><img src="image_11.png" /></figure>

<figure><img src="image_12.png" /><figcaption>**Supplementary Figure S 5.** Response of the righting reflex model (dotted line) in comparison with the trials (solid line) in terms of the roll angle (A) and the angular speed (B) in the two dark conditions: with the antennae intact *PA<sub>+</sub>V<sub>dark</sub>* presented in gray and glued, *PA<sub>-</sub>V<sub>dark</sub>* in yellow. Thick lines are means, and error bars are S.Ds. See Supplementary Information, section 1.1 for further information.</figcaption></figure>

<figure><img src="image_13.png" /></figure>

<figure><img src="image_14.png" /><figcaption>**Supplementary Figure S 6.** Linear models (dotted line) versus experimental data (solid line) in three different conditions. (A) Response of a linear integration model⁷ that computes the winner angle in Supplementary Figure 2 as $\alpha\mu_A + (1 - \alpha)\mu_V$ with $\alpha = \sigma_V^2/(\sigma_A^2 + \sigma_V^2)$ ($\mu_A, \mu_V$ and $\sigma_A^2, \sigma_V^2$ stand for the mean and variance of antennal and visual cues). The time constant of the output filter in Supplementary Figure 2 is here inversely proportional to the estimated variance given by $K = (\sigma_A\sigma_V)^2/(\sigma_A^2 + \sigma_V^2)$. (B) Response of the ring attractor with purely linear neurons (in replacement of sigma-pi neurons), i.e. $\omega = 0$ in Eq. 1 in main text. The time constant of the output filter is inversely proportional to the winner activation as in Supplementary Figure 2.</figcaption></figure>
<figure><img src="image_15.png" /></figure>

<figure><img src="image_16.png" /><figcaption>**Supplementary Figure S7.** Activation profile of the ring attractor network at $t = 0.14$ s in two experimental conditions: $PA_+$*V*<sub>b</sub> in panel A and $PA_-$*V*<sub>b</sub> in panel B. Winner angle and *K* give the preferred roll orientation and the winning neuron's activation amplitude, respectively.</figcaption></figure>
<figure><img src="image_17.png" /></figure>

<figure><img src="image_18.png" /></figure>

<figure><img src="image_19.png" /></figure>

<figure><img src="image_20.png" /></figure>

<figure><img src="image_21.png" /><figcaption>**Supplementary Figure S8.** Time course of the winner angle and $K$ (winner's preferred roll and activation amplitude) in the various experimental conditions.</figcaption></figure>
**Supplementary Movies**

Supplementary Movie S1. Video of the hoverfly righting reflex and response of the model in the condition $PA_+V_t$.

Supplementary Movie S2. Video of the hoverfly righting reflex and response of the model in the condition $PA_-V_b$.

Supplementary Movie S3. Video of the hoverfly righting reflex and response of the model in the condition $PA_+V_b$.

Supplementary Movie S4. Video of the hoverfly righting reflex and response of the model in the condition $PA_+V_{dark}$.

Supplementary Movie S5. Video of the hoverfly righting reflex and response of the model in the condition $PA_-V_{dark}$.

Supplementary Movie S6. Video of the hoverfly righting reflex and response of the model in the condition $PA_+V_t$.

**References**

1. Verbe, A., Varennes, L. P., Vercher, J.-L. & Viollet, S. How do hoverflies use their righting reflex? *J. Exp. Biol.* **223**, DOI: 10.1242/jeb.215327 (2020). Publisher: The Company of Biologists Ltd Section: Research Article.

2. Sun, X., Mangan, M. & Yue, S. An analysis of a ring attractor model for cue integration. In *Conference on Biomimetic and Biohybrid Systems*, 459–470 (Springer, 2018).

3. Touretzky, D. S. Attractor network models of head direction cells. *Head direction cells neural mechanisms spatial orientation* 411–432 (2005). Publisher: MIT Press Cambridge, MA.

4. Durbin, R. & Rumelhart, D. E. Product Units: A Computationally Powerful and Biologically Plausible Extension to Backpropagation Networks. *Neural Comput.* **1**, 133–142, DOI: 10.1162/neco.1989.1.1.133 (1989).

5. Rumelhart, D. E., Hinton, G. E., McClelland, J. L. & others. A general framework for parallel distributed processing. *Parallel distributed processing: Explor. microstructure cognition* **1**, 26 (1986). Publisher: Cambridge, MA: MIT Press.

6. Ulmann, B. Analog computing. In *Analog Computing* (Oldenbourg Wissenschaftsverlag, 2013).

7. Ghahramani, Z., Wolpert, D. M. & Jordan, M. I. Computational models of sensorimotor integration. In Morasso, P. & Sanguineti, V. (eds.) *Advances in Psychology*, vol. 119 of *Self-Organization, Computational Maps, and Motor Control*, 117–147, DOI: 10.1016/S0166-4115(97)80006-4 (North-Holland, 1997).