Skip to main content
Nature Communications logoLink to Nature Communications
. 2026 Apr 23;17:5617. doi: 10.1038/s41467-026-72152-x

Centralized brain networks controlling antennal grooming coordination

Pembe Gizem Özdil 1,2,3, Jonathan Arreguit 2, Clara Scherrer 1, Femke Hurtak 1, Auke Ijspeert 2, Pavan Ramdya 1,✉
PMCID: PMC13314972  PMID: 42026054

Abstract

Animals must coordinate their body parts to perform essential behaviors like grooming and locomotion. Here, we investigate the neural basis of body part coordination during antennal grooming in the fly, Drosophila melanogaster. Unilateral and bilateral grooming, targeting one or both antennae, respectively, arise from synchronized movements of the head, antennae, and forelegs. Replay of these kinematics in a biomechanical model suggests that coordination allows for unobstructed, forceful collisions between the foreleg tibiae and antennae, potentially increasing grooming efficiency. Movements of one body part do not require proprioceptive sensory feedback from the others: neither amputation of the forelegs or antennae, nor immobilization of the head prevented movements of the other unperturbed body parts. An antennal grooming network from the brain connectome shows that centralized interneurons and shared premotor neurons interconnect and thus likely synchronize body part movements. A simulated activation screen of this network reveals that cell classes critical for coordination form coupled circuit motifs of recurrent excitation and broadcast inhibition, the latter of which we experimentally validate through manipulations of ‘asteroid’ broadcast inhibitory neurons during antennal grooming. Similarly centralized controllers may represent a general motif for the flexible co-recruitment of multiple body parts for a variety of behaviors.

Subject terms: Motor control, Network models, Sensorimotor processing


The neural basis of grooming behavior remains incompletely understood. Here, the authors combine behavior, biomechanical simulations, connectome analysis, and neural network modeling to uncover centralized circuits in the fly that orchestrate grooming behavior.

Introduction

Complex animal behaviors rely upon the seamless coordination of multiple body parts. Many behaviors, ranging from locomotion and feeding to grooming and scratching, require the precise temporal synchronization of rhythmic movements across multiple limbs or appendages1,2 to produce coherent movement sequences. This can be mediated through co-activation of dedicated motor networks for each appendage as well as the suppression or modulation of competing motor pathways3. Effective communication between neuronal populations controlling each participating body part is therefore critical for motor coordination.

Grooming and scratching have been important model behaviors for studying motor coordination because they combine both spatial and temporal components: targeted reaching followed by stereotyped, rhythmic limb movements. For grooming this is intended to remove debris or parasites4. These behaviors are conserved across species ranging from mammals to insects5–9. In vertebrates, rhythmic scratching (e.g., hindlimb movements in turtles and cats) is governed by spinal commissural interneurons that mediate interlimb coordination10–14. Similarly, in insects grooming behaviors like leg rubbing in locusts are thought to be generated by central pattern generators (CPGs) located in the thoracic ganglia15. These CPGs also coordinate activity across contralateral pairs of limbs16,17. Despite this progress, systems-level circuit mechanisms, including specific cell-types that enable multi-limb coordination during grooming, remain poorly understood.

The fruit fly, Drosophila melanogaster, offers a particularly powerful experimental system to investigate these circuit mechanisms. Flies perform numerous behaviors that require the temporal synchronization of movements18–20. In addition, the fly’s brain and its motor system—the ventral nerve cord (VNC)—have been fully mapped21–27, enabling the detailed analysis of circuit connectivity. Finally, extensive libraries of transgenic driver lines make it possible to genetically target and manipulate specific neuronal subtypes28,29.

Here, we investigated antennal grooming in the fly to obtain a multi-scale mechanistic understanding of underlying body part coordination. Adult flies groom many different body parts—their antennae, eyes, proboscis, legs, wings, and abdomen—in a prioritized sequence governed by a suppression hierarchy20,30–32. Optogenetic neural activation experiments in Drosophila have identified key neurons responsible for grooming including peripheral sensory neurons33–35, brain interneurons36, descending neurons linking the brain to downstream VNC motor networks37,38, and interneurons within the VNC39,40 which may contribute to central pattern generation for limb control41. Nevertheless, the organizational logic of grooming kinematics and underlying motor networks remains largely unknown.

Numerous tools and resources now allow us to overcome this gap. First, markerless 3D pose estimation enables high-throughput measurements of body part movements42,43. Second, these kinematic data can be replayed in a biomechanical model of the fly to infer contact forces44–46. Third, the brain and VNC connectomes can be used to simulate network dynamics47,48. Here, we combine these tools and resources to uncover kinematic and circuit-level mechanisms for body part coordination during antennal grooming. We find that flies primarily perform two subtypes of grooming: unilateral for cleaning one antenna and bilateral for cleaning both antennae. These are distinguished by their differential synchronization of head, antennae, and foreleg movements. Replay of these kinematics in a biomechanical model shows that coordination prolongs grooming contact by preventing obstructions and enabling forceful foreleg-antennal collisions. Fixing the head in place or removing the antennae or forelegs does not disrupt synchronization, indicating that proprioceptive sensory feedback is not required. Indeed, the fly brain connectome reveals that centralized and shared premotor interneurons bind motor modules for these body parts. Simulated activation and silencing of neurons in this antennal grooming network uncovers coupled recurrent excitatory and broadcast inhibition circuit motifs that likely enable robust body part coordination. We experimentally validate our model’s predictions for the role of specific broadcast inhibition interneurons during antennal grooming.

Results

Antennal grooming arises from tripartite coordination

To precisely quantify antennal grooming, we developed an experimental system that allows us to measure head, antennal, and foreleg kinematics in tethered flies (Fig. 1A). We reliably elicited antennal grooming through bilateral optogenetic stimulation of antennal Johnston’s Organ F (‘JO-F’) neurons36 (aJO-GAL4-1 > CsChrimson; Supplementary Fig. 1A), or by presenting both antennae with a brief puff of air.

Fig. 1. Kinematic analysis reveals two major subtypes of Drosophila antennal grooming.

Fig. 1

A Schematic of the experimental platform for optogenetic induction and multi-camera recording of antennal grooming. A tethered fly is monitored by five cameras to capture 2D poses from multiple views. Grooming it elicited by either a 617 nm LED used to activate CsChrimson in Johnston’s Organs, or through air-puff stimulation. B Reconstruction of 3D poses from 2D keypoints. The 3D coordinate system defines the x-axis as antero-posterior, the y-axis as medio-lateral, and the z-axis as dorso-ventral. Arrows indicate axial polarity. Body parts are color-coded. C From the 3D poses, we use inverse kinematics to calculate joint angles for the neck, antennae, and forelegs. D Joint angles are used to control joint actuators in NeuroMechFly, a physics-based simulation of the adult fly. Collision bodies (left) can be used to quantify the contact forces (right) between the antennae and forelegs. E Front camera images overlaid with color-coded `bones' of the legs (blue/right, orange/left) and antennae (light blue/right, light orange/left). Illustrated are two antennal grooming subtypes: unilateral left (`uniL') and bilateral (`biLat') across (E–H). Head and antennal movements are schematized (white arrows). F Visualization of sample 3D kinematic trajectories of the base and tip of the antennae as well as the tibia-tarsus joints of the forelegs during antennal grooming. Joints are color-coded as in (E). G, top Mediolateral positions of the tibia-tarsus leg joints. Positive values represent the left side in fly-centric coordinates. Joints are color-coded as in panel (E). G, bottom Head and antennal degree of freedom angles. For head roll, positive values are leftward. For head pitch, negative values are downward. For antennal pitch, positive values are upward. H Contact diagrams inferred from collisions between the foreleg segments and the antennae. This was derived using kinematic replay of joint angles in NeuroMechFly. Asterisks mark the occurrence of each corresponding antennal grooming subtype.

We recorded animal behavior simultaneously from five camera views42 and then used these videos to track 2D positions of keypoints on the antennae, neck, and forelegs49. These positions were triangulated in 3D43 (Fig. 1B) and then, using sequential inverse kinematics50, we computed joint angles (Fig. 1C; Supplementary Video 1). In addition to providing quantitative measurements of grooming movements, these joint angles could be replayed in NeuroMechFly44–46, a biomechanical model of the fly (Fig. 1D; and Supplementary Video 2), to infer contacts and forces between body parts that are otherwise challenging to measure experimentally.

Visual inspection of our behavioral videos revealed that optogenetically-elicited antennal grooming tends to fall into two subtypes with distinct body part kinematics: (i) unilateral grooming of either the right (‘uniR’) or left (‘uniL’) antenna by both forelegs, or (ii) bilateral (‘biLat’) grooming in which each foreleg simultaneously grooms its ipsilateral antenna (Fig. 1E; and Supplementary Video 3). Importantly, both subtypes were also observed in response to air-puffs (Supplementary Video 4), with quantitatively similar head, antenna, and foreleg kinematics (Supplementary Fig. 2).

Unilateral grooming in response to optogenetic (Fig. 1F; and Supplementary Fig. 1B) or air-puff (Supplementary Fig. 1C) stimulation is characterized by several kinematic features. First, both forelegs move laterally toward the targeted antenna and produce cyclical, synchronized leg sweeps at  ~ 8 Hz39 (Fig. 1G, top). Second, the non-targeted antenna is lifted upwards via the actively controlled scape-pedicel joint, possibly to avoid collisions with the legs (Fig. 1G, bottom). Third, the head is pitched down and rolled to the side, bringing the targeted antenna into the task space of the forelegs (Fig. 1G, bottom). By contrast, during bilateral grooming, the antennae do not appear to be elevated. As well, the head does not rotate but is instead pitched downwards, lowering both antennae to the work space of the forelegs. Indeed, simulated replay of these kinematics in our biomechanical model confirmed that, during unilateral grooming, collisions occur between both forelegs and the targeted antenna whereas, during bilateral grooming, each foreleg principally collides with its ipsilateral antenna (Fig. 1H). Thus, the kinematics of the head, antennae, and forelegs are differentially correlated during unilateral versus bilateral antennal grooming (Supplementary Fig. 1D, E).

We quantified the frequency of grooming subtypes by manually classifying behaviors across multiple flies (n=10 animals) during optogenetic stimulation (Supplementary Fig. 1F). Unilateral and bilateral grooming are the most frequent, occurring in more than 70% of behavioral events. The remaining ( < 30%) behaviors could not clearly be defined as antennal grooming (e.g., leg lifting) and thus were labeled unclassified (‘non-class’). In other more rare instances, behaviors only partially matched unilateral coordination (‘partial uni’). We often observed that flies transitioned smoothly between different grooming subtypes. The most frequent transitions occurred from bilateral to unilateral grooming (Supplementary Fig. 1G, H). Importantly, our classification of antennal grooming into unilateral and bilateral subtypes also emerged using an unbiased, dimensionality reduction approach. Principal component analysis (PCA) performed on the same head and foreleg kinematics data revealed marked subdivisions along the first two principal components which explained over 40% of the variance (Supplementary Fig. 1I). Specifically, unilateral grooming subtypes reside on either side of a central PCA space filled by bilateral and non-classified subtypes (Supplementary Fig. 1J). Strikingly, features observed during each grooming subtype were evident in time-series data from these first two principal components. The first principal component resembles a posture characteristic of unilateral grooming: the left and right tibia-tarsus joints are positioned laterally on one side of the midline, the left and right antennae are pitched in opposite directions, and there is a low degree of head pitch when head roll angles are larger (Supplementary Fig. 1K). Consistent with this, uniR and uniL are found on opposite (negative versus positive) sides of this first principal component (Supplementary Fig. 1J). Kinematics in the second principal component were reminiscent of bilateral grooming: the tibia-tarsus joints are symmetrically on opposite sides of the midline, antennal pitch angles are similar, and although head roll is nearly zero, head pitch is large (Supplementary Fig. 1L). Indeed, bilateral and non-classified grooming are distributed along this second principal component axis (Supplementary Fig. 1J). We note that the scape-pedicel joint is the only joint in the Drosophila antenna that is actively controlled51. Therefore, throughout the text, we refer to pitch of the scape-pedicel joint as ‘antennal pitch’.

The synchronization of body part movements during antennal grooming can also be quantified as a systematic correlation of their kinematics over time (Supplementary Fig. 1D, E). To rule out the possibility that these correlations trivially arise from the displacement of the head and antennae by forceful contact with the forelegs, we optogenetically elicited antennal grooming in animals with their forelegs amputated. There we observed similar head/antennal kinematics reflected in overlapping spatial occupancies (Supplementary Fig. 3). Thus, the head, antennae, and forelegs appear to be actively coordinated.

Body-part coordination enhances sustained foreleg-antennal contact

Having observed stereotypically synchronized head, antennal, and foreleg movements during antennal grooming, we next asked to what extent this coordination facilitates grooming by increasing contacts between the forelegs and antennae. For example, we hypothesized that during unilateral grooming of the left antenna: (i) leftward roll of the head might bring the left antenna closer to the forelegs, (ii) upward pitch of the non-targeted right antenna might prevent contact with the forelegs, and (iii) leftward shift of the forelegs might facilitate contact with the targeted left antenna.

Testing these hypotheses experimentally would require measuring foreleg-antennal contacts while perturbing single degrees of freedom (e.g., by eliminating head pitch without affecting head roll). Such experiments are currently not technically feasible—we lack both a means of measuring body part contacts as well as the ability to genetically perturb motor neurons driving individual antennal and neck degrees of freedom. Therefore, we performed perturbation experiments in our neuromechanical model, NeuroMechFly44–46. Specifically, we replayed real, recorded body part kinematics in our simulation while measuring collisions and forces between the antennae and forelegs. We repeated this experiment while systematically modulating the amplitude of individual degrees of freedom—forward head pitch, sideways head roll, or upward pitch of the non-targeted antenna. We modulated joint angles by multiplying them with a scalar gain value ranging from 0 to 1.3 in increments of 0.1. This allowed us to attenuate or amplify movements while preserving individual variability and continuity in joint kinematics.

We first investigated the importance of downward head pitch during bilateral grooming. We replayed measured kinematics and quantified antenna-leg collisions from real data (‘gain = 1’, Fig. 2A, top), or while virtually fixing the head in its rest position (‘gain = 0’, Fig. 2A, bottom). Compared with our real data (Fig. 2B, top), when the head was fixed in place we observed that the leg segments in contact with the antennae shifted from the tibiae to the more distal tarsi (Fig. 2B, bottom; Supplementary Video 5, left). By systematically performing this experiment using kinematic data from multiple animals with substantial head pitch (median greater than 14 degrees) but minimal head roll (Supplementary Fig. 4A) we confirmed that larger head pitch results in increased tibia-antenna contact (Fig. 2C, left) and decreased tarsus-antenna contact (Fig. 2C, right). Thus, downward head pitch during bilateral antennal grooming may serve to maximize contact between the fly’s foreleg tibia and antennae.

Fig. 2. Kinematic replay in a biomechanical model reveals the contribution of head and antennal movements to foreleg-antennal interactions.

Fig. 2

We generated a kinematics dataset to be replayed in simulation, allowing us to gradually perturb individual joint degrees of freedom while measuring contacts between the forelegs and antennae. A, D, G Snapshots from kinematic replay simulations with either an intact (top), or perturbed (bottom) (A) head pitch, (D) head roll, or (G) antennal pitch. B, E, H Collision diagrams between tibia and tarsus foreleg segments and both antennae (right/blue, left/orange) either in intact (top), or perturbed (bottom) (B) head pitch, (E) head roll, or (H) antennal pitch. In panel B asterisks indicate where tibial collisions disappear as head pitch is decreased. In panel E, asterisks indicate that when head roll decreases, there are increased collisions between the targeted antenna (left/orange) and the ipsilateral, left tarsus. As well, circles indicate increased collisions between the non-targeted antenna (right/blue) and the ipsilateral, right tibia. In panel H as antennal pitch decreases asterisks indicate reduced collisions between the targeted antenna (left/orange) and its contralateral, right tibia. As well, circles show increased collision between the non-targeted antenna (right/blue) and its ipsilateral, right tibia. C, F, I Contact duration between specific antennal and foreleg segments as a function of the movement magnitude of a joint degree of freedom. Contact is normalized between minimum and maximum values across all gains/magnitudes for each trial. Data are presented for: (C) n = 4 flies, N = 13 bilateral grooming bouts; (F, I) n = 4 flies, N = 16 unilateral grooming (uniL and uniR combined) bouts. Intact, unmodified kinematics are highlighted in light gray boxes. Box plots show the median and quartiles. Box plot whiskers extend to 1.5 times the interquartile range (IQR). Shown are statistical results for a two-sided Mann-Whitney U test comparing the intact distribution with other gains/magnitudes: ***: P < 0.001, **: P < 0.01, *: P < 0.05 and not significant (NS): P ≥ 0.05. P values were corrected using the Simes--Hochberg procedure.

Next, we inspected bilateral antennal grooming in real animals after their heads were immobilized and fixed in a resting position (i.e., akin to zero gain head pitch and zero gain head roll in our simulations). Despite head fixation, these flies still predominantly used their tibial leg segments to rub their antennae (Supplementary Fig. 4B–D). Thus, animals appear to adapt their foreleg movements in an effort to reach their antennae using their tibial leg segments. Why might flies prioritize tibial contact with the antennae? One possibility is that the tibiae may exert more force on the antenna compared with the more compliant tarsi—a thinner multi-segmented structure with numerous passive joints. Consistent with this, even though our simulated tarsi are not compliant compared with real tarsi, they nevertheless exert less force than the tibiae on the antennae, on average (Supplementary Fig. 4E, F).

