Main

Behavioural context is critical to how animals detect and interpret visual information. For example, when driving on a congested highway, it is imperative to focus on the movement of the car ahead while ignoring other environmental cues. Such focus, or feature-based attention12, also occurs during certain behavioural states, including aggression, when it is important to be attuned to the movement of a competitor. Pioneering work across primates, rodents and invertebrates has shown the importance of neuronal populations tuned to specific features, including size, speed and colour1,2,3,4,5,6,7,8. Recordings in rodents suggest that visual processing regions receive input from non-sensory areas and circuits conveying information about behavioural state13,14,15,16,17,18, allowing for modulation by context. However, the exact circuit architecture underlying state-dependent gating of visual attention remains unclear.

The fruit fly Drosophila melanogaster provides a powerful model for the mechanistic dissection of state-dependent visual processing due to its genetic accessibility, brain-wide connectome and complex behaviours. In flies, visual projection neurons (VPNs) compute the presence and general location of distinct visual features, such as looming or translating objects of varying sizes and speeds19,20,21, and relay this information from the optic lobe to different target regions of the central brain19,22,23,24. These visual pathways appear to be highly stereotyped across sexes19,25. Selective activation of certain VPNs gives rise to robust behavioural outputs19, some of which are context dependent26,27,28,29,30,31,32. For example, the same looming-responsive VPNs are involved in both landing and take-off, with the resultant behavioural output determined by octopaminergic modulation of downstream neurons21,33,34.

During social behaviours, detection of conspecifics is critical35,36,37,38. Lobula columnar (LC) neurons, a major class of VPNs, project from the optic lobe to discrete brain glomeruli19. Three LC cell types, LC9, LC10a and LC11, that are tuned to fly-sized moving objects have been implicated in locomotor pursuit of conspecifics9,10,11,19,23,24,39,40,41,42. LC10a is one of the LC10-group cell types, or LC10s, each of which receive distinct inputs in the optic lobe. Previous work has shown that LC10a responses to fly-size objects increase substantially during male courtship pursuit11. Other LC10s do not appear to display this gain enhancement and their role in social pursuit is less well understood. Stimulation of courtship- and aggression-promoting P1 neurons38 in males increases LC10a sensitivity to fly-sized objects, suggesting arousal-dependent modulation of visual processing11. Yet, in the absence of a male brain-wide circuit diagram, the circuit mechanisms underlying P1 modulation of LC10a remain unresolved. While P1 is only found in males, it represents a subset of the pC1 lineage that gives rise to pC1d and pC1e neurons in females43,44,45, which also modulate social states. Recent work has shown that either simultaneous activation of pC1d and pC1e, or activation of the approximately 9 to 12 cells comprising the aIPg cell type can generate both acute aggressive behaviour and a persistent aggressive state in females46,47,48. Our previous research revealed that aIPg cells provide excitatory input to several LC10-group cell type targets, suggesting a role for aIPg cells in gating the flow of visual information46. Here we focus on female–female aggression and show that aIPg cells use three circuit mechanisms to modulate visual processing, which underlies this social behaviour (Fig. 1).

Fig. 1: The female aggressive state modifies the flow of visual information through three distinct mechanisms.
figure 1

a, Summary of the circuit mechanisms that we propose aIPg uses to modulate transmission of visual information by VPNs, specifically LC9, LC10s and LC11. These mechanisms include providing additional excitatory input to a select subset of the direct targets of LC9, LC10s and LC11 (convergence of excitatory inputs), relieving inhibition that acts on the dendritic arbours of LC10s in the lobula (dendritic disinhibition) and simultaneously flipping a pair of switches that act on the axonal terminals of the LC10a and LC10c cell types to influence which of these two LC10s is active in signalling to downstream targets (toggle switch). Other than the LC9, LC10-group and LC11 targets discussed above, only three other neurons get both 1.5% or more of their input from aIPg and 5% or more of their input from an LC type. The arrows indicate putative excitatory connections (cholinergic) and the bar endings indicate putative inhibitory connections (GABAergic or glutamatergic). b, Overview of the circuit components for each mechanism in a. Activation of aIPg (1) provides additional excitatory input to downstream targets of LC10s, represented here by AOTU015 and AOTU023; (2) leads to disinhibition of inputs to the dendrites of LC10s through IB112; and (3) governs whether LC10a or LC10c is able to signal to their downstream targets by a toggle switch. This switch is operated by the TuTuA_1 and TuTuA_2 neurons, which provide inhibition to LC10c and LC10a, respectively. The line widths represent synaptic connections and are scaled according to the key. For cell types with more than one cell per brain hemisphere, the number of cells is indicated below the cell type. Additional details are provided in Extended Data Fig. 10.

Vision is critical for aggression

Multisensory cues are important for locating others and directing aggressive actions37,46,49. Previous behavioural evidence suggested the importance of visual information in aIPg-induced aggression46. We confirmed this by eliminating the ability of females to receive visual information using a mutation in the norpA gene, which encodes a key component of the phototransduction pathway50. Activating aIPg in norpA-mutant females did not result in prolonged aggressive interactions, even after they made physical contact (Extended Data Fig. 1). These data emphasize the importance of visual cues in aggressive interactions elicited by aIPg activation.

Shared targets of vision and state

To determine which visual pathways are modulated by aIPg, we performed a comprehensive analysis of the female connectome25 and identified neurons receiving over 100 synaptic inputs from both aIPg and VPNs. We found that the VPNs participating in this circuit motif were a small subset (8 out of 44) of LC cell types. Moreover, each of these eight LC cell types is known to be responsive to small moving and/or looming objects19,23,24,32. This combination of aIPg and LC inputs may endow the downstream neurons with the ability to integrate an aggressive internal state with socially relevant visual information (Figs. 1 and 2). LC10s share the largest number of neuronal targets with aIPg. We identified 23 cell types that receive more than 25% of their input synapses from LC10-group cell types and about half of these also receive more than 2% of their input synapses from aIPg (Fig. 2a). Each of these shared outputs of aIPg and LC10s receives input from all LC10-group cell types, although in different proportions (Fig. 2a). Aside from LC10s, aIPg shares primarily one downstream target with LC11 (CL053) and two downstream targets with LC9 (PVLP114 and PVLP004) (Fig. 2b–e). Only three other downstream neurons receive substantial input from both LC and aIPg neurons: PVLP120 receives 30% of its synaptic inputs from LC17, 19% from LC12 and 1.5% from aIPg; SMP312 receives 5.3% of its inputs from LC21 and 4.6% from aIPg; and PVLP006 receives 35% of its inputs from LC6, 11% from LC16 and 2.3% from aIPg. Thus, LCs and aIPg share a limited number of downstream targets, and these target cell types have the capacity to receive both excitatory visual and aIPg input during an aggressive encounter.

