Animals, including humans, are capable of generating a remarkable variety of behaviours ranging from stereotyped movements—such as escape reflexes needed to rapidly evade a predator—to more elaborate actions such as navigating over unpredictable, rugged terrain. All of these behaviours require the active control of multiple joint degrees of freedom by motor circuits in the vertebrate spinal cord or invertebrate ventral nerve cord (VNC). In addition to the important role of spinal circuits in the execution of movements, a relatively small population of DNs projecting from the brain to motor circuits regulate the selection, initiation and online steering of many behaviours.

We still lack mechanistic understanding of how DNs as a population drive and coordinate behaviours, in part due to the technical difficulty of comprehensively recording and manipulating DNs in behaving mammals: there are more than 1 million in the human pyramidal tract5 and approximately 70,000 in the mouse corticospinal tract6. By contrast, the adult fly, Drosophila melanogaster, has approximately 1,300 DNs linking the brain to motor centres in the VNC7. Despite this numerical simplicity, flies can generate various complex behaviours including legged locomotion8, flight9, courtship10 and aggression11. Several tools facilitate the investigation of descending control in the fly including connectomes for quantifying the synaptic connectivity of every neuron in the brain7 and VNC12,13, as well as genetic tools for repeatedly targeting identified descending neurons14,15 across individual animals for experimental recordings (electrophysiological16 or optical17) and manipulations (activation18 or silencing19).

One notable discovery derived using these tools is that, despite the abundance of DNs in the fly brain, artificial activation of pairs of ‘command-like’ DNs (comDNs) can be sufficient to drive a complete behaviour (but not also necessary as is required to be considered ‘command’ neurons20). For example, DNs have been identified whose artificial activation trigger forwards walking3, grooming4,21, backwards walking2, escape16, egg-laying22 and components of courtship23,24. The capacity of some DNs to act as command-like neurons appears to be general across species including invertebrates25,26 and mammals27. Command-like descending control has also been leveraged to design controllers for robots28.

The concept of command-like control raises a fundamental question regarding to what extent each pair or small set of DNs drives a distinct action. Several lines of evidence have suggested that this is unlikely. Most directly, for many DNs, sparse optogenetic activation does not clearly and reliably drive a coordinated behaviour18. In addition, previously, we observed the co-activation of many DNs during walking29, and others have shown that a group of 15 DNs can modulate wing beat amplitude30 and that the activation of individual DNs has a lower probability of eliciting take-off than the co-activation of multiple DNs31. Furthermore, beyond controlling kinematics, DNs can also be neuromodulatory32,33. All of these observations imply that DN control of a given behaviour rather than being via one class of DNs conveying a simple but reliable drive signal could instead depend on multiple classes of DNs working together as a population. In this model, individual DNs would represent single dimensions of a high-dimensional control signal, which are combined to construct complete behaviours from simpler motor primitives.

At first glance, these two models—comDN versus population-based DN behavioural control—appear to be conflicting. However, we can envision at least two scenarios in which they can be unified. First, comDNs or non-comDNs may simply target different downstream motor circuits (in the spinal cord or VNC) that can or cannot generate complete behaviours, respectively. Alternatively, comDNs may be privileged in that they can recruit additional DN populations to drive complete behaviours. This latter possibility is supported by the fact that, in addition to projecting to the VNC, 85% of all DNs have axon collaterals and thus may engage one another in the gnathal ganglia (GNG) of the brain, a location where most DNs are found14.

Here we investigated the degree to which known comDNs interact with other DNs in the brain to generate complete behaviours. When optogenetically activating three sets of comDNs, we observed the co-activation of additional DN populations in the GNG. This functional recruitment covaries with and can be explained at least in part by monosynaptic excitatory connections between comDNs and downstream DN networks. Through decapitation experiments, we found that behaviours triggered by strongly connected DNs require the engagement of larger DN networks, whereas comDNs engaging smaller networks do not. We then identified nine additional sets of comDNs that allowed us to experimentally test and validate this model of DN recruitment for behavioural control. Finally, we performed a comprehensive analysis of all DN–DN interconnectivity in the brain and found that DN networks form predominantly excitatory clusters associated with distinct actions that mutually inhibit one another. In summary, these findings suggest a new framework that can reconcile the two dominant models of DN control: comDNs drive complete behaviours by recruiting additional downstream DN populations, which combine and coordinate multiple motor subroutines.

From comDNs to DN populations

We set out to explore the relationship between two prominent models for how DNs control behavioural kinematics. In the first model, the artificial activation of a few comDNs—a simple high-level descending signal—engages downstream motor circuits in the VNC to drive a complete behaviour (for example, walking or grooming) (Fig. 1a, left ‘comDNs’). In the second model, a larger population of DNs must become co-active to orchestrate a given behaviour. Each DN within this population would be responsible for controlling or modulating a particular movement or motor primitive. The combined activity of the entire population would yield a complete behaviour (Fig. 1a, right ‘popDNs’).

Fig. 1: Optical approach to probe the relationship between comDNs and popDNs in behaving animals.
figure 1

a, Schematic of the Drosophila nervous system showing a pair of DNs that project from the brain to motor circuits in the VNC (left). Activation of small sets of comDNs (green) can drive complete behaviours. Thus, comDNs are thought to send simple, high-level control signals to the VNC, where they are transformed into complex, multi-joint movements. However, larger popDNs (orange) are also known to become active during natural behaviours (right). Therefore, in another model, individual DNs contribute to complex behaviours by sending low-level signals that control the fine-grained movements of individual or sparse sets of joints. b, We stimulated three sets of comDNs to elicit three distinct behaviours: forwards walking (DNp09, green)3,14, antennal grooming (aDN2, red)4 and backwards walking (MDN, cyan) (left)2. DN cell body locations are schematized. Two coarse subdivisions of the adult Drosophila brain are the cerebral ganglia (CRG; previously known as the supraoesophageal ganglion) and the GNG (also known as the suboesophageal ganglion) (right)59. We recorded from DNs within the GNG, which houses most DNs14. c, We recorded neural activity in the axons of GNG DN populations (orange) during optogenetic stimulation of different sets of comDNs (green). The grey dashed line denotes a coronal section region of interest in the thoracic cervical connective illustrating DN axon cross-sections (orange ellipses). d, A system for recording behaviour, GNG DN neural activity29 and optogenetically stimulating comDN axons in the neck connective (schema not to scale). The inset shows a camera image of a fly with focused laser light on its neck. Superimposed on the camera image are pose estimation key points (light blue).

These two scenarios can be distinguished by the degree to which activation of comDNs further co-activates other DNs. We tested this using an all-optical experimental strategy in the adult fly D. melanogaster. We activated three sets of comDNs that drive a wide range of behaviours including forwards walking (DNp09 (ref. 3), green), antennal grooming (aDN2 (ref. 34), red) or backwards walking (MDN3 (ref. 2), cyan) (Fig. 1b, left) via cell-specific expression of the light-activated ion channel CsChrimson35 (comDN-spGAL4 > UAS-CsChrimson; Extended Data Fig. 1a,d) and laser light stimulation. Simultaneously, we recorded the activity of DN populations by expressing the genetically encoded calcium indicator GCaMP6s36 (Dfd-LexA > LexAOp-opGCaMP6s), in the GNG, the most caudal region of the fly brain (Fig. 1b, right ‘GNG DNs’, and Extended Data Fig. 1b), but not in our comDNs (Extended Data Fig. 1c). To further restrict our neural recordings to DNs, we performed two-photon microscopy of DN axons passing through the thoracic cervical connective29 (Fig. 1c). We further increased the specificity of comDN optogenetic activation by restricting stimulation of DN axons to the neck connective (Fig. 1d, red, and Extended Data Fig. 1e,f).

ComDNs recruit additional DNs

Using these tools, we examined whether additional DNs in the GNG might be recruited upon optogenetic activation of comDNs. We used an open-loop trial structure in which 5-s periods of optogenetic stimulation were interleaved with 10-s periods of spontaneous animal behaviour. This approach elicited robust behavioural responses, which we quantified through trial averaging (Fig. 2a). We observed a clear increase in GNG DN activity during the stimulation of any of the three sets of comDNs in individual animals: DNp09, aDN2 and MDN (Supplementary Video 1) (Fig. 2b–d). This result was also consistent across multiple animals (Fig. 2e,f). We did not observe pronounced activation of GNG DNs in control animals lacking an spGAL4 transgene (Fig. 2b–f, rightmost, and Supplementary Video 1). Thus, GNG DN populations become active due to comDN stimulation as, for all three sets of comDNs tested, the number and fraction of GNG DNs activated were significantly higher than for control animals (Fig. 2g,h; P = 0.018 (DNp09), P = 0.040 (aDN2) and P = 0.008 (MDN)).

Fig. 2: Activation of comDNs recruits larger, distinct DN populations.
figure 2

Optogenetic stimulation of comDNs: DNp09 (forwards walking, n = 5 flies, 120 stimulation trials), aDN2 (antennal grooming, n = 3 flies, 34 trials) and MDN (backwards walking, n = 9 flies, 271 trials). Control: no DN expression (n = 3 flies, 47 trials). a, Forwards walking velocities (top) and the probability of classified behaviours (bottom) during optogenetic stimulation (grey bar). b, Images illustrating GNG DN population activity upon comDN stimulation. For each, one representative animal is shown (as in Supplementary Video 1; n = 33, 10, 97 and 10 trials for DNp09, aDN2, MDN and control flies, respectively). The same flies are shown in panels c,d. c, Single-neuron responses to DN stimulation. Circles are scaled or colour coded to represent the maximum change in fluorescence (normalized ΔF/F) of one detected DN axon or region of interest (ROI). The small white dots indicate responses smaller than the 95% CI of the trial mean. d, Trial-averaged single ROI responses across time, ordered by response magnitude. Response magnitude is colour coded or white if smaller than the 95% CI. The red dashed line indicates the number of activated ROIs (that is, positive response larger than the 95% CI). e,f, A registered overlay (e) or density visualization (f) of the data from multiple flies analysed as in c. The number of flies or trials is identical to a. gi, Statistical comparison of the number of activated ROIs (that is, red dashed line in d) (g), the fraction of activated ROIs (that is, divided by the number of visible ROIs) (h) and the strength of activation (that is, the sum of the normalized ΔF/F for positively activated neurons) (i) using two-sided Mann–Whitney U-tests (n as in a; P values for each comparison to control: DNp09 = 0.018, aDN2 = 0.040 and MDN = 0.008). The shaded areas in a and the error bars in gi represent 95% CI of the mean. ***P < 0.001, *P < 0.05.

Source Data