During unilateral grooming, flies roll their heads to the side, lowering the targeted antenna. Similar to head pitch during bilateral grooming, we hypothesized that this head roll might bring the targeted antenna into the task space of the legs, while positioning the non-targeted antenna further away. To test this, we replayed unilateral grooming in our simulation while modulating the amplitude of head roll. Indeed, collision diagrams show that during, for example, unilateral left antennal grooming, compared with intact head roll (gain=1, orange epochs Fig. 2D–E, top) when head roll is suppressed, there is increased contact between the right leg and the non-targeted, right antenna (gain=0, blue epochs Fig. 2D-E, bottom; Supplementary Video 5, middle). Using kinematic data from multiple flies during unilateral grooming with appreciable head roll (median more than 8 degrees) (Supplementary Fig. 4G), we confirmed that suppressing head roll results in (i) a shift from contact with the ipsilateral tibia to the more distal tarsus (Fig. 2F, left) as well as (ii) an increase in collisions between the non-targeted antenna and its ipsilateral tibia (Fig. 2F, right). Thus, head roll appears to bring the targeted antenna toward and the non-targeted antenna away from the task space of the foreleg tibiae.

Finally, we asked whether upward pitch of the non-targeted antenna facilitates unilateral grooming by allowing the fly to avoid undesired leg collisions. Because in our real experiments antennal poses were often obstructed during leg-antenna interactions, direct replay of real antennal joint angles was not possible. Therefore, we instead set the antennal pitch degree of freedom to a constant value ranging from 0° to 60° in increments of 5°—a range of angles that resembles those measured from real flies (Supplementary Fig. 4G). We found that when the non-targeted antenna was pitched upward (angle 60°) both tibiae principally contact the targeted antenna (orange, Fig. 2G-H, top). However, when the non-targeted antenna remains in its resting position (angle 10°) it obstructs the ipsilateral tibia, reducing contact with the targeted antenna (Fig. 2G, H, bottom; Supplementary Video 5, right). This was consistent across multiple animals and grooming epochs: suppressing the upward pitch of the non-targeted antenna reduces grooming of the targeted antenna by the contralateral tibia (Fig. 2I, left) due to increased collisions with the non-targeted antenna (Fig. 2I, right).

Thus, head and antennal movements during grooming appear to optimize tibial contact with the targeted antenna(e) by (i) bringing the targeted antenna into the foreleg task space via downward head pitch or sideways head roll and (ii) preventing collisions between the legs and non-targeted antenna via sideways head roll and upward pitch of the non-targeted antenna. We expect that prolonged foreleg-antennal contact facilitates debris removal from the antennae and could therefore serve as a proxy for grooming efficiency. Next, we sought to decipher the neural mechanisms underlying this tripartite coordination of body parts during unilateral antennal grooming.

Proprioception does not play a major role in body-part coordination

The synchronous activation of motor networks for the head, antenna, and forelegs during unilateral grooming can arise from several potential control frameworks. First, in a ‘sensory feedback’ framework, movements of one body part (e.g., the head) may generate proprioceptive signals that initiate and/or maintain motor programs for the other two body parts (e.g., the antenna and forelegs) (Fig. 3A). Within this framework, we can envisage three mechanisms that may yield tripartite coordination of the head, antennae, and legs: (i) proprioceptive feedback from moving one body part could drive movements of a second whose proprioceptive feedback would in turn drive a third (‘cascading coordination’), (ii) proprioceptive feedback from two moving body parts may both be needed to drive movements of a third (‘additive coordination’), or (iii) proprioceptive feedback from one moving body part may drive movements of the other two (‘diverging coordination’) (Supplementary Fig. 5). In an alternative framework, proprioceptive feedback-independent or ‘open-loop’ mechanisms might underlie synchronous movements of the head, antennae, and legs (Fig. 3B). Open-loop models can be classified based on the origin of movement synchronization in the brain’s sensorimotor pathway: it may arise at the sensory layer of JO neurons (‘input shared’), via an ensemble of central neurons (‘central hub’), or as a consequence of intercommunicating motor modules (‘output shared’).

Fig. 3. Experimental perturbations show that proprioceptive sensory feedback is not essential for body part coordination.

Fig. 3

A Sensory feedback-dependent control models. Colored blocks denote motor modules (motor neurons and their premotor neurons) for specific body parts. Configurations shown: cascading (feedback from one body part drives another), additive (combined feedback from two parts drives a third), or diverging (feedback from one part drives two others). B Open-loop control models. Coordination is driven at various levels: downstream of JO sensory input (`Input shared'), via central interneurons (`Central hub'), or through motor module efference copies (`Output shared'). C Experimental perturbations used to test the contribution of sensory feedback to coordination, including foreleg or antennal amputation and head fixation using UV-curable glue. D, F, H, J, L, N Front and side camera images overlaid with line drawings of the legs (orange), and arrows indicating movements of an antenna (green), and/or head rotations (blue). The locations of experimental perturbation(s) are indicated (white arrowheads). E, G, I (top) Distribution of (E, I) tibia-tarsus joints' mean lateral positions and (G) head roll during unilateral left (magenta) or unilateral right (green) antennal grooming in either intact (darker color) or experimental (lighter color) animals. (bottom-left) Median values of each kinematic variable across trials for each fly and grooming subtype. (bottom-right) Differences between uniL and uniR kinematic variables for intact versus experimental conditions, computed as the difference between the data points in the bottom-left panel. For (E) n=8, (G) n=7, and (I) n=10 animals. K, M, O (left) Distribution of joint angles and positions for the remaining freely moving body part in experiments perturbing two body parts at once. (right) Differences between the 90th and 10th percentile of (K) the pitched antenna’s joint angles, and (M, O) median differences between body part movements to the left and right. For (K) n=6, (M) n=5, and (O) n=4 animals. In boxen plots, the median is represented by the largest middle line. The largest (primary) box represents the interquartile range (25th to 75th percentiles). The outermost whiskers extend to the minima and maxima of the distributions. In scatter plots, each dot represents an individual fly, with lines connecting the same fly across behavioral subtypes or experimental conditions. One-sided Mann-Whitney U tests compare uniR versus uniL under the same conditions, while two-sided tests compare data across experimental conditions (e.g., intact versus head-fixed). Significance levels are indicated as follows: ***: P < 0.001, **: P < 0.01, *: P < 0.05 and not significant (NS): P ≥ 0.05.

We first aimed to distinguish to what extent antennal grooming depends on a proprioceptive sensory feedback versus open-loop control framework. To do so, we measured antennal grooming in flies both before and after body part manipulations intended to eliminate proprioceptive sensory feedback: foreleg amputation, antennal amputation, and/or head fixation (Fig. 3C). Additionally, to test additive feedback models, we simultaneously perturbed two body parts (e.g., amputating the forelegs and immobilizing the head). In total, we tested six perturbations: (i) fixation of the head (Fig. 3D), (ii) amputation of the forelegs (Fig. 3F), (iii) amputation of the antennae (Fig. 3H), (iv) head fixation and foreleg amputation (Fig. 3J), (v) antennal and foreleg amputation (Fig. 3L), and (vi) antennal amputation and head fixation (Fig. 3N). To quantify the impact of perturbing one body part, we investigated the kinematics of the remaining two intact body parts. For example, we examined which antenna the forelegs reach laterally towards while the fly pitches one antenna upward (Fig. 3E, top). We observed that flies preserve their leg and antenna coordination pattern following head immobilization (Fig. 3E, bottom; Supplementary Video 6). Although we measured minor changes in foreleg trajectories, particularly in the proximal leg joints (Supplementary Fig. 6), this is likely because flies have more room to move when the head is fixed and not pitched downward. Similarly, amputation of the forelegs did not alter the relationship between head roll and antennal pitch during unilateral grooming (Fig. 3G; and Supplementary Video 7). Finally, after antennal amputation, we observed that the lateral position of the forelegs still tracked the direction of head rotation (Fig. 3I; and Supplementary Video 8).

Next, we perturbed two body parts simultaneously and measured the movement range of the remaining body part. In foreleg amputated and head-fixed flies without significant neck and leg proprioceptive sensory feedback, we found that flies still actively lift their antenna (Fig. 3K; and Supplementary Video 9). We note that in intact flies the forelegs push the antenna closer to the head, reducing antennal pitch angles. As well, after both foreleg and antennal amputations, we observed that the head still rolls in both directions (Fig. 3M; and Supplementary Video 10). Finally, amputating the antennae and fixing the head in place did not disrupt lateral movements of the forelegs (Fig. 3O; and Supplementary Video 11).

Because no perturbation significantly altered the coordinated movements of intact body parts, we conclude that proprioceptive sensory feedback is not required for head, antennae, and leg movement synchronization during antennal grooming. Other open-loop control mechanisms are thus more likely at play.

A centralized brain network links multiple motor modules

To evaluate potential open-loop control models for body part synchronization, we extended our abstract ‘input’, ‘central’, and ‘output’ models to include real neuronal subtypes like sensory inputs, interneurons, and motor modules (i.e., premotor neurons and their target motor neurons moving a specific body part). In this extended ‘open-loop’ framework we could envision at least four different neural network architectures that might enable the synchronization of head, antenna, and foreleg movements: via (i) shared antennal Johnston’s Organ sensory input (‘input shared’), (ii) common input from central interneurons controlling premotor-motor modules (‘central hub’), (iii) coupling between premotor circuits for each body part (‘premotor coupling’), or (iv) shared premotor circuits for multiple body parts (‘shared premotor’) (Fig. 4A).

Fig. 4. Body part motor modules are linked by central circuits in the fly brain connectome.

Fig. 4

A Theoretical open-loop models for motor coordination of the head, forelegs, and antennae: input shared (direct JO-F projections to all modules), central hub (divergent control by central neurons), premotor coupling (interconnected premotor neurons), and shared premotor (shared control of motor neurons). B Graph visualization of the connectivity of previously identified36 antennal grooming neurons (highlighted) in the fly brain connectome21–23. Neuron types are color-coded the same across panels (B–E). C Graph visualization of our antennal grooming network constructed using the fly brain connectome and seeded from the network in panel B. Arrows indicate connectivity; line colors and widths denote neurotransmitter identity and synaptic weights, respectively. D Renderings of all sensory, interneuron, descending, or motor neurons in the antennal grooming network. E Adjacency matrix of the constructed network, ordered by neuron type as in panel (C). The connectivity matrix was binarized, making excitatory connections +1 and inhibitory connections -1. F The frequency of different neurotransmitters across neurons (top) and synaptic connections (bottom) in the network. G Signal flows across five hops. Premotor neurons are defined by  > 5% output to motor neurons. Central neurons are situated between JO-F inputs and motor modules within four hops. H Neuronal groups ordered by their signal flow scores, ranging from input-like (left) to output-like (right). Each dot represents one neuron, with JO-F neurons merged into one group for each side of the brain. The axis was divided into nine intervals, and neurons were assigned to their respective layers. I Heatmaps of excitatory (left) and inhibitory (right) interlayer connectivity, indicating the degree of feedforward (black) versus feedback (orange) connectivity. J Network connectivity diagram (comparable to A). Line widths are proportional to the percentage of connections between groups; connections below 4.6% are omitted. The same color code is used across panels (J–M). K Heatmap showing the contribution of inputs from one neuron group to another. Expected connections for each hypothetical model are outlined. L Venn diagram of neurons classified as premotor to neck (blue), antennal (green), or leg (orange) motor neurons. Asterisks denote shared premotor neurons. M Relative contributions of inputs from premotor neuron types to motor neuron groups. “Separate” refers to premotor neurons that project onto only one motor neuron type, and “shared” refers to those projecting onto more than one motor neuron type. N Pearson correlation coefficients comparing real connectivity (panel J) against randomly shuffled adjacency matrices. Each dot represents a unique shuffled network. Box plots indicate the median (red line) and quartiles. Whiskers extend to the full distribution, excluding outliers beyond 1.5 times the interquartile range (IQR).

We investigated the degree to which these network architectures might underlie open-loop coordination by using the adult female whole-brain connectome21–23,52 to construct a comprehensive network of antennal grooming-related neurons. We began with neurons that had previously been described as involved in antennal grooming. These included sensory neurons like the antennal Johnston’s Organ (‘JO’ C-E-F)33,36 and mechanosensory bristles35, brain interneurons (aBN1,2,3), and descending neurons (aDN1,2,3)36 (Fig. 4B). To these we added antennal and neck motor neurons, allowing us to define the motor modules for each of these body parts. Then, we systematically incorporated neurons monosynaptically connected to any of these seed neurons (Supplementary Fig. 7A) with synaptic connections to the seed network exceeding a threshold defined by a parameter sweep (Supplementary Fig. 7B) and informed by previous work22. This threshold excluded extraneous neurons with little information flow to or from antennal grooming neurons while still retaining a broad range of neuron types (Supplementary Fig. 7C).

Our final antennal grooming network consists of 827 neurons with sparse connectivity (2195 connected neuron pairs or 0.3% sparsity) (Fig. 4C–E). Of these connections,  ~ 31% are contralateral across brain hemispheres. Although  ~ 77% of neurons are excitatory, they contribute only  ~ 55% of synapses (Fig. 4F). Thus, on average, inhibitory neurons contribute proportionally more synapses to this network, consistent with previous findings53. Additionally, we observed high degree distributions among inhibitory interneurons (Supplementary Fig. 7D, circled in black), and the excitatory aBN1, suggesting that these neurons may influence network dynamics on a global scale.

To test the relative match to our different open-loop control models (Fig. 4A), we next categorized interneurons as being either central or premotor. Neurons were defined as ‘central’ if they lay on the path (on average with more than 5% of synaptic inputs) from ‘JO-F’ sensory inputs to motor neurons within five hops53 (Fig. 4G). From this group of ‘central neurons’, we then reclassified as ‘premotor neurons’ those with at least 5% of their outputs directly targeting motor neurons controlling the antennae or neck (Fig. 4G).

Ultimately, our approach classified neurons in our antennal grooming network into four major groups: sensory (JO-F), central, premotor (antennal, neck, foreleg, or shared), and motor (antennal or neck). We used a signal flow sorting algorithm54 to measure the extent to which information flows in a feedforward manner in this network. This algorithm scores each node in the graph based on its proximity to the input and output. Signal flow scores across nodes in our neuron groups (Supplementary Fig. 7E) exhibited a clear gradient in which, as expected, sensory JO-F neurons were situated closest to the input, followed by central, premotor, and finally motor neurons near the output (Fig. 4H). We next asked to what degree neurons form feedback connections to preceding layers. Specifically, we divided the signal flow axis into nine layers to get sufficiently many ( ~ 40) neurons per layer. Then we examined the connectivity between neurons in each layer by summing the number of synapses made between each neuron pair. For both excitatory and inhibitory connections, we found that the grooming network is predominantly feedforward (gray), with some feedback (orange) connections enriched near sensory layers 2 and 3 (Fig. 4I). We speculate that this feedback might reflect presynaptic inhibition upon sensory inputs55.

Close examination of our network’s connectivity matrix appears to immediately exclude two open-loop models (Fig. 4J, K; and Supplementary Fig. 8). First, JO-F neurons connect only minimally to premotor and motor neurons. Therefore, sensory input does not appear to directly drive synchrony across motor modules (Fig. 4A, ‘input shared’ model). Second, premotor modules do not appear to be connected strongly to one another (Fig. 4A, ‘premotor coupling’ model). By contrast, we observe strong connectivity between central and premotor neurons (Fig. 4J, K) whereby individual central neurons project onto shared premotor or multiple categories of premotor neurons (Supplementary Fig. 7F). This finding supports the ‘central hub’ model. Similarly, there exist common premotor neurons which target multiple groups of motor neurons (Fig. 4J, K), consistent with our ‘shared premotor’ model. However, shared premotor neurons contribute only  ~ 42% and  ~ 26% of synapses to neck and antennal motor neurons, respectively (Fig. 4L, M). As well, in the VNC some shared premotor neurons project to both neck and foreleg motor neurons (Supplementary Fig. 7G). Interestingly, within the VNC, the axons of descending neurons arising from the brain represent the largest fraction of shared (rather than foreleg- or neck-specific) premotor neurons (Supplementary Fig. 7H). This suggests that brain networks may also be principally responsible for directly coordinating leg and neck movements within the VNC.

Taken together, our findings indicate that central interneurons, with a smaller contribution from shared premotor circuits, are best positioned to coordinate antennal, neck, and leg motor modules. Correlation analyses with randomized adjacency matrices confirm that the real network’s configuration is highly non-random (Fig. 4N). More specifically, comparing the real connectome network with randomized versions of this network (Supplementary Fig. 9A-B) shows that the proportion of connections in the ‘central’ and ‘shared premotor’ models is significantly greater than expected by chance (Supplementary Fig. 9C, purple and gray boxes). As well, connections associated with the ‘input-shared’ and ‘premotor coupling’ models are significantly lower or not statistically different than that expected by chance, aside from antennal premotor to foreleg premotor connectivity (Supplementary Fig. 9C, dark blue and orange boxes).

Simulating a connectome-derived antennal grooming network

Connectivity analysis revealed that central neurons likely coordinate the activity of head, antennae, and foreleg motor modules. However, static connectivity information alone is insufficient to understand the contributions of individual neurons and circuit motifs to behavioral dynamics. For example, instead of forming a continuous gradient of behavioral subtypes, grooming tended to be either unilateral or bilateral. This pattern suggests that the antennal grooming network may operate using winner-take-all action selection, a process whose study requires investigating the temporal evolution of neural activity. Therefore, we simulated our network’s dynamics to explore how it might drive this selection process.

