a, Head-fixed detection ask. A high-speed camera imaged whiskers. Pole movement (go/nogo) and laser (on/off) were randomized across trials. b, Coronal section of Emx1-GFP mouse. White dotted line: barrel cortex boundaries; green: GFP; magenta: NeuN. c, Cortical array recordings during detection task and photoinactivation. Example rasters (top) and PSTHs (middle) for a single unit when no response was made (miss/correct reject) during an example session. d, Same neuron for trials with lever response (hit/false alarm). The laser turns off when animal responds, ending the trial. Trials sorted by response time, which varied (arrows in schematic at bottom). e, Effect of laser on neuronal spiking (n=62 putative excitatory neurons, 8 sessions, 3 mice; mean±SD 7.02±6.81and 0.16±0.94 Hz for laser off vs on, respectively). f, Average spiking activity aligned to first whisker contact of trial during an example session (n=10 neurons). Contact times are defined as the local maxima, rather than onset, of curvature change (see Extended Data Fig. 3 and Methods). Firing rates were normalized to mean rate during 100 ms prior to contact during laser-off trials. Thin lines: individual cells, thick lines: means. Behavioral performance for laser off vs on trials: g, % correct trials h, Hit rate; i, False alarm rate. j, Response latency for hit trials. Emx1-Halo (n = 10 mice, red), negative control (n = 7 cre-negative, stop-Halo mice, black). Error bars: means ± SEMs. Scale bar: 1mm.