Fig. 2: Shared downstream targets of both aIPg and LC10s.
figure 2

a, Shared downstream targets of aIPg and LC10-group cell types. Each target cell type is represented by a circle of which the diameter represents the total number of synapses that it receives from LC10-group cell types. AOTu cell types are indicated as numbers without the AOTU0 prefix. The proportion of those inputs coming from each LC10-group cell type is indicated in the pie chart. Postsynaptic sites from aIPg (orange) and LC10s (dark grey) on the outline of AOTU023 (dark green) are shown in the inset. b, CL053’s morphology (dark green) is shown with the position of input synapses from aIPg (orange) and LC11 (dark grey). c, Shared downstream targets of both aIPg and LC11 neurons outside of the optic lobe (OL). Each target cell is represented by a light green circle of which the diameter indicates the total number of LC11 synapses that the cell receives and of which the position on the y axis represents the percentage of its inputs coming from aIPg and its position on the x axis represents the percentage coming from LC11. This graph shows LC11’s top 51 targets outside the optic lobe, representing 74% of its synapses to other cell types outside the optic lobe. d, PVLP114’s morphology (dark green) is shown with the position of input synapses from aIPg (orange) and LC9 (dark grey). e, Shared downstream targets of aIPg and LC9 neurons outside of the optic lobe. Each target cell is represented by a light green circle. The diameter of each circle indicates the total number of LC9 synapses that the cell receives, the position on the y axis represents the percentage of its inputs coming from aIPg and the position on the x axis represents the percentage coming from LC9. This graph shows LC9’s top 54 targets outside the optic lobe representing 83% of its synapses to other cell types outside the optic lobe. For a, b and d, scale bars, 50 μm.

The vast majority of cell types that receive input from LC10s are interneurons in the anterior optic tubercle (AOTu), which then connect to descending pathways that drive motor action41,51. These interneurons may therefore control distinct facets of aggressive behaviour. Genetic reagents that enable us to target AOTu cell types, and perhaps combinations of cell types, as well as assays for subtle aspects of behaviour will be needed to further explore these parallel pathways.

Previous work characterizing visual responses of different LC populations using in vivo calcium imaging revealed that LC11 is selectively tuned to small moving objects (around 4.5° in angular width and height as subtended on the retina)23,24,42. We used the same experimental approach to examine visual feature selectivity of LC9 and LC10a. Similar to LC11, LC9 was preferentially tuned to smaller moving objects (around 4.5° in width and about 2° in height) in contrast to LC10a (around 15–30° in width and height) (Fig. 3a and Extended Data Fig. 2a,b). As perception of an object’s size depends on its distance, such variations in size selectivity suggest differential activation of LC9 and LC10a when a female is far away from versus close to another fly, respectively. Moreover, LC9 displayed a prolonged calcium response to slow dark looming stimuli (Extended Data Fig. 2c). We found that, while the inputs to either LC10a or LC10c do not differ across sexes, inputs to these two cell types show little overlap, indicating that LC10a and LC10c respond to distinct visual features (Fig. 3b,c). For example, LC10c receives approximately 30% of its inputs from interneurons directly downstream of the R7 (Tm5a and Tm5b) and R8 (Tm20) photoreceptors that are critical for colour vision, whereas LC10a receives less than 4% of its input from such interneurons. Taken together, our results show that LC9, LC10a and LC11 are tuned to fly-sized moving objects and suggest that these LCs may be differentially activated over time, as a function of varying inter-fly distance, during aggressive encounters.

Fig. 3: LC10a is tuned to medium-sized moving objects and has a key role in female aggression.
figure 3

a, Schematic of the experimental setup (top left) for presentation of moving dark rectangles of parameterized spatial dimensions (bottom left). Heat map representations and average traces (right) for individual LC9 and LC10a axons are shown across multiple animals. LC9: n = 4 female flies, n = 4 neurons; LC10a: n = 5 male flies, n = 7 neurons. b,c, The dendritic inputs input provided to LC10a (b) and LC10c (c) in the female and male by their top 10 input neurons as ranked in the male optic lobe. These inputs account for 31% and 40% of LC10a’s inputs in the female and male, respectively, and 56% and 61% of LC10c’s inputs in the female and male. d, Conspecific angular sizes experienced during male courtship and aIPg-induced female aggression. e, Schematic of the data analysis protocol, representing one of the experiments in f. f, The average time spent performing aggressive behaviours before and during stimulus periods in which a 30 s continuous green (9 mW cm−2) light stimulus was delivered (green circles). The average over three stimulus periods is shown for display purposes. The time course and non-activating temperature controls are shown in Extended Data Fig. 3a–c. The average for the pre-stimulus period was calculated using the 15 s before the first stimulus period. All datapoints are shown to indicate the range, and the top edge of the bar represents the mean. Data were pooled from six independent biological replicates, which included separate parental crosses and were collected on different days. Statistical analysis was performed using nonparametric Wilcoxon matched-pairs signed-rank tests; asterisks indicate significance compared with 0; ****P < 0.0001.

Source Data