Specifically, we built a connectome-derived artificial neural network, in which each neuron is modeled as a leaky integrator56. We optimized network parameters to generate outputs that matched a training dataset consisting of head and antennal kinematics from flies (n=10 animals) whose JO-F neurons were stimulated with diverse optogenetic patterns, including steps of varying duration, and pulses of varying frequency (Fig. 5A, left). To keep sensory input well-defined, these animals’ forelegs were amputated (Fig. 5A, middle). This allowed us to (i) prevent leg-antennal contact during grooming and thereby limit mechanosensory feedback from the head35 and forelegs57, as well as (ii) reduce the importance of ascending leg proprioceptive sensory feedback58. Importantly, our previous amputation experiments (Fig. 3) demonstrated that head and antennal coordination can occur even in the absence of the forelegs. From these video data, we computed head and antennal kinematics (Fig. 5A, right; Supplementary Fig. 10A) as target outputs for our network to replicate during simulations.

Fig. 5. Training and evaluating connectome-derived artificial neural networks for antennal grooming.

Fig. 5

A Training dataset comprising head and antennal kinematics in response to optogenetic stimulation of varying durations and frequencies. Forelegs were amputated to isolate head and antennal movements. B Schematic of the connectome-constrained network. Virtual optogenetic stimuli (red) are delivered to JO-F neurons. Activities from antennal and neck motor neurons are processed by decoders representing musculoskeletal properties to output 1D joint angles for antennal pitch (right: blue; left: orange) and head pitch (black). JO-C and JO-E neurons receive antennal sensory feedback via processed, time-delayed joint angle copies. Model parameters were optimized against real kinematics; performance was evaluated on a held-out test dataset. C Trained models were analyzed by applying slightly asymmetric JO-F activation and quantifying the unilaterality of neural responses for each neuron pair. The unilateral selectivity index (USI) metric is defined as the area under the right neuron’s response curve minus that of the left neuron’s response, divided by the sum of both responses. Only positive neural responses were considered in this calculation. For instance, the metric equals one when there is a positive response in the right neuron but no response in the left neuron. The metric is undefined (N.A.) when both neurons do not respond. D Responses of antennal brain interneurons (aBNs), descending neurons (aDNs), and motor neurons (aMNs) to asymmetric JO-F input (left > right) in every trained model. Neural responses were quantified using the USI metric. Gray squares indicate zero neural activity in both neurons (USI = 0/0). Magenta and green squares represent neurons with larger ipsilateral and contralateral responses, respectively. The darkest colors denote cases in which neurons on one side are predominantly active. E Summary of unilateral selectivity of aBNs, aDNs, and aMNs across models. Among antennal motor neurons, only antennal motor neuron 4 (aMN4) consistently exhibits a contralateral response to asymmetric (left greater than right) JO-F input. Each dot represents a model (a square in panel D). Box plots show the median (red line) and quartiles. Whiskers extend to the full distribution, excluding outliers beyond 1.5 times the interquartile range (IQR).

Due to imperfections in connectome data acquisition and reconstruction as well as real biological variation, there are differences in connectivity across the left and right brain hemispheres22,59 (see Discussion). This might introduce spurious, artifactual asymmetries in network simulations. Therefore, to minimize the inductive biases stemming from this asymmetry, we made our network bilaterally symmetric. We symmetrized the adjacency matrix by setting the synaptic values for each connection to the maximum among each bilateral pair of neurons (Supplementary Fig. 10B; see Supplementary Fig. 10C to compare results using different methods). Consequently, each paired neuron has bilaterally-symmetric pre- and post-synaptic neighbors as well as an equal number of synapses in both hemispheres. Having prepared our network in this way, we next trained it to reproduce measured antennal and head kinematics in response to virtual optogenetic stimulation of JO-F neurons (Fig. 5B). The mechanosensory JO-C/E neurons also received a fictive sensory feedback: antennal kinematics with a sensorimotor delay of 40 ms60,61. We read out motor neuron activities from five pairs of antennal and four pairs of neck pitch motor neurons in the brain62 but excluded neck roll motor neurons because they have not been identified in the brain connectome. Motor neuron activities were then fed into two separate decoders, encapsulating antennal and neck musculoskeletal systems, which output fictive antennal and head pitch joint angles (Fig. 5B). As in previous connectome-constrained modeling work47, the edges of this network and each neuron’s neurotransmitter identity were fixed as they are in the brain connectome21–23,63. However, neuronal parameters including the membrane time constants, resting potentials, synaptic strengths, and decoder parameters were optimized via backpropagation through time (BPTT)64 to match our training dataset. We performed training across thirty random seeds and confirmed convergence in all cases to small loss values (Supplementary Fig. 10D).

We next analyzed neural dynamics in our trained models. To focus on the stimulus-dependent aspect of unilateral grooming in which the fly is more likely to reach towards the stimulated antenna (Supplementary Fig. 10E–G; and Supplementary Video 12), we presented slightly asymmetric JO-F input (left antenna input slightly exceeding the right) and examined which neurons are driven to purely right or left activation. We devised a metric, the unilateral selectivity index (USI), for each bilateral neuron or cluster pair by measuring the area under the response curves for the left and right hemispheres, and then computing their difference as a fraction of the total area (Fig. 5C). Thus, a USI of one indicates fully right-dominant activity (contralateral to the more stimulated left antenna), while a USI of negative one indicates fully left-dominant activity (ipsilateral to the more stimulated left antenna). Intuitively, a USI of one is analogous to unilateral left grooming in which the right (non-targeted) antenna lifts in response to stimulation of the left (targeted) antenna to avoid collisions with the forelegs (Fig. 1E, left). We applied this metric to key antennal grooming neurons (e.g., aBNs, aDNs, and aMNs) with asymmetric JO-F input (left  > right) and observed consensus across thirty models on the responses of each neuron class (Fig. 5D). Among the five motor neurons, only aMN4 consistently exhibited a contralateral response (Fig. 5E; and Supplementary Fig. 10H for an exemplary model), suggesting that aMN4 may drive upward antennal pitch of the non-targeted antenna during unilateral grooming—a prediction that may be tested once a more detailed functional characterization of antennal motor neurons becomes available.

A computational perturbation screen identifies key neurons for grooming

Having generated a connectome-derived model of the antennal grooming network, we next set out to identify circuit motifs that may underlie body part coordination during unilateral grooming. We focused our analysis on antennal pitch coordination: upward pitch of the contralateral, non-targeted antenna and quiescence of the targeted antenna. We studied antennal movements for several reasons. First, upward pitch of the non-targeted antenna is a hallmark of unilateral grooming that is synchronous with head roll and lateral foreleg movements (Fig. 1E). Second, unlike neck and leg motor neurons, antennal motor neurons are located exclusively in the fully mapped brain. Third, these motor neurons are a compact and tractable system for analysis: only five motor neurons control four muscles in each antenna51, compared with the numerous neurons and muscles controlling the neck62 and forelegs26.

The precise roles of individual antennal motor neurons have not been fully established. Therefore, because in six models aMN4 neurons consistently exhibited contralateral responses to asymmetric JO-F input (models 10, 11, 13, 16, 22, and 23; dark green rectangles in the aMN4 row in Fig. 5D), we used the activities of aMN4 motor neurons in these models as a readout. In combination with neural perturbations, this readout allowed us to identify neurons and circuits that encourage exclusively upward pitch of the non-targeted, contralateral antenna in response to bilaterally asymmetric JO-F input. Indeed, aMN4 activity closely reflected this action selection process; when systematically testing a range of left-right JO-F input current pairs, we found that even slight input asymmetries nevertheless result in fully unilateral aMN4 responses (Fig. 6A). To investigate the neural mechanisms underlying this stimulus dependent response, we focused on three models (11, 16, and 22) with the most biologically relevant characteristics: fully unilateral aMN4 activity during slightly asymmetric JO-F input as well as no aMN4 activity during bilaterally symmetric JO-F input (akin to no antennal pitch during bilateral grooming) (Fig. 6B, C; see Supplementary Fig. 11A, B for the other three models).

Fig. 6. Simulated neural activation predicts key neurons for antennal motor control.

Fig. 6

A aMN4 responses (USI metric) across six models for varying JO-F input current pairs (left, right): (5.0, 0.5), (4.5, 1.0), (4.0, 1.5), (3.5, 2.0), (3.0, 3.0), and mirrored values. USI values of 0 indicate no bias; -1 and 1 represent total left and right bias, respectively. B Representative aMN4 activity traces (left: magenta; right: green) for input pairs marked in C (models 11, 16, 22). Gray shading indicates the JO-F stimulation period. Under asymmetric input, only the contralateral aMN4 responds. Voltage traces are processed via a ReLU function; subthreshold responses are not shown. C Dominance of left (magenta) or right (green) aMN4 activity as a function of JO-F input magnitudes. Contours indicate area-under-the-curve differences in 0.1 increments (solid: positive; dashed: negative). White regions denote no dominance. Circles correspond to current pairs in (B). D Neural perturbations used to assess the contribution of neurons/cluster to driving unilateral coordination: (i) bilaterally symmetric JO-F input during unilateral activation of left-hemisphere neurons/clusters (top) and (ii) slightly asymmetric JO-F input (left  > right) during bilateral silencing of neurons/clusters (bottom). Perturbations were systematically applied to each cluster/neuron in the network. E Effects of unilateral neural activation on aMN4 responses (USI metric). Bilaterally symmetric JO-F input drives equal left and right aMN4 responses in the unperturbed, intact network (far-left column). Neurons whose unilateral activation transform this into contralateral right aMN4 responses are outlined in green; those driving ipsilateral left aMN4 responses are outlined in gray. Each dot represents a model. The median thresholds of 0.1 (contralateral) and -0.1 (ipsilateral) are highlighted (gray horizontal bar). Red and blue labels indicate excitatory and inhibitory neurons/clusters, respectively. F Effects of bilateral neural silencing on aMN4 responses (top) and global network activity (bottom). USI was calculated for responses during slightly asymmetric JO-F input (left  > right). The intact, unperturbed response (far-left column) is fully right-dominant (USI = 1). Global activity quantifies the number of neurons in the perturbed network with activity five times greater than their mean activity in the intact, unperturbed network. Each dot represents a model. E, F Box plots show the median and quartiles. Whiskers extend to the full distribution, excluding outliers beyond 1.5 times the interquartile range (IQR). G The number and type of neurons for each significant cluster shown in panels (H, I). Neuron types are color-coded.

We reasoned that central circuits promoting unilateral pitch might be identified by their ability to drive asymmetric network activity in the presence of equal JO-F sensory input to both antennae. Therefore, in a first neural activation screen, we provided bilaterally symmetric JO-F input and simultaneously activated individual neurons/clusters in the left hemisphere (Fig. 6D, top). In a second, complementary neural silencing screen, we presented asymmetric JO-F input (left  > right) to drive unilateral aMN4 responses. Simultaneously, we systematically silenced bilateral pairs of neurons/clusters to identify those necessary for driving the selection of unilateral antennal pitch (i.e., unilateral aMN4 responses) (Fig. 6D, bottom).

Our computational neural activation screen uncovered eighteen neurons/clusters whose unilateral activation could drive aMN4 activity, during bilaterally symmetric JO-F stimulation. These produced either higher contralateral (Fig. 6E, green outlines: aBN1,2, aDN1, DN52, c4, c5, c35, c62, c39, c40, c42), or ipsilateral (Fig. 6E, gray outlines: WED, c6, c49, c58, 12A-DN33, c23) responses. Notably, when perturbed in the neural silencing screen, not all of these neurons/clusters had an impact (Fig. 6F). This may be due to redundancy in the network or inactivity during JO-F stimulation in the unperturbed network. It is also worth noting that, across all seeds, silencing the inhibitory neurons/clusters WED and c6 also more globally amplified network activity (Supplementary Video 13) (Fig. 6F, bottom).

We observed that, although our primary focus was on antennal motor control, activation screen hits were not exclusively antennal premotor neurons/clusters (see Supplementary Fig. 11C for all aMN4 premotor neurons) and showed similar neural responses to JO-F stimuli across seeds (Supplementary Fig. 11D). We found numerous hits that could be categorized as central, shared premotor, neck premotor, and leg premotor (Fig. 6G). Thus, we hypothesized that hits may contribute to circuits performing motor coordination more broadly. To test this hypothesis, we next investigated the connectivity between these neuron groups.

Coupled circuit motifs enable robust unilateral coordination

Based on our extensive computational screen of neuronal activation (Fig. 6E, F), we grouped activation hits into two categories: whether they tipped the balance toward driving contralateral, or ipsilateral aMN4 activity. Remarkably, this coarse dichotomy yielded several well-connected circuit motifs (Fig. 7A, B).

Fig. 7. Circuit motifs driving unilateral coordination as proposed by the model, and experimental validation of key neurons in the inhibitory motif.

Fig. 7

