Occasional BAP related calcium signals that invaded the imaged spines were removed using a subtraction method, implemented in three steps (Supplementary Fig. 11). First, a region covering the entire parent dendritic shaft (∼30 micrometers of dendritic length; excluding all spines) was drawn for each recorded dendritic segment to estimate BAP related global dendritic signal, ΔF/F0_dendrite. Because of the much larger volume of the dendritic shaft compared to tuned dendritic spines (100-fold), spines above and below the focal plane were expected to contribute negligible signal to ΔF/F0_dendrite. This was verified using principle component analysis (data not shown). Plotting ΔF/F0_spine against ΔF/F0_dendrite reveals two components of spine signals, a BAP-related component and a spine-specific component. Second, the BAP-related component was removed from the spine signals by subtracting a scaled version of the dendritic shaft signal, ΔF/F0_spine_specific=ΔF/F0_spine - α ·ΔF/F0_dendrite. α was determined using robust regression (MATLAB function ‘robustfit.m’) of ΔF/F0_spine vs. ΔF/F0_dendrite (the slope of the fitted line in Supplementary Fig. 11b). Third, the visual responsiveness (ΔF/F0 > 10%) and the OSI of individual spines were calculated with the BAP signal removed.