LC10a has been implicated in male courtship behaviour10,11, yet the role of LC10a in female aggression has not been explored. To examine a potential role for LC10a in female social interactions, we first examined the visual object sizes and speeds experienced by female flies during aggressive encounters. During periods of aIPg-mediated aggression, female flies modulate their distance with respect to the nearest fly such that the angular size of that fly remains 32.1 ± 13.0° in width (mean ± s.d.) and 26.1 ± 8.8° in height, which corresponds to the flies being less than a body length apart (Fig. 3d). Such stimuli are within the preferred ranges of object size and speed of LC10a neurons (Fig. 3a and Extended Data Fig. 2d,f), consistent with the notion that LC10a could have a role during female aggression. The preferred range of stimuli for LC10a is also within the range of object sizes (28.70 ± 12.7° in width and 15.96 ± 4.4° in height) that courting males fixate on during courtship (Fig. 3d and Extended Data Fig. 2e,f), similar to previous work10.

To assess the involvement of specific cell types in aIPg-mediated aggression, we recorded, tracked, classified and analysed the aggressive behaviour of groups of female flies in an arena as diagrammed in Fig. 3e. We quantified the average percentage of trajectories in which flies were performing aggression in each such experiment, which we represented as a single point in our graphs, and performed approximately 20 experiments per condition (Fig. 3e). For different LC types, we performed epistasis experiments in which we thermogenetically activated aIPg cells while optogenetically silencing an individual LC type (Fig. 3f). Optogenetic inactivation of LC10a, but not LC10bc, LC9 or LC11, resulted in a sustained decrease in aggressive behaviours, including individual component features such as touch (Fig. 3f and Extended Data Fig. 3a–g). When LC10a was silenced, the distance between flies increased, and the angular size subtended on the retina by the nearest fly as well as the number of flies within two body lengths correspondingly decreased (Extended Data Fig. 3c,d). Collectively, these results suggest that LC10a has a similar role in the visuomotor tracking of social targets across sexes.

Broad disinhibition of visual inputs

Our connectomic analyses suggest a second mechanism by which aIPg enhances information flow from LC10s (Fig. 1). IB112, aIPg’s second highest target based on synapse count, has nearly 90% of its synaptic output in the lobula (Fig. 4a,b), suggesting a role in modulating visual inputs to the brain. We generated two cell-type-specific driver lines for IB112 and confirmed that this cell type is glutamatergic, suggesting that it is probably inhibitory52 (Extended Data Fig. 4). Whole-cell patch-clamp recordings and calcium imaging of IB112 during aIPg stimulation in female brain explants confirmed direct functional connectivity between aIPg and IB112 (Extended Data Fig. 5a,b). Moreover, inactivation of IB112 resulted in a prolonged decrease in aggression, including touch and other component behavioural features (Fig. 4c and Extended Data Fig. 5c–e), confirming the importance of IB112 outputs in the lobula.

Fig. 4: Polysynaptic connections from aIPg to the lobula shape aggressive behaviours.
figure 4

a, Postsynaptic sites from aIPg (orange) and presynaptic sites of IB112 going to its downstream targets (yellow) in the lobula are shown on the neuronal outline of IB112 (dark blue). Scale bar, 50 μm. b, Overview of the strong connections between aIPg, IB112, Li22, LC10a and LC10c neurons. IB112 is aIPg’s second strongest downstream target and receives 4.3% of its input from aIPg. Note that IB112 is named LoVC1 in the male optic lobe53 and cL14 in FlyWire54,59 datasets. The lobula interneuron Li22 (named Li01in the FlyWire dataset60) is IB112’s top downstream target, receiving over 40% of its output synapses (53% in males and 42% in females) in the optic lobe. Li22 cells receive 5.7% of their input from IB112 in the male optic lobe and 7.1% in the female optic lobe. Li22 provides 3.5% of LC10a, 1.1% of LC10b, 5.1% of LC10c and 5.9% of LC10d dendritic inputs in the male, and 3.5%, 0.8%, 4.9% and 5.3% in the female. c, The average time spent performing aggressive behaviours before and during stimulus periods in which a 30 s continuous green (9 mW cm−2) light stimulus was delivered. All datapoints are shown to indicate the range, and the top edge of the bar represents the mean. The time course and non-activating temperature controls are shown in Extended Data Fig. 5c–e. In the diagram in b, cell types inactivated with GtACR are circled in yellow and those activated with TrpA are circled in red. IB112 and the relevant lobula interneurons are glutamatergic and are presumed inhibitory (Extended Data Fig. 4h). Data were pooled from five biological replicates, which included separate parental crosses and were collected on different days. Statistical analysis was performed using nonparametric Wilcoxon matched-pairs signed-rank tests; asterisks indicate significance compared with 0; ***P < 0.001.

Source Data

We used the recently completed optic lobe connectome in males53 to examine the synaptic outputs of IB112 in this dataset (Fig. 4b) and then verified the presence of these connections in the less extensively annotated female optic lobe connectome54 (additional details in Methods). Within the male and female lobula, IB112 sends over 40% of its synapses to the lobula-intrinsic interneuron Li22, providing over 5% of Li22’s input. No other downstream cell type receives more that 1.5% of their input from IB112 in either sex. Li22 in turn provides a large number of synapses to the dendrites of LC10-group cell types in females and males (additional details are shown in Fig. 4b). Li22 is predicted to be glutamatergic, implying that connections from this cell type are probably inhibitory52.

IB112 is an example of a centrifugal neuron, defined as such by having most of its inputs within the central brain and its outputs in the optic lobes53,54. Analysis of the connectome has identified more than 70 centrifugal cell types53. While two previous examples of centrifugal neurons have been predicted to use neurotransmitters, such as octopamine, to modify behaviour55,56, their circuit-level functions are unclear. Thus, IB112 provides an example of this important class of inputs to the optic lobe for which not only a behavioural role but also the relevant direct synaptic inputs in the central brain and outputs in the optic lobe have been identified.

A toggle switch