A Recurrent excitation motif driving contralateral aMN4 activation (green-boxed clusters in Fig. 6E). Excitatory neurons are merged into a single cluster (`EC'). B Interaction between the EC and neurons driving ipsilateral aMN4 activation (gray-boxed clusters in Fig. 6E). In this `broadcast inhibition' motif, inhibitory neuron c23 suppresses its contralateral aMN4. Cluster c64 is dimmed to indicate inactivity in the intact network. A, B Black upward/green downward arrows denote higher/lower activity relative to contralateral counterparts; connections from lower-activity neurons are transparent. Red/blue lines indicate excitatory/inhibitory connections; line thicknesses are proportional to normalized weights (Model 22). C Schematic representation of the mechanism underlying unilateral coordination via aMN4 activation. JO-F neurons activate ipsilateral excitatory clusters, which drive non-targeted (contralateral) aMN4 motor neurons. Simultaneously, inhibitory neurons on the non-targeted side suppress motor neurons and excitatory clusters on the targeted side, preventing upward pitch. Red and blue lines indicate excitation and inhibition, respectively. Less active elements are dimmed. D Responses of c23 > CsChrimson flies (SS35281-splitGAL4  > UAS-CsChrimson; top row; n = 5) and negative control flies (UAS-CsChrimson only; bottom row; n = 4) to optogenetic and air-puff stimulation. Panels show the antenna-foreleg distance (the average distance between the right and left leg tibia-tarsus joints and the antennal scape-pedicel joints) as a proxy for antennal grooming. Each column corresponds to a different stimulation condition: air puff followed by optogenetic stimulation (left), air puff only (middle), and optogenetic stimulation only (right). Antennal grooming was elicited by air-puff delivery, and a decrease in antenna-foreleg distance indicates grooming. Shaded regions denote the duration of the air-puff (light blue) and optogenetic (light red) stimuli. Shown are medians across trials (solid lines), and 20th-80th percentile confidence intervals (shaded regions). Horizontal black bars mark the time windows used to quantify changes in the kinematic variable, with circle markers indicating the pre-stimulation window and diamond markers indicating the post-stimulation window (300 ms). E Quantification of changes in antenna-foreleg distance from panel D. The left column shows the median antenna-foreleg distance measured in the pre- and post-stimulation time windows indicated by the horizontal bars in panel (D). The right column shows the difference between post- and pre-stimulation values (after minus before), representing the stimulation-induced change in distance. Dots represent individual flies; lines connect paired measurements. Significance levels were calculated using two-sided paired t-tests (pre- and post- stimulus transition) and a two-sided Mann-Whitney U test with Bonferroni correction for multiple comparisons (across conditions). Values are indicated as follows: P < 0.05 and not significant (NS): P≥0.05.

The first motif consists of a circuit dominated by recurrent excitation between aBN1, aBN2, aDN1, c4, c5, c35, c39, c40, and c42 (Fig. 7A). The majority of these neurons/clusters are directly downstream of JO-F neurons (Fig. 7A, nodes in blue). Thus, we speculate that this circuit may amplify small biases in JO-F input. As well, models predict that activating any neuron/cluster within this circuit may robustly recruit the majority of the network, drive the activity of premotor neurons c39 and c42, and elicit a fully unilateral response from contralateral aMN4s (Supplementary Fig. 11E) to drive upward pitch of the non-targeted antenna. This group also includes two inhibitory neurons: DN52 and c62 (Fig. 6E). We did not include them in the motif because they are normally inactive during JO-F stimulation (Supplementary Video 14). However, they may be uncovered in the activation screen as encouraging contralateral aMN4 activation because they suppress their contralateral excitatory cluster, c40, which is involved in ipsilateral aMN4 activation. Therefore, rather than directly exciting the contralateral aMN4 and pitching the non-targeted antenna, DN52 and c62 indirectly inhibit the ipsilateral aMN4 and movements of the targeted antenna (Supplementary Fig. 11F).

Next we focused on neurons/clusters in the unilateral activation screen which drove responses in the ipsilateral aMN4. Among the seven neurons/clusters identified, two inhibitory clusters, WED and c6, reduce ipsilateral JO-F activity via presynaptic inhibition (Supplementary Fig. 11G). Their activation creates input asymmetry by suppressing sensory input from ipsilateral JO-F neurons (Supplementary Fig. 11H). However, the remaining five neurons/clusters appear to engage the inhibitory neuron, c23 (‘asteroid’65). c23 inhibits its ipsilateral recurrent excitatory circuit (‘EC’) and c40. The latter cluster acts as a bridge between the two motifs in that it receives strong excitatory input from EC and, in turn, excites the contralateral c23 (Fig. 7B). Additionally, c23 directly inhibits the targeted antenna’s aMN4. Interestingly, c23 neurons across the brain also reciprocally inhibit one another, a competitive inhibition motif commonly associated with decision-making and action selection66–73. Finally, other neurons in this motif include the leg premotor cluster c58, the neck premotor cluster c64—which is normally inactive during JO-F stimulation (Supplementary Video 14)—and the shared premotor cluster 12A-DN33. These neurons receive excitatory input from the contralateral EC and activate their ipsilateral c23 either directly or indirectly (Fig. 7B). Thus, c23-based broadcast inhibition appears to play a central role in circuit dynamics.

Our connectome-derived network neural activation screen uncovered two interconnected motifs that likely mediate predominantly unilateral antennal pitch in response to symmetric or only slightly asymmetric JO-F stimulation: (i) a recurrent excitatory circuit (EC) that encourages and maximizes contralateral aMN4 activity and non-targeted antennal pitch, as well as (ii) EC/c40-based activation of the contralateral broadcast inhibitory c23 which suppress the contralateral EC and movements of the targeted antenna. This interplay between excitatory and inhibitory motifs may combine to more robustly drive network activity into one of two discrete unilateral grooming states (Fig. 7C).

To evaluate the validity of some of these predictions, we focused on neurons whose role in antennal grooming—unlike that of aBNs and aDNs—had not been previously characterized. Among these, we were able to identify a transgenic driver line for c23 neurons (‘asteroid’ from65). Our simulations predicted that c23 neurons (i) unilaterally suppress the excitatory circuit motif (EC) and (ii) inhibit antennal movements. Based on this, we hypothesized that bilateral activation of c23 neurons should suppress antennal grooming as well as antennal elevation.

To test this prediction, we elicited antennal grooming with a 1 s air puff and then optogenetically activated c23 neurons for 3 s while flies continued grooming. We used a quantification of antenna-foreleg distance as a proxy for antennal grooming (Fig. 7D). For flies expressing CsChrimson in c23 neurons, optogenetic neuronal activation produced a sustained increase in antenna-foreleg distance, indicating a suppression of antennal grooming and, in some cases, a transition to other behaviors such as foreleg rubbing (Fig. 7D, E, left column, top row; Supplementary Video 15). By contrast, in the absence of optogenetic stimulation, antennal grooming typically persisted beyond the duration of the air puff (Fig. 7D, E, middle column, top row).

Although both experimental and control flies exhibited a brief transient response at light onset, this effect did not persist beyond the stimulus transition in control animals (homozygous UAS-CsChrimson), which continued grooming their antennae (Fig. 7D, E, left column, bottom row). Consistent with the suppression of grooming in experimental animals, c23 activation induced a sustained downward shift in antennal pitch and a reduction in foreleg height, indicating coordinated modulation of antennal and foreleg motor output (Supplementary Fig. 12). Together, these results support a role for c23 neurons in suppressing antennal grooming, in agreement with the model’s predictions.

In conclusion, our simulations identified two interconnected motifs that may underlie body part coordination during unilateral antennal grooming. Furthermore, we experimentally verified that the broadcast inhibitory neuron, c23, plays a causal role in terminating antennal grooming and antennal lifting upon activation. Notably, c23 and other neurons in this motif have not previously been linked to antennal grooming. More broadly, our results showcase the utility of connectome-constrained models for generating testable predictions about neural function. As more transgenic driver lines targeting other neurons (e.g., EC neurons) become available, it will become possible to directly test their role in antennal motor control by, for example, unilaterally activating these neurons while measuring antennal movements.

Discussion

Here, we have combined behavioral quantification and perturbations, biomechanical simulations, connectome analysis, and artificial neural network simulations derived from the connectome to investigate how the adult fly, Drosophila melanogaster, synchronizes head, antennae, and foreleg movements during antennal grooming. We found that this tripartite coordination does not rely heavily on proprioceptive sensory feedback from individual body parts, but appears to be driven by a centralized network of interneurons and shared premotor neurons. Embedded within this network, we discovered coupled recurrent excitatory and broadcast inhibitory circuit motifs that likely drive unilateral selection to elevate the non-targeted antenna while suppressing similar movements of the targeted/groomed antenna. Furthermore, targeted optogenetic perturbation of the broadcast inhibitory neuron c23 revealed that they specifically suppress antennal grooming and disrupt antennal lifting, consistent with our connectome–based model’s predictions.

Why would it be beneficial for the fly to coordinate head, antennae, and foreleg movements while grooming its antenna? Simulated kinematic replay in a biomechanical model suggests that this synchronization may facilitate unobstructed and more forceful tibial rather than tarsal contact with the antennae. In line with this, we observed antennal depression during bilateral grooming, possibly to increase the stiffness of the scape-pedicel joint and stabilize the antenna. Notably, this movement corresponds to active levation/depression (pitch) at the scape-pedicel joint, which is distinct from the active abduction/adduction (yaw) described during wind- and flight-related antennal movements51,74; both degrees of freedom have been anatomically characterized in higher Calliphora erythrocephala75. In addition, we speculate that brushing one antenna with both forelegs may be more effective in removing debris because it contacts areas that the ipsilateral leg alone cannot reach. It also allows for greater forces to be applied to the antenna. Complex hair-like structures on the tibial segments may also act as a brush to improve debris cleaning and, thus, improve olfactory sensing76,77. Finally, because the neuromuscular system that controls the tibia is more complex than the tarsal control system26,78, a strategy to maximize the contact between the tibia and the antenna may benefit from more precise leg positioning.

A longstanding question in motor control has been the extent to which body part coordination arises from sensory feedback versus feedforward centralized control79,80. In some cases, movements are primarily driven by sensory feedback81,82, while in others centrally generated motor patterns remain intact even without input from leg mechanosensors83,84. We found that Drosophila antennal grooming does not rely on proprioceptive feedback to compensate for alterations in target body part position and maintain coordination, consistent with previous studies of grooming in other insects85,86. Although this coordination does not depend critically on proprioception, proprioceptive feedback likely contributes to the fine control of leg movements during grooming, such as to adjust limb trajectories87. We speculate that the unimportance of proprioceptive feedback during grooming may be acceptable because imperfect coordination does not pose an existential threat. As a result, a simpler centralized control strategy may eliminate the computational and energetic costs associated with continuously processing sensory feedback. Moreover, we found that tibial-antennal contacts remain robust despite slight perturbations of individual head and antennal joint angles (Fig. 2C, F, I, gain values 0.9-1.1). This suggests that grooming can be preserved despite variability and noise in joint kinematics.

Within the open-loop grooming control framework, we observed that motor modules are primarily interconnected by central interneurons, rather than by inputs (i.e., JO sensory neurons) or outputs (i.e., premotor neurons). This configuration may best balance the needs for robust yet flexible coordination. We speculate that if motor modules were all directly targeted by JO sensory inputs they might be able to generate fast and reliable coordinated movements—something that would be desired for an escape response. However, this configuration would impede the independent and flexible control of individual body parts because the control signal stems from a single shared source. Furthermore, any input noise or perturbation would directly propagate to downstream motor networks. Similarly, if motor modules were connected near the output layer we might observe slower but similarly inflexible coordination: the movements of multiple body parts would be inextricably yoked together. Therefore, coupling motor modules at a central layer (i) offers multiple entry points to drive grooming (e.g., JO or bristle stimulation), (ii) allows behaviors to be more readily gated by internal state, and (iii) still enables the independent control of constituent body parts for different purposes (e.g., head pitch for gaze stabilization). We speculate that in this way centralized coordination may simplify the evolution of new behaviors through the coupling or uncoupling of motor modules. This centralized coordination mechanism may be conserved across species in different contexts16.

Previous studies have shown that fruit flies exhibit individual preferences in walking handedness88,89 as well as olfactory90 and phototactic91 decision-making. Recent modeling work has suggested that slight variations in synaptic connectivity might account for these idiosyncratic behaviors92,93. Notably, structural asymmetries exist even among fully reconstructed and proofread neurons in the fly brain connectome21,22. We hypothesize that these asymmetries might explain why we observe some flies consistently initiating unilateral grooming of the same antenna across trials, even during bilaterally symmetric optogenetic stimulation.

To investigate whether structural asymmetries in the connectome could drive grooming preferences in response to bilaterally symmetric JO-F input, we trained the original, non-symmetrized network. Indeed, the original network exhibited a strong and consistent bias toward unilaterally activating key antennal grooming neurons despite bilaterally symmetric JO-F stimulation (Supplementary Fig. 13A, left). For example, among the antennal motor neurons, aMN5 consistently showed rightward selectivity, whereas aMN1, aMN2, and aMN4 exhibited a bias to the left (Supplementary Fig. 13B). This bias disappeared when the network was symmetrized (Supplementary Fig. 13A, right). Although experimental variability could partially be attributed to genetic factors, such as differences in CsChrimson expression levels, our findings support the possibility that asymmetries in brain connectivity may contribute to idiosyncratic behavioral preferences.

Methods

Data acquisition

Fly husbandry and stocks

All experiments were performed on female adult Drosophila melanogaster raised at 25 °C and 50% humidity on a 12 hr light-dark cycle. Two days (36-40h) before optogenetic experiments, we transferred experimental flies to a vial containing food covered with 40μ l of all-trans-retinal (ATR) solution (100 mM ATR in 100% ethanol; Sigma Aldrich R2500, Merck, Germany) and wrapped in aluminum foil to limit light exposure. Experiments were performed on flies 3-5 days post-eclosion (dpe) between Zeitgeber Times (ZT) 4-10. Genotype used and sources are indicated in Table 1.

Table 1.

Fly strains used in this study

Reagent Stock # Reference Source stock
aJO-GAL4-1 39250 118 Bloomington
Asteroid SS35281 65 Gift from Gabriella Sterne
UAS-CsChrimson 55134 - Gift from Brian McCabe
Spaghetti Monster smFP 62147 119 Gift from Brian McCabe

Behavior recording system

Tethered fly behaviors were recorded using a previously described 7-camera (Basler, acA1920-150 μm, Germany) system42 with the exception that rear right and rear left cameras were ignored, which does not capture anterior grooming behaviors. Animals were illuminated with an infrared (850 nm) ring light (CSS, LDR2-74IR2-850-LA, Japan). To track the positions of each leg joint, five cameras were equipped with 94 mm focal length 1.00xInfiniStix lenses (Infinity, 94 mm 1.00x, USA). Cameras recorded data at 100 fps and were synchronized with a hardware trigger. The full field-of-view (FOV) of each cameras is 1920 × 1200 pixels with a pixel size of 4.8 × 4.8 μm. To reduce the size of the captured images and to increase acquisition rate, we set the ROI of each camera to 960 × 480 pixels. Flies were tethered to a wire, but otherwise freely behaving upon an air-supported (0.8 L/min) spherical treadmill. Foam balls were manually fabricated to be 10 mm in diameter (Last-A-Foam FR-7106, General Plastics, Burlington Way, WA USA, density: 96.11 kgm−3).

Confocal imaging

We dissected the brain and VNC from 3-6 dpe female flies as described in ref. 58. Primary and secondary antibodies were applied for 24 hrs and sample was rinsed 2-3 times after each step (for details, see ref. 94). Antibodies and concentrations used for staining are indicated in Table 2. Samples were imaged using a Carl Zeiss LSM 700 Laser Scanning Confocal Microscope. Standard deviation z-projections of imaging volumes were made using Fiji95. We rotated, translated, and modified the brightness and contrast of images to enhance their clarity (Supplementary Fig. 1A).

Table 2.

List of antibodies used for immunofluorescence tissue staining in Supplementary Fig. 1A

Type AB name Dilution Company AB ID
1∘ Anti-Bruchpilot (mouse) nc82 1:20 Dev. Studies Hybridoma Bank AB2314866
1∘ GFP Tag Rabbit 1:500 ThermoFisher G10362
2∘ Goat anti-Mouse Alexa 633 1:500 ThermoFisher A21052
2∘ Goat anti-Rabbit Alexa 488 1:500 ThermoFisher A11008

Tethering for behavioral measurements

For optogenetics experiments, we used a stick-tether method. First, we cooled a copper apparatus housing a fly-sized ‘coffin’ on a cold plate for 10 minutes. This is used to keep the fly anesthetized during tethering. The fly was then gently placed inside this coffin using forceps, and its position was adjusted using a brush. If the thorax was misaligned, the coffin was rotated (using a knob) to reposition the fly upright.

A silver wire, 0.2032 mm in diameter (A-M Systems, Silver 0.008" 25 feet wire), was then glued (UV-curable glue, Bondic, Aurora, ON Canada) to the fly’s scutoscutellar suture and cured with UV light. This wire was connected to a female contact (Distrilec, female contact size 20 7.5 A 14458991) that was then inserted into a corresponding male contact on the experimental setup, securing the fly onto an air-suspended ball or spherical treadmill. Each experiment began at least  ~ 30 minutes after tethering to allow the fly to acclimate to its environment. Experiments were performed at 25 °C and 50% humidity, in the dark.

Optogenetic stimulation

For optogenetic stimulation, we used a 617 nm LED (ThorLabs, M617L3) mounted behind a lens (Thorlabs, LA1951–N–BK7 Plano-Convex Lens) to deliver  ~ 6.0 mW/mm2 intensity light to the fly from the right-anterior side (as shown in Fig. 1A). The entire anterior body of the fly was thus illuminated. For flies used in Fig. 1, Fig. 3, and Fig. 7, we delivered step pulses of 2-3 s duration, with at least 30 s intervals. In Fig. 5, stimulation patterns included both step pulses and flickering of varying periods and frequencies. All experiments were conducted in the dark.

Laser stimulation

We used a 640 nm laser (Coherent OBIS 1185055 640 nm LX 100 mW, Edmund Optics) as an optogenetic excitation light source. We reduced the light intensity using neutral density filters (Thorlabs) and controlled the light intensity with mixed analog and digital control signals from an Arduino with custom software. A digital signal was used to turn the laser on and off. An analog signal (PWM output from Arduino and RC low-pass filtered) was used to modulate the power. Both of these signals were sent in parallel to the laser and acquisition board and were recorded along with two-photon microscope signals using ThorSync 3.2 software (Thorlabs). The light was directed towards the fly using several mirrors. Fine control of the target location was achieved using a kinematic mount (KM100, Thorlabs) and a galvanometric mirror (GVS011/M, Thorlabs). We tethered flies to a custom stage as described in ref.96. This tethering constrains the position of the head, enabling a consistent target locus for laser stimulation. We manually optimized targeting of the laser onto the scape segment before each experiment. The light was focused onto the fly using a plano-convex lens with f = 75.0 mm (LA1608, Thorlabs) placed at the focal distance from the fly. The optogenetic light intensity was 2.3 uW for aJO and 10.5 uW for negative control (PR) experiments in Supplementary Fig. 10E–G.

Air puff stimulation

To elicit antennal grooming, humidified, non-odorized air was delivered at the fly’s antennae, deflecting them towards the head. Mass flow controllers (MFCs, Bronkhorst High-Tech B.V., Netherlands) supplied regulated air flow at 70 mL/min. Airflow was diverted using six solenoid valves (SMC, S070C-6AG-32, Japan) controlled by an Arduino UNO (Arduino, Italy). This air was delivered to the fly’s antennae by way of a glass capillary held by a probe holder (MXB, Siskiyou Corporation, USA) linked to a post (ThorLabs, MS3R) and positioned facing the fly’s head. To better target air puffs, the glass capillary was pulled to thin its edge (P-1000, Sutter Instrument, USA; parameters: Pull: 0; Velocity: 10; Heat: 502; Pressure: 500).

To compare air puff- and optogenetically-induced antennal grooming, we stimulated the same individual flies in alternation using a custom Arduino script to switch between the two stimulus sources.

Morphological perturbation experiments

To investigate the role of sensory feedback in body part coordination, we first recorded optogenetically-elicited antennal grooming in intact flies over 5 trials (each with 2 stimulation periods and  ~ 40 s intervals). We then used cold anesthesia to surgically remove sensory feedback via leg amputation, antennal amputation, head fixation, or multiple combinations of two of these perturbations.

To amputate the legs, flies were first cold anesthetized. We then extended a foreleg using forceps and amputated it near the thorax-coxa joint with clipper scissors (FST, Clipper Neuro Scissors, no. 15300-00, Fine Science Tools GmbH). This, rather than pulling, ensured that the VNC would not be damaged. To prevent desiccation and movement of the remaining leg piece, we sealed the stump with UV-curable glue. To amputate the antennae, we used two precision forceps to gently remove the pedicel and funiculus by pulling the antenna away from the head. To fix the head at its resting position, we applied a small drop of UV curable glue between the dorsal head and anterior thorax, avoiding head bristle deflection. After each surgery, we ensured that the flies could still actively move their other body parts; those that could not were discarded. Experimental flies were then placed on a spherical treadmill for 5 trials after a 20-minute acclimation period. For two-body part perturbation experiments, we repeated the same procedure and conducted an additional 5 trials to ensure comparisons were made using the same flies across conditions.

Data processing

2D & 3D pose estimation

To quantify foreleg and head kinematics during antennal grooming, we used DeepLabCut49 and Anipose43. We annotated 10, 11, and 9 key points on the forelegs, head, and thorax, respectively. The first two sets of key points were used to calculate joint angles, while the thorax key points were used to help align the fly’s 3D pose within a common coordinate system. Three neural networks were trained for distinct sets of cameras: the front camera (camera 3), the front-right and front-left cameras (cameras 2 and 4), and the side-right and side-left cameras (cameras 1 and 5), as shown in Fig. 1A. We used DeepLabCut v2.2.1 to annotate camera images and train ResNet50 models. Each network was trained on  ~ 650 manually annotated frames for 500,000 epochs with batch size of 8, using a 95–5% train/test ratio. The dataset included primarily anterior grooming behaviors, including those with variations in head and foreleg configurations across different conditions such as leg or antennal amputation. Several iterations of training were conducted to correct outlier frames, culminating in a final comprehensive training phase where all annotated frames were merged and networks were retrained from scratch.

For 3D pose reconstruction, we used Anipose v0.9.0 and calibrated five cameras with a ChArUco board. The pattern was designed using OpenCV v4.5.5 with the board marker dictionary number 250 (aruco.DICT_4 × 4_250) and 4-bit markers97. The board contains 7 × 6 squares, with each marker measuring 0.225 mm and each square 0.300 mm. The pattern size is 2.1 × 1.8 mm, and the board size is 2.4 × 2.1 mm ( ± 0.1 mm). The board, printed on Opal with Blue chrome etching by Applied Image (Rochester, NY), features an etching dye that minimizes light reflection from the infrared (IR) ring-light, reducing interference with the cameras. We attached the board to a pin, allowing smooth movement while maintaining stability when inserted into the fly holder. The calibration video was captured at 40 FPS with full FOV (1920 × 1200 pixels) for 2 min, ensuring that the board remained visible and in focus in at least two cameras simultaneously. We used Anipose for marker detection and manually verified the accuracy frame-by-frame. The video acquisition and calibration process were repeated until the intrinsic and extrinsic camera matrices aligned with expected values. For instance, we verified that the camera locations from the calibration process matched those in our behavioral recording setup for the extrinsic values.

We performed 3D pose reconstruction on filtered 2D pose tracking data using the Viterbi filter provided in Anipose. We chose this filter for its simplicity and effectiveness43. The filter window length was set to 25 frames (250 ms), which preserved rapid behavioral movements while mitigating most outliers. Since camera calibration is a one-time process, the quality of pose reconstruction can degrade due to environmental factors such as changes in lighting or slight shifts in cameras’ positions. To improve the robustness of our reconstructions, we enabled animal calibration and extended the number of iterations while tightening the tolerance in the bundle adjustment algorithm, which increased the processing time (these adjustments are available in the repository: https://github.com/gizemozd/anipose/tree/master). We disabled Ransac triangulation and activated spatiotemporal regularization.

The yand z axes of the 3D coordinate system were aligned with the vector from the right to left dorsal humeral, and from the left ventral to dorsal humeral bristles, respectively. The x axis was defined as the cross product of the y and z axes. The thorax “mid-point” was designated as the origin of the coordinate system, as these key points were minimally occluded in the recordings, providing sufficient stability. For more details, refer to the code, which includes all configuration files and a page explaining parameter choices (https://github.com/NeLy-EPFL/kinematics3d).

3D pose alignment & inverse kinematics

To calculate joint angles, we first align the experimentally acquired 3D poses to a template biomechanical fly model (NeuroMechFly v245), using a process also called scaling98,99. This alignment is performed in two stages. First, we calculate the distances between key body landmarks to derive scaling factors that adjust the experimental 3D data to match the body segment proportions of the biomechanical model. These landmarks include the Thorax-Coxa and Claw (or Tibia-Tarsus joint) for each foreleg, base and tip of each antenna, and mid-wing hinge to mid-antennae for the head (when the fly is stationary). This process yields five scaling factors—two for the forelegs, two for the antennae, and one for the head. We then multiply each scaling factor with the corresponding limb, allowing us to match the task space of the real animal with that of the biomechanical model. In the second stage, we translate the positions of “fixed” joints (e.g., Thorax-Coxa, Base Antenna joints) to their respective locations on the biomechanical model. This two-step process aims to (i) reduce noise from jittery fixed key points and (ii) minimize leg size variations caused by triangulation or false positives in pose tracking.

Conventional optimization-based inverse kinematics methods aim to match the end effector position closely but often disregard the positions of preceding joints, leading to unrealistic movements of kinematic chains. To track each joint position closely, we developed a sequential inverse kinematics method, constrained by the fly’s exoskeleton50, also known as “body movement optimization”100,101. Our approach begins with the proximal-most leg segment to calculate the degrees of freedom (DOF) angles for the next joint. It then sequentially extends the kinematic chain by adding one segment at a time, repeating this process until it reaches the chain’s tip. This method is performed in four steps as follows:

  • Stage 1: The kinematic chain includes only the coxa, used to calculate Thorax-Coxa yaw (rotation around the anteroposterior axis) and pitch (rotation around the mediolateral axis) by following the coxa tip as the end-effector.

  • Stage 2: The chain extends to the coxa and the trochanter + femur (fused), calculating Thorax-Coxa roll (rotation around the dorsoventral axis) and Coxa-Trochanter pitch, using the femur tip as the end-effector.

  • Stage 3: The chain includes the coxa, trochanter + femur, and tibia, used to calculate Coxa-Trochanter roll and Femur-Tibia pitch by following the tibia tip as the end-effector.

  • Stage 4: The full leg is included to calculate Tibia-Tarsus pitch, using the claw as the end-effector.

Our pipeline builds on the open-source inverse kinematics library IKPy102, which uses SciPy’s least squares optimizer103 to minimize the Euler distance between the original end-effector pose and the forward kinematics derived from the calculated joint angles.

To facilitate comparison with physiological studies, we map leg kinematic DoFs to anatomical movements as follows: pitch at the thoraco-coxal (ThC) joint corresponds to leg promotion and remotion; yaw at the ThC joint corresponds to leg abduction and adduction; and roll at the ThC joint corresponds to long-axis rotation of the leg. Pitch at the coxa-trochanter (CTr) joint corresponds to levation and depression, while roll at the CTr joint contributes to femoral rotation and out-of-plane positioning of the leg. Finally, pitch at the femur-tibia (TiTa) joint corresponds to tibial flexion and extension.

Since the head has two moving parts (left and right antennae) parented by the main neck joint, the kinematic chain method can introduce errors by favoring one antenna over the other. To avoid this, we calculated neck and antennal joint angles using the cosine angle formula between two vectors. The vectors for the head joint angles are defined as follows:

  • Head roll: The angle between the vector from the right antenna base to the left antenna base, and the global mediolateral axis in the transverse plane.

  • Head pitch: The angle between the vector from the neck to the mid-antennae base and the global anteroposterior axis in the sagittal plane. We subtracted the resting head pitch angle from the calculated joint angles to obtain joint angles relative to the resting position.

  • Head yaw: The angle between the vector from the right antenna base (i.e., the scape-pedicel joint) to the left antenna base, and the global anteroposterior axis in the dorsal plane.

  • Antennal pitch: The angle between the vector from the neck to the antenna base and the vector from the antenna base to the antenna tip (i.e., the tip of the funiculus) in the sagittal plane.

  • Antennal yaw: The angle between the vector from the right antenna base to the left antenna base and the vector from the antenna base to the antenna tip in the transverse plane.

Note that, when head rotation reaches 90°, the antennal pitch and yaw calculations switch roles, leading to inaccuracies. To avoid this, we first calculate the head joint angles, then derotate the head key points by the head rotation to compute the antennal joint angles.

Performance-wise, the entire pipeline takes 36 s to run inverse kinematics for six legs on 100 frames, using a MacBook Pro with a 2.3 GHz Quad-Core Intel Core i7, when parallelized.

Our method is publicly accessible at50: https://nely-epfl.github.io/sequential-inverse-kinematics.

Classification of behaviors

To investigate the kinematics of different antennal grooming subtypes, we labeled the recordings based on behavior. Seven distinct labels were used to annotate the videos. Five of these groups represent some variations of antennal grooming, while the remaining two correspond to other behaviors unrelated to antennal grooming. Each antennal grooming subtype is characterized by a specific coordination between the movements of the forelegs, head, and antennae. Using DeepEthogram v0.1.4 GUI104, we labeled each video frame for 33 trials across 10 flies (see Supplementary Video 3). The subtypes can be summarized as follows:

  • Bilateral grooming:
    • Both antennae are cleaned simultaneously.
    • The forelegs move synchronously, typically at the same height.
    • Frequent observation of head pitch, with occasional slight head roll ( ~ 10°).
  • Unilateral antennal grooming (right or left):
    • Grooming is focused on a single antenna.
    • The head rotates towards the groomed antenna, lowering it.
    • The non-groomed antenna actively lifts up.
    • The forelegs target the groomed antenna, shifting their position to one side.
    • The head is slightly pitched downward.
  • Unilateral non-tripartite antennal grooming (right or left):
    • A single antenna is groomed, but not all conditions described in unilateral antennal grooming are met.
    • A single leg is raised to touch one antenna.
  • Non-classified grooming:
    • The forelegs are not in contact with the head but hover in front of the fly, typically at the level of the maxillary palps.
    • Involves other forms of anterior grooming, such as head grooming.
  • Background:
    • Behaviors outside of the anterior grooming such as foreleg rubbing, resting, or locomotion.

Data analysis

Transitions between behaviors

We computed the transition frequencies between grooming subtypes. Each time point was assigned a behavior label, and we counted the number of transitions from one label to another during each trial, ignoring transitions with the same label.

For visualization purposes, we used the NetworkX105 library to create a directed graph, where each node represents a behavior, and the edges indicate the transition frequencies between behaviors. To represent these transitions as a probability matrix, we converted the graph into a matrix using NetworkX and normalized each row by the sum of its values, ensuring that the transition probabilities from one behavior to all others sums to one.

Dimensionality reduction using PCA

To reduce the dimensionality of optogenetically-induced antennal grooming kinematics data, we performed Principal Component Analysis (PCA). We first identified kinematic variables showing the most significant changes during antennal grooming. These included joint space variables such as antennal pitch, head pitch and roll, thorax-coxa pitch and roll, coxa-trochanter pitch and roll, as well as the 3D positions of the antennal base and tip, and the foreleg Tibia-Tarsus joints in the transverse plane. In total, we had 28 time series inputs for dimensionality reduction (12 joint angles and 16 joint positions in 3D). Each kinematic variable was standardized to have zero mean and unit variance. We then partitioned the dataset (size Ntimesteps, 28) into 10-time-step chunks (Nchunks, 10, 28) using a sliding window of 8. As the sampling rate of the data is 100 fps, this amounts to the data partitions of 100 ms with a 20 ms of overlap. To ensure that each chunk contained continuous time series data, rather than transitions between trials, this process was performed on a trial-by-trial basis.

Note that each chunk is assumed to represent one behavior; however, a chunk might be populated by several behavioral labels. To ensure data chunks predominantly reflected a single behavior, we excluded chunks with fewer than 60% of the labels corresponded to a specific behavior. That is, we removed chunks with fewer than six labels for a given behavior. Additionally, chunks labeled as ‘background’ were excluded, as this category includes a diverse set of behaviors unrelated to antennal grooming. After this filtering, we retained 2,537 chunks as data points. Next, we reshaped our kinematic matrix (Nchunks, 10, 28) into a 2D array (Nchunks, 280) for PCA. Five principal components captured more than 60% of the variance in our data. For visualization, we plotted the first two columns of the weight matrix as it captured 40% of the variance (Supplementary Fig. 1J). Each point, representing a chunk, was colored according to the most frequent behavioral label within that chunk.

Analysis of perturbation experiments

For each perturbation type, we first divided the kinematics during optogenetic stimulation into chunks of 300 ms with 50 ms overlaps for each fly after denoising single kinematic traces with a Savitzky-Golay filter (window size: 9, degree: 3). For each chunk, we checked if a given epoch of kinematics is free from outliers (Table 3, outlier check) and if any of the body parts was moving (Table 3, behavior check). If these conditions were not met, we discarded the chunk. Valid chunks were labeled based on the movements of freely moving body parts (Table 3, right label condition). For head-fixed flies, we labeled chunks based on antennal movements, using the difference between left and right antennal pitch angles. If this difference exceeded a set threshold, we annotated the chunk according to the lifted antenna. The annotated data was then used to plot the distribution of Tibia-Tarsus joint positions in the mediolateral plane (Fig. 3E). Similarly, we used antennal pitch angles to annotate leg amputation experiments, but we plotted the head rotation angles this time (Fig. 3G). For antennae amputation, we designated the labels based on the head rotation: chunks were annotated if the median head roll angle fell within a certain range; otherwise, they were labeled as either right or left based on the direction of rotation. As with head-fixed experiments, we then plotted the Tibia-Tarsus joint position distribution (Fig. 3I). The thresholds used for each kinematic variable are listed in (Table 3).

Table 3.

Thresholds used for annotating behavioral chunks in Fig. 3

Experiment Outlier check Behavior check Right label condition
Head-fixed ant_p < 0∘ med(ant_pR,L) > 22∘ med(ant_pL − ant_pR) > 6∘
∣∣titaR,LY∣∣>2 mm
Leg amp. ant_p < 0∘ med(ant_pR,L) > 22∘ med(ant_pL − ant_pR) > 6∘
Ant. amp. ∣∣titaR,LY∣∣>2 mm med(head_p) > 8∘ med(head_r) > 5∘
Head-fix&Leg amp. ant_p < 0∘ med(ant_pR,L) > 22∘ med(ant_pL − ant_pR) > 6∘
Head-fix&Ant. amp. titaR,LY>2 mm med(titaRZ,titaLZ)>0.8 mm mean(titaRY,titaLY)>0 mm
Leg amp.&Ant. amp. ∣∣head_r∣∣ > 90∘ med(head_p) > 8∘ med(head_r) > 2∘

Variables shown: ant_p antennal pitch, head_r head roll, head_p head pitch, tita tibia-tarsus joint position. Only conditions for labeling a chunk ‘right’ are shown: labeling the ‘left’ is simply the opposite.

For phenotype analysis (Fig. 3E-I, bottom left), we calculated the median value for each biological replicate (i.e., each fly) for both phenotypes (left and right) and visualized them using scatter plots. To compare intact and experimental flies, we examined the difference between these left and right label values, using the median across all trials for each fly to measure the variation in joint configurations (Fig. 3E–I, bottom right). This approach allowed us to assess the range of movement for a given degree-of-freedom between the left and right behavioral conditions.

From two-body part perturbations, we compared the movement range of the remaining body part to that in intact flies. For head-fixed and foreleg-amputated flies, we first checked for outliers and antennal pitch movement. If a chunk was valid and one antenna was pitching, we proceeded with the chunk corresponding to the upward-pitched antenna. We repeated the same procedure for the head roll in antennae- and leg-amputated flies, and for the lateral position of forelegs in antennae-amputee and head-fixed flies. Each valid chunk was labeled based on the direction of the freely moving body part (i.e., right or left). The distribution was then plotted using all valid chunk data (Fig. 3K-O, left).

To compare flies across different conditions, we calculated the difference between the 90th and 10th percentile values of antennal pitch as a proxy for the movement’s maximum and minimum range (Fig. 3K right). For the head roll and Tibia-Tarsus joint positions, we took the median of all left-labeled chunks from each fly and subtracted it from the median of the right-labeled chunks (Fig. 3M, O right). We kept the fly identities across conditions, indicated by a line between each dot in the scatter plots (Fig. 3E, G, I, K, M, O).

Analysis of optogenetic stimulation of c23 neurons

We used the antenna-foreleg distance as a proxy for antennal grooming. This distance was computed as the 3D Euclidean distance between the antennal base (scape-pedicel joint) and the ipsilateral tibia-tarsus joint. Because forelegs are synchronized and expected to be close to both antennae during antennal grooming we then averaged the right and left antenna-foreleg distances. To account for variability arising from pose tracking errors or morphological differences across animals, we normalized the distance by subtracting and dividing by the resting pose distance, defined as the mean distance during the first 500 ms before any stimulus onset.

Next, we excluded trials in which (i) the fly did not initiate grooming following airpuff delivery, or (ii) the fly stopped grooming before the end of airpuff stimulation and thus before the onset of optogenetic stimulation. The first criterion was defined as a decrease of less than 10% in distance within the first 450 ms after airpuff onset, and the second as the distance rising below 50% of baseline during the late stimulus period (500 ms). For airpuff-only experiments, we excluded trials in which the fly did not initiate grooming upon airpuff delivery. For optogenetics-only experiments, we excluded trials in which the fly was already grooming at the onset of the optogenetic stimulus.

Kinematic replay and antennal contact detection

To infer limb-antennal contacts, we performed kinematic replay using the updated fly biomechanical model from45 in the physics engine MuJoCo v2.3.7106 and integrated in the FARMS framework46.

Simulating antennal grooming in a physics engine poses several challenges. First, because there are numerous contact points between the antennae and foreleg meshes, extensive collision detections are required at every time step. Second, we used mesh-based collision bodies, including complex geometries, further increasing the computational load.

To address these issues and to ensure smooth kinematic replay, we implemented several optimizations. First, we reduced the time step to 10−4 s and limited the simulations to short snippets (around 5 s) to increase the stability of integrators and to avoid error accumulation throughout the simulation. We also fine-tuned the physics engine parameters, using the ‘Projected Gauss–Seidel’ solver with an Euler integrator. We increased the number of solver iterations to 107 and lowered the residual threshold to 10−10 to improve stability. Additionally, to speed up the simulation, we restricted collision detection to only between the forelegs and head segments.

In total, we actively controlled 16 degrees of freedom: 7 for each foreleg, as described in44, and 2 for head roll and pitch. We set the antennal joints as passive (following spring-damper dynamics). We maintained a fixed resting pose because replaying measured antennal joint angles introduced confounding factors due to collisions occurring during these measurements. To better emulate the kinematics of unilateral grooming, we adjusted the antennal joint angles (e.g., pedicel and funiculus pitch) to different values, placing the non-groomed antenna in an upward pitch position. We empirically tuned the joint damping and stiffness parameters to qualitatively mimic passive antennal movements after contact. All passive antennal joint angles are provided in Table 4.

Table 4.

Resting positions of passive joint angles given in degrees

Head yaw Pedicel roll, pitch, yaw Funiculus roll, pitch, yaw Arista roll, pitch, yaw
Behavior - Right Left Right Left Right Left
UniL 0 0, -60, -35 0, -40, 35 10, -25, 0 -10, -10, 0 0, 0, 35 0, 0, -35
UniR 0 0, -40, 35 0, -60, -35 10, -10, 0 -10, -25, 0 0, 0, 35 0, 0, -35
BiLat 0 0, -40, 35 0, -40, 35 -10, -10, 0 -10, -10, 0 0, 0, 35 0, 0, -35

To visualize collisions between the antennae and leg segments (Fig. 1H and Fig. 2B,E,H), we binarized the contact force read-outs, converting any non-zero forces between a collision pair to 1, representing “contact on” time points. For articulated parts—pedicel, funiculus, arista for antenna, and tarsi 1-5 for the tarsus—we combined the binarized contact arrays into a composite contact array by taking their union. The resulting binary contact arrays between each antenna and leg segment pair over time were displayed as collision diagrams.

To quantify contact duration (Fig. 2C,F,I), we summed each contact array over time for a given collision pair, representing the total contact duration for that trial. We performed kinematic replay at different gains and normalized the data to a 0-1 range based on the maximum and minimum values observed. This normalization allowed us to identify the gain at which maximum contact occurred for each trial. We modulated degree of freedom kinematics by multiplying the original joint angles with a constant factor (attenuating  ∈ [0, 1) or amplifying  ∈ (1, 1.3]) while keeping the kinematics of other degrees of freedom unchanged. Due to noise and outliers in the 2D and 3D pose estimation, and variations in animal morphology, the mapped kinematics might not always yield an accurate kinematic replay of the behavior. To mitigate this effect, we ignored simulations where the detected contacts lasted less than 10 ms, amounting to, on average,  ~ 2% of a simulation trial.

To quantify contact forces (Supplementary Fig. 4E), we calculated the median of all non-zero contact force values for each replay experiment. Specifically, we measured contact forces between the tibia and its ipsilateral antenna and between the tarsus and its ipsilateral antenna. Each data point in the distribution represents the median contact force for a single trial. This process was repeated across multiple animals/trials and gain values.

Connectome analysis

Loading connectomics data

As for brain connectivity analysis, we used the female adult fly brain (FAFB21,22) connectomics dataset from Codex (FlyWire materialization snapshot 783; https://codex.flywire.ai/api/download) to generate figures Fig. 4, Supplementary Fig. 7B–F and Supplementary Fig. 8. The FlyWire snapshot used in this study relied on synapse predictions from107 as it was performed prior to improved JON synapse predictions in108. Nevertheless, although we observed a larger total number of synapses, we found no qualitative change in the identities of neurons postsynaptic to JONs using the newer dataset. We also used the male adult nerve cord (MANC, version 1.2.127,109) dataset using NeuPrint Python API to generate figures Supplementary Fig. 7G–H.

Constructing the antennal grooming network

We constructed a comprehensive antennal grooming network in two stages, starting with a smaller foundational network and then expanding it by exploring its neighboring connections.

To build the foundational network, we first identified key antennal grooming-related neurons in the brain connectome, including JO-C/E/F, antennal bristles, aBN1-3, and aDN1-333,36. JO-C/E/F and antennal bristle mechanosensory neurons were selected because they are known to trigger antennal grooming35,36. We also included antennal and neck motor neurons in this foundational network, as they act as the output layer of this system.

We used FlyWire Community labels21,22,52 to identify neck motor neurons, but similar labels were not available for antennal motor neurons. To address this, we examined motor neurons passing through the antennal nerve, focusing on their branching patterns. Among the seven pairs of motor neurons we found, two primarily received inputs from visual neurons and were likely retinal motor neurons110. Therefore, to narrow down the search space of network, we excluded those two motor neurons. Among the remaining five, several motor neurons received inputs from JO and aBN neurons, suggesting a role in antennal motor control.

Having established the foundational network, we next expanded it by mapping out all monosynaptically connected neurons using the connectivity diagram from the FAFB connectome (Supplementary Fig. 7A). In particular, for each of these monosynaptically connected neurons, we calculated the percentage of synapses incoming from and outgoing to foundational network neurons. Neurons with connectivity percentages below a predefined threshold were pruned from the network. Depending on the neuron type (e.g., descending neurons sometimes lacking axon terminals in the brain and sensory neurons lacking dendrites), we applied specific rules based on “super_class” annotations in FAFB to guide the pruning process, described below:

  • Sensory neurons: outgoing synapse percentage  > threshold

  • Interneurons: incoming syn. perc.  > threshold and outgoing syn. perc.  > threshold

  • Descending neurons: incoming synapse percentage  > threshold

We excluded ascending neurons and other sensory neurons from our network, as their role in antennal grooming is not yet well characterized. To ensure that we capture only neurons with significant information exchange, we applied a threshold of 5%, accounting for only those neurons that contribute to at least 5% of the input/output interactions within our predefined network. This threshold is ten times lower than the threshold after which the algorithm does not find any new neurons (Supplementary Fig. 7B), suggesting that 5% is sufficiently high to discover new neurons. Furthermore, this choice of threshold is consistent with recent findings indicating that connections providing more than 1.1% of target neuron’s inputs are 90% more likely to be preserved across brains22. This process introduced ~240 new neurons to the network (Supplementary Fig. 7C). Because all leg motor neurons are located downstream of the brain within the VNC, descending neurons with more than 10 synapses upon foreleg-controlling (T1) leg motor neurons were defined as ‘leg premotor neurons’. These were limited to descending neurons that have been matched across brain21–23 and VNC27,109 connectome datasets111. We did not include foreleg motor neurons as a separate group, because they are part of the VNC dataset. Neurons that did not fit into any predefined categories were left unassigned.

Most of these neurons had contralateral counterparts, but due to differences in synapses between the left and right hemispheres, our network construction algorithm was not always able to find these pairs automatically. Therefore, to identify missing contralateral pairs, we used two approaches. First, we calculated dissimilarity scores between a neuron and all of its contralateral candidates. The dissimilarity score Dij between neuron i and neuron j is given by

Dij=degree_scoreij+eigenvector_scoreij+(1−neighbors_scoreij) 1

where

degree_scoreij=∣diin−djin∣0.5*(diin+djin)+10−6+∣diout−djout∣0.5*(diout+djout)+10−6 2
neighbors_scoreij=∣Ni∩Nj∣∣Ni∪Nj∣+10−6 3
eigenvector_scoreij=∣υi−υj∣ 4

where din, dout in- and out-degrees, υ eigenvector scores, and N sets of neighbors of nodes. We obtained degree and eigenvector scores using the built-in NetworkX105 functions degree_centrality and eigenvector_centrality. Note that, for identical neurons, the dissimilarity metric becomes zero. We verified that dissimilarity scores for the same cell types were lower than those for different cell types. We used this approach to match sensory neurons. Specifically, we first divided sensory neurons into high-level classes, that is, JO-C/E/F and antennal bristles based on the FlyWire neuron classification (cell type attribute). Within each class, we then computed dissimilarity scores for each neuron pair, resulting in a global list of Nneuron2 entries storing dissimilarity scores. We then assigned neurons by sequentially pairing those with the highest dissimilarity scores.

The remaining neurons were matched through a combination of community label matching, anatomical and biological comparisons (e.g., hemilineage), and the similarity of their neighbors. In cases where FlyWire had already identified a “mirror twin” neuron, we adopted its match. For neuron populations where individuals were indistinguishable, we assigned pairs randomly.

Connectivity analysis

For our antennal grooming network, we identified pre- and post-synaptic neurons, along with all the connections between them, including neurotransmitter types. We used the publicly available FlyWire brain connectome dataset to conduct these analyses. For each synaptic connection, we assigned the neurotransmitter with the highest prediction probability. To maintain consistency, we assigned the most commonly predicted neurotransmitter to each neuron and applied it uniformly to all of its connections. This rule, however, did not apply to neurons lacking axon terminals in the brain. To analyze connectivity in the VNC, we used the neuprint.fetch_adjacencies function to retrieve synaptic adjacency data.

Assigning neurons to groups

To investigate the coordination between antennal, foreleg, and neck motor neurons, we analyzed common connectivity motifs within our network. To simplify this task, we categorized the network into eight main groups: sensory neurons (JO-F), central neurons, antennal premotor neurons, neck premotor neurons, foreleg premotor neurons, shared premotor neurons, antennal motor neurons, and neck motor neurons. Since leg motor neurons are part of the VNC dataset and there is no one-to-one mapping between descending or ascending neurons in the brain and those in the VNC, we excluded them from our analysis. Neurons that did not fit into these categories were classified as “other.”

Motor neurons and JO-F sensory neurons were already annotated in the brain connectome. We defined premotor neurons as those having more than 5% of their total output directed toward motor neurons that control the same appendage. For example, an antennal premotor neuron projected more than 5% of its output to antennal motor neurons, but may have had less than 5% output to other types of motor neurons. Shared premotor neurons were those with more than 5% of their output projecting onto more than one type of motor neuron.

Because leg motor neurons are not in the brain, we also examined descending neurons (DNs) projections in the VNC to identify those with direct connections with T1 leg motor neurons (annotated as MNfl in MANC27,78). Since a completely proof-read “full CNS” connectome is not yet available, we relied on a recent study111 that bridged brain descending neurons with their VNC counterparts through light-level descriptions of their full morphology. Among the 188 DNs in our network, 75 were matched with their VNC extensions. However, a bijection could not be achieved for some DN populations because it was challenging to distinguish individual neurons whose axons travel together in bundles. Therefore, if any neuron in a population projected onto a leg motor neuron, we classified the entire population as ‘leg premotor’. We set a threshold of 10 synapses in the VNC to qualify as a premotor neuron. We employed the same approach for VNC neck motor neurons (annotated as MNnm in MANC27,78). Since the DNs presynaptic to VNC neck motor neurons belonged to the same DN population presynaptic to leg premotor neurons, we excluded neck premotor neurons in the VNC to avoid overestimating the number of shared premotor neurons.

After defining the premotor neuron classes, we proceeded to identify central neurons. Central neurons were defined as those located between the input (JO-F neurons) and output layers (premotor and motor neurons) of the network. To identify these neurons, we used the networkx.all_simple_paths105 function to generate all simple paths between source (JO-F) and target (premotor and motor neurons) neurons, with a maximum of four hops. We set the limit to four layers, as this has been shown to be sufficient to reach a majority of neurons in the fly nervous system53,78,112. To further refine the network and eliminate neurons with minimal synaptic contribution, we computed the average synaptic percentage, defined as the number of synapses between a pre- and post-synaptic neuron divided by the total synapses the presynaptic neuron makes. We discarded paths with an average synaptic percentage below 5%.

To create randomized networks (Supplementary Fig. 9A, B), we reassigned existing connections, along with their synaptic counts, to random pairs of presynaptic neurons (excluding motor neurons) and postsynaptic neurons (all neurons). The identities of JO-F sensory neurons, motor neurons, and leg premotor neurons were preserved. Using these predefined modules, we constructed other neuron groups (e.g., premotor and central) following the same procedure.

Graph visualizations

We used the NetworkX package105 to visualize network connectivity in Fig. 4B, C, J; Fig. 7A, B; Supplementary Fig. 8 and Supplementary Fig. 11C, F, G. From the connectivity table, we generated a directed graph where the source node represented the pre-synaptic neuron and the target node represented the post-synaptic neuron. The edge widths were proportional to synaptic counts. We used dark blue, light blue, and dark red to denote GABA, glutamate, and acetylcholine neurotransmitters, respectively, and gray for the remaining neurotransmitters (e.g., dopamine and serotonin). For graph visualizations in Fig. 4J, Fig. 7A,B and Supplementary Fig. 11F,G we exported NetworkX graphs in .gephx format and imported them into Gephi v0.10.1 to modify node locations and graph esthetics.

Connectome-constrained neural network modeling

Preparing the training dataset

The training dataset consisted of head kinematics (i.e., antennal pitch and head pitch joint angles) from leg-amputated flies. We optogenetically elicited antennal grooming following a recovery and habituation period of ~20 min. Data was collected from 10 flies; around 22 trials were conducted per fly. Each trial involved two types of stimuli: step inputs of varying duration (0.5, 1, 2, 3 s) and pulsatile inputs of varying frequencies (5, 10, 20 Hz) delivered over a 2 s period.

Measured antennal and head pitch angles were then used as an output dataset, and optogenetic stimulation patterns served as an input dataset. Stimulation values were coded 0 for off periods and 1 for on periods. Joint angles were scaled with 99th percentile corresponding to 1 and 1st percentile corresponding to 0. This effectively mapped the joint angle range to a 0-1 scale. Baseline subtraction was performed to ensure that the resting pose corresponds to 0. Since the model was simulated at a 1 ms resolution, we interpolated the data captured at 100 FPS to match this sampling rate.

To create fictive sensory feedback, we only used antennal pitch angles. Neck proprioceptive neurons are not yet fully characterized. By contrast, the antennal JO is well-studied and contains distinct populations of mechanosensory neurons (i.e., JO-C and JO-E), which are tuned to upward and downward movements of the antenna, respectively33,113. From antennal joint angle traces, we first standardized the antennal joint angles such that the resting position of the antenna would correspond to zero. We then identified movements above and below the baseline, corresponding to upward and downward antennal movements. Since these signals would be provided as inputs to their corresponding sensory neurons, we converted negative values to positive. Additionally, we introduced a 40 ms time delay to emulate the sensorimotor delay between the creation of motor commands and their reception by mechanosensory neurons.

Each input-output pair represented a single stimulation period and had a fixed length of 3.8 s, allowing us to run the network with no input for a certain duration (with the longest stimulus being 3 s). To ensure that the loss was calculated only during optogenetic stimulation, we constructed a “mask” to indicate the start and end of stimulation, and only calculating the loss (and hence the gradient) during the stimulus periods. In total, we obtained 412 trials, resulting in an input dataset of (Ntrials = 412, Ntime = 3800, Nneurons = 852) and an output dataset of (Ntrials = 412, Ntime = 3800, Njoints = 3). A sample is shown in Supplementary Fig. 10A.

Adjacency matrix preparation

While constructing our antennal grooming network, we ensured that each neuron had a contralateral pair. However, we observed differences in synaptic connectivity between the left and right hemispheres, likely due to biological variability and imperfections in the connectome dataset. To eliminate the impact of this asymmetry on our results, we tried three different ways to make connections across both hemispheres symmetrical:

  • Maximum: Set synaptic counts to the maximum observed for a neuron pair.

  • Minimum: Set synaptic counts to the minimum observed for a neuron pair.

  • Average: Set the synaptic counts to the average of observed for a neuron pair.

This resulted in three different adjacency matrices: 7772 connections for the maximum and average methods, 2148 connections for the minimum method, and 4961 connections in the original network. The minimum method is likely to eliminate important connections and the average method might bias synaptic counts if a connection was missing on one side. Therefore, we used the maximum model.

Next, in our maximum adjacency matrix, we grouped neurons—except for sensory and motor neurons—based on the similarity between their pre- and post-synaptic connections. We calculated the Pearson correlation coefficient between two neurons’ upstream and downstream connections and summed them. Therefore, in this similarity matrix, two identical neurons will have an entry value of 2 whereas two highly different neurons will have a score of  − 2. From this matrix, we calculated a distance matrix, calculated my 0.5*(2 − Asim) where Asim is the similarity matrix. Then, we applied the unsupervised clustering algorithm DBSCAN114 to the distance matrix to cluster neurons. We performed a parameter search to optimize the algorithm’s parameters—epsilon (set to 0.5) and the minimum number of samples (set to 1)—and to ensure that the resulting clusters are biologically meaningful (i.e., each cluster is either excitatory or inhibitory). Any neuron that DBSCAN left unclustered was assigned as its own individual cluster. We set sensory neurons (i.e., JO-C/E/F and antennal bristle neurons) to their respective cell types. Furthermore, each right-left motor neuron pair was assigned to a different cell type. In total, we obtained 104 clusters, reducing the number of node type 8-fold (from 852).

We additionally trained models based on the three different adjacency matrices (maximum, minimum, and average), a shuffled, and the original (i.e., unprocessed) version for multiple seeds (Supplementary Fig. 10C). For the shuffled matrix, we started with the symmetric adjacency matrix from the maximum count approach, then randomly rearranged the post-synaptic connections of each neuron on one hemisphere while preserving neurotransmitter identity. This shuffled matrix was then mirrored across hemispheres to maintain symmetry. For all types of adjacency matrices, we used the same cell types obtained from the previously mentioned clustering process.

The training results revealed that the network with the minimum number of connections, and thus the fewest open parameters, performed the worst (Supplementary Fig. 10C). By contrast, the shuffled and maximum connection networks, which had the highest number of open parameters, achieved the smallest test errors. These findings highlight the trade-off between model complexity and computational efficiency. Notably, the original connectome network’s performance was between the maximum and minimum connection networks (Supplementary Fig. 10C).

Model parameters and training

We adapted the open-source Python package for connectome-constrained model training47 (https://github.com/TuragaLab/flyvis, commit 056e4aa) to the grooming network and dataset. Specifically, each neuron 0≤j≤N is modeled as a leaky integrator neuron, where N is the number of neurons in the network, whose voltage dynamics vj(t) are governed by the following equations (trainable parameters are shown in red),

τjv°j(t)=−vj(t)+vjrest+∑i=0Nwi,jf(vi(t))+Ijext(t)+ξ(t) 5

where τj is membrane time constant and vjrest is resting potential, shared among neurons of the same cell-type (previously defined by an unsupervised clustering algorithm). Mechanosensory neurons JO-C/E/F receive an external input Ijext (i.e., sensory feedback and optogenetic stimuli) as described above while for other neurons in the network external input is zero. Each neuron also has an intrinsic noise ξ~N(0,0.01) and receives input from its pre-synaptic neurons i. We used rectified-linear unit (ReLU) to model neurotransmitter release f(x) = max(0, x). Transformed membrane potential of each pre-synaptic neuron i to post-synaptic neuron j is then weighted by the synaptic connection between the two wi,j as in reference47,

wi,j=σi,jαiNi,jsyn_count 6

where Ni,jsyn_count is the natural logarithm of the average synaptic count between cell types i to j, and αi is the neurotransmitter sign that is  − 1 if the detected neurotransmitter type is inhibitory and  + 1 otherwise. We assigned both GABA and Glutamate to be inhibitory115. We assigned Acetylcholine and Dopamine to be excitatory. Synaptic strength σi,j is an non-negative parameter and modulates the connection strength between neurons, initialized as

σi,j=0.1Ni,jsyn_count 7

Neuron parameters were initialized within physiologically plausible ranges. Resting potential was drawn from a normal distribution vjrest~N(μ=40mV,σ=5mV), clamped to a minimum of 0 mV to prevent excessive positive bias in neurons. The membrane time constant was uniformly initialized to 30 ms for all neurons and constrained to remain within the range [0, 150 ms].

To transform motor neuron activity into joint kinematics, we designed two Multi Layer Perceptrons (MLPs) (Table 5) by using built-in PyTorch functions. Decoders are used to emulate the nonlinearities arising from the musculoskeletal properties of antennal and neck pitch joints. We choose a feedforward network, rather than a recurrent neural network, to limit the capacity of decoder. In particular, there are 5 pairs of antennal motor neurons and 4 pairs of neck pitch motor neurons in the brain. left and right antennal MN activities were passed separately through the same antenna decoder, assuming that the left and right antennal muscles have identical properties. For the neck pitch motor neurons, both left and right activities were passed through a single neck decoder. In total, we had 3 output traces, obtained as follows:

ypred=Decoder(vimn(t)),i∈{1,2,...,Nmn} 8

where vimn(t) denotes motor neuron voltage values, and Nmn is the number of motor neurons. The model parameters are optimized through Backpropagation Through Time (BPTT)64 to minimize the loss between the decoder output and measured kinematics for every output trace, as described below:

L=LMSE+Lρ 9
LMSE(ypred,ytrue)=1T∑t=1T∥ypred,t−ytrue,t∥2 10
Lρ(ypred,ytrue)=1−1T∑t=1T(ypred,t−y¯pred)⋅(ytrue,t−y¯true)∥ypred,t−y¯pred∥2∥ytrue,t−y¯true∥2 11

where T is the number of time points, y¯pred and y¯true are the mean of ypred and ytrue, respectively. LMSE and Lρ denote mean-squared-error and correlation losses.

Table 5.

Antennal and neck motor decoder parameters

Decoder Input Hidden unit Hidden layer Output Drop-out Activation function
Antenna 5 10 1 1 0.20 hard tanh (min=0, max=5)
Neck 8 16 1 1 0.25 hard tanh (min=0, max=5)

Our connectome-constrained brain model had Ncell_type × Nneuron_param = 104 × 2 = 208 open parameters for neuronal dynamics and 624 (number of unique connections between cell types) open parameters for weights, giving a total of 832 parameters. We used the optimizer AMSGrad116, a variance of Adam optimizer with a learning rate of 10−4 and batch size of 16 over 5000 iterations. The models were trained using NVIDIA Hardware (GeForce RTX 2080, GeForce RTX4080, and V100). Each model took about 3–6 days to complete training.

Computational neural activation and silencing experiments

In our activation screen, we simultaneously delivered bilaterally symmetric input (left: 1.5, right: 1.5) to the JO-F neurons and unilateral input (left: 10, right: 0) to each neuron in the network for 2 s. The goal of this experiment was to identify neurons whose activation was sufficient to convert bilateral grooming into unilateral grooming.

In our silencing experiment, we bilaterally silenced neurons by setting all of their post-synaptic connections to zero. An bilaterally asymmetric step input (left: 3, right: 5) was then given to JO-F neurons. Here the objective was to identify neurons whose silencing disrupts unilateral aMN4 responses.

In both experiments, the aMN4 response was quantified using our response metric (Fig. 5C) after denoising single neural traces with a Savitzky-Golay filter (window size: 11, degree: 3).

Additionally, global network activity was evaluated after silencing neurons by comparing intact network activity to post-silencing activity. Neurons with mean activity more than five times the intact network activity during stimulation were labeled as ‘highly active.’ The total number of highly active neurons was then counted. Note that, this metric did not account for neurons that decreased global network activity after silencing.

All analyses were performed at the cluster (population) level by averaging the activity of all neurons within each cluster. Neural activity was passed through a ReLU activation function before analysis.

Identifying network motifs

Neurons were identified as important in our activation screen if their median USI metric (across three models) was either greater than 0.1 or less than -0.1. These neurons were categorized based on their effect of driving either ipsilateral aMN4 or contralateral aMN4.

To compute cluster weights from the single-neuron adjacency matrix, we summed the presynaptic and postsynaptic connections of all neurons within each cluster. Since each cluster is exclusively inhibitory or excitatory, the sign of the summed weights was preserved during this operation.

When visualizing network motifs, we included neurons that had both incoming and outgoing synapses within the motif, except for motor neurons. To simplify the network diagram, connection weights below the 1st percentile of all weights in the network were omitted from the visualization.

Statistical analysis

All statistical analyses were conducted using Python v3.10 with SciPy v1.10.1103. Unless otherwise specified, we employed the Mann-Whitney U test, a non-parametric method that does not assume any particular underlying probability distribution of the samples.

In Fig. 2C,F,I and Supplementary Fig. 4C, we compared force or contact read-outs across different gain values (modified versus intact) and between two leg segments (tibia versus tarsus) using a two-sided Mann-Whitney U test. Specifically, each trial is summarized with a single value using a metric, and distributions of these trial values were used for comparison. Each gain value was compared to the natural behavior (gain = 1 or gain = 60°), using the natural distribution repeatedly. To account for multiple comparisons, we applied the Simes–Hochberg false discovery rate correction, with a significance threshold of α = 0.05117.

In Fig. 3E, G, I, K, M, O, we performed within-fly comparisons between two phenotypes (uniR versus uniL kinematics; Fig. 3E, G, I bottom left) and between experimental conditions (intact versus experimental animals; Fig. 3E, G, I, K, M, O bottom right). We summarized data from each fly by taking the median of all trials. For phenotype comparisons, we used a one-sided Mann-Whitney U test, with the alternative hypothesis selected based on the specific kinematic variable. Comparisons between intact and experimental animals were made using a two-sided Mann-Whitney U test.

In Fig. 7D, E and Supplementary Fig. 12, we performed within-fly comparisons between two time windows (300 ms before and 300 ms after stimulus transition; Fig. 7E, left column; Supplementary Fig. 12B, D, left column) and between stimulus types (Fig. 3E, right column; Supplementary Fig. 12B, D, right column). We summarized data from each fly by taking the median of all trials. We used paired t-tests to compare time windows before and after each stimulus within individual flies, and two-sided Mann-Whitney U tests for comparisons across conditions, with Bonferroni correction for multiple comparisons.

In all figures showing statistical tests, significance levels are indicated as follows: ***: P < 0.001, **: P < 0.01, *: P < 0.05 and not significant (NS): P≥0.05. Sample sizes and P values are described in the respective figure legends and in the supplementary file.

Ethical compliance

All experiments were performed in compliance with relevant national (Switzerland) and institutional (EPFL) ethical regulations.

Reporting summary

Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.

Supplementary information

Supplementary Video 1 (3.8MB, mp4)
Supplementary Video 2 (582.6KB, mp4)
Supplementary Video 3 (30.1MB, mp4)
Supplementary Video 4 (6.2MB, mp4)
Supplementary Video 5 (16.8MB, mp4)
Supplementary Video 6 (16.1MB, mp4)
Supplementary Video 7 (7.9MB, mp4)
Supplementary Video 8 (8.7MB, mp4)
Supplementary Video 9 (11.9MB, mp4)
Supplementary Video 10 (13.5MB, mp4)
Supplementary Video 11 (12.5MB, mp4)
Supplementary Video 12 (5.1MB, mp4)
Supplementary Video 14 (11.5MB, mov)
Supplementary Video 15 (29.7MB, mp4)
Supplementary Data 1 (48.9KB, xlsx)
Reporting Summary (90.3KB, pdf)

Acknowledgements

We thank Stefanie Hampel and Andrew Seeds for helpful discussions and sharing the identification of antennal grooming neurons in FAFB; Janne Lappalainen for assistance in using the Flyvis package; Melissa Faggella and Olivia Caroline Ruggaber for 2D pose estimation annotations; Stefanie Boy-Röttger and Maite Azcorra for fly dissections and confocal imaging; Jasper Phelps for help with EM datasets; Kathi Eichler and Gregory Jefferis for sharing comprehensive proofreading and annotation of DNs in the FAFB and FANC datasets before publication; Marie Suver for helpful discussions on the identification of antennal motor neurons; Stephen Huston for sharing neck motor neuron identification data from FANC and MANC before publication. We thank members of the Biorobotics and Neuroengineering Laboratory for helpful discussions and invaluable feedback on the manuscript. We thank Brian McCabe (EPFL, Lausanne, Switzerland) for transgenic Drosophila strains. Stocks obtained from the Bloomington Drosophila Stock Center (NIH P40OD018537) were used in this study. PR acknowledges support from an SNSF Project Grant (175667) and an SNSF Eccellenza Grant (181239). FH acknowledges support from a Boehringer Ingelheim Fonds PhD stipend. JA acknowledges support from a European Research Council Synergy grant (951477). PGÖ acknowledges support from a Swiss Government Excellence Scholarship for Doctoral Studies and a Google PhD Fellowship.

Author contributions

P.G.O. - Conceptualization, Methodology, Software, Investigation, Formal Analysis, Data Acquisition, Data Curation, Visualization, Writing - Original Draft Preparation, Writing - Review & Editing. J.A. - Methodology, Software, Investigation, Visualization, Writing - Review & Editing. C.S. - Methodology, Investigation, Formal Analysis, Data Curation, Writing - Review & Editing. F.H. - Methodology, Investigation, Data Acquisition, Data Curation. A.J.I. - Conceptualization, Methodology, Investigation, Resources, Writing - Review & Editing, Supervision, Project Administration, Funding Acquisition. P.R. - Conceptualization, Methodology, Resources, Writing - Original Draft Preparation, Writing - Review & Editing, Supervision, Project Administration, Funding Acquisition.

Peer review

Peer review information

Nature Communications thanks the anonymous reviewers for their contribution to the peer review of this work. A peer review file is available.

Data availability

Data are available at: (https://dataverse.harvard.edu/dataverse/ozdil_2024_antennal_grooming). This repository includes behavioral recordings used in Fig. 1, Fig. 3, Fig. 7, Supplementary Fig. 1, Supplementary Fig. 2, Supplementary Fig. 3, Supplementary Fig. 6, Supplementary Fig. 12; trained DeepLabCut networks to perform 2D pose estimation; a table representing the antennal grooming network used in Fig. 4. Raw behavioral videos are available upon request from the authors and are omitted here due to storage limitations.

Code availability

Code is available at: https://github.com/NeLy-EPFL/antennal-grooming.

Competing interests

The authors declare that no competing interests exist.

Footnotes

Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Supplementary information

The online version contains supplementary material available at 10.1038/s41467-026-72152-x.

References

  • 1.Gelfand, I., Orlovsky, G. & Shik, M. Locomotion and scratching in tetrapods. In Neural Control of Rhythmic Movements in Vertebrates. 167–199 (John Wiley & Sons, New York, NY, 1988).
  • 2.Naghizadeh, M., Mohajerani, M. H. & Whishaw, I. Q. Mouse arm and hand movements in grooming are reaching movements: Evolution of reaching, handedness, and the thumbnail. Behav. Brain Res.393, 112732 (2020). [DOI] [PubMed] [Google Scholar]
  • 3.Ruder, L. & Arber, S. Brainstem circuits controlling action diversification. Annu. Rev. Neurosci.42, 485–504 (2019). [DOI] [PubMed] [Google Scholar]
  • 4.Li, J. et al. A defensive kicking behavior in response to mechanical stimuli mediated by Drosophila wing margin bristles. J. Neurosci.36, 11275–11282 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 5.Kalueff, A. V. et al. Neurobiology of rodent self-grooming and its value for translational neuroscience. Nat. Rev. Neurosci.17, 45–59 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 6.Sachs, B. D. The development of grooming and its expression in adult animals. Ann. N. Y. Acad. Sci.525, 1–17 (1988). [DOI] [PubMed] [Google Scholar]
  • 7.Zhukovskaya, M., Yanagawa, A. & Forschler, B. T. Grooming behavior as a mechanism of insect disease defense. Insects4, 609–630 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 8.Böröczky, K., Wada-Katsumata, A., Batchelor, D., Zhukovskaya, M. & Schal, C. Insects groom their antennae to enhance olfactory acuity. Proc. Natl. Acad. Sci. USA. 110, 3615–3620 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 9.Wada-Katsumata, A. & Schal, C. Antennal grooming facilitates courtship performance in a group-living insect, the German cockroach Blattella germanica. Sci. Rep.9, 2942 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 10.Stein, P., Victor, J. C., Field, E. C. & Currie, S. Bilateral control of hindlimb scratching in the spinal turtle: contralateral spinal circuitry contributes to the normal ipsilateral motor pattern of fictive rostral scratching. J. Neurosci.15, 4343–4355 (1995). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 11.Berkowitz, A. & Stein, P. Activity of descending propriospinal axons in the turtle hindlimb enlargement during two forms of fictive scratching: phase analyses. J. Neurosci.14, 5105–5119 (1994). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 12.Kuhta, P. C. & Smith, J. L. Scratch responses in normal cats: hindlimb kinematics and muscle synergies. J. Neurophysiol.64, 1653–1667 (1990). [DOI] [PubMed] [Google Scholar]
  • 13.Deliagina, T., Orlovsky, G. & Perret, C. Efferent activity during fictitious scratch reflex in the cat. J. Neurophysiol.45, 595–604 (1981). [DOI] [PubMed] [Google Scholar]
  • 14.Currie, S. N. & Gonsalves, G. G. Reciprocal interactions in the turtle hindlimb enlargement contribute to scratch rhythmogenesis. J. Neurophysiol.81, 2977–2987 (1999). [DOI] [PubMed] [Google Scholar]
  • 15.Berkowitz, A. & Laurent, G. Local control of leg movements and motor patterns during grooming in locusts. J. Neurosci.16, 8067–8078 (1996). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 16.Berkowitz, A. & Laurent, G. Central generation of grooming motor patterns and interlimb coordination in locusts. J. Neurosci.16, 8079–8091 (1996). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 17.Ryckebusch, S. & Laurent, G. Interactions between segmental leg central pattern generators during fictive rhythms in the locust. J. Neurophysiol.72, 2771–2785 (1994). [DOI] [PubMed] [Google Scholar]
  • 18.Pick, S. & Strauss, R. Goal-driven behavioral adaptations in gap-climbing Drosophila. Curr. Biol.15, 1473–1478 (2005). [DOI] [PubMed] [Google Scholar]
  • 19.Muijres, F. T., Elzinga, M. J., Melis, J. M. & Dickinson, M. H. Flies evade looming targets by executing rapid visually directed banked turns. Science344, 172–177 (2014). [DOI] [PubMed] [Google Scholar]
  • 20.Seeds, A. M. et al. A suppression hierarchy among competing motor programs drives sequential grooming in Drosophila. eLife3, e02951 (2014). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 21.Dorkenwald, S. et al. Neuronal wiring diagram of an adult brain. Nature634, 124–138 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 22.Schlegel, P. et al. Whole-brain annotation and multi-connectome cell typing of Drosophila. Nature634, 139–152 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 23.Zheng, Z. et al. A complete electron microscopy volume of the brain of adult Drosophila melanogaster. Cell174, 730–743 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 24.Scheffer, L. K. et al. A connectome and analysis of the adult Drosophila central brain. eLife9, e57443 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 25.Phelps, J. S. et al. Reconstruction of motor control circuits in adult Drosophila using automated transmission electron microscopy. Cell184, 759–774.e18 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 26.Azevedo, A. et al. Connectomic reconstruction of a female Drosophila ventral nerve cord. Nature631, 360–368 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 27.Takemura, S. et al. A connectome of the male Drosophila ventral nerve cord. eLife (2024).
  • 28.Meissner, G. W. et al. A searchable image resource of Drosophila GAL4 driver expression patterns with single neuron resolution. eLife12, e80660 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 29.Simpson, J. H. & Looger, L. L. Functional Imaging and Optogenetics in Drosophila. Genetics208, 1291–1309 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 30.Hampel, S., McKellar, C. E., Simpson, J. H. & Seeds, A. M. Simultaneous activation of parallel sensory pathways promotes a grooming sequence in Drosophila. eLife6, e28804 (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 31.Mueller, J. M., Zhang, N., Carlson, J. M. & Simpson, J. H. Variation and variability in Drosophila grooming behavior. Front. Behav. Neurosci.15, 769372 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 32.Mueller, J. M., Ravbar, P., Simpson, J. H. & Carlson, J. M. Drosophila melanogaster grooming possesses syntax with distinct rules at different temporal scales. PLOS Comput. Biol.15, e1007105 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 33.Hampel, S. et al. Distinct subpopulations of mechanosensory chordotonal organ neurons elicit grooming of the fruit fly antennae. eLife9, e59976 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 34.Zhang, N., Guo, L. & Simpson, J. H. Spatial comparisons of mechanosensory information govern the grooming sequence in Drosophila. Curr. Biol.30, 988–1001.e4 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 35.Eichler, K. et al. Somatotopic organization among parallel sensory pathways that promote a grooming sequence in Drosophila. Elife12, RP87602 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 36.Hampel, S., Franconville, R., Simpson, J. H. & Seeds, A. M. A neural command circuit for grooming movement control. eLife4, e08758 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 37.Guo, L., Zhang, N. & Simpson, J. H. Descending neurons coordinate anterior grooming behavior in Drosophila. Curr. Biol.32, 823–833.e4 (2022). [DOI] [PubMed] [Google Scholar]
  • 38.Zhang, N. & Simpson, J. H. A pair of commissural command neurons induces Drosophila wing grooming. IScience25 (2022). [DOI] [PMC free article] [PubMed]
  • 39.Syed, D. S., Ravbar, P. & Simpson, J. H. Inhibitory circuits control leg movements during Drosophila grooming. Elife14, RP106446 (2026). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 40.Yoshikawa, S., Tang, P. & Simpson, J. H. Mechanosensory and command contributions to the Drosophila grooming sequence. Curr. Biol. 34, 2066–2076.e3 (2024). [DOI] [PMC free article] [PubMed]
  • 41.Ravbar, P., Zhang, N. & Simpson, J. H. Behavioral evidence for nested central pattern generator control of Drosophila grooming. eLife10, e71508 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 42.Günel, S. et al. DeepFly3D, a deep learning-based approach for 3D limb and appendage tracking in tethered, adult Drosophila. eLife8, e48571 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 43.Karashchuk, P. et al. Anipose: A toolkit for robust markerless 3D pose estimation. Cell Rep.36, 109730 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 44.Lobato-Rios, V. et al. NeuroMechFly, a neuromechanical model of adult Drosophila melanogaster. Nat. Methods19, 620–627 (2022). [DOI] [PubMed] [Google Scholar]
  • 45.Wang-Chen, S. et al. Neuromechfly v2: simulating embodied sensorimotor control in adult Drosophila. Nat. Methods21, 2353–2362 (2024). [DOI] [PubMed] [Google Scholar]
  • 46.Arreguit, J., Ramalingasetty, S. T. & Ijspeert, A. Farms: framework for animal and robot modeling and simulation. bioRxiv10.1101/2023.09.25.559130 (2023).
  • 47.Lappalainen, J. K. et al. Connectome-constrained networks predict neural activity across the fly visual system. Nature634, 1132–1140 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 48.Shiu, P. K. et al. A Drosophila computational brain model reveals sensorimotor processing. Nature634, 210–219 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 49.Mathis, A. et al. DeepLabCut: markerless pose estimation of user-defined body parts with deep learning. Nat. Neurosci.21, 1281–1289 (2018). [DOI] [PubMed] [Google Scholar]
  • 50.Özdil, P. G., Wang-Chen, S., Ning, C., Ijspeert, A. & Ramdya, P. SeqIKPy: a Python package for inverse kinematics in insects. J. Open Source Softw.11, 8557 (2026). [Google Scholar]
  • 51.Suver, M. P., Medina, A. M. & Nagel, K. I. Active antennal movements in Drosophila can tune wind encoding. Curr. Biol.33, 780–789.e4 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 52.Dorkenwald, S. et al. Flywire: online community for whole-brain connectomics. Nat. methods19, 119–128 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 53.Lin, A. et al. Network statistics of the whole-brain connectome of Drosophila. Nature634, 153–165 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 54.Winding, M. et al. The connectome of an insect brain. Science379, eadd9330 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 55.Dallmann, C. J. et al. Presynaptic inhibition selectively suppresses leg proprioception in behaving Drosophila. bioRxiv 10.1101/2023.10.20.563322 (2023).
  • 56.Scharstein, H. Input-output relationship of the Leaky-Integrator Neuron Model. J. Math. Biol.8, 403–420 (1979). [DOI] [PubMed] [Google Scholar]
  • 57.Chen, C. et al. Functional architecture of neural circuits for leg proprioception in Drosophila. Curr. Biol.31, 5163–5175.e7 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 58.Chen, C. et al. Ascending neurons convey behavioral state to integrative sensory and action selection brain regions. Nat. Neurosci.26, 682–695 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 59.Pascual, A., Huang, K.-L., Neveu, J. & Préat, T. Brain asymmetry and long-term memory. Nature427, 605–606 (2004). [DOI] [PubMed] [Google Scholar]
  • 60.Tuthill, J. C. & Wilson, R. I. Mechanosensation and adaptive motor control in insects. Curr. Biol.26, R1022–R1038 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 61.Azevedo, A. W. et al. A size principle for recruitment of Drosophila leg motor neurons. eLife9, e56754 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 62.Gorko, B. et al. Motor neurons generate pose-targeted movements via proprioceptive sculpting. Nature628, 596–603 (2024). [DOI] [PubMed] [Google Scholar]
  • 63.Eckstein, N. et al. Neurotransmitter classification from electron microscopy images at synaptic sites in Drosophila melanogaster. Cell187, 2574–2594 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 64.Werbos, P. Backpropagation through time: what it does and how to do it. Proc. IEEE. 78, 1550–1560 (1990). [Google Scholar]
  • 65.Sterne, G. R., Otsuna, H., Dickson, B. J. & Scott, K. Classification and genetic targeting of cell types in the primary taste and premotor center of the adult Drosophila brain. eLife10, e71679 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 66.Erginkaya, M. et al. A competitive disinhibitory network for robust optic flow processing in Drosophila. bioRxiv2023-08 (2023). [DOI] [PMC free article] [PubMed]
  • 67.Feng, K. et al. A central steering circuit in Drosophila. bioRxiv 10.1101/2024.06.27.601106 (2024).
  • 68.Machens, C. K., Romo, R. & Brody, C. D. Flexible control of mutual inhibition: a neural model of two-interval discrimination. Science307, 1121–1124 (2005). [DOI] [PubMed] [Google Scholar]
  • 69.Koyama, M. & Pujala, A. Mutual inhibition of lateral inhibition: a network motif for an elementary computation in the brain. Curr. Opin. Neurobiol.49, 69–74 (2018). [DOI] [PubMed] [Google Scholar]
  • 70.Jovanic, T. et al. Competitive disinhibition mediates behavioral choice and sequences in Drosophila. Cell167, 858–870.e19 (2016). [DOI] [PubMed] [Google Scholar]
  • 71.Mysore, S. P. & Knudsen, E. I. Reciprocal inhibition of inhibition: a circuit motif for flexible categorization in stimulus selection. Neuron73, 193–205 (2012). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 72.Jing, J. & Gillette, R. Neuronal elements that mediate escape swimming and suppress feeding behavior in the predatory sea slug pleurobranchaea. J. Neurophysiol.74, 1900–1910 (1995). [DOI] [PubMed] [Google Scholar]
  • 73.Berkowitz, A., Roberts, A. & Soffe, S. R. Roles for multifunctional and specialized spinal interneurons during motor pattern generation in tadpoles, zebrafish larvae, and turtles. Front. Behav. Neurosci.4, 1810 (2010). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 74.Mamiya, A., Straw, A. D., Tómasson, E. & Dickinson, M. H. Active and passive antennal movements during visually guided steering in flying Drosophila. J. Neurosci.31, 6900–6914 (2011). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 75.Gewecke, M. et al. Der Bewegungsapparat der Antennen von Calliphora erythrocephala. Z. für. Morphologie und Ökologie der Tiere59, 95–133 (1967). [Google Scholar]
  • 76.Hlavac, T. F. Grooming systems of insects: Structure, mechanics. Ann. Entomological Soc. Am.68, 823–826 (1975). [Google Scholar]
  • 77.Rebora, M., Salerno, G., Piersanti, S., Michels, J. & Gorb, S. Structure and biomechanics of the antennal grooming mechanism in the southern green stink bug nezara viridula. J. insect Physiol.112, 57–67 (2019). [DOI] [PubMed] [Google Scholar]
  • 78.Cheong, H. S. et al. Transforming descending input into behavior: The organization of premotor circuits in the Drosophila Male Adult Nerve Cord connectome. eLife13, RP96084 (2024). [DOI] [PMC free article] [PubMed]
  • 79.Bidaye, S. S., Bockemühl, T. & Büschges, A. Six-legged walking in insects: how CPGs, peripheral feedback, and descending signals generate coordinated and adaptive motor rhythms. J. Neurophysiol.119, 459–475 (2018). [DOI] [PubMed] [Google Scholar]
  • 80.Ijspeert, A. J. & Daley, M. A. Integration of feedforward and feedback control in the neuromechanics of vertebrate locomotion: a review of experimental, simulation and robotic studies. J. Exp. Biol.226, jeb245784 (2023). [DOI] [PubMed]
  • 81.Büschges, A. & Gruhn, M. Mechanosensory feedback in walking: from joint control to locomotor patterns. Adv. Insect Physiol.34, 193–230 (2007). [Google Scholar]
  • 82.Pearson, K. G. Proprioceptive regulation of locomotion. Curr. Opin. Neurobiol.5, 786–791 (1995). [DOI] [PubMed] [Google Scholar]
  • 83.Fuchs, E., Holmes, P., Kiemel, T. & Ayali, A. Intersegmental coordination of cockroach locomotion: adaptive control of centrally coupled pattern generator circuits. Front. neural circuits4, 125 (2011). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 84.Ayali, A. et al. Sensory feedback in cockroach locomotion: current knowledge and open questions. J. Comp. Physiol. A201, 841–850 (2015). [DOI] [PubMed] [Google Scholar]
  • 85.Zack, S. The effects of foreleg amputation on head grooming behaviour in the praying mantis, Sphodromantis lineola. J. Comp. Physiol.125, 253–258 (1978). [Google Scholar]
  • 86.Matheson, T. Hindleg targeting during scratching in the locust. J. Exp. Biol.200, 93–100 (1997). [DOI] [PubMed] [Google Scholar]
  • 87.Page, K. L. & Matheson, T. Functional recovery of aimed scratching movements after a graded proprioceptive manipulation. J. Neurosci.29, 3897–3907 (2009). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 88.de Bivort, B. et al. Precise quantification of behavioral individuality from 80 million decisions across 183,000 flies. Front. Behav. Neurosci.16, 836626 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 89.Buchanan, S. M., Kain, J. S. & De Bivort, B. L. Neuronal control of locomotor handedness in Drosophila. Proc. Natl. Acad. Sci.112, 6700–6705 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 90.Honegger, K. S., Smith, M. A.-Y., Churgin, M. A., Turner, G. C. & de Bivort, B. L. Idiosyncratic neural coding and neuromodulation of olfactory individuality in Drosophila. Proc. Natl. Acad. Sci.117, 23292–23297 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 91.Kain, J. S. et al. Variability in thermal and phototactic preferences in Drosophila may reflect an adaptive bet-hedging strategy. Evolution69, 3171–3185 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 92.Skutt-Kakaria, K., Reimers, P., Currier, T. A., Werkhoven, Z. & de Bivort, B. L. A neural circuit basis for context-modulation of individual locomotor behavior. BioRxiv (2019).
  • 93.Churgin, M. A. et al. Neural correlates of individual odor preference in Drosophila. eLife (2023). [DOI] [PMC free article] [PubMed]
  • 94.Braun, J., Hurtak, F., Wang-Chen, S. & Ramdya, P. Descending networks transform command signals into population motor control. Nature630, 686–694 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 95.Schindelin, J. et al. Fiji: an open-source platform for biological-image analysis. Nat. methods9, 676–682 (2012). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 96.Chen, C.-L. et al. Imaging neural activity in the ventral nerve cord of behaving adult Drosophila. Nat. Commun.9, 4390 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 97.Bradski, G. The OpenCV Library. Dr. Dobb’s. J.: Softw. Tools Professional Program.25, 120–123 (2000). [Google Scholar]
  • 98.Pagnon, D., Domalain, M. & Reveret, L. Pose2sim: an open-source python package for multiview markerless kinematics. J. Open Source Softw.7, 4362 (2022). [Google Scholar]
  • 99.Werling, K. et al. Addbiomechanics: automating model scaling, inverse kinematics, and inverse dynamics from human motion data through sequential optimization. Plos one18, e0295152 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 100.Begon, M., Andersen, M. S. & Dumas, R. Multibody kinematics optimization for the estimation of upper and lower limb human joint kinematics: a systematized methodological review. J. Biomech. Eng.140, 030801 (2018). [DOI] [PubMed] [Google Scholar]
  • 101.Kim, C., Kim, D. & Oh, Y. Solving an inverse kinematics problem for a humanoid robots imitation of human motions using optimization. In Proc. of Int. Conf. on Infomatics in Control, Automation and Robotics, 85–92 (2005).
  • 102.Manceron, P. et al. IKPy https://zenodo.org/record/6551158 (2022).
  • 103.Virtanen, P. et al. SciPy 1.0: fundamental algorithms for scientific computing in Python. Nat. Methods17, 261–272 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 104.Bohnslav, J. P. et al. DeepEthogram, a machine learning pipeline for supervised behavior classification from raw pixels. eLife10, e63377 (2021). [DOI] [PMC free article] [PubMed]
  • 105.Hagberg, A., Swart, P. J. & Schult, D. A. Exploring network structure, dynamics, and function using networkx. Tech. Rep., Los Alamos National Laboratory (LANL), Los Alamos, NM, United States (2008).
  • 106.Todorov, E., Erez, T. & Tassa, Y. MuJoCo: A physics engine for model-based control. In 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems, 5026–5033 (2012).
  • 107.Buhmann, J. et al. Automatic detection of synaptic partners in a whole-brain Drosophila electron microscopy data set. Nat. methods18, 771–774 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 108.Yu, S.-C. et al. New synapse detection in the whole-brain connectome of Drosophila. bioRxiv 10.1101/2025.07.11.664377 (2025).
  • 109.Marin, E. C. et al. Systematic annotation of a complete adult male Drosophila nerve cord connectome reveals principles of functional organisation. eLife13, RP97766 (2024).
  • 110.Fenk, L. M. et al. Muscles that move the retina augment compound eye vision in Drosophila. Nature612, 116–122 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 111.Stürner, T. et al. Comparative connectomics of the descending and ascending neurons of the Drosophila nervous system: stereotypy and sexual dimorphism. bioRxiv (2024).
  • 112.Schlegel, P. et al. Information flow, cell types and stereotypy in a full olfactory connectome. eLife10, e66018 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 113.Yorozu, S. et al. Distinct sensory representations of wind and near-field sound in the Drosophila brain. Nature458, 201–205 (2009). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 114.Ester, M., Kriegel, H.-P., Sander, J., Xu, X. et al. A density-based algorithm for discovering clusters in large spatial databases with noise. In kdd, 96, 226–231 (1996).
  • 115.Liu, W. W. & Wilson, R. I. Glutamate is an inhibitory neurotransmitter in the Drosophila olfactory system. Proc. Natl. Acad. Sci.110, 10294–10299 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 116.Reddi, S. J., Kale, S. & Kumar, S. On the convergence of adam and beyond. arXiv preprint arXiv:1904.09237 (2019).
  • 117.Simes, R. J. An improved bonferroni procedure for multiple tests of significance. Biometrika73, 751–754 (1986). [Google Scholar]
  • 118.Jenett, A. et al. A gal4-driver line resource for Drosophila neurobiology. Cell Rep.2, 991–1001 (2012). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 119.Nern, A., Pfeiffer, B. D. & Rubin, G. M. Optimized tools for multicolor stochastic labeling reveal diverse stereotyped cell arrangements in the fly visual system. Proc. Natl. Acad. Sci. USA. 112 (2015). [DOI] [PMC free article] [PubMed]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Supplementary Video 1 (3.8MB, mp4)
Supplementary Video 2 (582.6KB, mp4)
Supplementary Video 3 (30.1MB, mp4)
Supplementary Video 4 (6.2MB, mp4)
Supplementary Video 5 (16.8MB, mp4)
Supplementary Video 6 (16.1MB, mp4)
Supplementary Video 7 (7.9MB, mp4)
Supplementary Video 8 (8.7MB, mp4)
Supplementary Video 9 (11.9MB, mp4)
Supplementary Video 10 (13.5MB, mp4)
Supplementary Video 11 (12.5MB, mp4)
Supplementary Video 12 (5.1MB, mp4)
Supplementary Video 14 (11.5MB, mov)
Supplementary Video 15 (29.7MB, mp4)
Supplementary Data 1 (48.9KB, xlsx)
Reporting Summary (90.3KB, pdf)

Data Availability Statement

Data are available at: (https://dataverse.harvard.edu/dataverse/ozdil_2024_antennal_grooming). This repository includes behavioral recordings used in Fig. 1, Fig. 3, Fig. 7, Supplementary Fig. 1, Supplementary Fig. 2, Supplementary Fig. 3, Supplementary Fig. 6, Supplementary Fig. 12; trained DeepLabCut networks to perform 2D pose estimation; a table representing the antennal grooming network used in Fig. 4. Raw behavioral videos are available upon request from the authors and are omitted here due to storage limitations.

Code is available at: https://github.com/NeLy-EPFL/antennal-grooming.


Articles from Nature Communications are provided here courtesy of Nature Publishing Group

RESOURCES