We found that GNG DNs were recruited in a spatially distinct manner across the cervical connective depending on which class of comDNs was activated (Fig. 2e,f). Stimulation of forwards walking (DNp09) and antennal grooming (aDN2) increased the activity of DNs localized in distinct regions of the medial cervical connective: the entire dorsal–ventral axis for forwards walking, and the medial and ventral connective for grooming. Activation of backwards walking (MDN) led to weaker GNG DN recruitment localized to the medial connective. We quantified the strength of GNG DN recruitment as the summed responses of neurons that were positively activated during optogenetic stimulation (Fig. 2i), a quantity that was significantly higher for comDN stimulation than for controls (P = 0.018 (DNp09), P = 0.040 (aDN2) and P = 0.008 (MDN)). In addition, we observed a recruitment gradient among comDNs: DNp09 stimulation resulted in very strong recruitment of GNG DNs, aDN2 in slightly weaker recruitment and MDN the weakest.

Co-activation of GNG DNs by optogenetic stimulation may be non-ethological rather than reflecting what is seen during natural behaviour. For example, when animals groom their antennae to remove debris, aDN2 will have a specific firing rate with a specific temporal activity pattern. This may not be well reflected by the potentially high firing rate and relatively static temporal activity pattern driven by optogenetic stimulation of the same neurons. Thus, an unusually high firing rate might be responsible for recruiting other DNs. To address this concern, we compared the activity of GNG DN populations in the same individual animals during both optogenetic stimulation and the corresponding natural behaviour. Specifically, we compared neural activity during both DNp09 stimulation and bouts of spontaneous forwards walking (Extended Data Fig. 2a and Supplementary Video 2), aDN2 stimulation and air-puff-induced anterior grooming (Extended Data Fig. 2b and Supplementary Video 2), as well as MDN stimulation and spontaneous backwards walking on a cylindrical treadmill (Extended Data Fig. 2c and Supplementary Video 2). In each case, we observed that populations of GNG DNs were recruited during both optogenetic stimulation and natural behaviour. For backwards walking, these patterns were largely similar across optogenetic and natural conditions (Extended Data Fig. 2c). However, for forwards walking (Extended Data Fig. 2a) and, to a lesser extent, for anterior grooming (Extended Data Fig. 2b), there were some differences. DNp09 stimulation consistently and strongly activated a small subset of DNs located in the medial–dorsal and medial–ventral connective, which were not active during spontaneous forwards walking (Extended Data Fig. 2d–f). However, the remaining largest fraction of DNs were active in a similar manner during optogenetic DNp09 stimulation and during spontaneous forwards walking (Extended Data Fig. 2e, white region).

We next considered how comDNs might recruit additional GNG DNs. On the one hand, it could be through connections within the brain. On the other hand, it could be indirectly via the VNC. For example, a DN might target (or indirectly drive) an interneuron in the VNC, which in turn ascends to the brain and engages GNG DNs. To determine whether DN recruitment can arise from brain connections alone, we resected the VNC in the anterior-most prothoracic (T1) neuromere to sever axonal projections of DNs to the VNC and of ascending neurons to the brain. We then performed functional imaging of GNG DNs during optogenetic stimulation of DNp09 (Extended Data Fig. 3a and Supplementary Video 1) and observed that GNG DNs were still co-activated in T1-severed animals (Extended Data Fig. 3b–e) but not in control flies without a DN driver (Extended Data Fig. 3f–j). This confirms that connections in the brain can be sufficient for DN recruitment.

Together, these data show that optogenetic stimulation of comDNs leads to the recruitment of many additional DNs in a manner that, particularly for backwards walking and antennal grooming, is similar to DN population activity during natural behaviour.

ComDNs connect to DN networks

The functional recruitment of GNG DNs by comDNs could arise from various circuit mechanisms in the brain. Broadly speaking, it might either result from direct, monosynaptic excitatory connections or indirectly via local interneurons. We investigated these possibilities by examining DN–DN connectivity within the female adult fly brain connectome7,37,38. There, we identified our three sets of comDNs—DNp09, aDN2 and MDN (Fig. 3a)—and all of their downstream partners. We found that each comDN has direct, monosynaptic connections to other DNs (Fig. 3b).

Fig. 3: ComDNs connect to other DNs, forming larger DN networks.
figure 3

a, The neuronal morphologies of three sets of comDNs in the female adult fly brain connectome: DNp09 (left), aDN2 (middle) and MDN (right)7. b, The location and morphologies of DNs directly (monosynaptically) targeted by comDNs. DNs are colour coded based on their cell body localization in the GNG (orange) or CRG (purple). Command-like neurons are colour coded as in a. c, ComDNs form monosynaptic excitatory connections to downstream DN targets. Edge weights reflect the number of synapses as shown in d, with consistent scaling across all plots. Edge colours denote whether synapses are excitatory (red), inhibitory (blue) or glutamatergic (pink), which can be excitatory or inhibitory depending on the receptor type60. DNs are colour coded as in b. d, Network connectivity among downstream DNs shows strong recurrence and minimal feedback to comDNs (only in aDN2). e, The cumulative number of downstream DNs that three sets of command-like neurons—DNp09 (green lines; 2 DNs), aDN2 (red lines; 2 DNs), MDN (cyan lines; 4 DNs)—connect to across an increasing number of DN–DN synapses or ‘hops’. This is compared with the number of DNs accessible over an increasing number of hops for all DNs (grey lines) and the median of all DNs (black line). Many DNs do not connect to any other DN, and 455 DNs only receive inputs from maximally one other DN, limiting the maximum number of recruited DNs to approximately 800.

On the basis of the predictions from electron microscopy images, our three sets of comDNs are cholinergic7,39. Thus, they probably form excitatory connections with downstream DNs (Fig. 3c, red arrows). These connections are predominantly feedforward with only sparse feedback connections for aDN2 (Fig. 3d). By contrast, among their downstream DNs, we observed strong recurrent interconnectivity, including some inhibition (Fig. 3d, blue arrows). Of note, the three sets of comDNs connect to a variable number of downstream DNs, which mirrors their differential recruitment of GNG DNs during our functional imaging experiments (Fig. 2i): those for forwards walking (DNp09) have the most downstream DNs (32), whereas those for antennal grooming (aDN2) have fewer (23) and those for backwards walking (MDN) have the fewest (14). This ordering also holds for polysynaptic connections to downstream DNs (Fig. 3e). These data support a mechanism in which comDNs engage additional DN populations in the brain via direct excitatory connections.

Behavioural requirement of DN recruitment

We next asked to what extent the recruitment of additional DN populations is necessary for comDNs to drive complete behaviours. To do this, we needed to stimulate comDNs while preventing the recruitment of additional DN populations. Sensory neurons in the brain provide inputs to help initiate and regulate natural behaviours, whereas DNs are thought to integrate these signals to drive specific motor actions. In this experiment, we aimed to identify which elements of behavioural kinematics result solely from optogenetic stimulation of comDNs alone, without also recruiting sensory inputs to the brain or other downstream DNs in the brain (Fig. 4a, right). We achieved this by studying animals that were carefully decapitated with their exposed necks sealed. Following decapitation, flies can survive and generate behaviours for hours40. A less invasive approach—acute optogenetic inhibition of GNG DNs using GtACR1 (ref. 41)—would inhibit only a fraction of all DNs and, when tested, caused animals to groom even at low light intensities (Extended Data Fig. 1g), obstructing analysis of comDN-driven behaviours.

Fig. 4: Recruited DN networks are required for forwards walking and grooming, but not for backwards walking.
figure 4

a, In intact animals (left), activation of a comDN (green) recruits other DNs (orange) and leads to the execution of a complete behaviour. In headless animals (right), the axons of comDNs (green) can still be activated in the VNC. However, other DN axons (orange) cannot be recruited in the brain and remain silent. This comparison between intact and headless animals allows one to isolate the necessity of downstream DN networks to generate complete behaviours. be, Forwards walking velocities and behaviour probabilities for DNp09 (b), aDN2 (c), MDN (d) or control (e) flies. Mann–Whitney U-tests compare the difference between the means of the first 2.5 s of optogenetic stimulation across intact (black traces) versus headless (blue traces) animals. f, DNp09 stimulation in both intact and headless animals leads to abdominal contraction (change in Euclidian distance between the anal plate and the ventral side of the most posterior stripe). Mann–Whitney U-test compares the mean of the first 2.5 s of stimulation (blue bars) for headless DNp09 versus headless control animals (blue traces). g, aDN2 stimulation in both intact and headless animals leads to front leg approach (change in Euclidian distance between the front leg tibia–tarsus joint and the neck). Mann–Whitney U-test compares the first 2.5 s of stimulation (blue bars) between headless aDN2 and headless control animals (blue traces). All plots in bg show data from n = 5 flies with 10 trials each (trial mean and 95% CI (shaded area)). Two-sided Mann–Whitney U-tests compare the trial mean across different flies. ***P < 0.001, **P < 0.01, *P < 0.05 and not significant (NS) P > 0.05. For exact P values, see Supplementary Table 5.

Source Data

Using this approach, we compared the behaviours of intact and headless animals upon optogenetic activation of comDNs. As for our previous experiments, stimulation of DNp09, aDN2 and MDN in intact animals drove forwards walking, antennal grooming and backwards walking, respectively (Fig. 4b–d, black traces), with no reliable behaviour generated in control animals (Supplementary Video 3) (Fig. 4e, black traces). After decapitating these same animals, we found that the activation of MDN in headless flies still drove backwards walking. This confirms that decapitation does not trivially impair movement generation (Fig. 4d; P = 0.265 comparing the backwards walking probabilities of headless versus intact flies). By contrast, decapitation had a different effect on the other two comDNs: DNp09 and aDN2 stimulation in headless animals did not elicit forwards walking (Fig. 4b; P = 0.006) or antennal grooming (Fig. 4c; P = 0.006), respectively. However, these headless animals could still exhibit behaviours distinct from control animals; optogenetic stimulation of DNp09 and aDN2 in headless flies reliably elicited stereotyped abdomen contraction for DNp09 (Fig. 4f; P = 0.006 comparing headless DNp09 versus headless control animals) and front leg approach for aDN2 animals (Fig. 4g; P = 0.030 comparing the distance between the tibia–tarsus joint and neck in headless aDN2 versus headless control animals). These observations confirm that DN axons in the VNC alone are capable of activating downstream VNC motor circuits in headless animals and led us to posit that differences in optogenetically driven behaviours between intact and headless flies result from the failure to recruit additional, downstream DN networks in the brain. The fact that functional recruitment of DN populations is necessary for comDNs to drive some behaviours (that is, forwards walking and antennal grooming via DNp09 and aDN2 stimulation, respectively), but not others (backwards walking via MDN stimulation), implies several distinct modes of DN behavioural control that we next set out to explore.

Network size predicts behavioural necessity