Our previous work identified the TuTuA neurons as potential targets of aIPg that could regulate LC10s signalling in the AOTu46. Further analysis of the female connectome revealed that there are two TuTuA cell types, referred to as TuTuA_1 and TuTuA_2, each represented by a single glutamatergic cell per brain hemisphere. We found that the TuTuAs have distinct patterns of connectivity that suggest they differentially gate LC10a and LC10c (Fig. 5a). Given the connectivity and predicted neurotransmitters in this circuit, our simplest interpretation is as follows: when active, aIPg provides excitatory input to TuTuA_1, which forms connections interspersed with LC10c’s output synapses and inhibits its ability to transmit information (Fig. 5b,c). Moreover, aIPg indirectly targets TuTuA_2 through the GABAergic interneuron SMP054. TuTuA_2 forms inhibitory connections with LC10a that are interspersed with its output synapses. This disynaptic sequence of inhibitory connections serves to disinhibit LC10a transmission (Fig. 5b,d). In this simple view, aIPg activation has the potential to oppositely modulate LC10a and LC10c and their respective downstream circuits. Should aIPg have only two states—active and silent—the TuTuA neurons would act as a pair of opponent switches that flip from LC10c to LC10a transmission when aIPg becomes active.

Fig. 5: aIPg selectively amplifies LC10a, while dampening LC10c transmission through TuTuA neurons.
figure 5

a, The connectivity between aIPg, TuTuAs, LC10a and LC10c in one brain hemisphere. Synapse numbers are indicated on the arrows. TuTuAs connect to specific LC10s: 98% of TuTuA_1’s synapses onto LC10s go to LC10c and 98% of TuTuA_2’s synapses go to LC10a. TuTuA_1 and TuTuA_2 make <1% of their synapses onto LC10b, LC10d, LC10e or LC10f. The arrows indicate putative excitatory connections (cholinergic) and the bar endings indicate putative inhibitory connections (SMP054, GABAergic; TuTuA_1 and TuTuA_2, glutamatergic). b, Predicted outcomes for circuit dynamics based on aIPg activity. Cells and connections with higher predicted activity are displayed in bold font and dark colours. c,d, Synapses between TuTuA_1, TuTuA_2, LC10a and LC10c on representative skeletons for LC10c (c) and LC10a (d). Note how inhibitory synapses from the TuTuA neurons are interspersed with LC10s’ output synapses. e, Excitatory responses recorded from TuTuA_1 (n = 16 cells) in female brain explants in response to a 2 ms stimulation of aIPg neurons (72C11-LexA > Chrimson). The excitation was largely abolished by mecamylamine, an n-AchR blocker. No evoked response was recorded when stimulating Chrimson in the absence of a LexA driver (n = 5; bottom right). Individual trials are shown in purple (n = 8 trials from 1 cell) and the mean is shown in black. f, Inhibitory responses recorded from TuTuA_2 (n = 16 cells) to a 2 ms stimulation of aIPg neurons. The inhibition was completely removed by mecamylamine. No evoked response was recorded when stimulating Chrimson in the absence of a LexA driver (n = 5; bottom right). Individual trials are shown in pink (n = 8 trials from 1 cell) and the mean is shown in black. In the diagrams above the traces, cell types activated with LexAop-Chrimson are circled in red and those recorded from are shown in in purple or pink depending on the TuTuA cell type. For c and d, scale bars, 50 μm, and 5 μm in the inset images.

TuTuA_1 and TuTuA_2 are predicted to have opposite effects on the activity of LC10a and LC10c (Fig. 5b). Excitatory feedback from LC10a and LC10c to TuTuA_1 and TuTuA_2, respectively, probably reinforces this opponency (Fig. 5b). Specifically, the connectome revealed that a major downstream target of LC10a is TuTuA_1, the same TuTuA that inhibits LC10c. Thus, when LC10a is active it serves to reinforce the suppression of LC10c activity. Analogous to LC10a’s connections to TuTuA_1, a major LC10c target is TuTuA_2. This complementary indirect pathway serves to suppress LC10a activity when LC10c is active.

In the simplest interpretation of the circuit, TuTuA_1 and TuTuA_2 would function as a reciprocal on/off switch for LC10a and LC10c. However, we recognize that our interpretation of the mechanisms suggested by the circuit diagram are most likely incomplete, and there are features of this circuit that cannot be fully understood from the connectome alone. For example, both TuTuAs provide inhibition on distinct LC10-group cell types and receive substantial excitatory feedback from those same LC10s. It is possible that this circuit motif provides inhibitory feedback to regulate the gain of TuTuA output56,57,58. Furthermore, how the neurons of this circuit integrate synaptic connections over time and at a subcellular level remain unclear and would require pointed neurophysiological interrogation beyond the current technical capacities.

We were able to test many of the predictions from the circuit diagram by generating GAL4 driver lines specific for each of the TuTuAs (Extended Data Fig. 6), and using these genetic reagents in functional assays. Electrophysiology and calcium imaging during aIPg stimulation confirmed several predicted connections: direct aIPg excitatory connections to TuTuA_1; indirect inhibitory connections to TuTuA_2; and excitatory connections of LC10a to both TuTuA_1 and TuTuA_2 (Fig. 5e,f and Extended Data Fig. 7a–e). pC1d and pC1e neurons, which were previously shown to be upstream of aIPg in the female aggression circuit46, were also found to provide indirect inhibitory inputs to TuTuA_2 through SMP054 (Extended Data Fig. 7f–k).

To test the behavioural effects of this circuit architecture, we acutely silenced TuTuA_1 while activating aIPg. As expected, we found that optogenetic inhibition of TuTuA_1 activity during chronic aIPg activation transiently decreased aggression (Fig. 6a and Extended Data Fig. 8a,e). Next, we optogenetically activated TuTuA_2 during chronic aIPg thermogenetic activation and found that it significantly reduced female aggressive behaviour throughout the duration of the stimulus (Fig. 6a and Extended Data Fig. 8b–e). Furthermore, TuTuA_2 optogenetic inactivation increased aggression behaviour in the absence of aIPg activation (Fig. 6b and Extended Data Fig. 8f). Taken together, these results provide strong evidence in support of a toggle switch mechanism whereby aIPg activation shifts the relative gain of the LC10a and LC10c visual pathways.

Fig. 6: Selective modulation of TuTuA_1 and TuTuA_2 shapes female aggression and male courtship.
figure 6

