a, Schematic of setup. Inset, close-up of fly on air-supported ball (modified from ref. 20). b, Schematic of fly central brain and CX: ellipsoid body (EB), fan-shaped body (FB), protocerebral bridge (PB), paired noduli (NO), lateral accessory lobe (LAL) and gall (Gall). MB: mushroom body. c, Each EBw.s neuron receives inputs from an EB wedge and sends outputs to a corresponding PB column, and to the gall24,26. The PB has 18 columns24, but EBw.s neurons only innervate the central 16. OddR, EvenR, OddL and EvenL, odd and even PB columns, right and left side of brain, respectively. d, GFP-labelled EBw.s neurons in a brain counterstained with nc82 (maximum intensity projection (MIP), reproduced with permission from Janelia FlyLight Image Database23). e, MIP of two-photon imaging stack (5 frames, 5 μm apart, see Methods) showing EB processes of GCaMP6f-labelled EBw.s neurons. f, Top, closed-loop walking with a vertical stripe. Bottom, EBw.s activity is measured in 16 regions of interest (ROIs). Sample frames from calcium imaging time series (Fly 15) showing MIP of EB activity bump (see Methods) as fly rotates visual cue around arena (top). F, fluorescence intensity (arbitrary units). Arrows near top of h indicate frame times. g, Steps to compute PVA based on EBw.s population activity. EB is unwrapped from Wedge 1 to Wedge 16 to display population time series in h. Superimposed is PVA estimate that incorporates trial-specific offset (m; see Methods). h, EBw.s fluorescence transients during a single trial (same trial as f). Colour scale at right. Superimposed brown line indicates PVA estimate of angular orientation of visual cue. Top, horizontal greyscale stripe shows PVA amplitude; intensity scale at left. i, PVA estimate of angular orientation plotted against actual orientation of visual cue (see Methods). j, Mean and standard deviation (s.d.) of number of activity bumps in EBw.s population activity across trials for each of 15 flies (see Methods). k, Mean and s.d. of full width at half maximum (FWHM) of activity bump across trials and flies (see Methods). l, Mean and s.d. of correlation between PVA estimate and actual orientation (pattern position) (see Methods). m, Mean and s.d. of angular offsets between PVA position and pattern position (see Methods, Extended Data Fig. 2e, f). All scale bars, 20 μm.