A context-dependent whisker detection task.

(A) Schematic of the task structure. (B) Block-average lick rate in one example expert session for whisker trials (orange), auditory trials (blue) and catch trials (black). W+ and W-blocks are shown by green and purple shaded areas, respectively. Single trials are shown by individual ticks (below). (C) Averaged lick probability for whisker, auditory and catch trials in W+ and W-context. Small dots represent individual mice (n = 41 mice, 201 sessions); large-filled circles represent grand-averages with error bars showing the 95% confidence interval. (D) Same as C, but split according to brown (B) or pink (P) noise context identity. (E) As a control, the contextual brown and pink noises (Context On) were replaced by constant white noise (Context Off) for one session (n = 7 mice). (F) Averaged lick probability for whisker trials centered on context transitions. From W- to W+ in green and from W+ to W- in purple (n = 41 mice). (G) Lick probability at last and first whisker trials around context transition (n = 41 mice). (H) Lick probability in response to the last and first whisker trial around context transition according to the delay at which it occurs. Transition from W- to W+ in green and from W+ to W- in magenta. (I&J) Quantification of orofacial posture (panel I) and movements (panel J) during the no-lick window preceding trial onset. Each line represents an individual mouse; large-filled circles represent grand-averages with error bars showing the 95% confidence interval. (K) Drop in accuracy for permutation of labels for each of the parameters of the gradient-boosted model predicting single-trial responses. (L) SHAP values for the ‘whisker trial in block’ parameter aligned on context transition from W+ to W- in magenta and from W- to W+ in green.

Optogenetic inactivation screen.

(A) Schematic of the optoinhibition screening in VGAT-ChR2 mice. (B) 30° rotated top view of the Allen mouse brain atlas, as in the experimental setup. (C) Top: Grid map showing changes in lick probability, ΔP(Lick), during catch trials in W- and W+ evoked by optogenetic inactivation of the target area. Bottom: d’ computed between the distribution of ΔP(Lick) in stim trials and a null distribution computed by shuffling all trials 1,000 times. (D) Same as C, but for auditory trials. (E) Same as C, but for whisker trials. (F) Top: Grid map showing change in lick reaction time (tongue-spout contact time) in correct response to auditory and whisker trials during optogenetic inactivation of the target area relative to control trials. Bottom: associated d’.

Imaging cortical spatiotemporal dynamics of context-dependent sensorimotor processing.

(A) Experimental apparatus. (B) Averaged time course of jaw opening aligned on whisker stimulus for correct trials in W+ (green) and W- (purple) contexts. (C) Reaction time in auditory and whisker trials in W- and W+ context derived from the time course of the jaw opening. (D) Grid map showing the target areas that are used as ROIs for trial averaged activity. The stars represent the center of mass of manually drawn ROIs centered on the peak of sensory-evoked activity for each mouse. (E) Left: Image series showing evolution of cortical dynamics following auditory trials in W+ (first row), in W- (second row), and d’ showing time-by-time distance between W- and W+ activity maps (third row). Right: Average time-course of stimulus-evoked activity in correct auditory trials in W+ (green) and W- (magenta) of selected target areas. (F) Same as in E, but for whisker trials. (G) Left: correlation between peak ΔF/F0 response to whisker and auditory trials in W+ and W-. Right: correlation between peak ΔF/F0 responses in W- and W+ for whisker and auditory trials. Each dot represents a mouse, dashed dark line represents equality of the two variables. (H) Left: Heatmap showing the first time at which the d’ comparing W- and W+ in correct whisker passed above 2 for each pixel. Right: Same comparison, but derived from ROI time-courses shown in F.

Context-dependent interactions across cortical areas.

(A) Map of correlation values for pixels significantly correlated to each seed. (B) Graph of connected network for correct and incorrect trials in W- and W+ extracted from maps of significant pixel to seed correlation. The rightmost column shows the difference between correct and incorrect trials in both contexts. The bottom row shows the difference between W+ and W- for correct and incorrect trials. (C) Left: schematic of the experimental setup for simultaneous optogenetic and imaging. Right: averaged image series for whisker trials in W+ contexts for control trials and 3 example inhibition locations. Time of frames in ms is aligned to whisker onset, and the optogenetic train starts in the immediately prior inter-frame interval. (D) Time course of activity projected on PC3 for whisker trials with optogenetic inhibition in W+ and W-. Dark green lines show whisker trials with lick in W+ for control trials, whereas light green lines show the same for no–lick outcome. Dark purple and light purple lines show the equivalent in W-. Blue lines show the projected activity for optogenetic inhibition of each of the selected grid locations in W+ and W-. Shaded areas represent 95% confidence intervals. (E) Quantification of the angle in PC3 between the optogenetic low dimensional projection and control-lick projection. Each dot represents a mouse and error bars are 95% confidence intervals. (F) Left: Grid projection of the average angle for each mouse between projections after optogenetic stimulation and control-lick projection in W+. Right: Pearson correlation between the angle in the average map (see left panel) and changes in lick probability for the opto-widefield mice in W+. (G) Same as F, but for W-

