signal Fneuropil(t) surrounding each cell was measured by averaging the signal of all pixels within a 20 μm region from the cell center (excluding all selected cells). Cell-attached recordings confirmed that neuropil-compensated fluorescence changes reflect action potentials in single neurons (Supplementary Fig. 15). To ensure robust neuropil subtraction, only cells that were at least 3% brighter than the surrounding neuropil were included. The neuropil correction was not applied for dendritic imaging experiments because sparse labeling provided negligibly low background. ΔF/F0 was calculated as (F-F0)/F0, where F0 is the baseline fluorescence signal averaged over a 2 second period immediately before the start of visual stimulation. Visual responses were measured for each trial as ΔF/F0, averaged over the stimulus period. Visually responsive neurons were defined as cells with significant stimulus-related fluorescence changes (ANOVA across blank and eight direction periods, p<0.01)5 with an average ΔF/F0 at preferred orientations greater than 6%.