Transforming a head direction signal into a goal-oriented steering command – Nature

    0
    1
    Transforming a head direction signal into a goal-oriented steering command – Nature


    Flies

    Unless otherwise specified, flies were raised on cornmeal-molasses food (Archon Scientific) in an incubator on a 12 h:12 h light:dark cycle at 25 °C at 50–70% relative humidity. Experimenters were not blinded to fly genotype. For iontophoresis stimulus experiments (Fig. 2a,b) flies were grouped for analysis based on genotype. Sample sizes were chosen based on conventions in our field for standard sample sizes; these sample sizes are conventionally determined on the basis of the expected magnitude of animal-to-animal variability, given published results and pilot data. All experiments used flies with at least one wild-type copy of the white (w) gene. Genotypes used in each figure are as follows.

    Fig. 1:

    PFL2 and PFL3 calcium imaging, w/+;P{VT033284-p65AD}attP40/20XUAS-IVS-cyRFP{VK00037}; P{y[+t7.7];w[+mC]=VT044709-GAL4.DBD}attP2/PBac{y[+t7.7] w[+mC]=20XUAS-IVS-jGCaMP7b}VK00005.

    PFL2 calcium imaging, w/+;P{VT033284-p65AD}attP40/20XUAS-IVS-cyRFP{VK00037}; P{y[+t7.7];P{VT007338-Gal4DBD}attP2/PBac{y[+t7.7] w[+mC]=20XUAS-IVS-jGCaMP7b}VK00005.

    Fig. 2:

    PFL2 cells expressing P2X2, w/+;P{VT033284-p65AD}attP40/P{w[+mC]=UAS-RnorP2rx2.L}4/;P{VT007338-Gal4DBD}attP2/20XUAS-mCD8::GFP {attP2}.

    Empty split control,

    w/+;P{y[+t7.7] w[+mC]=p65.AD.Uw}attP40/P{w[+mC]=UAS-RnorP2rx2.L}4;P{y[+t7.7] w[+mC]=GAL4.DBD.Uw}attP2/20XUAS-mCD8::GFP {attP2}.

    PFL2 calcium imaging,

    w/+;P{VT033284-p65AD}attP40/20XUAS-IVS-cyRFP{VK00037}; P{y[+t7.7];P{VT007338-Gal4DBD}attP2/PBac{y[+t7.7] w[+mC]=20XUAS-IVS-jGCaMP7b}VK00005.

    Fig. 3:

    PFL2 calcium imaging,

    w/+;P{VT033284-p65AD}attP40/20XUAS-IVS-cyRFP{VK00037}; P{y[+t7.7];P{VT007338-Gal4DBD}attP2/PBac{y[+t7.7] w[+mC]=20XUAS-IVS-jGCaMP7b}VK00005.

    PFL2 and PFL3 calcium imaging,

    w/+;P{VT033284-p65AD}attP40/20XUAS-IVS-cyRFP{VK00037}; P{y[+t7.7];w[+mC]=VT044709-GAL4.DBD}attP2/PBac{y[+t7.7] w[+mC]=20XUAS-IVS-jGCaMP7b}VK00005.

    Fig. 4:

    w/+;P{VT033284-p65AD}attP40/P{20XUAS-IVS-mCD8::GFP}attP40;P{y[+t7.7] w[+mC]=VT044709-GAL4.DBD}attP2/+.

    Fig. 5:

    PFL2 calcium imaging,

    w/+;P{VT033284-p65AD}attP40/20XUAS-IVS-cyRFP{VK00037}; P{y[+t7.7];P{VT007338-Gal4DBD}attP2/PBac{y[+t7.7] w[+mC]=20XUAS-IVS-jGCaMP7b}VK00005.

    PFL2 and PFL3 recordings,

    w/+;P{VT033284-p65AD}attP40/P{20XUAS-IVS-mCD8::GFP}attP40;P{y[+t7.7] w[+mC]=VT044709-GAL4.DBD}attP2/+.

    Extended Data Fig. 2:

    MCFO, w[1118] P{y[+t7.7] w[+mC]=R57C10-FLPG5}su(Hw)attP8; PBac{y[+mDint2] w[+mC]=10xUAS(FRT.stop)myr::smGdP-HA}VK00005 P{y[+t7.7] w[+mC]=10xUAS(FRT.stop)myr::smGdP-V5-THS-10xUAS(FRT.stop)myr::smGdP-FLAG}su(Hw)attP1.

    PFL2 and PFL3 line:

    w/+;P{VT033284-p65AD}attP40/P{20XUAS-IVS-mCD8::GFP}attP40;P{y[+t7.7] w[+mC]=VT044709-GAL4.DBD}attP2/+.

    PFL2 line:

    w/+;P{VT033284-p65AD}attP40/P{20XUAS-IVS-mCD8::GFP}attP40; P{y[+t7.7];P{VT007338-Gal4DBD}attP2/+.

    Extended Data Fig. 3:

    PFL2 calcium imaging,

    w/+;P{VT033284-p65AD}attP40/20XUAS-IVS-cyRFP{VK00037}; P{y[+t7.7];P{VT007338-Gal4DBD}attP2/PBac{y[+t7.7] w[+mC]=20XUAS-IVS-jGCaMP7b}VK00005.

    PFL2 and PFL3 calcium imaging,

    w/+;P{VT033284-p65AD}attP40/20XUAS-IVS-cyRFP{VK00037}; P{y[+t7.7];w[+mC]=VT044709-GAL4.DBD}attP2/PBac{y[+t7.7] w[+mC]=20XUAS-IVS-jGCaMP7b}VK00005.

    Extended Data Fig. 4:

    PFL2 cells expressing P2X2, w/+;P{VT033284-p65AD}attP40/P{w[+mC]=UAS-RnorP2rx2.L}4/;P{VT007338-Gal4DBD}attP2/20XUAS-mCD8::GFP {attP2}.

    Empty split control,

    w/+;P{y[+t7.7] w[+mC]=p65.AD.Uw}attP40/P{w[+mC]=UAS-RnorP2rx2.L}4;P{y[+t7.7] w[+mC]=GAL4.DBD.Uw}attP2/20XUAS-mCD8::GFP {attP2}.

    Extended Data Fig. 5:

    PFL2 calcium imaging,

    w/+;P{VT033284-p65AD}attP40/20XUAS-IVS-cyRFP{VK00037}; P{y[+t7.7];P{VT007338-Gal4DBD}attP2/PBac{y[+t7.7] w[+mC]=20XUAS-IVS-jGCaMP7b}VK00005.

    PFL2 and PFL3 calcium imaging,

    w/+;P{VT033284-p65AD}attP40/20XUAS-IVS-cyRFP{VK00037}; P{y[+t7.7];w[+mC]=VT044709-GAL4.DBD}attP2/PBac{y[+t7.7] w[+mC]=20XUAS-IVS-jGCaMP7b}VK00005.

    Extended Data Fig. 6:

    w/+;P{VT033284-p65AD}attP40/P{20XUAS-IVS-mCD8::GFP}attP40;P{y[+t7.7] w[+mC]=VT044709-GAL4.DBD}attP2/+.

    Extended Data Fig. 7:

    w/+;P{VT033284-p65AD}attP40/P{20XUAS-IVS-mCD8::GFP}attP40;P{y[+t7.7] w[+mC]=VT044709-GAL4.DBD}attP2/+.

    Extended Data Fig. 8–10:

    PFL2 calcium imaging,

    w/+;P{VT033284-p65AD}attP40/20XUAS-IVS-cyRFP{VK00037}; P{y[+t7.7];P{VT007338-Gal4DBD}attP2/PBac{y[+t7.7] w[+mC]=20XUAS-IVS-jGCaMP7b}VK00005.

    Origins of transgenic stocks

    The following stocks were obtained from the Bloomington Drosophila Stock Center (BDSC) and previously published as follows: P{y[+t7.7]w[+mC]=VT044709-GAL4.DBD}attP2 (BDSC_75555)41, P{y[+t7.7] w[+mC]=p65.AD.Uw}attP40; P{y[+t7.7] w[+mC]=GAL4.DBD.Uw}attP2 (BDSC_79603), P{w[+mC]=UAS-RnorP2rx2.L}4/CyO (BDSC_91223)42, w[1118] P{y[+t7.7] w[+mC]=R57C10-FLPG5}su(Hw)attP8; PBac{y[+mDint2] w[+mC]=10xUAS(FRT.stop)myr::smGdP-HA}VK00005 P{y[+t7.7] w[+mC]=10xUAS(FRT.stop)myr::smGdP-V5-THS-10xUAS(FRT.stop)myr::smGdP-FLAG}su(Hw)attP1 (BDSC_64088)43.

    The following stocks were obtained from WellGenetics: w[1118];P{VT007338-p65ADZp}attP40/CyO;+ (SWG9178/A), w[1118];P{VT033284-p65AD}attP40/CyO;+ (A/SWG8077). Using these lines, we constructed a split-Gal4 line whose expression in the lateral accessory lobe (LAL) is specific to PFL2 and PFL3 cells (+;P{VT033284-p65AD}attP40;P{y[+t7.7] w[+mC]=VT044709-GAL4.DBD}attP2). We validated the expression of this line using immunohistochemical anti-GFP staining and also using Multi-Color-Flip-Out (MCFO)43 to visualize single-cell morphologies. This line has significant non-specific expression throughout the brain but is specific for PFL2 and PFL3 in the LAL. We also constructed a split-Gal4 line to target PFL2 neurons, +;P{VT033284-p65AD}attP40; P{y[+t7.7];P{VT007338-Gal4DBD}attP2. We validated the expression of this line using immunohistochemical anti-GFP staining and also using MCFO to visualize single-cell morphologies. This line exhibits expression in various peripheral neurons but is selective for PFL2 neurons within the central complex—specifically, the protocerebral bridge, fan-shaped body and LAL.

    Fly preparation and dissection

    Flies used for all experiments were isolated the day before the experiment by single-housing on molasses food. For calcium imaging experiments we used female flies 20–72 h posteclosion. For electrophysiology experiments, including the iontophoresis experiments, we used female flies 16–30 h posteclosion. No circadian restriction was imposed for the time of experiments.

    Manual dissections in preparation for experiments were as follows. Flies were briefly cold-anaesthetized and inserted using fine forceps (Fine Science Tools) into a custom platform machined from black Delrin (Autotiv or Protolabs). The platform was shaped like an inverted pyramid to minimize occlusion of the fly’s eyes. The head was pitched slightly forward, so the posterior surface was more accessible to the microscope objective. The wings were removed, then the fly head and thorax were secured to the holder using UV-curable glue (Loctite AA 3972) with a brief pulse of ultraviolet light (LED-200, Electro-Lite Co.). To prevent large brain movements, the proboscis was glued in place using a small amount of the same UV-curable glue. Using fine forceps in extracellular Drosophila saline, a window was opened in the head cuticle, and tracheoles and fat were removed to expose the brain. To further reduce brain movement, muscle 16 was stretched by gently tugging the oesophagus, or else it was removed by clipping the muscle anteriorly. For electrophysiology and iontophoresis experiments only, the perineural sheath was minimally removed with fine forceps over the brain region of interest. For all experiments, saline was continuously superfused over the brain. Drosophila extracellular saline composition was: 103 mM NaCl, 3 mM KCl, 5 mM TES, 8 mM trehalose, 10 mM glucose, 26 mM NaHCO3, 1 mM NaH2PO4, 1.5 mM CaCl2 and 4 mM MgCl2 (osmolarity 270–275 mOsm). Saline was oxygenated by bubbling with carbogen (95% O2, 5% CO2) and reached a final pH of about 7.3.

    Two-photon calcium imaging

    We used a two-photon microscope equipped with a galvo-galvo-resonant scanhead (Thorlabs Bergamo II GGR) and ×25, 1.10 numerical aperture (NA) objective (Nikon CFI APO LWD; Thorlabs, WDN25X-APO-MP). For volumetric imaging, we used a fast piezoelectric objective scanner (Thorlabs PFM450E). To excite GCaMP we used a wavelength-tunable femtosecond laser with dispersion compensation (Mai Tai DeepSee, Spectra Physics) set to 920 nm. GCaMP fluorescence signals were collected using GaAsP PMTs (PMT2100, Thorlabs) through a 405–488 nm band-pass filter (Thorlabs). All image acquisition and microscope control was conducted in MATLAB 2021a (MathWorks Inc), using ScanImage 2021 Premium with vDAQ hardware (Vidrio Technologies LLC) and custom MATLAB scripts for further experimental control. The region for imaging the fan-shaped body and protocerebral bridge was 150 × 250 pixels, whereas the region for imaging the LAL was 150 × 400 pixels. We acquired 10–12 slices in the z axis for each volume (4 µm per slice), resulting in 6–8 Hz volumetric scanning rate. For experiments using the selective PFL2 split-Gal4 line, we imaged in the protocerebral bridge, fan-shaped body, or LAL for different trials. For experiments imaging the mixed PFL2 and PFL3 split-Gal4 line, we only imaged in the LAL.

    Patch-clamp recordings

    Patch pipettes were pulled from filamented borosilicate capillary glass (outer diameter: 1.5 mm, inner diameter 0.86 mm; BF150-86-7.5HP, Sutter Instrument Company), using a horizontal pipette puller (P-97, Sutter Instrument Company) to a resistance range of 9–13 MΩ. Pipettes were filled with an internal solution44 consisting of 140 mM KOH, 140 mM aspartic acid, 1 mM KCl, 10 mM HEPES, 1 mM EGTA, 4 mM MgATP, 0.5 mM Na3GTP and 15 mM neurobiotin citrate, filtered twice through a 0.22 µm PVDF filter (Millipore).

    All electrophysiology experiments used a semicustom upright microscope consisting of a motorized base (Thorlabs Cerna), with conventional collection and epifluorescence attachment (Olympus BX51), but no substage optics in order to better fit the virtual-reality system. The microscope was equipped with a ×40 water immersion objective (LUMPlanFLN 40×W, Olympus) and CCD Monochrome Camera (Retiga ELECTRO; 01-ELECTRO-M-14-C Teledyne). For GFP excitation and detection, we used a 100 W Hg arc lamp (Olympus U-LH100HG) and an eGFP long-pass filter cube (Olympus F-EGFP LP). The fly was illuminated from below using a fibre optic coupled LED (M740F2, Thorlabs) coupled to a ferrule-terminated patch cable (200 µM core, 0.22 NA, Thorlabs) attached to a fibre optic cannula (200 µM core, 0.22, Thorlabs). The cannula was glued to the ventral side of the holder and positioned approximately 135° from the front of the fly to be unobtrusive to the fly’s visual field. Throughout the experiment, saline bubbled with 95% O2 and 5% CO2 was superfused over the fly using a gravity fed pump at a rate of 2 ml min−1. Whole-cell current-clamp recordings were performed using an Axopatch 200B amplifier with a CV-203BU headstage (Molecular Devices). Data from the amplifier were low-pass filtered using a 4-pole Bessel low-pass filter with a 5 kHz corner frequency, then acquired on a data acquisition card at 20 kHz (NiDAQ PCIe-6363, National Instruments). The liquid junction potential was corrected by subtracting 13 mV from recorded voltages45. Membrane potential data was then resampled to a rate of 1 kHz for ease of use and compatibility with behavioural data. To estimate baseline membrane voltage (Fig. 5e–g), we removed spikes from voltage traces by median filtering using a 50 ms window and lightly smoothed using the smoothdata function in MATLAB (loess method, 20 ms window). For all electrophysiology experiments in the mixed PFL2 and PFL3 line, we recorded from only one cell per fly. During recordings the cell was filled using internal solution containing neurobiotin citrate, so that we could visualize the cell morphology in order to determine its identity, using the protocol described in the ‘Immunohistochemistry’ section.

    Spherical treadmill and locomotion measurement

    Experiments used an air-cushioned spherical treadmill and machine-vision system to track the intended movement of the animal. The treadmill consisted of a 9-mm-diameter ball machined from foam (FR-4615, General Plastics), sitting in a custom-designed concave hemispherical holder three-dimensionally printed from clear acrylic (Autotiv). The ball was floated with medical-grade breathing air (Med-Tech) through a tapered hole at the base of the holder using a flow meter (Cole Parmer). For machine-vision tracking, the ball was painted with a high-contrast black pattern using a black acrylic pen and illuminated with an IR LED (880 nm for two-photon experiments; M880L3, Thorlabs, or 780 nm for electrophysiology experiments; M780L3, Thorlabs). Ball movement was captured online at 60 Hz using a CMOS camera (CM3-U3-13Y3M-CS for two-photon imaging, or CM3-U3-13Y3C-CS for electrophysiology, Teledyne FLIR) fitted with a macro zoom lens InfiniStix (68 mm ×0.66 for two-photon, InfiniStix 94 mm ×0.5 for electrophysiology). The camera faced the ball from behind the fly (at 180°). Machine vision software (FicTrac v.2.1) was used to track the position of the ball43 in real time. We used a custom Python script to output the forward axis ball displacement, yaw axis ball displacement, forward ball displacement and gain-modified yaw ball displacement to an analogue output device (Phidget Analog 4-Output 1002_0B) and recorded these signals along with other experimental timeseries data on a data acquisition card (NiDAQ PCIe-6363) card at 20 kHz. The gain-modified yaw ball displacement voltage signal was also used to update the azimuthal position of the visual cues displayed by the visual panorama.

    Visual panorama and visual stimuli

    To display visual stimuli, we used a circular panorama built from modular square (8 × 8 pixel) LED panels46. The circular arena was twelve panels in circumference and two panels tall. To accommodate the ball-tracking camera view and the light source the upper panel 180° behind the fly was removed. In all experiments, the modular panels contained blue LEDs with peak blue (470 nm) emission; blue LEDs were chosen to reduce overlap with the GCaMP emission spectrum. For calcium imaging experiments, four layers of gel filters were added in front of the LED arena (Rosco, R381) to further reduce overlap in spectra. For electrophysiology experiments, only two layers of gel filters were used. On top of the gel filters in both cases we added a final diffuser layer to prevent reflections (SXF-0600, Snow White Light Diffuser, Decorative Films). The visual cue was a bright (positive contrast) 2-pixel-wide (7.5°) vertical bar. The bar’s height was the full two-panel height of the area (except for −165 to +165° behind the fly with a single visual display panel, where the bar was half this height). The bar intensity was set at a luminance value of 4 with a background luminance of 0 (maximum value 15).

    The azimuthal position of the cue was controlled during closed-loop experiments by the yaw motion of the ball (see section ‘Spherical treadmill and locomotion measurement’). For all experiments, a yaw gain of 0.7 was used, meaning that the visual cue displacement was 0.7 times the ball’s yaw displacement. For calcium imaging and electrophysiology experiments the cue was instantaneously jumped every 60 s by ±90° or 180°. Immediately following each jump, the cue would continue to move in closed loop with the fly’s movements. We recorded the position of the cue during experiments using analogue output signals from the visual panels along with other experimental timeseries data on a data acquisition card at 20 kHz (PCIe-6363, National Instruments). We converted analogue signals from the visual panels into cue position in pixels during offline analysis. Cue positions were then converted into head direction as follows: 0° when the fly was directly facing the cue, 90° when the fly’s head direction was 90° clockwise to the cue, −90° when the fly was 90° counterclockwise and 180° when the fly was facing directly away from the cue. These signals were lightly smoothed and values above 180° or below −180° were set to ±180°.

    Experimental trial structure

    Before data collection in each experiment, the fly walked for a minimum of 15 min in closed loop with the visual cue. For calcium imaging experiments, data were collected in 10 min trials. In each trial, the fly was in closed loop with the cue, and every 60 s the cue jumped to a new location relative to its current one, alternating between +90°, 180° and −90°, in that order. Between trials during calcium imaging experiments, there was 30 s of darkness. Electrophysiology experiments followed a similar protocol, though occasionally 20 min trials were collected rather than 10 min trials. Additionally, during the intertrial period, flies viewed the cue in closed loop. As these experiments were heavily dependent on spontaneously performed behaviour, trials were run until the fly stopped walking or, in the case of electrophysiology experiments, the cell recording quality significantly decreased.

    Iontophoresis stimuli

    Pipettes for iontophoresis were pulled from aluminosilicate capillary glass (outer diameter 1.5 mm, inner diameter 1.0 mm, Sutter Instrument Company) to a resistance of approximately 75 MΩ using a horizontal pipette puller (P-97, Sutter Instrument Company). Pipettes were filled with a solution47 consisting of 10 mM ATP disodium in extracellular saline with 1 mM AlexFluor 555 hydrazine (Thermo Fisher Scientific) for visualization. This solution was stored in aliquots at −20 °C, thawed fresh daily and kept on ice during the experiment. The tip of the iontophoresis pipette was positioned to be approximately in the medial region of the protocerebral bridge every trial. During experimental trials, we simultaneously recorded from a PFL2 neuron. During control trials, we recorded from unidentified neurons with somata in the same approximate region as PFL2 somata (medial area dorsal to the protocerebral bridge). Pulses of ATP were delivered using a dual current generator iontophoresis system (Model 260, World Precision Instruments). Holding current was set to 10 nA to prevent solution leakage, and a current of −200 nA was used for ejection. Visual confirmation of ATP ejection following current pulses was obtained before and after each trial. For the duration of the 10 min trial period, flies viewed a visual cue that moved in closed loop with their rotational movements, as described above. Throughout the trial, pulses were delivered every 30 s with lengths of 100, 200, 300 and 500 ms, repeating in that order.

    Immunohistochemistry

    Brains were dissected from female flies 1–3 days posteclosion in Drosophila external saline and fixed in 4% paraformaldehyde (Electron Microscopy Sciences, catalogue no. 15714) in phosphate-buffered saline (PBS, Thermo Fisher Scientific, 46-013-CM) for 15 min at room temperature. Brains were washed with PBS before adding a blocking solution containing 5% normal goat serum (Sigma-Aldrich, catalogue no. G9023) in PBS with 0.44% Triton-X (Sigma-Aldrich, catalogue no. T8787) for 20 min. Brains were then incubated in primary antibody with blocking solution for roughly 24 h at room temperature, washed in PBS and incubated in secondary antibody with blocking solution for roughly 24 h at room temperature. Primary and secondary antibodies were protocol-specific (see below). Brains were then rinsed with PBS and mounted in antifade mounting medium (Vectashield, Vector Laboratories, catalogue no. H-1000) for imaging. For MCFO protocols, a tertiary incubation step for about 24 h at room temperature and wash with PBS was performed before mounting. Mounted brains were imaged on a Leica SPE confocal microscope using a ×40, 1.15 NA oil-immersion objective. Image stacks comprised 50 to 200 z-slices at a depth of 1 μm per slice. Image resolution was 1,024 × 1,024 pixels. For visualizing Gal4 expression patterns, the primary antibody solution contained chicken anti-GFP (1:1,000, Abcam, catalogue no. ab13970) and mouse anti-Bruchpilot (1:30, Developmental Studies Hybridoma Bank, nc82). The secondary antibody solution contained Alexa Fluor 488 goat anti-chicken (1:250, Invitrogen, catalogue no. A11039) and Alexa Fluor 633 goat anti-mouse (1:250, Invitrogen, catalogue no. A21050). For visualizing cell fills after whole-cell patch-clamp recordings, 1:1,000 streptavidin::Alexa Fluor 568 (Invitrogen, catalogue no. S11226) was added to the primary and secondary solutions.

    For MCFO48, the primary antibody solution contained mouse anti-Bruchpilot (1:30, Developmental Studies Hybridoma Bank, nc82), rat anti-Flag (1:200, Novus Biologicals, catalogue no. NBP1-06712B) and rabbit anti-HA (1:300, Cell Signaling Technology, catalogue no. 3724S). The secondary antibody solution contained Alexa Fluor 488 goat anti-rabbit (1:250, Invitrogen, catalogue no. A11039), ATTO 647 goat anti-rat (1:400, Rockland, catalogue no. 612-156-120) and Alexa Fluor 405 goat anti-mouse (1:500, Invitrogen, catalogue no. A31553). The tertiary antibody solution contained DyLight 550 mouse anti-V5 (1:500, Bio-Rad, catalogue no. MCA1360D550GA).

    Processing calcium imaging data

    Analysis was performed in either MATLAB 2019 or MATLAB R2021a. The calcium imaging dataset comprised 23 flies expressing GCaMP under the control of the PFL3 + 2 split-Gal4 line and 33 flies expressing GCaMP under the control of the PFL2 split-Gal4 line. Rigid motion correction in the x, y and z axes was performed for each trial using the NoRMCorre algorithm49. Each region of interest (ROI) was defined across the z-stack. For each ROI ΔF/F was calculated with the baseline fluorescence (F) defined as the mean of the bottom 10% of fluorescence values in a given trial (600 s in length). From this measurement a modified z-score was calculated using the median absolute deviation (MAD) normalized difference from the median, which we refer to as the z-scored ΔF/F (Extended Data Fig. 9):

    $${y}_{i}=frac{{x}_{i}-,underline{X}}{{rm{MAD}}},{rm{where}},underline{X}={rm{median}},{rm{of}},X,,{rm{MAD}}={rm{median}},(| {x}_{i}-underline{X}| )$$

    (1)

    For protocerebral bridge imaging, ten ROIs were defined, one for each of the ten glomeruli occupied by PFL2 dendrites and defined to be approximately the same width and without overlap, constrained by estimated anatomical boundaries. For fan-shaped-body imaging, nine ROIs were defined for PFL2 neurites corresponding to the nine columns spanning the horizontal axis of the fan-shaped body. ROIs were approximately the same width without overlap. For LAL imaging, two ROIs were defined, one for the left LAL and one for the right. In any given 10 min epoch, we imaged either the protocerebral bridge or the fan-shaped body, or the LAL, that is, one brain region only. Signals in the protocerebral bridge and fan-shaped body had a similar sinusoidal profile, similar bump amplitude and a similar relationship to fly behaviour, so we used both protocerebral-bridge-imaging epochs and fan-shaped-body-imaging epochs to obtain our measurements of bump amplitude, and we pooled these bump amplitude measurements without regard to whether they came from the protocerebral bridge or fan-shaped body, see Figs. 2e–g, 3a and 5k, and Extended Data Figs. 3 and 5. The single fly examples shown in Fig. 5j, and Extended Data Figs. 8 and 9 are from trials where we imaged the protocerebral bridge.

    Processing locomotion and visual arena data

    The position of the spherical treadmill was computed online using machine vision software (Fictrac v.2.1) and output as a voltage signal for acquisition. For post hoc analysis, the voltage signal was converted into radians and unwrapped. Signals were then low-pass filtered using a second-order Butterworth filter with 0.003 corner frequency and downsampled to half the ball-tracking update rate.Velocity was calculated using the MATLAB gradient function. Artefactually large velocity values (greater than 20 rad s−1) were set to 20 rad s−1, and timeseries were then smoothed using the smooth function in MATLAB (using the loess method with an 33 ms window) and resampled to 60 Hz, the ball-tracking update rate. Forward and sideways velocities were then converted to millimetres per second while yaw (rotational) velocity was converted to degrees per second.

    During calcium imaging, we acquired a signal from our imaging software indicating the end of each volumetric stack on the same acquisition card as online ball tracking signals. These imaging time points were then resampled to the ball-kinematic data update rate of 60 Hz, allowing us to align the acquired volumes. Electrophysiology data were collected on the same acquisition card as online ball tracking signals, so alignment was not required; however, ball-tracking data were resampled to 1 kHz to match the sampling rate of the electrophysiology data.

    Computing inferred goal direction and consistency of head direction across trials

    Head direction (θ) and consistency of head direction (ρ) were calculated for every datapoint over each entire trial using a 30 s window centred on each datapoint index. Here we excluded datapoints where the fly’s cumulative speed (forward + sideways + rotational) was less than 0.67 rad s−1. At values below this threshold, the fly is essentially standing still, so including these time points might result in an overestimation of the fly’s internal drive to maintain its head direction. We also excluded time points within 5 s after a cue jump; this was to avoid underestimating the fly’s internal drive to maintain its head direction, as these points represent a forced deviation from the angle the flies were attempting to maintain. If no datapoints within the 30 s window satisfied these requirements, then the window was excluded from further analyses. Head directions were treated as unit vectors and used to compute the goal direction θg and the consistency of head direction ρ:

    $${theta }_{{rm{g}}}={rm{atan}}2(Sigma sin ({theta }_{{rm{w}}}),Sigma cos ({theta }_{{rm{w}}}))$$

    (2)

    $${rho }_{t}=sqrt{{left(frac{Sigma cos ({theta }_{{rm{w}}})}{{N}_{{rm{w}}}}right)}^{2}+{left(frac{Sigma sin ({theta }_{{rm{w}}})}{{N}_{{rm{w}}}}right)}^{2}}$$

    (3)

    In equation (2), θg represents the goal direction associated with time point t, θw is a vector consisting of all head directions within the 15 s before and after time point t at which the fly was moving, and the atan2 function is the two-argument arctangent. As each head direction is treated as a unit vector we can simply convert each value of θw into Cartesian coordinates, calculate the sum of these values along each axis and take the arctangent to convert them back to polar coordinates to find the average angle the fly travelled at during that window. In equation (3), ρt represents the ρ value associated with time point t, and Nw is the number of data points over which ρ is calculated. Again, we first convert each θ value into Cartesian coordinates and find the average distance travelled along each axis before calculating ρ, so that ρ ranges between 0 and 1. Note that ρ = 1 would indicate that the fly maintained the same head direction for the entire window, while ρ = 0 would indicate that the fly uniformly sampled all possible head directions during the window. Figure 1g shows mean ρ and θ values from each trial, with radial length proportional to ρ.

    Path segmentation based on walking straightness

    We observed that flies often walked in a straight line for an extended segment and then switched to a different apparent goal direction (θg) to initiate a new segment (Extended Data Fig. 10). To infer the fly’s goal direction, we automatically divided each path into segments. We reasoned that a switch in θg, would coincide with a dip in head direction consistency. Therefore, we looked for moments when ρ crossed a threshold value, and we broke the path into segments at those moments of threshold-crossing. The only exception was if ρ fell below threshold only very briefly (less than 0.5 s); here we did not count these as segment breaks, but lumped those time points together as part of a continuous segment with the preceding and following time points. We found that a threshold of ρ = 0.88 matched our commonsense notion of when a new segment should start, but varying the threshold value over a wide range (0.70–0.98) did not dramatically change the outcome of our segmentation process nor the resulting relationships between neural activity and behaviour.

    We then calculated the average θ and ρ for each of these segments and used the mean θ value as the inferred goal head direction. For all analyses, segments were discarded if ρ was equal to 1, as this indicated the panels had not been initiated correctly and that the cue had remained in a single location for the duration of the trial. Segments were also discarded if the fly was inactive (that is, if the fly’s cumulative velocity was not above a threshold of 0.67 rad s−1 for at least 2 s). For population analyses shown in Figs. 1h, 2e–g and  3, all remaining segments were used regardless of ρ.

    For the head direction tuning analysis shown in Fig. 4f,g we used a threshold of ρ = 0.7, and we only used data from segments where ρ ≥ 0.7. We lowered the threshold on ρ for this analysis because we needed to include a larger number of time points in the analysis, to improve the resolution for binning the activity of cells into groups defined by θp − θg.

    Classifying jumps as ‘corrected, high ρ’ versus ‘uncorrected, low ρ

    To analyse cue jumps (Figs. 1f and  5e–h and Extended Data Figs. 3 and 7), we classified jumps as ‘corrected, high ρ’ or ‘uncorrected, low ρ’. Here we rejected jumps where the fly was essentially immobile in the epoch before the jump (meaning its cumulative speed did not exceed 0.67 rad s−1 for at least 1 s in the 15 s before the jump). For each jump, we measured the original mean head direction (θ) during the 15 s before the jump, and we judged jumps as ‘corrected’ if θ returned to within 30° of its original value for ±90° jumps, or within 60° for 180° jumps, in the 10 s after the jump. We classified a jump trial as ‘high ρ’ if the average ρ was equal to or greater than 0.88 as calculated over time points within the 15 s before the jump, where the fly’s cumulative speed was over 0.67 rad s−1 and ‘low ρ’ otherwise.

    In principle, it is possible that the jumps we categorized as uncorrected might have happened (by chance) to produce a smaller absolute change in the distance between a fly’s head direction and a cell’s preferred head direction |Δ(θ − θp)|, as compared to the jumps in the corrected category. If this sampling artefact existed, it could produce an overall smaller absolute change in membrane potential for uncorrected jumps, leading us to misinterpret this result. However, we found no difference in the variance of ∆(θ − θp) or the mean value of |Δ(θ − θp)| for uncorrected versus corrected jumps (Extended Data Fig. 7d).

    Computing average response to iontophoresis stimulation

    For the plots shown in Fig. 2a,b and Extended Data Fig. 4, data from the ±10 s period around each ATP pulse were averaged within individual flies to get the fly-averaged response to the 100 ms, 200 ms, 300 ms and 500 ms pulses for the membrane potential, forward velocity, sideways velocity and rotational velocity (each condition had at least four repetitions per fly). We then calculated the grand mean and s.e.m. across all flies using these per-fly averages.

    Computing activity bump parameters

    To track the amplitude and phase of PFL2 activity for analyses in Figs. 2c–g and 5j,k and Extended Data Figs. 3, 5 and 8, a sinusoid was fit independently to each time point of the z-scored ΔF/F activity across fan-shaped body and protocerebral bridge imaging trials:

    $${rm{PFL}}2,,{rm{activity}}=atimes sin (x-u)+c$$

    (4)

    Here, PFL2 activity is a vector of z-scored ΔF/F values at a single time point such that it has ten bins if from a protocerebral bridge trial or nine if from an fan-shaped body trial, corresponding to the number of ROIs specified for each region. Here, u sets the phase of the sinusoid, c is the vertical offset term, a represents the bump amplitude, and the position in brain space where the peak of the sinusoid is located defines the bump phase. A bump phase of +180° represents the rightmost position in the protocerebral bridge and fan-shaped body while a phase of −180° represents the leftmost position.

    Computing change in bump phase versus change in head direction

    We calculated the relative changes in PFL2 bump phase and head direction in 1.5 s bins as shown in Fig. 2d. In each time window, we took the difference between start and end points for θ or bump phase. Positive differences represent a clockwise shift while a negative difference represents a counterclockwise shift. The relationship between changes in θ and changes in bump phase was strongest when a 200 ms lag was implemented, such that changes in bump phase lagged 200 ms behind changes in θ. The line of best fit for the relationship between the two variables was found with the polyfit and polyval functions. We then used the corrcoef function to find the correlation coefficients and P value of the relationship. We excluded indices where the adjusted r2 value of the sinusoidal fit for bump parameters was below 0.1 or the fly was not moving.

    Computing population activity as a function of behaviour

    To determine the relationship between neural activity and various behavioural parameters (Figs. 2e–g and 3 and Extended Data Fig. 5) we binned conditioned data. Within each segment described above, indices with cumulative velocity less than 0.67 rad s−1 were removed, and head directions were recalculated to be relative to the inferred goal head directions, meaning that a negative value indicated that the fly was facing counterclockwise to its goal head direction, and a positive value indicated that the fly was facing clockwise to its goal head direction. The z-scored ΔF/F was then averaged within bins of 10° s−1 for rotational velocity, 1 mm s−1 for forward velocity, or 10° for head direction. For Fig. 3d,e and Extended Data Fig. 5, the sum or difference between right and left LAL activity was calculated per segment following binning. The mean and s.e.m. was then calculated across flies.

    Computing preferred head direction

    To show preferred cell head direction in Fig. 4a, we divided the estimated baseline membrane voltage (see section ‘Patch-clamping’) into 20° bins, based on the fly’s head direction. We considered the preferred head direction to be the value with the maximum binned membrane potential. The amplitude of the preferred head direction was calculated by taking the difference between the maximum and minimum binned membrane potential values.

    Analysis of IPSPs

    To detect IPSPs for analyses in Fig. 4d, we focused only on jump trials where the fly was essentially immobile, to avoid any confounds associated with the membrane potential fluctuations in these cells that are associated with movement transitions. Action potentials were first removed from the voltage trace by median filtering the membrane potential with a 25 ms window, then lightly smoothing (smoothdata function in MATLAB, window size 20 ms, using the loess method). We then calculated the derivative of the membrane potential (gradient function in MATLAB) and found local minima corresponding to periods of rapid decreases in membrane potential (findpeaks function in MATLAB, peak distance of 20 ms, threshold determined for each cell). We also generated a detrended version of the membrane potential by subtracting the median filtered membrane potential (500 ms window) and found local minima (findpeaks function in MATLAB, peak distance of 20 ms, threshold determined for each cell). We categorized IPSPs as indices where a negative peak was detected from the derivative of the membrane potential trace within 30 ms before a negative peak in the baseline corrected trace.

    Computing change in IPSP parameters as a function of the change in head direction

    To examine changes in IPSP parameters as a function of change in head direction, ±5 s windows around cue jumps in which the fly did not move for the entire 10 s period were used (Fig. 4c). All jumps fitting this category were analysed for 20 of 27 neurons in this dataset; the remaining 7 neurons were not included, as there were no cue jumps around which the fly was stopped for the entire 10 s window around the jump.

    Detected IPSP frequency was calculated for the 5 s before or after the cue jump. The change in frequency before jump versus after jump was then compared to change in head direction relative to the cell’s preferred head direction produced by the cue jump. This was determined by first finding the absolute angular difference between the head direction before the jump and the cell’s preferred head direction (see section ‘Computing preferred head direction’) and doing the same for the new head direction following the cue jump. Then the precue jump value was subtracted from the postcue jump value. This means that a negative value indicated that the head direction was closer to the cell’s preferred head direction following the jump while a positive value indicated that the distance between the head direction and the cell’s preferred head direction increased following the jump. The change in IPSP frequency was then plotted against the change in the distance from the cell’s preferred head direction for each jump. MATLAB’s polyfit and polyval functions were used to find the line of best fit for the relationship between the two variables, while the corrcoef function was used to find the correlation coefficients of the relationship. Additionally, we used an unbalanced two-factor ANOVA to determine the significance of the relationship between change in frequency and change in head direction compared to that with cell identity.

    Exploring interactions between goal head direction and single-cell head direction tuning curves

    To explore how single-cell dynamics lead to the population level relationships between neural activity and behaviour, we first segmented electrophysiology data into groups of continuous data points based on their associated goal head directions and ρ values (see section ‘Trial segmentation based on walking straightness and inferred goal direction’). For each trial, the cell’s preferred heading was determined (see section ‘Computing preferred head direction’) and the difference between the preferred heading and goal was found (θg − θp). Segments were assigned to 72˚ wide bins based on the θg − θp value and for each segment, the head direction tuning curve was recalculated for both firing rate and membrane potential, using the data points within the bin. For Fig. 4f,g, the minimum value of each tuning curve was calculated and subtracted from that tuning curve. Following the subtraction, the mean and s.e.m. values were calculated across all tuning curves within each θg − θp bin. For Extended Data Fig. 6, the only difference is that the minimum value of the tuning curves was not subtracted.

    Determining the temporal relationship between neural activity and behaviour

    The figures shown in Fig. 5h were created using the same method as previous jump analyses (see section ‘Classifying jumps as “corrected, high ρ“ versus ”uncorrected, low ρ”’) but pooling data across the PFL2 and PFL3 corrected jumps. For Extended Data Fig. 7e, jumps were categorized as corrected as done previously, except jumps were deemed corrected if within 4 s following the cue jump, the cue was returned to within 40˚ for ±90˚ jumps, or within 75˚ for 180˚ jumps. This was done to select for jumps where the fly initiated a behavioural response quite rapidly following the cue jump, as behavioural response times varied across and within flies. For each corrected jump, the mean membrane potential was calculated from data in the 4 s preceding the cue jump and subtracted from the membrane potential in the 4 s following the cue jump, in order to focus on the change in membrane potential. Pearson’s linear correlation coefficient was then found between the absolute change in membrane potential from the 4 s following the jump and the lagged copies of the rotational speed over the same time window using MATLAB’s corr function. The mean and s.e.m. for each lag (stepped by 0.01 s with a maximum and minimum lag of ±1 s) across all individual correlations was then calculated.

    Examining single-cell responses around cue jumps

    For Fig. 5e–g and Extended Data Fig. 7a–d, jumps were categorized as either corrected or uncorrected as described previously (see section ‘Classifying jumps as “corrected, high ρ” versus “uncorrected, low ρ”’). For each jump, the difference between the mean membrane potentials calculated over the 1 s before and following each jump was found, and the distribution of these values is shown for both categories in Fig. 5f,g. A two sample Brown–Forsythe test was used to determine whether the variance of membrane potential changes was significantly different between the two categories.

    Examining the relationship between PFL2 activity and consistency of head direction

    For Fig. 5j,k and Extended Data Fig. 8, we binned data from each ROI (protocerebral bridge glomerulus) individually across the entire non-segmented trial to obtain the average response of each glomerulus across different values of (θ − θg). Here we inferred θg from neural activity rather than behaviour, because we wanted to include epochs with low ρ, and it is difficult to infer θg from the fly’s behaviour when ρ is low. To infer θg from neural activity, we grouped PFL2 bump amplitude data points by θ in 5˚ bins, and we calculated the difference in bump amplitude between pairs of bins 180˚ apart. Our model predicts that the absolute bump amplitude difference should be largest between the bins representing the goal and anti-goal, and so we searched for the pair of opposing bins with the largest difference in bump amplitude, and we took θg as the value of θ corresponding to the bin with the smaller bump amplitude. For Fig. 5k, we plotted the largest bump amplitude difference against the trial’s average ρ value, as calculated over the entire trial. For the individual brain space plots shown in Fig. 5i,j and Extended Data Fig. 8, we used this θg value to calculate the directional error (θ − θg) and we binned the z-scored ΔF/F data points from each individual ROI into 90˚ bins based on their associated directional error value. We then plotted the z-scored ΔF/F within each directional error bin against neural space (ROI identity), with the rightmost glomeruli represented by an angular position of +180˚ and the leftmost by −180˚.

    Note that this analysis assumes that θg does not change very much over the course of a trial. If θg did change dramatically, this would result in a lower ρ value for the trial and possibly also a reduced bump amplitude range value, despite the fly potentially being in a state of high goal fixation strength for the entire trial. Flies that switched between periods of very strong and weak goal fixation would be expected to result in a similar potential mismatch between ρ and bump amplitude range. Therefore, the limitations of the analysis in Fig. 5k should, if anything, reduce our ability to detect a relationship between PFL2 activity and behaviour.

    Neurotransmitter predictions

    There are 12 complete PFL2 cells, 13 complete PFL3 cells and one nearly complete DNa03 cell in the hemibrain connectome, with over 100 presynapses associated with each of these cells. Although the axon terminal of DNa03 is not present in the hemibrain dataset, DNa03 makes many output synapses in the brain, so there are still many EM images of the presynaptic sites within this cell. A recent algorithm50,51 automatically infers transmitter identification from electron micrographs in the hemibrain dataset, and it predicts that, of these, 12 of 12 PFL2 neurons are cholinergic, 13 of 13 PFL3 neurons are cholinergic and 1 of 1 DNa03 neuron is cholinergic. This algorithm predicts transmitters on a per-synapse basis, with an error rate that varies with cell and transmitter type. For PFL2 and PFL3 neurons, 74% of high-confidence presynapses (confidence score greater than or equal to 0.5) are predicted as cholinergic; the second most commonly predicted transmitter is glutamate (11%). For DNa03, 85.2 % of high-confidence presynapses are predicted as cholinergic; the second most commonly predicted neurotransmitter is glutamate (5.6%). This algorithm used 3,094 hemibrain neurons in its ground-truth data to train the model and included ground truth neurons identified as cholinergic using light microscopy pipelines and antibody staining or RNA sequencing. Among this ground-truth population, 73% of presynapses are correctly predicted as cholinergic. All synapse predictions are available from ref. 51.

    Connectome analyses

    Cell connectivity data was obtained from the hemibrain connectome at https://neuprint.janelia.org/ and analysis of this data was performed using the neuprintr natverse 1.1 software package52 available at https://natverse.org/.

    Network model

    Our model shares features with several other recent models of central complex steering control4,5,11,12,13. These studies, in turn, built upon the existing idea that vectors should be represented as sinusoidal spatial patterns of neural activity, so that vector addition can be implemented via the addition of sinusoids9,15,16,53,54. Webb and colleagues extended this idea to an explicit notion of how rotational velocity commands might be generated via vector addition, by using right–left shifted basis vectors9. While our model incorporates these previous insights, it also takes advantage of new information from the automatic assignment of neurotransmitters50, as well as our neurophysiological experiments. For these reasons, it differs from previous models in a few important ways, as noted below. Most notably, our model shows how this network can adaptively control steering gain based on the magnitude of directional error (via PFL2 cells). Previous studies did not mention PFL2 cells, or else proposed that they have a non-steering-related role (as putative positive regulators of forward speed5,13). In contrast, our model gives these cells a strong influence over steering, and it shows how they can prevent oscillations in the steering system by boosting steering only when error is high, while throttling down steering when error is low.

    In broad terms, the aim of the model is to understand how steering signals arise from the head direction system. We take the steering signal as the right–left difference in the activity of DNa02 descending neurons, because these neurons have been shown to predict and influence steering4:

    $${rm{d}}theta /{rm{d}}tpropto {rm{DNa02R; -; DNa02L}},,+{epsilon }$$

    (5)

    where θ is head direction and ε is a random term that accounts for neural noise and the influence of unmodeled circuits (that is, the influence of other brain regions that affect steering and other descending pathways4,55,41). Here, (({rm{d}}theta /{rm{d}}t) > 0) denotes rightward (clockwise) steering.

    DNa02 receives direct input from central complex output neurons (PFL3 cells), as well as indirect input from PFL2 and PFL3 cells via DNa03. We model the activity of each DNa02 cell by taking the weighted sum of its synaptic inputs and passing this through a nonlinearity:

    $$begin{array}{c}{rm{DNa}}02{rm{R}}=f(Sigma {W}_{{rm{DNa}}02{rm{R}},{rm{PFL}}3{{rm{R}}}_{j}}times {rm{PFL}}3{{rm{R}}}_{j}+Sigma {W}_{{rm{DNa}}02{rm{R}},{rm{DNa}}03{rm{R}}}times {rm{DNa}}03{rm{R}})\ \ {rm{DNa}}02{rm{L}}=f(Sigma {W}_{{rm{DNa}}02{rm{L}},{rm{PFL}}3{{rm{L}}}_{j}}times {rm{PFL}}3{{rm{L}}}_{j}+Sigma {W}_{{rm{DNa}}02{rm{L}},{rm{DNa}}03{rm{L}}}times {rm{DNa}}03{rm{L}})end{array}$$

    (6)

    where (W) denotes an array of synaptic weights and (f) represents a nonlinear activation function (see below). We define PFL3R cells as the members of the PFL3 cell class that project their axons to the right hemisphere; PFL3L cells are the members of the PFL3 cell class that project their axons to the left hemisphere. This differs from some previous work where PFL3 cells were divided according to dendritic location rather than their axonal projection5.

    We model the activity of each DNa03 cell by taking the weighted sum of its synaptic inputs and passing this sum through the same type of nonlinearity. Here the relevant inputs to each DNa03 cell are from PFL3 cells and PFL2 cells. Each PFL2 axon projects bilaterally to both right and left brain hemispheres, and we model these connections as right–left symmetric, because we do not find any systematic asymmetry in connectome data; thus we use the same weights for PFL2 connections onto DNa03R and DNa03L:

    $$begin{array}{c}{rm{DNa}}03{rm{R}}=f(Sigma {W}_{{rm{DNa}}03{rm{R}},{rm{PFL}}3{{rm{R}}}_{j}}times {rm{PFL}}3{{rm{R}}}_{j}+Sigma {W}_{{rm{DNa}}03,{rm{PFL}}{2}_{j}}times {rm{PFL}}{2}_{j})\ \ {rm{DNa}}03{rm{L}}=f(Sigma {W}_{{rm{DNa}}03{rm{L}},{rm{PFL}}3{{rm{L}}}_{j}}times {rm{PFL}}3{{rm{L}}}_{j}+Sigma {W}_{{rm{DNa}}03,{rm{PFL}}{2}_{j}}times {rm{PFL}}{2}_{j})end{array}$$

    (7)

    We then combine equations (5)–(7) to obtain an expression that predicts steering as a function of PFL2 and PFL3 activity. Here we assume that DNa03 output is anatomically symmetric in the right and left hemispheres. For compactness, we notate weight arrays using the abbreviations D2 (DNa02), D3 (DNa03) P2 (PFL2) and P3 (PFL3):

    $$begin{array}{l}{rm{d}}theta /{rm{d}}tpropto {rm{DNa}}02{rm{R}}-{rm{DNa}}02{rm{L}}+{epsilon }\ =,f(Sigma {W}_{{rm{D2R}},{rm{P}}3{{rm{R}}}_{j}}times {{rm{P3R}}}_{j}+Sigma {W}_{{rm{D2,D3}}}times {rm{D3R}})\ ,-f(Sigma {W}_{{{rm{D2L,P3L}}}_{j}}times {{rm{P3L}}}_{j}+Sigma {W}_{{rm{D2,D3}}}times {rm{D3L}})+{epsilon }\ =,f(Sigma {W}_{{{rm{D2R,P3R}}}_{j}}times {{rm{P3R}}}_{j}+Sigma {W}_{{rm{D2,D3}}}times f(Sigma {W}_{{{rm{D3R,P3R}}}_{j}}times {{rm{P3R}}}_{j}\ ,+Sigma {W}_{{{rm{D3,PFL2}}}_{j}}times {{rm{PFL2}}}_{j}))\ ,-f(Sigma {W}_{{{rm{D2L,P3L}}}_{j}}times {{rm{P3L}}}_{j}+Sigma {W}_{{rm{D2,D3}}}times f(Sigma {W}_{{{rm{D3L,P3L}}}_{j}}times {{rm{P3L}}}_{j}\ ,+Sigma {W}_{{{rm{D3,PFL2}}}_{j}}times {{rm{PFL2}}}_{j}))+{epsilon }end{array}$$

    (8)

    If the activation function (f) is linear, the PFL2 terms will cancel out and PFL2 cells will have no effect on steering; therefore, we require (f) to be nonlinear, at least for DNa03 cells. Below we will see that (f) must also be nonlinear for PFL3 cells. For consistency, we give (f) the same form for all cells in the model (see below). If (f) is an expansive nonlinearity and if PFL2 cells are excitatory (as inferred from neurotransmitter predictions, see above), then PFL2 cells will increase the gain of steering commands, because they push DNa03 cells up into the steeper part of the nonlinearity.

    We specify the weight array (W) for each connection type based on data from the hemibrain 1.2.1 (ref. 5) connectome, following the heuristic that functional weights are roughly proportional to the number of synaptic contacts per unitary connection42,45. Connectome data imply that PFL3 → DNa03 connections are approximately equal in strength to PFL3 → DNa02 connections, on average; all these weights are set to 1 in our model. Meanwhile, connectome data imply that PFL2 → DNa03 connections are approximately 4-fold stronger than PFL3 → DNa02 and PFL3 → DNa03 connections, on average; therefore, we set PFL2 → DNa03 weights equal to 4. Finally, connectome data imply that DNa03 → DNa02 connections are approximately 12-fold stronger than PFL3 → DNa02 and PFL3 → DNa03 connections; therefore, we set DNa03 → DNa02 connections to 12. We verified that our conclusions were not altered if we chose somewhat different scaling factors for these connections. Within each weight array (W), we set all entries to the same value; in other words, all connections of the same type were given the same weight. All weights were positive, because all the presynaptic cells are cholinergic and thus excitatory (see section ‘Neurotransmitter predictions’). Some previous studies assumed that PFL3 cells are inhibitory5,11, which produces different model behaviour, because it aligns the system’s stable fixed point with the point of maximum PFL2 activity (not the minimum of PFL2 activity), resulting in more oscillatory steering around the goal.

    Our model contains 1,000 PFL2 units, 1,000 PFL3R units, 1,000 PFL3L units and 1,000 goal cell units. We chose to use a large number of units for these cell types, so that model output resembles a quasi-continuous function over neural space, because this makes it easier to see how spatial patterns of ensemble neural activity might resemble a sinusoidal function. In reality, however, there are only 12 PFL2 cells, 12 PFL3R cells and 12 PFL3L cells in the brain, according to the hemibrain 1.2.1 (ref. 5) connectome, so activity in the brain is actually more discretized than in our model. We verified that discretizing neural activity to match these numbers does not alter our conclusions.

    In our model, the activity of each PFL cell depends on both head direction and goal direction. Δ7 cells provide most of the head direction input to PFL2 and PFL3 cells5. Available data indicate that there are two complete linearized topographic maps of head direction in Δ7 cells, positioned side-by-side and formatted as two cycles of a sinusoidal function over neural space5,24,47,56. The spatial phase of the Δ7 activity pattern should have an arbitrary offset (θ0) relative to the fly’s head direction, with different values of θ0 in different individuals and at different times in the same individual, because this is true of EPG cells, which provide head direction input to Δ7 (ref. 19). We define the offset θ0 as the angular position of the EPG bump at a head direction of 0°. For simplicity, we lump the contributions of EPG output and Δ7 cells, and we treat their lumped contributions as a sinusoidal function over neural space. Specifically, we model their lumped output as cos(θ − θ0 − h), where h is a vector with 1,000 entries that uniformly tile the full 360° of angular space, representing the preferred head directions of 1,000 units. As the fly rotates rightward (clockwise), the sinusoidal pattern of neural activity moves leftward across the protocerebral bridge47,56.

    We define PFL3 cells as R or L depending on whether they project to right or left descending neurons, respectively. The head direction maps in PFL3 cells are shifted ±67.5° relative to the map in Δ7 cells, according to hemibrain connectome data41 (not ±90° as reported previously5,12,13). Therefore, we model the head direction input to PFL3R cells as cos(θ − θ0 − h + 67.5°), and we model the head direction input to PFL3L cells as cos(θ − θ0 − h − 67.5°). Meanwhile, PFL2 cells sample one full head direction map from the middle section of the protocerebral bridge. Therefore, their head direction map is offset by 180°, relative to the map in Δ7 cells. Thus, we model the head direction input to PFL2 cells as cos(θ − θ0 − h + 180°).

    We model the neural representation of the goal direction (θg) as another sinusoidal pattern over neural space, which is reasonable, because the goal direction can be thought of as just a special head direction, and head direction is represented as a sinusoid. Because PFL2, PFL3R and PFL3L cells receive almost identical inputs in the fan-shaped body, we assume the goal input is the same in the PFL2, PFL3R and PFL3L populations. The output of goal cells is modelled as A × cos(θg − θ0 − h); note that if there is a shift in the offset of the head direction system (θ0), the goal representation will shift accordingly. As the goal direction rotates rightward (clockwise), the peak of activity in goal cells will move leftward across the fan-shaped body. We use A = 1 in our model implementations, so that the amplitude of the goal signal is equal to the amplitude of the head direction signal, but some of our results can be potentially explained by a mechanism that modulates A (Extended Data Fig. 8).

    To obtain PFL activity levels, we sum head direction inputs and goal inputs. We then rescale this sum according to a scaling factor S. Finally, we pass the result through a nonlinear activation function (f):

    $$begin{array}{l},,{rm{PFL}}2,=,f(Stimes (cos (theta -{theta }_{0}-{bf{h}}+18{0}^{circ })+Atimes ,cos ({theta }_{g}-{theta }_{0}-{bf{h}})))\ {rm{PFL}}3{rm{R}},=,f(Stimes (cos (theta -{theta }_{0}-{bf{h}}+67.{5}^{circ })+Atimes ,cos ({theta }_{g}-{theta }_{0}-{bf{h}})))\ {rm{PFL}}3{rm{L}},=,f(Stimes (cos (theta -{theta }_{0}-{bf{h}}-67.{5}^{circ })+Atimes ,cos ({theta }_{g}-{theta }_{0}-{bf{h}})))end{array}$$

    (9)

    Note that the activation function (f) must be nonlinear or else the goal input will have no influence on the right–left difference in PFL3 activity (ΣPFL3R − ΣPFL3L). We use S = 1 by default, except in Figs. 5c,d and 5j,k, where we investigate the effect of lowering S.

    For simplicity, we use the same nonlinear activation function (f) for all units in this model (meaning all PFL2, PFL3, DNa03 and DNa02 cells). Specifically, we use an exponential linear unit or ELU. We chose an ELU because it is biologically highly plausible (as a ‘soft’ expansive nonlinearity57) and it is a good fit to our data. The input to the ELU is an array M that represents the weighted sum of the inputs to each cell, over its lifetime, for all values of head direction (θ), goal direction (θg), scaling parameter (S) and cell index (j). We rescale M so that min(M) = −1 and max(M) = 1. Then, we apply the function

    $$begin{array}{c}{rm{ELU}}(M)=M,{rm{for}},Mge 0\ \ {rm{ELU}}(M)={{rm{e}}}^{M}-1,{rm{for}},M < 0end{array}$$

    (10)

    before finally rescaling the resulting array ({rm{ELU}}(M)) so that it ranges from 0 to 1. These rescaling procedures are motivated by the idea that a neuron’s inputs are adjusted (over development and/or evolution) to fit into some standard dynamic range dictated by the biophysical properties of a typical neuron; rescaling in this way is useful because it ensures that every cell type has a similar overall level of activity, and every cell has an activation function with the same shape. Note that from the perspective of a single PFL cell, the goal input is a fixed value that does not change as head direction changes, and when this goal signal becomes more positive (again, from the perspective of a single PFL cell), it pushes the cell’s activity up to a steeper part of the nonlinear function (f), effectively amplifying the cell’s head direction tuning. This aspect of the model captures our experimental observation that head direction tuning is stronger in some cells than in other cells, in a way that depends systematically on the distance between the cell’s preferred head direction (θp) and the goal direction (θg). Notably, this observation emerges only at the level of spike rate, not membrane potential (Fig. 4f,g), and this implies that the nonlinearity (f) is largely due to the voltage-gated conductances that transform total synaptic input into spike rate. We verified that the basic conclusions of our model are unchanged if we substitute different nonlinear activation functions (sigmoid or ReLU rather than ELU); other published models have assumed a multiplicative12 or divisive nonlinearity13.

    To model steering behaviour over time (Fig. 5d), we closed the loop on the brain’s feedback control system for steering: we took the fly’s predicted rotational velocity (({rm{d}}theta /{rm{d}}t)) at each time point, and we fed it back into the head direction representation at the next time point, in order to compute updated PFL2 and PFL3 activity. The simulation was updated at a frequency of 10 Hz, and Fig. 5d shows 10 s of simulated time. We arbitrarily took 0° as the goal direction, so directional error is equal to θ. We drew the random steering component ε (equation (5)) from a Gaussian distribution, then we low-pass filtered ε(t) at 2 Hz, before rescaling ε(t) to enforce a standard deviation of 10°. This was done for different values of S, using the same frozen noise sample ε(t) in each case. In Fig. 5k, we used many independent random samples of ε(t), each simulation run included 100 s of simulated time, and we swept through many values of S, computing PFL2 bump amplitude and the consistency of head direction (p) for each run, with p = (one-circular variance(θ)). Model code was written and implemented in Python v.3.9.5.

    Reporting summary

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



    Source link