a,b, The average time spent performing aggressive behaviours before and during periods in which a 30 s continuous green (9 mW cm−2) or red (3 mW cm−2) light stimulus was delivered. The time course and non-activating temperature controls are shown in Extended Data Fig. 8a–f. The 10 s (a (left)) or 30 s (a (right) and b) before each stimulus period was compared to average aggression during the same time intervals across all three stimulus periods. The empty > GtACR control in b displayed a small change in aggression after stimulation, but in the opposing direction to the experimental group. Experiments were performed as shown in Fig. 3e. All datapoints are shown to indicate the range and the top edge of the bar represents the mean. Cell types inactivated with GtACR are circled in yellow and those activated with either TrpA or Chrimson are circled in red. Data were pooled from six (a (left)) and three (a (right) and b) biological replicates. c, Schematics of the visual virtual reality preparation for male courtship (left, adapted from ref. 11) and circuit activity during male courtship pursuit (right) are shown. The identity of cell types indicated by question marks are not known. Responses of TuTuAs (centre, average ∆F/F0) to a visual target during periods of courtship pursuit (purple or pink) or during general locomotion (black). The mean is represented as a solid line, and the shaded bars represent standard error between experiments (TuTuA_1-SS1: n = 4 (courting), n = 9 (running); TuTuA_2-SS1: n = 5 (courting), n = 6 (running) flies). The black line above indicates when the visual target was oscillating. Statistical analysis was performed using nonparametric Wilcoxon matched-pairs signed-rank tests; asterisks indicate significance compared with 0; *P < 0.05.

Source Data

Note that the targets of LC10s within the AOTu are regulated in two ways by aIPg. First, aIPg provides substantial direct input to about half of these AOTu interneurons (Fig. 2a). Second, aIPg activation is predicted to produce a global shift in the visual input those neurons receive—even those that do not receive direct aIPg inputs—by gating whether LC10a or LC10c can effectively signal to them (Figs. 1b and 5). Thus, aIPg is primed to regulate the flow of visual information through all visual AOTu interneurons using either one or both of these distinct circuit mechanisms.

The TuTuA switch functions in males

Previous work has demonstrated that P1 neurons, directly or indirectly, increase the gain of LC10a activity, but not LC10c activity, in the AOTu during courtship pursuit11. We previously suggested that a common mechanism involving the TuTuA neurons might underlie state-dependent gating in females and males46. Consistent with this suggestion, we show that TuTuA neurons exhibit similar morphology across sexes and share aspects of their baseline physiological properties (Extended Data Figs. 6p–s and  9). We next examined TuTuA activity in tethered males as they spontaneously initiated courtship pursuit of a ‘fictive female’ represented as a high contrast dot that moves at a constant angular velocity across the male’s visual field11 (Fig. 6c). While both TuTuA neurons were insensitive to the visual profile of the fictive female when males viewed it passively, the onset of courtship marked a striking change in their calcium activity: the activity of TuTuA_1 increased whereas that of TuTuA_2 decreased (Fig. 6c). These results are consistent with our circuit model in females, supporting the notion that the same TuTuA-mediated switch may also be used in males to gate visual processing during social interactions.

Concluding remarks

Animals gate visual information in a context-dependent manner. Using the connectome as a guide, our work provides a detailed circuit-level understanding of how this can be accomplished. We found three distinct mechanisms, under coordinated control by a single cell type conveying internal state, that selectively amplify visual information critical for social interactions (Fig. 1b). This cell type, aIPg, appears to be largely dedicated to this task with its six most highly connected synaptic targets contributing to the gating of the visuo-motor circuits we described. These circuits are engaged by aIPg and have the potential to regulate distinct motor programs (Extended Data Fig. 10). The presence of these multiple circuit mechanisms endows the system with more degrees of freedom and flexibility in regulation of attention toward different visual features. It is difficult to imagine how we could have efficiently discovered these circuit mechanisms without the connectome. aIPg is the primary sexually dimorphic neuron in the circuits we described, while other circuit components—the LC neurons, lobula interneurons, IB112 and TuTuA neurons—are present in males and females with indistinguishable morphologies. Our data on TuTuA activity in males during tracking of a fictive female stimulus combined with analysis of the connectome of the male optic lobe suggest that the same toggle switch operates across sexes. Together, our results illustrate how a single node that differs across sexes could regulate multiple shared sensorimotor circuits. Our observations imply that these same circuit mechanisms and cell types will have a role in a range of social behaviours in which a fly must focus its attention on other nearby flies.

Methods

Fly stocks

All experiments used mated female flies unless otherwise stated. Flies were reared on standard cornmeal molasses food at 25 °C and 50% humidity. For optogenetic activation experiments, flies were reared in the dark on standard food supplemented with retinal (Sigma-Aldrich) unless otherwise specified, 0.2 mM all trans-retinal before eclosion and 0.4 mM all trans-retinal after eclosion. Hemidriver lines were created using gateway cloning as previously described61. Stable split GAL4 lines used in this study were constructed as described previously61 and hemidrivers used are described in Supplementary Table 1. iLexA stands for improved LexA, in which additional activating domains were added the transcription activator to enhance expression62. For the aIPg-iLexA line, the pBPnlsLexA::p65::GADUw vector was used for cloning as described previously48). Original confocal image data of GAL4 lines are available at https://www.janelia.org/split-GAL4. Genotypes used in each figure are listed in Supplementary Tables 1, 35, 7, 911, 13, 15, 17, 18, 2022, 24, 2630, 3234, 36 and 37.

Thermogenetic and optogenetic activation behavioural experiments

Groups of 5–8 group-housed mated female flies (7–10 days after eclosion) were video recorded at 60% relative humidity in a 53.3 mm × 3.5 mm circular arena. This assay and automated analysis pipeline was used as described63. All non-thermogenetic (TrpA) experiments were performed at 24 °C, while thermogenetic experiments were performed at 22 °C for non-activating controls and 31 °C for activation experiments. All tests were conducted under visible light conditions at zeitgeber time 0 to zeitgeber time 4 unless otherwise stated. Flies were loaded into the arena using an aspirator. For activation of neurons expressing Chrimson, the arena was illuminated as specified in the figure legends using constant uniform illumination with 660 nm LEDs. For inactivation of neurons expressing GtACR, we used constant uniform illumination with 525 nm LEDs. All of the trials were performed under white-light illumination from above. Videos were recorded from above using a camera (USB 3.1 Blackfly S, Monochrome Camera; Point Grey) with an 800 nm long-pass filter (B+W filter; Schneider Optics) at 170 frames per second and 1,024 × 1,024 pixel resolution.

