a From left to right, first panel: One-photon widefield imaging is performed while presenting drifting bars to the mouse to locate primary visual cortex. The two-photon FOV is positioned in a region with good GCaMP and opsin expression. The task visual stimuli are positioned in the retinotopically appropriate location. Scale bar represents 1 mm. Second panel: Example FOV (one plane from a 4-plane volume) showing construct expression in L2/3 mouse primary visual cortex. GCaMP6s is expressed transgenically and C1V1-Kv2.1 is expressed virally through injection. Third panel: Visual stimulus orientation preference map. 4 different orientations of drifting gratings are presented to the mouse. Pixel intensity is dictated by the stimulus triggered average response magnitude. Hue corresponds to preferred stimulus orientation. Fourth panel: Photostimulation responsivity of the FOV to clustered randomized photostimulation. The majority of recorded cells were grouped into 76 different clusters of 50 cells each (distributed across 4 planes) and targeted for sequential photostimulation to confirm responsivity prior to the experiment. Pixel intensity indicates the change in fluorescence caused by photostimulation. Color corresponds to the photostimulation cluster which caused the largest change in activity. White circles indicate example targets within this plane ultimately selected for targeted photostimulation of a co-tuned ensemble. All scale bars 100 μm. Examples shown are from one representative experiment but were repeated for each experiment in this study (n = 28 sessions, 12 mice). b Left: Example traces from the visual response mapping block of the experiment (prior to the behavioral task). Vertical lines indicate stimulus onsets with color indicating orientation (dashed lines for orientations over 135 degrees). Right: Example traces from the photostimulation response mapping block. Vertical lines indicate clusters of cells stimulated as a group. Cells are sorted by photostimulation cluster (in this experiment clusters were determined by orientation preference). c Example co-tuned stimulation ensemble. In this experiment 28 neurons were selected based on their responsivity to visual and optogenetic stimuli in b. Left: average responses to the drifting gratings of various orientations. Single lines represent individual neurons, thick black line indicates ensemble average. This ensemble shares a preference for 90 and 270 degree stimuli. Black triangle indicates the orientation of visual stimulus chosen for the remainder of this session. Middle: The ensemble response to photostimulation. Right: The spatial configuration of the neurons selected for stimulation. d Pixel-wise stimulus-triggered average (STA) showing the response of the FOV to the stimulation pattern from c. Red circles indicate target neurons on that imaging plane. Fade circles show all targets collapsed across planes. Scale bar represents 100 μm. e Boxplots showing the number and co-tuning of the photostimulated neurons across all experiments. Box shows the interquartile range (IQR), the plus sign shows the mean, solid line the median, and the whiskers denote 1.5 times the IQR (n = 28 sessions, 12 mice). f Photostimulation of co-tuned ensembles was paired with visual stimuli. Sessions are split into two states as in Fig. 1, here renamed to a ‘less engaged’ and a ‘more engaged’ state. Black lines indicate performance on visual-only trials. Red lines indicate performance on visual+photostimulation trials. Inset: Width of fitted psychometric curve. Error bars and shading show mean ± SEM across sessions, n = 28 sessions, 12 mice. Statistical test was two-sided Wilcoxon sign rank test, ** denotes P < 0.01. g The effect of photostimulation manifests as an increase in the width of fitted psychometric curves (n = 28 sessions, 12 mice). There was no change to the threshold of the psychometric functions. Error bars show mean ± SEM across sessions. Statistical tests were two-sided Wilcoxon sign rank, ** denotes P < 0.01, * denotes P < 0.05. h Photostimulation has a consistent effect on the detectability of visual stimuli in the ‘more engaged’ state and not in the ‘less engaged’ state. Photostimulation enhances detection of low (2%) contrast stimuli and suppressed the detection of higher (10%) contrast stimuli. Significance across each full curve indicates results of a one-way ANOVA within state. Significance across the two curves indicates the results of a repeated measures ANOVA. Significance above individual curve points indicates results of two-sided Wilcoxon signed-rank tests with Bonferroni (number of contrasts) correction. Error bars show mean ± SEM across sessions, n = 28 sessions, 12 mice. We use * to denote a P-value < 0.05, ** for P < 0.01 and *** for P < 0.001.