Our results thus far revealed a correlation between three properties of comDNs (Fig. 5a, top): (1) the functional recruitment of other DNs (Fig. 2), (2) the degree of monosynaptic connectivity to downstream DNs (Fig. 3), and (3) the necessity of recruiting downstream DNs to generate complete optogenetically driven behaviours (Fig. 4). Together, these properties suggest that comDNs may lay on a continuum. ‘Broadcaster’ DNs, such as DNp09, have a large number of downstream DNs that must be recruited to generate behaviours, possibly by combining multiple motor primitives42,43. By contrast, ‘standalone’ DNs, such as MDN, have few or no downstream DNs and may by themselves be sufficient to drive behaviours that are largely dependent on VNC circuitry alone (Fig. 5a). Thus, for a given comDN, one might be able to predict the behavioural outcome of optogenetic stimulation in intact versus headless animals based on the number of downstream DNs that it is connected to. Specifically, broadcaster or standalone DNs should show, respectively, either a strong or weak degradation of their associated optogenetically driven behaviours following decapitation (Fig. 5a, light blue box).

Fig. 5: Network connectivity accurately predicts the necessity for downstream DNs to drive behaviour.
figure 5

a, For the comDNs investigated, three important properties covary in a continuum that spans from broadcaster DNs to standalone DNs. Schematized along this continuum are our three comDNs, giant fibre (GF) neurons and nine additional tested neurons: DNp42, aDN1, DNa01, DNb02, DNa02, oviDN, DNg11, Mute and DNg14. b, For each Drosophila DN, the total (grey) or GNG-based (orange) number of monosynaptically downstream DNs. ComDNs are colour coded. The inset shows median and 25% and 75% quantiles (left violin plot, n = 1,303) comparing all DNs to DNp09, aDN2 and MDN. c, The number of DNs directly downstream of nine additional sets of DNs (colour-coded circles as in a) for which connectome-based experimental predictions are made. All DNs (grey) shown are as in b. d, The morphology of two sets of DNs (DNb02 and DNg14) in the female adult fly brain connectome. e, Monosynaptic connectivity for two tested DNs (DNb02 and DNg14). Edge weights denote the number of glutamatergic synapses (pink). f, Absolute, undirected turn velocity for DNb02 (top) and control (bottom) animals upon laser stimulation. g, Abdomen dipping for DNg14 (top) and control (bottom) animals upon laser stimulation (change in anal plate vertical position). In f,g, data are shown for intact (black traces) and headless (blue traces) animals. The number of animals is indicated for each condition. Each fly was optogenetically stimulated ten times. Traces show the average and 95% CI across n × 10 trials. Two-sided Mann–Whitney U-tests comparing the trial mean of intact and headless animals (black bars) or comparing headless experimental with headless control flies (blue bars, between top and bottom plots). **P < 0.01, *P < 0.05 and NS P > 0.05. For exact P values, see Supplementary Table 5.

Source Data

To test this hypothesis, we examined direct DN–DN connectivity across all DNs in the brain connectome38 to identify additional broadcaster and standalone DNs. We observed a continuum of interconnectivity for DNs across the brain (Fig. 5b, grey) that was also present for connections to GNG-based DNs specifically (Fig. 5b, orange): a few DNs have dozens of DN partners, whereas hundreds of others have no downstream DN partners. This continuum ranging from well-connected broadcaster DNs to sparsely connected standalone DNs held true even when accounting for both excitatory and inhibitory connections (Extended Data Fig. 4a–c), excitatory connections alone (Extended Data Fig. 4d–f) or inhibitory connections alone (Extended Data Fig. 4g–i). These differences also persisted when accounting for disynaptic connections via another DN (Extended Data Fig. 4b,e,h) or via any other brain interneuron (Extended Data Fig. 4c,f,i).

Our three sets of comDNs lie in the middle of this continuum with higher connectivity than most DNs (median number of connected DNs: all DNs (4), MDN (9), aDN2 (15) and DNp09 (23); Fig. 5b, inset). Of note, consistent with our model, giant fibre neurons, which are known to drive relatively stereotyped, ballistic escape behaviours in both intact and headless animals44,45, have only a few DN partners (three and four for the left and right giant fibre neurons, respectively; Fig. 5a, grey circle). We selected an additional nine sets of DNs along this continuum of connectivity (Fig. 5c, squares in colour) based on specific connectivity criteria (see Methods) and the availability of transgenic driver lines for optogenetic stimulation14,15.

Data from optogenetically stimulating these nine sets of DNs in both intact and headless animals confirmed our predictions: DNs with many downstream DN partners drove behaviours that were lost in headless animals (Extended Data Fig. 5), whereas DNs with few or no downstream DN partners elicited simple, stereotyped movements (for example, abdominal curling and ovipositor extension) that persisted following decapitation (Extended Data Fig. 6). Among broadcasters, this degradation of behaviour was most profound for DNb02, which connects to 20 other DNs (Fig. 5d,e) and drives turning in intact animals. In headless animals, DNb02 stimulation does not elicit turning (Fig. 5f; P = 0.001 comparing intact and headless flies), but instead drives flexion of the front legs upon stimulation onset (Supplementary Video 4). This is noticeable as a small spike in forwards velocity in headless animals (Extended Data Fig. 5d). Similarly, for other broadcasters, we observed a loss of backwards retreat in DNp42 (Extended Data Fig. 5a and Supplementary Video 4) and turning in DNa01 (Extended Data Fig. 5c and Supplementary Video 4) and DNa02 (Extended Data Fig. 5e and Supplementary Video 4) headless animals. aDN1 animals retained only uncoordinated front leg movements following decapitation (Extended Data Fig. 5b and Supplementary Video 4).

Among standalone DNs, the maintenance of stereotyped movements was most clear for DNg14, which do not directly synapse upon any other DN (Fig. 5e). These neurons drive a subtle dip and vibration of the abdomen in both intact and headless animals (Fig. 5g and Extended Data Fig. 6d; P = 0.144; Supplementary Video 5). Similarly, for other standalone DNs, in both intact and headless animals, we observed a downward curling of the abdomen in oviDN flies (Extended Data Fig. 6a and Supplementary Video 5), foreleg rubbing in DNg11 flies (Extended Data Fig. 6b and Supplementary Video 5) and ovipositor extension in Mute flies (Extended Data Fig. 6c and Supplementary Video 5). Thus, our experiments on a total of 12 sets of DNs support a model in which the connectivity of a comDN to other DNs is predictive of its necessity for network recruitment to generate behaviour.

Network clusters correlate with behaviour

Our investigation of the brain connectome revealed that DN–DN connectivity lies on a continuum: a few DNs have very high connectivity (for example, with more than 80 downstream DNs), whereas 567 (44%) target only two or fewer DNs (Fig. 5b). This overall structure of DN networks has implications for how information flows between neurons, motivating us to examine the large-scale structure of the entire DN network. We compared the DN network derived from the fly brain connectome with a shuffled network having the same number of neurons and interconnections, but with individual connections randomly assigned. We found that the connectivity degree distribution (that is, the distribution of how many other DNs each DN connects to) is dramatically different (R2 = −0.04 comparing connectivity distributions) for real (Fig. 6a, black) versus shuffled (Fig. 6a, red) DN networks. This is largely because very strongly connected DNs (more than 30 partners) and very weakly connected DNs (fewer than 5 partners) only appear in the real DN network but not in the shuffled network. That the original DN network can be fit better by an exponential (R2 = 0.92; Fig. 6a, green) or a power law (R2 = 0.79; Fig. 6a, blue) degree distribution indicates that it has intrinsic network structure. A power law connectivity degree distribution is the defining feature of a scale-free network46,47 and hints that DNs may be linked via well-connected ‘hub’ neurons.

Fig. 6: Networks of DNs for similar behaviours excite one another and inhibit those for other behaviours.
figure 6

a, The connectivity distribution of the DN–DN network (black), the same data after shuffling individual connections (red), the best exponential fit (green) or the best power law fit (blue). b, DN–DN connectivity clusters (grey squares) indicating excitatory (red) and inhibitory (blue) connectivity between presynaptic DNs (rows) and postsynaptic DNs (columns). The numbers on the right side indicate cluster numbers in d,fi. c, As in b, but for a network with shuffled DN–DN connectivity. d, The number of synapses (excitatory minus inhibitory) between any two clusters normalized by the number of DNs in the postsynaptic cluster. e, As in d, but for the shuffled network in c. f, Fraction of known DNs within each cluster projecting to different VNC neuropil regions. Anm, abdominal neuromere; HTct, haltere tectulum; IntTct, intermediate tectulum; LTct, lower tectulum; mVAC, medial ventral association centre; NTct, neck tectulum; Ov, ovoid; T1–T3, leg neuropils; WTct, wing tectulum. Data are from ref. 13. g, Fraction of known DNs within each cluster associated with distinct behaviours. Data are taken from the literature (Supplementary Table 8). Open squares indicate clusters containing fewer than five known DNs (f,g). h, The distribution of experimentally investigated DNs across DN clusters. i, A network visualization of clusters in d with associated behaviours from g. There are predominantly excitatory (red) connections within each DN cluster and inhibitory (blue) connections between clusters.

Inherent structure within this network also implies the existence of subnetworks, or clusters, with unique properties. To explore this possibility, we identified clusters of DNs in the fly brain by applying the Louvain method, a community detection algorithm48. Indeed, we could reliably identify multiple clusters of DNs with strong interconnectivity (Fig. 6b, grey boxes). When we applied the same algorithm to our shuffled network, we only inconsistently found small clusters (Fig. 6c, grey boxes). This was apparent in the number of DNs in the five largest clusters for the original DN–DN network (726 ± 42 neurons) versus the shuffled DN–DN network (581 ± 51 neurons; mean ± s.d., P < 0.001 comparing 100 repetitions of the Louvain method). Within clusters, we observed predominantly strong excitatory connections (Fig. 6d, diagonal elements). By contrast, connectivity between clusters was dominated by inhibition (Fig. 6d, off-diagonal elements). In the shuffled DN–DN network, this inhibition was weaker and more uniformly distributed (Fig. 6e, off-diagonal elements).

Distinct excitatory clusters imply parallel DN modules with distinct anatomical and/or functional properties. We investigated this possibility by first asking whether DN clusters (with similar connectivity in the brain) connect to similar targets in the VNC. Specifically, we studied the projections of known DNs2,14 within the VNC connectome of an adult male fly13. This analysis revealed very specific projection patterns including, for example, that cluster 1 predominantly projects to a neuropil controlling the front legs (T1), cluster 2 predominantly to the lower tectulum (LTct), clusters 3 and 5 most strongly to all three leg neuropils (T1, T2 and T3), and clusters 4, 7, 9 and 10 predominantly to dorsal neuropils involved in wing, haltere and neck control (WTct, HTct and NTct, respectively) (Fig. 6f).