Behavioural classification and analysis

For each trial, flies were acclimatized to the arena for 30 s before the delivery of six sets of constant stimuli each lasting 30 s with 30 s in between each stimulus. For all experiments, only the lowest stimulus intensity in which an effect was found is depicted and was analysed. Unless otherwise stated, the pre-stimulus average was calculated from the three periods before the stimulus periods used for analysis. In Fig. 3f, the previous stimuli appeared to alter behaviour during successive stimulus-off periods; therefore, only the first 15 s of the first pre-stimulus period was used for comparison. The videos were processed using the automated pipeline described previously63. In brief, flies were tracked using Caltech FlyTracker followed by automated classification of behaviour with JAABA classifiers64. Novel classifiers for touch and aggression were created based on previous definitions46,65. We validated the performance of these classifiers against manually labelled ground-truth data using videos that were not part of the training dataset (framewise performance is shown in Supplementary Table 2). As aggression is inherently the interaction of more than one fly, we cannot disassociate the behaviour of one fly from that of the others. Aggression is therefore computed on a per-arena basis rather than a per-fly basis. The percentage aggression is the sum of the aggression scores for all the trajectories in which flies were performing aggression divided by the total number of flies in the arena times 100. For figures displaying behavioural time courses, the mean of 0.35 s (60-frame) bins is shown. The angle occluded by nearest fly was calculated using the anglesub perframe feature65 and was computed by finding the two lines tangent to the fit ellipse that intersect at the nose-point of this fly, and measuring the angle between them.

For dyadic courtship assays (n = 13), the courtship start frame was manually identified based on first-instance inter-fly distance of <3 mm and fixation angle of <|20°| lasting for >1 min. Courtship end was defined as first copulation frame or end of video acquisition (30 min).

For calculation of visual features experienced during aggressive and courtship interactions, the angular position, velocity, height and width were calculated on a frame-by-frame basis using a custom MATLAB (MathWorks) script whereby, for each frame, the coordinates and orientations of subject fly and nearest conspecific, or target fly, were translated and rotated such that the subject was situated at the origin facing zero degrees. In this new basis, the target fly’s angular position (θ) and velocity (φ) with respect to the subject fly’s visual field were calculated as \(\theta ={\tan }^{-1}\left(\frac{y}{x}\right)\) and \(\varphi =\frac{{\rm{d}}\theta }{{\rm{d}}t}\,\), respectively. To approximate the angular size and expansion of the target fly in the subject’s visual field, an ellipse was fit to the major and minor axes of the target fly in this new basis. The target fly’s angular width was approximated as the length of the cross-section of this ellipse that lies perpendicular to the Euclidean line between the anterior-most point of the subject fly and target fly centroid. Thus, for each frame, the equation for the target fly’s angular width, w, is \(w=2\left({\tan }^{-1}\frac{R}{d}\right)\), where R is half the real cross-sectional length of the ellipse (in mm) and d is the Euclidean distance (in mm) between the anterior-most point of the subject fly and target fly centroid. The target fly’s angular height was approximated in a similar manner; however the target fly’s real height was fixed at 1 mm (which a reasonable estimation of a female fly’s height), so the equation for angular height, h, was simply \(h=2\left({\tan }^{-1}\frac{0.5\,{\rm{mm}}}{d}\right)\), where d is the Euclidean distance (in mm) between the anterior-most point of the subject fly and target fly centroid. Female aggression frames were defined using the JAABA aggression classifier and calculated from 79 trajectories.

Fly preparation for calcium imaging

For Fig. 3a and Extended Data Fig. 2a–d, experiments were performed similarly to those described previously24 with a similar preparation to that described in a previous study66. Notably, the fly’s head was positioned and glued to the fly holder such that the eye’s equator faced the middle of the visual projection screen. The proboscis remained intact but was glued in position, and a dissection needle was used to remove the cuticle and sever muscle 16.

For Fig. 6c, experiments were performed similarly to as described previously11. In brief, the flies were anaesthetized on CO2 and tethered to a custom-milled plate. The flies were held in place by a string across the neck and fixed to the holder by both eyes and the back of the thorax using UV-curable glue. The proboscis was also glued to the mouthparts to minimize brain motion. Flies were left to recover in a warm, humidified chamber (25 °C, 50–70% humidity) in the dark for 1–4 h. The cuticle was subsequently dissected from the top of the head and flies were transferred to an air-supported foam ball.

Two-photon calcium imaging

In Fig. 3a and Extended Data Fig. 2a–d, calcium imaging experiments were performed with male or female flies (LC10a and LC9 experiments respectively) 5–10 days after eclosion, maintained under standard conditions (21.8 °C, 55% humidity, 16 h–8 h light–dark, standard cornmeal/molasses food). A full list of fly genotypes used in the calcium imaging experiments is provided in the Supplementary Information. The imaging setup is identical to the previously described two-photon microscope (Thorlabs) setup24. In brief, we used a Ti:Sapphire femtosecond laser (Spectra-Physics Mai Tai eHP DS) tuned to 920 nm and delivering <20 mW power at the sample. Fluorescence signals were collected using a ×16 water-immersion objective (Nikon CFI75, NA 0.8) with a band-pass filter (Semrock 503/40 nm) in front of the photomultiplier tube (Hamamatsu GaAsP H10770PB-40 SEL). Oxygenated saline was circulated throughout. Imaging volumes were acquired at 5.6 Hz or higher. Visual stimuli were delivered to the fly’s right eye and all imaging was from the right side of the brain. The stimuli were presented on a screen that subtended approximately 90° by 90° of the fly’s field of view with a green (532 nm) projector setup as previously described24.