(A) Correlation between contrast value used for selection of expert sessions and discriminability index d’. Each dot represents a session. The dashed red line represents the threshold for the selection of expert sessions. Sessions with significantly above threshold average contrast values were classified as expert and shown in green. (B) Histogram showing the distribution of the total number of blocks in expert sessions. The dashed red line represents the average of the distribution. (C) Average duration of single context block. Each dot represents a mouse. Context block durations were averaged within session then further average across sessions to preserved paired data for each mouse. Population average is shown with the 95% confidence interval of the mean. Whisker rewarded context blocks were significantly longer than whisker non-rewarded blocks (W+: 196 ± 13 s, W-: 185 ± 4 s, t-value = 4.3, p-value = 2.0 x 10-4). (D) Average spout contact time in response to auditory and whisker trials in W- and W+ showing slightly faster response in W+ compared to W- for both auditory and whisker trials (Auditory: W+: 370 ± 9 ms, W-: 400 ± 9 ms, t-value = −8.7, p-value = 1.8 x 10-10, Whisker: W+: 392 ± 9 ms, W-: 418 ± 9 ms, t-value = −4, p-value = 6.0 x 10-4). (E) Left: average lick probability in response to whisker trials centered on block transition when contextual backgrounds are replaced by constant white noise. Right: same center on first trials around transition. Showing absence of context modulated response to the whisker stimulus when context is not explicitly and continuously given to the mice. (F) Example traces for whisker angle, jaw angle and pupil area. Vertical lines represent trial onsets: auditory, blue; catch, grey; and whisker, orange. (G) Tracking of face posture (whisker angle, jaw opening and pupil area) during quiet window preceding whisker trials sorted by context (top row) or by trial outcome (bottom row). Pupil area was significantly modulated by context with larger values in W+ compared to W- (W+: 0.52 ± 0.13 mm2, W-: 0.50 ± 0.12 mm2, t-value = 3.7, p-value = 0.023). Whisker angle and jaw opening were modulated by trial outcome with larger values in the baseline preceding lick for jaw opening (Lick: 0.27 ± 0.05 mm, No-Lick-: 0.23 ± 0.04 mm, t-value = 4.6, p-value = 0.0035), and smaller values in the baseline preceding lick for whisker angle (Lick: 97.3 ± 13 °, No-Lick-: 98.6 ± 12 °, t-value = −4, p-value = 0.0103). (H) Same as G, but for movement features (jaw speed and whisker speed). Jaw speed was significantly higher in W+ compared to W- (W+: 3.0 ± 1.0 mm/s, W-: 2.5 ± 0.8 mm/s, t-value = 5.1, p-value = 0.0011) and before Lick compared to No-Lick (Lick: 2.8 ± 0.1 mm/s, No-Lick: 2.6 ± 0.7 mm/s, t-value = −3.7, p-value = 0.0254). (I) Example tree extracted from the gradient boosted tree model showing the impact of parameter values on model decision. Each node of the tree corresponds to a decision step at which a parameter value is used to follow one branch or the other. Positive values in the final leaf tend to deviate the model toward predicting a lick whereas negative values tend to deviate it toward predicting no lick. (J) Correlation matrix between the features used to train the behavioral model showing that the model parameters are decorrelated. (K) SHAP values for one example trial showing the impact of the parameter value (in grey) on the model prediction for this given trial. Positive values (in red) tend to deviate the model toward predicting a lick whereas negative values (in blue) tend to deviate it toward predicting no lick. (L) Performance of the model in one session held out from the training set.