These results strongly suggest that specific excitatory DN clusters may also regulate distinct behaviours. To investigate this possibility, we identified 132 known DNs that have been shown or are predicted to be involved in anterior movements, walking, take-off, flight and landing (Supplementary Table 8). Indeed, we found that clusters included DNs with known links to specific behaviours and VNC projections (Fig. 6g). For example, as might be expected, DNs related to anterior grooming—DNg10 (ref. 21), DNg12 (ref. 21), aDN1 (ref. 4) and aDN2 (ref. 4)—were predominantly in cluster 1 targeting the T1 neuropil controlling the front legs. ComDNs that we studied experimentally were also in behaviourally consistent clusters (Fig. 6h). aDN1 and aDN2 are in the ‘anterior grooming’ cluster 1, whereas DNp09, MDN, DNa01, DNa02 and DNb02 are in the ‘walking’ or ‘steering’ clusters 3 and 9, with neurons in the right hemisphere being assigned mainly to cluster 3 and those in the left hemisphere being assigned to cluster 9 (Extended Data Fig. 7).

These data support the model that DNs form networks to orchestrate particular behaviours. A closer look at the comDNs that we tested experimentally supports this community-based inference (Extended Data Fig. 8a). First, DNp09 neurons driving forwards walking have direct excitatory connections with both DNa02 and DNb02 (Extended Data Fig. 8b), which, when optogenetically activated, elicit turning (Extended Data Fig. 5d,e). Second, aDN2 antennal grooming neurons connect directly to aDN1 neurons (Extended Data Fig. 8c), which also elicit antennal grooming (Extended Data Fig. 5b). Third, MDN backwards walking neurons connect to DNa01 neurons (Extended Data Fig. 8d), which, when activated, elicit turning (Extended Data Fig. 5c). Fourth, beyond DNs that we tested experimentally, we found that BDN2 and oDN1 (ref. 49)—two sets of recently discovered comDNs that drive walking—have similar DN connectivity patterns (Extended Data Fig. 8e) and interconnectivity to DNp09 (Extended Data Fig. 8f–h). In addition, we observed similar (Extended Data Fig. 8i) and mutual (Extended Data Fig. 8j,k) connectivity among DNs known to drive antennal grooming (aDN1 and aDN2). Together, these data support a model in which distinct behaviours are orchestrated by specific excitatory DN networks.

Of note, some clusters receive strong inhibition from other clusters. For example, cluster 2 related to take-off inhibits cluster 3 related to walking (Fig. 6i). Within these two clusters, excitatory connections prevail (Extended Data Fig. 9a,b). However, inhibitory DNs within cluster 2 project strongly to cluster 3 (Extended Data Fig. 9c,d). In particular, four cluster 2 ‘web’ DNs15 inhibit a large number of cluster 3 DN targets (96, 86, 45 and 41 DNs) (Extended Data Fig. 9d, asterisks). These inhibitory connections are well poised to contribute to action selection and the suppression of conflicting behaviours.


Here, by combining optogenetic activation, functional imaging and brain connectome analysis, we have resolved two seemingly conflicting observations: the activation of a few comDNs is sufficient to drive complete behaviours such as forwards walking even though many more DNs are co-active when the same behaviour is generated naturally. To explain this discrepancy, we have found that precise stimulation of multiple classes of comDNs recruits activity in many additional DNs. Thus, the ‘command’ signal is not only conveyed directly to the VNC, but can also be sent to other brain neurons that convey additional descending signals. There are a number of circuit motifs that could give rise to DN–DN interactions. Although we focus on monosynaptic connectivity, we have also shown that comDNs (DNp09, aDN2 and MDN) ultimately reach—and may potentially co-activate—hundreds of other DNs within only a few synapses. Future work may map the identity of recruited DNs by matching volumetric imaging data to anatomical templates from connectomes50.

Our experiments and brain connectivity analyses for 12 sets of comDNs show that they lie along a continuum of interconnectivity in which those targeting larger downstream DN populations require network recruitment to generate a complete behaviour, whereas those with fewer DN partners largely do not. These results are consistent with a descending control model in which most DNs drive relatively simple body part kinematics. Other privileged DNs (for example, comDNs) can then directly recruit an assortment of such DNs to construct a full behaviour. This resembles the proposal drawn from work in other insects that descending fibres ‘act in consensus’ to assemble a complete behaviour51. Each of these individual fibres may drive distinct ‘motor primitives’—fundamental kinematic elements which, when combined, have been suggested to underlie both innate and learned behaviours in vertebrates and mammals42,43,52,53,54. Consistent with this framework, a recent study of DN control during walking in Drosophila has shown that specific DN classes control limb movement ‘gestures’ akin to motor primitives55.

For a given comDN, we speculate that the number of actively controlled joints or appendages engaged to generate its behaviour may be reflected by the size of its downstream DN network (Extended Data Fig. 10a). Consistent with this, we found that behaviours driven by stimulating broadcaster DNs (for example, walking and turning) appear more complex than movements driven by stimulating standalone DNs (for example, abdomen curling and ovipositor extension). A similar distinction has been suggested for the descending control of complex (for example, forwards walking) versus simple, stereotyped (for example, stridulation) behaviours in Orthoptera56. To take a quantitative example from our own study, DNp09 requires its large downstream DN network to drive forwards walking, but MDN does not require a relatively small downstream DN network to drive backwards walking. We found that MDN-driven backwards walking only depends on active movements of the two hindlegs57 (Extended Data Fig. 10b and Supplementary Video 6), whereas DNp09-driven forwards walking can be controlled by active movements of any two pairs of the six legs (Extended Data Fig. 10c–e and Supplementary Video 6).

A framework in which comDNs recruit additional DNs to generate complete behaviours suggests an efficient substrate for the evolution of new behaviours or the diversification of existing behaviours (for example, species-specific courtship displays) through the de novo coupling or uncoupling of DNs and their associated motor primitives. This mechanism is therefore likely also used for descending control in other species including mammals27,52 and suggests new avenues for the design of more flexible artificial controllers in engineering and robotics58.


Fly stocks and husbandry

All experiments were performed on female adult D. melanogaster raised at 25 °C and 50% humidity on a 12-h light–dark cycle. The day before optogenetic experiments (22–26 h prior), we transferred experimental and control61 flies to a vial containing food covered with 20 μl all trans-retinal (ATR) solution (100 mM ATR in 100% ethanol; Sigma Aldrich R2500, Merck) and wrapped in aluminium foil.

Functional imaging and behaviour experiments

We generated transgenic flies expressing LexAop-opGCaMP6s (a gift from O. Akin62) under the control of a Dfd-LexA driver (a gift from J. Simpson63) and having a copy of UAS-CsChrimson (Bloomington ID 55135) (Supplementary Table 1, ID 1). We also generated flies that additionally had the LexAop-tdTomato transgene (Bloomington ID 77139) (Supplementary Table 1, ID 2). For most experiments, we used flies without tdTomato expression.

MDN-spGAL4 flies (also known as MDN3 from ref. 2) were used to drive backwards walking. aDN2-spGAL4 flies (also known as aDN2-spGAL4-2 from ref. 4) were used to drive antennal grooming. DNp09-spGAL4 flies (from ref. 3) were used to drive forwards walking. Their genotypes2,3,4,14,15,22,64 are listed at the top of Supplementary Table 2.

For all experiments in Figs. 2 and 4, we crossed spGAL4 flies or wild-type flies (Phinney Ridge flies, Dickinson laboratory) with one of our stable transgenic driver lines for imaging (Supplementary Table 1, ID 1 or ID 2). For Fig. 2, flies were 2–9 days post-eclosion and experiments were performed at Zeitgeber time 7–13 (ZT7–13). For Fig. 4, flies were 2–9 days post-eclosion and experiments were performed at ZT4–7. For Fig. 5, Extended Data Figs. 5, 6 and 10, we crossed spGAL4 lines with 20XUAS-CsChrimson.mVenus (attP40) flies (Bloomington ID 55135). Control experiments were performed by crossing wild-type flies (Phinney Ridge flies, or Canton S) to 20XUAS-CsChrimson.mVenus (attP40). The exact genotypes of the split lines and the source stocks are listed in Supplementary Table 2. All experiments were performed on flies 4–8 days post-eclosion at ZT4–7.

Confocal imaging experiments

We generated flies with stable Dfd-driven expression of membrane-targeted tdTomato or nuclear-targeted mCherry based on flies generated by the McCabe laboratory (EPFL) (Supplementary Table 1, IDs 3 and 4). For the three spGAL4 driver lines targeting comDNs (MDN, DNp09 and aDN2), we generated stable lines expressing CsChrimson (Supplementary Table 1, IDs 5, 6 and 7). We crossed flies expressing a red fluorescent protein variant with flies expressing CsChrimson in a spGAL4 driver line to visualize the expression patterns using confocal microscopy (Extended Data Fig. 1).

Recording from DNs using a Dfd driver line

We leveraged a genetic-optical intersectional approach to selectively record from GNG DNs. We chose to record from GNG DNs because we found that 73% of all DN–DN synapses in the brain connectome are in the GNG. In addition, the GNG houses 60% of all DNs and 85% of all DNs have axonal output in the GNG14. However, the Hox gene Dfd does not include the entirety of all GNG DNs: it excludes those driven by the Hox gene Sex combs reduced (Scr)65. Sterne et al.15 have estimated that 550 cells in the GNG are Dfd positive and 1,100 are Scr positive, with only a small fraction expressing both. We show, for example, that aDN2, although localized to the GNG, is Dfd negative and thus most likely Scr positive (Extended Data Fig. 1c). In our study, functional imaging of DNs using an Scr driver line proved difficult because Scr expression extends into the neck and anterior VNC63. Specifically, we observed strong expression of GCaMP in the tissues surrounding the thoracic cervical connective (potentially ensheathing glia66), making it very hard to record the activity of DN axons. We expect that some Scr-positive DNs will also be recruited by comDNs. Thus, we probably under-report the number of recruited GNG DNs.

Limitations of selected spGAL4 driver lines

In addition to descending neurons, our aDN2-spGAL4 driver line (aDN2-GAL4.2 (ref. 4)) contains two more groups of neurons. One pair is on the anterior surface of the brain and, based on our control experiments, is probably not or only weakly activated by targeted optical stimulation of the neck (and not at all activated by thoracic stimulation). Another is a set of neurons in the anterior VNC. Because other driver lines targeting aDN2 neurons with more, different off-target neurons have the same behavioural phenotype as our aDN2 driver4, we are confident that the effects that we observed are due to stimulating aDN2 neurons.

Different studies have reported variable behavioural phenotypes for stimulating the DNp09-spGAL4 driver line: some saw forwards walking3, whereas others observed stopping or freezing18,67. We observed both: at our standard 21-μW optogenetic stimulation power, heterozygous animals mostly walked forwards. Occasionally, flies would only transiently walk forwards and then stop, or alternate rhythmically between walking and stopping. With higher expression levels of CsChrimson (that is, DNp09-spGAL4 > UAS-CsChrimson homozygous animals), we observed mostly freezing. We used heterozygous animals for our study.

Immunofluorescence tissue staining and confocal imaging

We dissected brains and VNCs from 3 to 6 days post-eclosion female flies as described in ref. 68.