In Fig. 6c, calcium imaging experiments were performed with TuTuA_1 and TuTuA_2 male flies 3–7 days after eclosion, maintained under standard conditions (25 °C, 65% humidity, 12 h–12 h light–dark, standard Würzburg food). The imaging preparation for tethered courtship was identical to that previously described11. In brief, male flies rested and walked on a small 6.35 mm diameter ball, which was shaped from foam and manually painted with uneven black spots using a Sharpie. The foam ball was held by a custom-milled aluminium base and floated by air supplied at ~0.8 l min−1 such that the ball could move smoothly. The ball was illuminated by infrared LED flood lights, and imaged with a Point Grey FLIR Firefly camera using a mirror. The ball was surrounded by a 270° conical screen with a large diameter of ~220 mm, a small diameter of ~40 mm and a height of ~60 mm. As males walked on the foam ball, all three rotational axes of the ball were read out by the FicTrac2.0 software67 at 60 Hz in real-time. The visual stimulus was projected around the male from a DLP 3010 Light Control Evaluation Module (Texas Instruments) through a first-surface mirror below the fly. The red and green LEDs in the projector were turned off, leaving only the blue LEDs to minimize interference with GCaMP emissions.

Visual stimuli were generated in the MATLAB-based ViRMEn software68 and projected onto the screen using custom perspective transformation functions. The net visual refresh rate of the visual stimulus ranged from 47.6 Hz to 58.9 Hz. Each trial was initiated by the presentation of a stationary visual target for 60 s to examine the animal’s baseline locomotion, after which the visual target began to oscillate. The visual target oscillated in a 107° arc around the animal with a constant angular velocity of approximately 75° s−1, but the angular size of the dot was continuously altered to mimic the dynamics of a natural female during courtship. The angular size was altered by changing the distance between the male and the target in the ViRMEn world. The distance between the male and the target was taken from the inter-fly distance in a courting pair over the course of two minutes of courtship and, at each frame, the angular position of the target was scaled by this inter-fly distance to give rise to a more dynamic female path. Angular sizes ranged between around 8 and 50°, with the average size being 22.5°. Each stimulus frame was therefore unique for 2 min of time, and subsequently repeated until the end of the trial when it intersected its original position. Each trial lasted 10 min.

Male imaging experiments were performed using the Ultima Investigator or Ultima Investigator Plus two-photon laser-scanning microscope (Bruker Nanosystems) with a Chameleon Ultra II Ti:Sapphire laser. All of the samples were excited at a wavelength of 920 nm, and emitted fluorescence was detected with a GaAsP photodiode detector (Hamamatsu). All images were acquired using a ×40 Olympus water-immersion objective with 0.8 NA. All images were collected using PrairieView Software (v.5.5 or 5.7) at a resolution of 512 px × 512 px.

Courtship and running was classified based on the fidelity and vigour of a male’s pursuit of the visual target, as described previously11.

In Extended Data Figs. 5b and 7a–e, ex vivo calcium imaging experiments were performed similarly to those described previously69. In brief, flies were reared at 25 °C on cornmeal medium supplemented with retinal (0.2 mM) that was shielded from light. All experiments were performed on female flies, 3–5 days after eclosion. Brains were dissected in a saline bath (103 mM NaCl, 3 mM KCl, 2 mM CaCl2, 4 mM MgCl2, 26 mM NaHCO3, 1 mM NaH2PO4, 8 mM trehalose, 10 mM glucose, 5 mM TES, bubbled with 95% O2/5% CO2). After dissection, the brain was positioned anterior side up on a coverslip in a Sylgard dish submerged in 2 ml saline at 20 °C. The sample was imaged with a resonant scanning 2-photon microscope with near-infrared excitation (920 nm, Spectra-Physics, INSIGHT DS DUAL) and a ×25 objective (Nikon MRD77225 25XW). The microscope was controlled using ScanImage 2017 (Vidrio Technologies). Volumes were acquired with a 230 μm × 230 μm field of view at 512 × 512 px resolution at 2  μm steps over 42 slices, at approximately 1 Hz. The excitation power for Ca2+ imaging measurement was 15 mW. On the emission side, the primary dichroic was Di02-R635 (Semrock), the detection arm dichroic was 565DCXR (Chroma), and the emission filters were FF03-525/50 and FF01-625/90 (Semrock). During photostimulation, the light-gated ion channel Chrimson was activated with a 660 nm LED (M660L3 Thorlabs) coupled to a digital micromirror device (Texas Instruments DLPC300 Light Crafter) and combined with the imaging path with a FF757-DiO1 dichroic (Semrock). Photostimulation occurred at 10 Hz over two periods with a duration of 14 s at 0.037 mW mm−2 intensity interspersed by a 2 s pause. After responses to the photostimulation, the laser power was increased to take two-colour high-resolution images containing fluorescence from both the red and green channels. Using custom Python scripts, regions of interest (ROIs) corresponding to cell compartments were identified in the high-resolution images. These ROIs were then applied to the time-series images to measure intensity changes in response to the photostimulation. Fluorescence in a background ROI, which contained no endogenous fluorescence, was subtracted from the cell compartment ROIs. In the ΔF/F calculations, baseline fluorescence is the mean fluorescence over a 10 s time period before stimulation started. The ΔF is the fluorescence minus the baseline. The ΔF is then divided by the baseline to normalize the signal (ΔF/F). Outlier samples with very low intensities or those of which the intensity randomly fluctuated were excluded from the analysis.

Electrophysiology

Whole-cell patch-clamp recordings were obtained from freshly isolated brains of 3–5 day old flies. The brain was continuously perfused with oxygenated (95% O2/5% CO2) extracellular saline containing 103 mM NaCl, 3 mM KCl, 1.5 mM CaCl2·2H2O, 4 mM MgCl2·6H2O, 1 mM NaH2PO4·H2O, 26 mM NaHCO3, 5 mM TES, 10 mM glucose and 10 mM trehalose·2H2O. Osmolarity was 275 mOsm and the pH was 7.3. Recording electrodes were pulled from thick-walled glass pipette (1.5 mm/0.86 mm) using the P-97 puller (Sutter Instruments) and fire polished using MF 830 (Narishige) to achieve resistances of 10–12 MΩ. Intracellular saline contained 137 mM KAsp, 10 mM HEPES, 1.1 mM EGTA, 0.1 mM CaCl2·2H2O, 4 mM MgATP, 0.5 mM NaGTP. Osmolarity was 260–265 mOsm and the pH was adjusted to 7.3 with KOH. Biocytin was added to intracellular solution at 0.5% for post hoc morphological confirmation.