(A) Grid showing the total number repetitions of inhibition for each trial type and both contexts at each target location summed over the 7 mice. (B) Grid showing the absolute lick probability in catch, auditory and whisker trials in W- and W+. For each mouse we obtained a grid representation of the lick probability in response to each trial type in both contexts and further averaged these grids over mice. (C) Grid inhibition results in control mice not expressing ChR2. Grid map showing change in lick probability in response to catch, auditory and whisker trials in W- and W+ during optogenetic inactivation of the target area. Changes in lick probability are computed relative to lick probability in match trial type for each context in control stimulation trials, where the optogenetic laser beam is directed out of the brain. (D) Quantification of the optogenetic effect by computing d’ between the distribution of ΔLick probability in stim trials with a null distribution computed by shuffling all trials 1,000 times. (E) Effect of wS1 muscimol or Ringer injection on task execution. Mice were trained until they reliably performed at expert level and on the test day, injections were performed just before the behavior session. Left: lick probability in response to catch, auditory and whisker trials in W- and W+ in baseline day 0 and in day 1 with either Ringer or muscimol injection. Right: change in lick probability in response to catch, auditory and whisker trials in W- and W+ relative to the baseline day. Muscimol injection in wS1 significantly reduced lick probability in response to whisker trials in W- and W+ (hierarchical bootstrapping, p-value < 1.0 x 10-5). (F) Same as in E, but for injection into the forepaw primary somatosensory cortex (fpS1), serving as an injection control. (G) Same as E, but for RSC inactivation, which leads to a non-significant positive trend in lick probability for whisker trials in W- (hierarchical bootstrapping, p-value = 0.059). (H) Top: traces of jaw opening aligned on whisker trials for control (grey) or inactivation of the target area (blue) in W+ and W-. Bottom: quantification of the area under the curve in the 150 ms following trial onset and grid representation of the average effect.

(A) Image series showing evolution of cortical dynamics following whisker trials in W+ and W- in jRGECO1a (data duplicated from Figure 3F to facilitate direct comparison) and tdTomato control mice imaged under identical conditions. Early activation of primary and secondary whisker associated somatosensory cortices and propagation of sensory evoked activity were observed only in jRGCO1a expressing mice. (B) Same as A, but for GCaMP6f vs GFP mice. Sensory-evoked activity patterns in GCaMP6f-expressing mice were similar to jRGECO1a-expressing mice and not present in GFP-expressing control mice. (C) To image axonal projections from retrosplenial cortex, mice were injected with an AAV allowing for the expression of membrane bound opsin Chronos fused with GFP (AAV5.Syn.Chronos-GFP.WPRE.bGH). Injections were performed 1.5 mm posterior from bregma and 0.5 mm lateral at 4 depths from the pial surface (−200 µm, −400 µm, −600 µm and −800 µm, 25 nL / site). 4 weeks after injection, animals were perfused and brains extracted to be cleared and immunostained against GFP through iDISCO. We show light sheet imaging sections registered to Allen Mouse Brain Atlas after AAV injection in RSC in an example mouse. Left is a dorsal view of the cleared brain rotated 30 degrees to match the orientation in our widefield imaging. Middle panel is a sagittal view and coronal sections of the injection site (bottom) and M2 (top). Right panel shows branching axon innervating wM1/2 at higher resolution.

(A) Top row: correlation map for wS1, wS2, wM1/2, RSC, ALM, tjM1 and tjS1 seeds in correct whisker trials in W+. Bottom row: After data shuffling, we obtained for each seed and pixel a distribution of correlation value across shuffles. We represented for each seed a map showing the number of standard deviations of the correlation in the observed data compared to shuffled data. (B) To investigate correlations between areas, we reduced the correlation maps to grid space. We show as bar plots the correlation between seed and target areas in W- and W+ in correct (left) and incorrect (right) trials. The red dashed line indicates statistical threshold for correlation values defined as 1.8 standard deviation of the shuffle distribution above the shuffle mean. This allows us to identify significantly ‘connected’ regions, such as wS1 and wS2 or ALM and tjM1 in W+ and W- for both correct and incorrect trials. We used this criterion to obtain the 4 graphs of Figure 4B showing correlation between ‘connected’ regions in W+ and W- for both correct and incorrect trials. (C) Correlation changes across contexts between selected seed and target area for correct (top row) and incorrect (bottom row) trials. Stars indicate significantly different correlations in W- compared to W+. We used the d’ associated with the amplitude of the context modulation Δ (W+ - W-) or the outcome modulation Δ (Incorrect - Correct) of the correlation for previously identified ‘connected’ regions to build the delta summary graphs shown in Figure 4B. (D) Image series showing evolution of cortical dynamics following optogenetic stimulation trials in naïve mice expressing the calcium indicator jRGECO1a - but not the ChR2 opsin - with opto-inhibition laser directed to wS1 (top line) and wM1/2 (bottom line). This control experiment shows a locally restricted jRGECO1a photo-activation effect (jRGECO1a is based on mApple, which shows photoconversion upon blue light stimulation), but no widespread inhibition as observed in mice expressing the ChR2 opsin in inhibitory neurons (Figure 4C). (E) Cumulative variance explained by the first 15 components resulting from PCA analysis. (F) Grid representation of the loading on the first 3 PCs of each of the grid locations. (G) Time course of PC1 and PC2 in W+ and W- for control and selected optogenetic inhibition points.