For samples in Extended Data Fig. 1a,c, we fixed flies in 4% paraformaldehyde (PFA; 441244-1KG, Sigma Aldrich, Merck) in 0.1 M PBS (Gibco PBS, pH 7.4, 10010-015, Thermo Fisher Scientific). We then washed them six times for 10 min with 1% Triton (Triton X-100, X100-100ML, Sigma Aldrich, Merck) in PBS (hereafter named 1% PBST) at room temperature. We then transferred them to a solution of 1% PBST, 5% natural goat serum (goat serum from controlled donor herd, G6767-100ML, Sigma Aldrich, Merck) and primary antibodies (see Supplementary Table 3) and left them overnight at 4 °C. We then washed the samples six times for 10 min with 1% PBST at room temperature. We transferred them to a solution of 1% PBST, 5% natural goat serum and secondary antibodies (see Supplementary Table 3) and left them for 2 h at room temperature. We then washed the samples six times for 10 min with 1% PBST at room temperature. We mounted the samples on glass slides using SlowFade (SlowFade Gold Antifade Mountant, S36936, Thermo Fisher Scientific) and applied a coverslip. To space the slide and the coverslip, we placed a small square of two layers of double-sided tape at each edge. We sealed the edges of the coverslip with nail polish.

For samples in Extended Data Fig. 1b, we fixed flies in 4% PFA in PBS and transferred them to 1% PBST and left them overnight at 4 °C. We then washed the samples three times for 15 min with 1% PBST at room temperature. We transferred them to a solution of 1% PBST, 5% natural goat serum and primary antibodies (see Supplementary Table 3) and left them overnight at 4 °C. We then washed the samples three times for 15 min with 1% PBST at room temperature. We transferred them to a solution of 1% PBST, 5% natural goat serum and secondary antibodies (see Supplementary Table 3) and left them overnight at 4 °C. We then washed the samples three times for 15 min with 1% PBST at room temperature. We mounted the samples on glass slides using SlowFade and applied a coverslip. To space the slide and the coverslip, we applied a small square of two layers of double-sided tape at each edge. We sealed the edges of the coverslip with nail polish.

We imaged samples using a Leica SP8 Point Scanning Confocal Microscope with the following settings: ×20, 0.75 NA HC PL APO dry objective, 2× image averaging, 1,024 × 1,024 pixels, 0.52 × 0.52-μm pixel size, 0.5-μm z-step interval; green channel 488-nm excitation, 50–540-nm emission bandpass; red channel (imaged separately to avoid cross-contamination) 552-nm excitation, 570–610-nm emission bandpass; and infrared channel (nc82, imaged in parallel with the green channel) 638-nm excitation, 650–700-nm emission bandpass. We summed confocal image stacks along the z-axis and rotated and translated the images to centre the brain/VNC using Fiji69.

Optogenetic stimulation system and approach

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 analogue and digital control signals coming from an Arduino with custom software. A digital signal was used to turn the laser on and off. An analogue signal (PWM output from Arduino and RC low-pass filtered) was used to modulate the power. Both of those signals were sent in parallel to the laser and acquisition board and were recorded alongside the two-photon microscope signals using ThorSync 3.2 software (Thorlabs). The light was directed towards the fly with multiple mirrors. Fine control of the target location was achieved using a kinematic mount (KM100, Thorlabs) and a galvanometric mirror (GVS011/M, Thorlabs). We manually optimized targeting of the laser onto the neck/thorax 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. For stimulation of the inhibitory opsin GtACR1, we used the same system, but with a 561-nm laser (Coherent OBIS 1280720 561 nm LS 150 mW, Edmund Optics) instead of a 640-nm laser to better match the optical excitation spectrum of GtACR1.

We note that, although comDNs have axon collaterals in the GNG, none of the comDNs in this study were among the DN populations that we imaged: DNp09-spGAL4 and MDN-spGAL4 lines drive expression in neurons with cell bodies in the cerebral ganglia and not in the GNG (Extended Data Fig. 1a). The DN cell bodies of the aDN2-spGAL4 line are within the GNG but do not overlap with Dfd driver line expression (Extended Data Fig. 1c). Thus, we could be certain that any active DNs would be recruited through synaptic connections and not optogenetically. We identified laser light intensities that could elicit robust forwards walking, anterior grooming and backwards walking (Fig. 2a and Extended Data Fig. 1d).

We used different laser intensities to stimulate MDN (21 μW), DNp09 (21 μW) and aDN2 (41.6 μW) animals because 21-μW stimulation power mostly causes aDN2 animals to stop (Extended Data Fig. 1d). Activation of MDN in the head, neck and thorax was sufficient to trigger backwards walking (Extended Data Fig. 1e). Although some tissue scattering of laser light can be expected, in control experiments, we found that activation of the head capsule, but not the thorax, could strongly elicit forwards walking in the ‘bolt protocerebral neurons’ of the brain—these neurons are known to drive robust and fast forwards walking3 (Extended Data Fig. 1f). Stimulation (21 μW) was more specific than 41.6 μW, which is why we selected 21-μW stimulation for MDN and DNp09 as well as the spGAL4 lines tested (Fig. 5f,g and Extended Data Figs. 5 and 6). We regularly calibrated the laser intensity by measuring it with a power metre (PM100D, Thorlabs) and adjusting the analogue gain of the laser.

In vivo two-photon calcium imaging experiments

We performed two-photon microscopy with a ThorLabs Bergamo II two-photon microscope augmented with a behavioural tracking system as described in ref. 29. In brief, we recorded a coronal section of the thoracic cervical connective using galvo-resonance scanning at around 16-Hz frame rate. In addition, optogentic stimulation was performed as described above. We only recorded the green PMT channel (525 ± 25 nm) because the red PMT channel would be saturated by red laser illumination of the fly. In parallel, we recorded animal behaviour at 100 frames per second (fps) using two infrared cameras placed in front and to the right of the fly.

Flies were dissected to obtain optical access to the VNC and thoracic cervical connective as described in ref. 70. In brief, we mounted the fly to a custom stage by gluing its thorax and anterior head to the holder and removed its wings. Then, we opened the dorsal thorax using a syringe needle and waited for indirect flight muscles to degrade for approximately 1.5 h. We pushed aside the trachea and resected the gut and salivary glands. For some flies, where the trachea was obstructing the view, we placed a V-shaped implant71 into the thoracic cavity to push the trachea aside. We then placed the fly over an air-suspended spherical treadmill marked with a pattern visible on infrared cameras for ball tracking (air flow at 0.6 l min−1). While the fly was adapting to this new environment (approximately 15 min), the imaging region was identified and the optogenetic stimulation laser was centred onto the neck.

We used ThorImage 3.2 to record and ThorSync 3.2 software to synchronize imaging data. We recorded 10,000 microscopy frames (around 10 min) while also recording behavioural data using cameras placed around the fly and presenting optogenetic stimuli. During a typical 10-min recording session, we presented 40 stimuli (5-s stimulation and 10-s inter-stimulus intervals). Whenever the recording quality was still good enough (that is, many neurons were visible and the fly still behaved healthily), we recorded multiple sessions to increase the number of stimulation trials. Many GNG DNs were active during spontaneous behaviour in the absence of optogenetic stimulation. Thus, to distinguish between GNG DN activity due to comDN stimulation versus the spontaneous initiation of behaviours, we only analysed trials for which flies were walking immediately before optogenetic stimulation. Because flies were quite spontaneously active, analysing trials for which flies were previously walking instead of resting increased the data available for trial averaging. It also allowed us to avoid laser light causing quiescent control animals to behave, obscuring our analyses.

Investigating natural behaviours

In Extended Data Fig. 2, we compared optogenetically elicited neural activity to activity observed during natural behaviours: forwards walking, anterior grooming and backwards walking. Natural forwards walking is frequently spontaneously generated by the flies. By contrast, we needed to stimulate the antennae with 5-s puffs of humidified air to increase the probability of natural grooming (Extended Data Fig. 2b). We provided humidified air puffs with an olfactometer (220A, Aurora Scientific) using the following parameters: 80 ml min−1 air flow, 100% humidity, 5-s duration and 20-s inter-stimulus interval. To have humid air puffs (that is, an abrupt change in flow rate) instead of a switch from dry air to humidified air—the default olfactometer configuration—we only connected the ‘odour’ tube to the final valve and not the ‘air’ tube. Furthermore, to increase the likelihood of spontaneous backwards walking (Extended Data Fig. 2c), we replaced the spherical treadmill with a custom cylindrical treadmill that we found increases the motivation to backwards walk. Specifically, we designed a 10-mm diameter, 80-mg 3D-printed wheel (RCP-30 resin) and printed it using stereolithography through digital light processing (Envisiontec Perfactory P4 Mini XL). This wheel was mounted on a low-friction jewel-bearing holder (ST-3D sapphire shafts, VS-40 sapphire bearings, Freudiger SA). We marked the sides of the wheel with infrared-visible dots to facilitate infrared camera tracking of rotations and calculations of velocity to classify bouts of backwards walking. When using the wheel, we added an additional third infrared camera to the left of the wheel, where dot markers were visible.

Recording neuronal activity of DNs after resecting the VNC

To record neuronal activity in Dfd DNs after cutting the VNC, we first mounted and dissected flies as described above for intact animals. We verified that the animal was responding to optogenetic stimulation where appropriate and that the animal was still healthy. Then, we used a pair of microscissors (FST, Clipper Neuro Scissors, no. 15300-00, Fine Science Tools GmbH) to cut the entire VNC in the T1 neuromere. We cut just posterior to the fat bodies surrounding the cervical connective. We verified that the VNC was cut by pulling on its posterior region with forceps. We then performed two-photon imaging and optogenetic stimulation as in experiments with intact flies (that is, laser stimulation of the neck while recording a cross-section of the cervical connective). We recorded 5,000 microscopy frames (around 5 min) with 20 stimulation repetitions. Flies were hanging freely from the stage and not placed on the spherical treadmill because the VNC was injured resulting in no notable leg movements. Post-hoc, we recorded a volume stack of the cervical connective and T1 neuromeres to verify the location of the cut.

Behavioural experiments in leg-amputated animals

To investigate the number of actively controlled appendages involved in forwards and backwards walking, we mounted flies to the same stages used for imaging and behaviour experiments. We recorded ten trials of responses to optogenetic stimulation on the spherical treadmill, leaving 25 s between each stimulation. We then used cold anaesthesia to amputate the legs of the flies, before letting the flies recover for at least 10 min. The amputation was performed bilaterally for either the front legs, mid-legs or hindlegs, using clipper scissors (FST, Clipper Neuro Scissors, no. 15300-00, Fine Science Tools GmbH). We amputated the legs at the level of the tibia–tarsus joint to minimize the lesion while removing tarsal adhesion. Once they recovered, we recorded flies again on the spherical treadmill for ten trials. The control flies used to investigate walking phenotypes were Canton S, in accordance with previous work on locomotion—in particular DNp09 (ref. 3).