The brain was visualized by an IR-sensitive CCD camera (ThorLabs 1501M) with an 850 nm LED (ThorLabs M850F2). GFP-labelled cell body was visualized with 460 nm LED (Sutter Instruments). Images were acquired using Micro-Manager with automatic contrast adjustment. Recordings were obtained from cell bodies under a 60× water-immersion objective (Olympus).

Current-clamp recordings were sampled at 20 kHz, low-pass filtered at 10 kHz using the Digidata 1550B system, Multiclamp 700B system and Clampex v.11.2 software (Molecular Devices). Recordings were made at a membrane potential of −50 mV to −65 mV, with small (5–30 pA) hyperpolarizing current injections as needed, and not corrected for liquid junction potentials.

Chrimson was activated by 630 nm LED at 0.4 mW cm−2. The stimulation duration was set at minimal value that is sufficient to induce reliable responses from target neurons. After the electrophysiology recording, the whole brain was fixed in 4% paraformaldehyde in 0.1 M PBS until further staining. After rinsing in PBS, the brain was incubated in Streptavidin Alexa Fluor 647 (1:200) in PBS-T overnight at room temperature. The preparations were then rinsed, dehydrated and mounted with DPX. The confocal images were captured on the LSM 980 microscope (Zeiss), with 639 nm excitation wavelength.

The electrophysiological recordings were analysed using pClamp (Clampfit v.11.3). The instantaneous action potential frequency was calculated for about 1 min in each cell. The action potential amplitude was averaged from 20–30 individual events in each cell, and measured as the difference between the threshold and peak.

Immunohistochemistry and imaging

All experiments were performed as described previously46,70,71,72,73,74. Additional details of the imaging pipeline used are available online (https://data.janelia.org/pipeline).

Connectomics analyses

Our analyses are based on the hemibrain dataset25 (v.1.2.1) as queried using the neuPrint interface (https://neuprint.janelia.org/) unless otherwise noted. The unique identifier (bodyID number in the hemibrain v.1.2.1 database) for neurons is shown in the figures, and a complete list of synaptic connections used to construct our circuit diagrams can be found in neuPrint. LC10s in the hemibrain dataset were assigned to candidate types based on connectivity and morphology differences. As the hemibrain did not include the entire lobula, we also performed analyses in the recently completed and fully annotated male optic lobe connectome53 (neuprint release: optic-lobe: v.1.0) and the Flywire54 (v.783) analysis of the FAFB datasets75.

Synaptic connections organized by neuron pair and neuropil for FlyWire or optic lobe were obtained from Zenodo76 and neuPrint (using neuprint-python fetch_adjacencies with the default settings), respectively. The connection tables obtained in this way do not include synapses with small, untyped EM bodies as, in most cases, unidentified fragments of larger reconstructed cells are included in the tables and we did not include such synapses when calculating relative connection strengths. Including these additional synapses in calculations of relative connections strength (as done for example in the neuPrint web interface) results in lower numbers that most likely underestimate the relative contribution of one cell type to the inputs or outputs of another type. Although we did observe highly similar relative connection strengths for many cell type pairs, we also note that there were methodological differences between the FlyWire/FAFB and optic lobe datasets that may result in significant non-biological differences between synapse counts.

Neurotransmitters for TuTuA_1 and IB112 were determined by EASI-FISH77 using lines SS77547 for TuTuA_1 and SS81529 for IB112. Neurotransmitters for aIPg46 and LC10s78 were previously reported. Other reported neurotransmitters are based on computational predictions53,79.

Cell type annotations for FlyWire neurons59,60 were as downloaded from Codex on 24 April 2024 from https://codex.flywire.ai/api/download?data_product=visual_neuron_types&data_version=783. Matches of cell type names between the optic lobe and FlyWire datasets were as published53. FlyWire data to evaluate connections to descending interneurons described in Extended Data Fig. 10 were accessed through Codex (https://codex.flywire.ai) and evaluated using Flywire.

Statistics

No statistical methods were used to predetermine sample size. Sample size was based on previous literature in the field and is provided in the Supplementary Information (Supplementary Tables 6, 8, 12, 14, 16, 19, 23, 25, 31 and 35). Experimenters were not blinded in most conditions as all data acquisition and analysis were automated. Experiments were not randomized as most controls were performed within animals. Biological replicates completed at separate times using different parental crosses were performed for each of the behavioural experiments. Behavioural data are representative of at least two independent biological repeats. For figures in which the behavioural data over the course of a trial are shown, a yellow or red bar indicates the stimulus period, the mean is represented as a solid line and shaded error bars represent the variation between experiments.

For each experiment, the experimental and control flies were collected, treated and tested at the same time. A Wilcoxon matched-pairs signed-rank test (two-tailed) was used for statistical analysis of optogenetic experiments when examining effects within the same group. The results of two-way analysis of variance followed by Tukey’s test (three or more groups) or uncorrected Fisher’s least significant difference test (two groups) for multiple comparisons for each optogenetic experiment are also reported in the Supplementary Information. For analysis among two groups, Mann–Whitney U-tests (two-tailed) were used, while Kruskal–Wallis tests with Dunn’s multiple-comparisons post hoc analysis were used to compare across multiple groups. All statistical analysis was performed using Prism (GraphPad, v.10). P values are indicated by asterisks. The exact P values for each figure are provided in the Supplementary Information.

For bar plots, all datapoints are shown to indicate the range and the top edge of the bar represents the mean. The box plots show the median and interquartile range. The lower and upper whiskers represent 1.5 ×  interquartile range of the lower and upper quartiles, respectively; the boxes indicate lower quartile, median and upper quartile, from bottom to top. When all points are shown, the whiskers represent the range and the boxes indicate the lower quartile, median and upper quartile, from bottom to top. In the violin plots, the lower and upper quartiles are indicated by dotted light grey lines, and the median is indicated by a solid light grey line. Shaded error bars on graphs represent the mean ± s.e.m.

Reporting summary

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