Behavioural experiments in headless animals

For behavioural experiments, we mounted flies to the same stages used for two-photon imaging, but without gluing the anterior part of the head to the holder. Then, without further dissection, we placed animals onto the spherical treadmill. After recording ten trials of responses to optogenetic stimulation in intact animals, we decapitated the fly by inverting the holder and pushing a razor blade onto the neck. To achieve this, we mounted a splinter of the razor blade onto the tip of a pair of dissection forceps for finer control. We took care not to injure the legs of the fly and to make a clean cut without pulling out thoracic organs passing through the neck connective. To limit desiccation, we then sealed the stump of the neck with a drop of UV-curable glue. We only continued experiments on flies if their limbs were moving following decapitation. We then placed the headless flies onto the spherical treadmill and let them recover for at least 10 min. Then, we recorded ten trials of responses to optogenetic stimulation on the spherical treadmill and ten trials in which the fly was hanging from the holder without contacting the spherical treadmill. In experiments for testing connectome-based predictions, we slightly modified this experimental procedure. Because intact control animals become aroused by optogenetic stimulation, to avoid false positives and to discover behavioural phenotypes for less well-studied DNs, we attempted to reduce the spontaneous movements of flies. First, instead of 10 s between optogenetic stimulation trials, we used 25 s. Second, we filled the fly holder with room temperature saline solution to buffer heating from infrared illumination. For Extended Data Figs. 5 and 6, control flies (no DN > CsChrimson) were of the Phinney Ridge genetic background except for the later-studied DNp42, oviDN and DNg11, which were compared with control flies of the Canton S genetic background.

Data exclusion

We manually scored the quality of neural recordings (signal-to-noise ratio, occlusions, and so on) and the behaviour of the fly (rigidity, leg injury, among others) on a scale from 1 to 6 (where 1 is very good, 3 is satisfying and 6 is insufficient) for each 10-min recording session. We only retained sessions in which both criteria were at least at a ‘satisfying’ quality level. Unless indicated otherwise, we analysed trials in which the fly was walking before stimulus onset. Thus, we did not retain data from flies with less than ten trials of walking before stimulation. We chose to do this for several reasons: (1) GCaMP6s decays very slowly. Even if the fly was moving approximately 2 s before stimulation, we still observed residual fluorescence signals, increasing the variability of changes upon stimulation. There were only very few instances in which the animal was robustly resting for more than 2 s, making the inverse analysis impossible. (2) We observed that control flies became aroused upon laser light stimulation. Thus, they may begin moving if they were resting before stimulation, indirectly driving DN activity and making it harder to discriminate between optogenetically induced versus arousal-induced activity. Data from flies that were resting before stimulation exhibit recruitment patterns that are similar, although not identical (see data at DNp09 shows strong activation in the medial cervical connective (as for when the fly was walking before stimulation) and additional activation in lateral regions. The central neurons characteristic of aDN2 activation in animals that were previously walking are also active in animals that were previously resting. In addition, we observed more widespread, weaker activation. DN signals upon MDN activation were slightly more spread out when the fly was resting before stimulation.

For experiments with headless animals, we excluded data from flies in which one of the legs was visibly immobile after decapitation, when at least one leg was not displaying spontaneous coordinated movements, or when the abdomen was stuck to the spherical treadmill such that other movements became impossible.

Behavioural data analysis

For analysis, we used a custom Python code unless otherwise indicated. Code for behavioural data preprocessing can be found in the ‘twoppp’ Python package on GitHub ( previously used in ref. 71. Code for more detailed analysis can be found in the GitHub repository ( for this paper.

Velocity computation

As a proxy for walking velocities, we tracked rotations of the spherical treadmill using Fictrac72. Data from an infrared camera placed in front of the fly were used for these measurements as described in ref. 29. Raw velocity traces acquired at 100 Hz were noisy and thus low-pass filtered with a median filter (width = 5 = 0.05 s) and a Gaussian filter (σ = 10 = 0.1 s).

The velocity of the cylindrical treadmill was computed as follows. First, the wheel was detected in a camera on the left side of the fly using Hough circle detection. For each frame, we extracted a line profile along the surface of the wheel showing the dot pattern painted on its side. We then compared this line profile to the line profile of the previous frame to determine the most likely rotational shift. We converted this shift to a difference in wheel angle and then transformed this into a linear velocity in millimetres per second to make it comparable to quantification of spherical treadmill rotations. This image processing was prone to high-frequency noise. Therefore, we filtered raw velocities with a Gaussian filter (σ = 20 = 0.2 s).

2D pose estimation

We tracked nine keypoints from a camera on the right side of the fly: anal plate, ovipositor, most posterior stripe, neck, front leg coxa, front leg femur tibia joint, front leg tibia–tarsus joint, mid-leg tibia–tarsus joint and hindleg tibia–tarsus joint (see Fig. 1d) using SLEAP (v1.3.0)73.

Behaviour classification

We classified behaviours using an interpretable classifier based on heuristic thresholds on the walking velocity, limb motion energy and front leg height. For example, we classified forwards and backwards walking as having a forwards velocity of more than 1 mm s−1 and − 1 mm s−1 or less, respectively. All parameters are shown in Supplementary Table 4. If none of the conditions was fulfilled, we classified the behaviour as undefined.

Anterior grooming was composed of a logical ‘OR’ of two conditions: (1) the front leg was lifted up high, or (2) the front leg was moving with high motion energy. Front leg height was computed as the vertical distance between the front leg tibia–tarsus joint and the median position of the coxa. Pixel coordinates start from the top of the image. Thus, it is positive when the front leg is low (for example, during resting) and negative when the front leg is high (for example, during head grooming). Motion energy (ME) of the front legs, mid-legs and hindlegs was computed based on the movements of the respective tibia–tarsus joint as follows: \({\rm{ME}}=\sqrt{{(\Delta {x}_{t})}^{2}+{(\Delta {y}_{t})}^{2}}\), where Δxt and Δyt are the difference in x and y between two consecutive frames. We then computed the moving average of the motion energy within a 0.5-s (that is, 50 samples) window to focus on longer timescale changes in motion energy.

Two-photon microscopy image analysis

We used a custom Python code unless otherwise indicated. For all image analysis, the y axis is dorsal–ventral along the body of the fly, and the x axis is medial–lateral. Image and filter kernel sizes are specified as (y, x) in units of pixels. Code for two-photon data preprocessing can be found in the ‘twoppp’ Python package on GitHub ( previously used in ref. 71. Code for more detailed analysis can be found in the GitHub repository ( for this paper.

Motion correction

Recordings from the thoracic cervical connective suffer from large inter-frame motion including large translations, as well as smaller, non-affine deformations. Contrary to motion-correction procedures used before for similar data71, here we made use of the high baseline fluorescence seen in Dfd > LexAop-GCaMP6s animals instead of relying on an additional, red colour channel for motion correction. Thus, we performed motion correction directly on the green GCaMP channel. We compared the performance for data where a red channel was available and could only find negligible differences in ROI signals. Whether a neuron was encoding walking or resting was unchanged irrespective of whether we used the GCaMP channel or recordings from an additional red fluorescent protein.

We performed centre-of-mass registration on every microscopy frame to compensate for large cervical connective translations. We cropped the microscopy images (from 480 × 736 to 320 × 736 pixels). Then, we computed the motion field for each frame relative to one selected frame per fly using optic flow. We corrected the frames for this motion using bi-linear interpolation. The algorithm for optic flow motion correction was previously described in ref. 70. We only used the optic flow component to compute the motion fields and omitted the feature matching constraint. We regularized the gradient of the motion field to promote smoothness (λ = 800).

ROI detection

For each pixel, we computed the standard deviation image across time for the entire recording. This gives a good proxy of whether a pixel belongs to a neuron: it has high standard deviation because the neuron was sometimes active. We used this image as a spatial map of the recording to inform ROI detection. Example standard deviation images are also used as the background image for Fig. 2c.

We applied principal component analysis (PCA) on a subset of all pixels in the two-photon recording. We then projected the loadings of the first five principal components back into the image space. This gave us additional spatial maps integrating functional information to identify neurons. We then used a semi-automated procedure to detect ROIs; we performed peak detection in the standard deviation map. We visually inspected these peaks for correctness by looking at both the standard deviation map and the PCA maps. We manually added ROIs that the peak detection algorithm had missed, for example, because the neuron was only weakly active. The functional PCA maps allowed us to discriminate between nearby neurons with dissimilar functions. They might show up as one big peak in the standard deviation map, but would clearly be assigned to different principal components. We were able to annotate between 50 and 80 ROIs for each fly. The number of visible neurons varies due to GCaMP6s expression levels, dissection quality, recording quality and the behavioural activity level of the fly.

Neural signal processing

We extracted fluorescence values for each annotated ROI by averaging all pixels within a rhomboid shape placed symmetrically over the ROI centre (11 pixels high and 7 pixels wide). This gave us raw fluorescence traces across time for each neuron/ROI. We then low-pass filtered those raw fluorescence traces using a median filter (width = 3 = ~0.185 s) and a Gaussian filter (σ = 3 = ~0.185 s).

ΔF/F computation

Because of variable expression levels among cells, GCaMP fluorescence is usually reported as a change in fluorescence relative to a baseline fluorescence. Here we were mostly interested whether neurons were activated. To have a quantification that was comparable across neurons, we also normalized fluorescence of each neuron to its maximum level. Thus, we computed \(\Delta F/F=\frac{F-{F}_{0}}{{F}_{{{\max}}}-{F}_{0}}\), where F is the time-varying fluorescence of a neuron, F0 is its fluorescence baseline and Fmax is its maximum fluorescence. We computed Fmax as the 95% quantile value of F across the entirety of the recording. In rare instances, neurons would get occluded, or slight glitches of the motion-correction algorithm would result in some residual movement. Both of these make it challenging to estimate the minimum fluorescence. When the fly is resting, nearly all neurons are at their lowest levels (aside from several29) and there is usually less movement of the nervous system. Thus, we computed F0 as a ‘resting baseline’ as follows. First, using our behavioural classifier, we identified the onset of prolonged resting (at least 75% of 1 s after onset classified as resting and at least 1 s after the previous onset of resting) outside of optogenetic stimulation periods. For each neuron, we then computed the median fluorescence across repetitions aligned to resting onset. We then searched for the minimum value in time over the 2 s following rest onset. Taking the median across multiple instances of resting provided a more stable way to compute the baseline than by simply taking the minimum fluorescence. For flies that were not behaving (that is, those with resected VNCs shown in Extended Data Fig. 3), we could not compute a resting baseline and instead used the 5% quantile value as F0. The normalization using F0 and Fmax provided a way to compare fluorescence across multiple neurons with similar units. Thus, whenever we report absolute ΔF/F, a value of 0 refers to neural activity during resting and 1 refers to the 95% quantile of neural activity. When we report ΔF/F relative to pre-stimulus values (Fig. 2b–f,i and Extended Data Fig. 2), the unit of ΔF/F persists and a value of 0.5 means that the neuron has changed its activity level half as much as when it would go from a resting state to its 95% quantile state.

Video data processing

To process the raw fluorescence videos shown in Supplementary Videos 1 and 2 and in Fig. 2b, we first low-pass filtered the data with the same temporal filters as for ROI signals (median filter width = 3 = ~0.185 s, Gaussian filter σ = 3 = ~0.185 s). In addition, we applied spatial filters (median filter width = [3,3] pixels, Gaussian filter σ = [2,2] pixels). We then applied the same ΔF/F computation method described above, but for each individual pixel instead of for individual ROIs. Thus, the units used in the videos are identical to the units used for ROI signals in Fig. 2 and Extended Data Fig. 1.

Synchronization of two-photon imaging and camera data

We recorded two different data modalities at two different sampling frequencies: two-photon imaging data were recorded at approximately 16.23 Hz and behavioural images from cameras were acquired at 100 Hz. We synchronized these recordings using a trigger signal acquired at 30 kHz. When it was necessary to analyse neural and behavioural data at the same sampling rate (for example, Supplementary Videos 1 and 2), we downsampled all measurements to the two-photon imaging frame rate by averaging all behavioural samples acquired during one two-photon frame. In the figures, we report data at its original sampling rate.

Stimulus-triggered analysis of neural and behavioural data

We proceeded in the same way irrespective of whether the trigger was the onset of optogenetic stimulation (Figs. 2, 4 and 5 and Extended Data Figs. 1, 3, 5, 6 and 10) or the onset of a natural (spontaneous or puff elicited) behaviour (Extended Data Fig. 2). To compute stimulus-triggered averages, we aligned all trials to the onset of stimulation and considered the times between 5 s before the stimulus onset and 5 s after stimulus offset. In Fig. 2, we only considered trials in which the fly was walking in the 1 s before stimulation (behaviour classification applied to the mean of the 1-s pre-stimulus interval). We only considered flies with at least ten trials of walking before stimulation. Behavioural responses in Figs. 2a, 4b–g and 5f,g and Extended Data Fig. 1d–f, 2a–c, 5, 6 and 10 show the average across all trials (including multiple animals) and the shaded area indicates the 95% confidence interval of the mean across trials. When behavioural probabilities are shown, the fraction of trials that a certain behaviour occurs at a specific time after stimulus onset is shown. Neural responses over time in Fig. 2d and Extended Data Figs. 2a–c and 3c,h show average responses across all trials for one animal. To visualize the change in neural activity upon stimulation, the mean of neural activity in the 1 s before stimulation is subtracted for each neuron. If the absolute value of the mean across trials for a given neuron at a given time point was less than the 95% confidence interval of the mean, the data were masked with 0 (that is, it is white in the plot). This procedure allowed us to reject noisy neurons with no consistent response across trials. Because we subtracted the baseline activity before stimulus onset, we also observed DNs that became less active upon optogenetic stimulation (neurons appearing blue). However, GCaMP6s fluorescence does not reliably reflect neural inhibition. Thus, we cannot claim that this reduced activation in some neurons is due to inhibition. Instead, because the flies were walking before stimulation onset, those neurons most likely encode walking and became less active when the fly stopped walking forwards.

Individual neuron responses in Fig. 2c and Extended Data Fig. 2a–c,f and 3b,g show the maximum response of a single neuron/ROI. We detected the maximum response during the first half of the stimulus (2.5 s). We then computed the mean response of this neuron during 1 s centred around the time of its maximum response. If during at least half of that 1 s the mean was confidently different from 0 (that is, mean > CI), we considered the neuron to be responsive, otherwise we masked the response to zero to reject noisy neurons with no consistent response across trials. Figure 2b shows the same as Fig. 2c, but with this processing applied to pixels rather than individual neurons/ROIs. Contrary to previous ROI processing, pixels are not masked to 0 in case they are not responsive. Figure 2e shows an overlay of Fig. 2c for multiple flies. Data from each of these flies were registered to one another by aligning the y coordinates of the most dorsal and ventral neurons, as well as the x coordinate of the most lateral neurons. Figure 2f is a density visualization of Fig. 2e. To compute the density, we set the individual pixel values where a neuron was located to its response value and summed this across flies. We then applied a Gaussian filter (σ = 25 pixels, kernel normalized such that it has a value of 1 in the centre to keep the units interpretable) and divided by the number of flies to create an ‘average fly’. Extended Data Fig. 2d was generated in the same manner.

Statistical tests

Figure 2g–i includes a statistical analysis of neural responses. We quantified the number of activated neurons for each fly (Fig. 2g) as the neurons whose response value was positive (as in Fig. 2c). We quantified the fraction of activated neurons for each fly (Fig. 2h) by dividing the number of activated neurons by the number of neurons detected in the recording. In Fig. 2i, we quantified the summed ΔF/F as the sum of the response values of neurons that were positively activated (see the red line in Fig. 2d). Here we ignored neurons with negative response values because reductions in GCaMP fluorescence should not be interpreted as reflecting inhibition (see above). We used two-sided Mann–Whitney U-tests (scipy.stats.mannwhitneyu74) to statistically analyse these comparisons. Sample sizes and P values are described in the figure legends. The Mann–Whitney U-test is a ranked test. Thus, comparing three samples against three samples (for example, aDN2 versus control), where all samples are at identical relative positions (that is, ranks), will yield the same P value, even if the absolute values are slightly different. This leads the P values to be identical across Fig. 2g–i, reflecting the conservative choice of a rank test that does not assume an underlying distribution.

Figures 4b–e and 5f,g and Extended Data Figs. 5 and 6 show statistical tests comparing the behavioural responses of intact and headless flies. Figures 4f,g and 5f,g and Extended Data Figs. 5 and 6 show statistical tests comparing the behavioural responses of headless experimental flies with headless control flies. In each case, we used two-sided Mann–Whitney U-tests (scipy.stats.mannwhitneyu74) to compare the average value within the first 2.5 s after stimulus onset. We averaged across technical replicates (trials) and only compared biological replicates (individual flies) using statistical tests. Exact P values rounded to three digits are indicated in Supplementary Table 5.

Statistical tests in Extended Data Fig. 10 show comparison of the behavioural responses of leg-amputated experimental flies with intact experimental flies, and leg-amputated experimental flies with leg-amputated control flies. In each case, we used two-sided Mann–Whitney U-tests (scipy.stats.mannwhitneyu74) to compare the total displacement after 5 s of stimulation. We averaged across technical replicates (trials) and only compared biological replicates (individual flies) using statistical tests. Exact P values rounded to three digits are in Supplementary Table 6.

Extended Data Fig. 2a–c (right) and 2e show the Pearson correlation between neural responses to optogenetic stimulation and neural activity during natural (spontaneous or puff-elicited) behaviours. The two-sided significance of the correlation is measured as the probability that a random sample has a correlation coefficient as high as the one reported (scipy.stats.pearsonr v1.4.1 (ref. 74)).

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.

Brain connectome analysis

Loading connectome data

We used the female adult fly brain (FAFB) connectomics dataset7 from Codex75 (version hosted on Codex as of 3 August 2023, FlyWire materialization snapshot 630; to generate all figures. We merged the ‘neurons’, ‘morphology clusters’, ‘connectivity clusters’, ‘classification’, ‘cell stats’, ‘labels’, ‘connections’ and ‘connectivity tags’ tables. We then found DNs by filtering for the attribute super_class=descending. We identified DNs with known, named (for example, DNp09) genetic driver lines from Namiki et al.14 by checking the ‘cell type’, ‘hemibrain type’ and ‘community labels’ attributes (in this priority) and using the following rules. Otherwise, we used the consensus cell type38 (for example, DNpe078). We semi-automatically assigned names using the following rules:

  1. 1.

    For special neurons, we manually labelled root IDs 720575940610236514, 720575940640331472, 720575940631082808 and 720575940616026939 as MDNs based on community labels from S. Bidaye (consensus cell type DNpe078); root IDs 720575940616185531 and 720575940624319124 as aDN1 based on community labels from K. Eichler and S. Hampel (consensus cell type DNge197); and root IDs 720575940624220925 and 720575940629806974 as aDN2 based on community labels from K. Eichler and S. Hampel (consensus cell type DNge078). We verified visually that the shape of the neurons corresponded to published light-level microscopy images2,4.

  2. 2.

    Otherwise, if both the hemibrain_type attribute and the cell_type attribute followed the Namiki format (‘DN{1 lowercase letter} {2 digits}’, for example, ‘DNp16’) and they are identical, we used this as the cell name. If they are both in this format but are not identical, we marked this neuron for manual intervention.

  3. 3.

    Otherwise, if the hemibrain_type attribute follows the Namiki format, we used this as the cell name. In addition, if the hemibrain_type attribute follows the Namiki format, but the cell_type attribute has a different value following the consensus cell-type format (‘DN{at least 1 lowercase letter} {at least 1 digit}’, such as ‘DNge198’), we marked the cell as requiring manual attention.

  4. 4.

    Otherwise, if the cell_type attribute follows the Namiki format, we used this as the cell name.

  5. 5.

    Otherwise, if the cell_type attribute follows the consensus cell-type format, we used this as the cell name.

  6. 6.

    Otherwise, we marked the cell as requiring manual intervention.

  7. 7.

    Wherever manual intervention was required (mostly in which the hemibrain_type is the Namiki format, but the cell_type is in the consensus cell-type format), we manually assigned the consensus cell type. However, we assigned the Namiki type if there was no other DN in this Namiki cell type or if the cell type was still missing a pair of DNs14.

Next, we stored the connectome as a graph using SciPy sparse matrix74 and NetworkX DirectedGraph76 representations. We identified DNs with somas in the GNG by checking the third letter of the consensus cell type to be ‘g’ (that is, DNgeXXX)38.

Analysing connectivity

We only considered neurons with at least five synapses to be connected and computed the number of connected DNs based on this criterion (Figs. 3, 5b,c,e and 6a–c and Extended Data Figs. 49). This is the same value as the default in Codex, the connectome data explorer provided by the FlyWire community37,75. Analysis of connectivity across three brain hemispheres (two brain halves from the FAFB dataset7 and one from the hemibrain dataset77) revealed that connections “stronger than ten synapses or 1.1% of the target’s inputs have a greater than 90% change to be preserved”38. We visualized all DNs connected to a given DN (Figs. 3a,b and 5d and Extended Data Figs. 5 and 6) using the neuromancer interface, and manually coloured neurons depending on whether they are in the GNG.

Neurotransmitter identification was available from the connectome dataset based on classification of individual synapses with an average accuracy of 87%39. Here we report neurotransmitter identity for a given presynaptic–postsynaptic connection. To define neurotransmitter identity for a given presynaptic–postsynaptic pair, we asserted that the neurotransmitter type would be unique using a majority vote rule. This was chosen as a tradeoff between harmonizing neurotransmitters for a neuron (especially GABA, acetylcholine and glutamate78) and avoiding the propagation of classification errors.

DN network visualizations and DN hierarchy

We used the networkx library76 to plot networks of DNs in Figs. 3c,d and 5e and Extended Data Fig. 59. Again, we considered neurons to be connected if they had at least five synapses. In the circular plots, we show summed connectivity of multiple DNs. For example, the network for DNp09 in Fig. 3c shows only one green circle in the centre representing two DNp09 neurons. All connections shown as arrows are the sum of those two neurons. DNs are considered excitatory if they have the neurotransmitter acetylcholine and inhibitory if they have the neurotransmitter GABA. Whether glutamate is excitatory or inhibitory is unclear; this depends on the receptor subtype60, which is unknown in most cases. To emphasize this, we highlight glutamatergic network edges in a different colour (pink).

In Fig. 3e, we show the cumulative distribution of the number of DNs reachable within up to n synapses. Statistics on DN connectivity across multiple synapses were computed using matrix multiplication with the numpy library on the adjacency matrix of the network. Lines in colour represent a DN network traversal starting at specific comDNs. The black trace represents the median of all neurons. Only a maximum of approximately 800 DNs can be reached because the others have maximally one DN input. In Fig. 5b,c, we sorted DNs by the number of monosynaptic connections that they make to other DNs. In Fig. 5b, the same sorting is applied to show the number of connected GNG DNs (orange).

In Extended Data Fig. 4, we show the effect of the choice of different constraints of the underlying connectome network on DN–DN connectivity degree. Statistics on DN connectivity across multiple synapses were computed using matrix multiplication with the numpy library on the adjacency matrices of the network. The segregation of excitatory and inhibitory connections was obtained by applying a mask on the direct connection signs. This implies that an inhibitory neuron acting on another inhibitory neuron would not be counted as excitatory but simply ignored in Extended Data Fig. 4d–f.

Fitting network models to connectivity degree distribution

In Fig. 6a, we generated a shuffled network of the same size by keeping the number of neurons constant and keeping the number of connections constant. Then, we randomly shuffled (that is, reassigned) those connections. Here we only considered the binary measure of whether a neuron was connected (number of synapses > 5) and not its synaptic weight. We then fit a power law or an exponential to the connectivity degree distribution using the scipy.optimize74 library. Histograms of the degree distributions for all four distributions are shown in Fig. 6a using constant bin widths of five neurons. The quality of the fits are quantified using linear regression (R2).

Detection of DN clusters

We applied the Louvain method48 with resolution parameter γ = 1 to detect clusters in the undirected network of DNs (that is, connections between two neurons are scaled by their synaptic strength and neurotransmitter identity, but the directionality of the connection is not taken into account). Here all connections—feedforward, lateral and feedback—are taken into account. In brief, the Louvain method is a greedy algorithm that maximizes modularity (that is, the relative density of connections within clusters compared with between clusters). To simplify analysing the network during the optimization, we did not consider the directionality of connections between neurons. If there is reciprocal connectivity between neurons, we add up the number of synapses (positive if excitatory, negative if inhibitory; here glutamate is considered inhibitory and neuromodulators are disregarded for the sake of simplicity). The Louvain method finds different local optima of cluster assignments due to its stochastic initialization and greedy nature. Therefore, we ran the algorithm 100 times. On the basis of the outcomes of these 100 runs, we defined a co-clustering matrix: the matrix has the same size as the connectivity matrix (number of DNs × number of DNs). Each entry represents how often two DNs end up in the same cluster. This matrix assigns each pair of DNs a probability to be in the same cluster. Using this meta-clustering, we could be sure that the sorting of DNs that we found through clustering is not a local optimum and that it is reproducible. We then applied hierarchical clustering to this matrix (using the ‘ward’ optimization method from the scipy.cluster.hierarchy library74) to get the final sorting of DNs shown in Fig. 6b. We used this final sorting to detect the clusters shown in grey in Fig. 6b as follows: we started from one side of the sorted DNs and sequentially grew the cluster. If the next DN was in the same Louvain clusters at least 25% of the time, we assigned it to the same cluster as the previous DN. If not, we started a new cluster with this DN and kept testing subsequent DNs to determine whether they fulfil the criteria for this new cluster. Finally, we only kept clusters that had at least ten neurons. This yielded 12 clusters (grey squares). We applied this same meta-clustering and sorting approach to analyse the shuffled network (same number of DNs, same number of connections and same number of synapses, but shuffled connections). On this shuffled network, we found 34 clusters of much smaller size (Fig. 6c), hinting at a better clustering in our network than in a shuffled control (modularity = 0.27 for the original network and modularity = 0.12 for the shuffled network). The number of synapses is shown as positive (red) if it is excitatory and as negative (blue) if it is inhibitory.

We then analysed the connectivity within and between clusters. To do this, we accumulated the number of synapses between two clusters (positive for excitatory and negative for inhibitory). To be able to compare this quantity between clusters of different sizes, we divided this number of synapses by the number of DNs in the cluster that receives the synaptic connections. This quantity is visualized in Fig. 6d for the original DN–DN network clusters and Fig. 6e for the shuffled network as the ‘normalized number of synapses’. If positive (red), then connections from one cluster to another are predominantly excitatory. If negative (blue), then connections are predominantly inhibitory. We did not mirror connectome data before clustering because it requires resolving discrepancies between left and right neuron pairs, which, in many cases, are also not identifiable as corresponding cell classes across the brain.

Statistical comparison of original versus shuffled DN–DN clusters

As detailed above, we applied the Louvain algorithm 100 times to increase the robustness of clustering. We computed statistics on the clustering of this dataset (mean and standard deviation) specifically on metrics including the size and number of clusters. We then compared these distributions with those for the shuffled graph using one-sided Welch’s t-tests (scipy.stats.ttest_ind74 with equal_var = False). The resulting statistics are a conservative quantification of the difference between the original network and the shuffled control, as each data point is taken independently. When performing the hierarchical clustering across 100 iterations, the large clusters from the biological network are preserved, whereas the random associations of the shuffled network become incoherent. In practice, the difference in cluster sizes reported statistically underestimates the difference between the resulting matrices shown in Fig. 6b,c. The 100 iterations result from random seed initialization, on the condition that the algorithm converges. We restarted it whenever the convergence criteria were not reached within 3 s. Indeed, we observed empirically that when the algorithm would not converge in 3 s, it would not do so for at least 30 min and was, therefore, terminated.

Identifying DNs to test predictions

On the basis of the cell-type data associated with each neuron in FAFB (see above), we were able to find many DNs from refs. 4,14,15,22,64 in the connectome database. We then checked which of them have either a very high number of synaptic connections to other DNs or a very low number. We then filtered for lines where a clean spGAL4 line was available. In addition, we focused on lines whose major projections in the VNC were outside of the wing neuropil, because we removed the wings in our experimental paradigm and thus might not be able to see optogenetically induced behaviours. This left us with 15 additional DNs to test our predictions. DNp01 (giant fibre) activation was reported to trigger take-off in intact and headless flies44,45, so we did not repeat those experiments. This left us with 14 lines to test. The source and exact genotypes of those fly lines are reported in Supplementary Table 2. We then performed experiments with those 14 lines. Because intact control flies become aroused by laser illumination, but not headless control animals, to avoid false positives, we only analysed DN lines that either had a known optogenetic behaviour in intact flies (that is, DNp42, aDN1, DNa01, DNa02, oviDN and DNg11) or that had a clear phenotype in headless flies (that is, DNb02, DNg14 and Mute). Thus, we excluded Web, DNp24, DNg30, DNb01 (involved in flight saccades in ref. 79, but with no obvious phenotype on the spherical treadmill) and DNg16 as they did not fulfil either of these criteria and only analysed the remaining nine driver lines in Fig. 5 and Extended Data Figs. 5 and 6.

Analysing DN–DN connectivity in the VNC

We used the neuprint website to interact with the male adult nerve cord (MANC) connectome dataset13,80. There, we searched for neurons based on their names (MDN, DNp09, and so on) and checked whether there were any DNs among their postsynaptic neurons. We found all neurons that we used from ref. 14 (that is, DNp09, DNa01, and so on), MDN and oviDN. We were not able to find aDN2, aDN1, Mute, Web and DNp42.

Analysing VNC targets of DN clusters

We used data shown in Cheong et al.13 (figure 3, supplement 2) to define whether a DN known from Namiki et al.14 was projecting to a particular VNC neuropil. In brief, a DN is considered as projecting to a given neuropil if at least 5% of its presynaptic sites are in that region. We manually found the MDNs in the MANC dataset and determined the regions that they connect to using the same criterion. To generate Fig. 6f, for each cluster, we accumulated the number of known DNs that project to a given VNC region. We then divided this by the number of known DNs to obtain the fraction of known DNs within a cluster that project to a given region. The number of unknown DNs per cluster is also shown next to the plot. The raw data of associations between DNs and VNC neuropils are shown in Supplementary Table 8.

Analysing behaviours associated with DN clusters

We examined the literature2,3,4,13,16,18,19,21,30,64,70,81,82,83,84 to identify behaviours associated with DNs and grouped them into broad categories (anterior grooming, take-off, landing, walking and flight). This literature summary is available in Supplementary Table 8. Of the 35 DN types annotated, we found conflicting evidence for only two: DNg11 is reported to elicit foreleg rubbing21 while targeting mostly flight-related neuropils13; DNa08 targets flight power control circuits13 but has been reported to be involved in courtship under the name aSP22 (ref. 23). In Fig. 6g, we assigned DNg11 to ‘anterior’ and DNa08 to ‘flight’. We accumulated the number of known DNs that are associated with a given behaviour for each cluster. We then divided by the number of known DNs in the respective cluster to get a fraction of DNs within a cluster that have a known behaviour. The number of unknown DNs per cluster is also shown next to the plot. The raw data of associations between DNs and behaviours are shown in Supplementary Table 8.

Analysing brain input neuropils for each DN cluster

We used data from FAFB to identify the brain input neuropils for each DN cluster based on the neuropil annotation for each DN–DN synapse. Thus, localization information is given by the position of each synaptic connection and not the cell body of the presynaptic partner. This allows us to account for local processing and modularity of neurons. The acronyms of brain regions are detailed in Supplementary Table 7, with ‘L’ and ‘R’ standing for the left and right brain hemispheres, respectively. Results are reported as the fraction of synapses made in a neuropil out of all the postsynaptic connections made by DNs of a given cluster.

Ethical compliance

All experiments were performed in compliance with relevant national (Switzerland) and institutional (EPFL) ethical regulations. Characteristics of animals such as sex, age and husbandry are detailed in the Methods.

Reporting summary

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