Figures and data

A context-dependent whisker detection task.
(A) Schematic of the task structure. (B) Block-average lick probability 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- contexts. 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 centred on context transitions. From W-to W+ contexts in green and from W+ to W- contexts 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+ contexts in green and from W+ to W- contexts in magenta. Grey solid lines show exponential fits of the averaged lick probability over time. (I&J) Quantification of the changes in orofacial posture (panel I) and movements (panel J) during the no-lick window preceding whisker trial onset, relative to No-lick trials in the W- context. 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 whisker-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), evoked by optogenetic inactivation of the target area during catch trials in W-and W+ contexts. Bottom: d’ computed between the distribution of ΔP(Lick) in optoinhibition 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+ contexts 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 centre of mass of manually drawn ROIs centred on the peak of sensory-evoked activity for each mouse (auditory trials for A1; whisker trials for wS1 and wS2). (E) Left: Image series showing evolution of cortical dynamics following auditory trials in the W+ context (first row), in the W- context (second row), and the time-by-time distance (d’) between W-and W+ context activity maps (third row). Right: Average time-course of stimulus-evoked activity in correct auditory trials in W+ (green) and W- (magenta) contexts 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- contexts. Right: correlation between peak ΔF/F0 responses in W- and W+ contexts 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+ contexts in correct whisker trials 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+ contexts 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- contexts 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 (blue dot on the grid). 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- contexts. Dark green lines show whisker trials with lick in the W+ context for control trials, whereas light green lines show the same for no–lick outcome. Dark purple and light purple lines show the equivalent in the W- context. Blue lines show the projected activity for optogenetic inhibition of each of the selected grid locations in W+ and W-contexts. 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 the W+ context. Right: Pearson correlation between the angle in the average map (see left panel) and changes in lick probability for the opto-widefield mice in the W+ context. (G) Same as F, but for the W-context.

(A) Correlation between contrast value used for selection of expert sessions and discriminability index d’ between W- and W+ contexts. Each dot represents a session. The dashed red line represents the threshold for the selection of expert sessions. Sessions with a lower bound 95% confidence interval of mean contrast values (estimated from bootstrapping 10,000 times) above the 0.375 threshold 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) Left: Discriminability index d’ between catch and whisker trials in W- and W+ contexts. Right: decision criterion between catch and whisker trials in W- and W+ contexts. Each dot represents a mouse. (E) Average spout contact time in response to auditory and whisker trials in W- and W+ contexts showing slightly faster response in the W+ context compared to the W- context 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). (F) Left: average lick probability in response to whisker trials centred on block transition when contextual backgrounds are replaced by constant white noise. Right: same centre 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.

(A) Example traces for whisker angle, jaw angle and pupil area. Vertical lines represent trial onsets: auditory, blue; catch, grey; and whisker, orange. (B) 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 the W+ context compared to the W- context (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). (C) Same as G, but for movement features (jaw speed and whisker speed). Jaw speed was significantly higher in the W+ context compared to the W- context (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).

(A) 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. (B) Correlation matrix between the features used to train the behavioral model showing that the model parameters are decorrelated. (C) 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. (D) 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+ contexts. 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) Change in lick probability in optogenetic trials compare to control for a selection of cortical regions for the whisker rewarded (W+ green) and whisker non-rewarded (W- magenta) contexts. Each dot represents a mouse, error bars show the 95th confidence interval of the population mean. (D) 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+ contexts during optogenetic inactivation of the target area. Changes in lick probability were computed relative to lick probability in the corresponding trial type for each context in control stimulation trials, where the optogenetic laser beam is directed out of the brain. (E) 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.

(A) 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+ contexts 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+ contexts relative to the baseline day. Muscimol injection in wS1 significantly reduced lick probability in response to whisker trials in W- and W+ contexts (hierarchical bootstrapping, p-value < 1.0 x 10-5). (B) Same as in A, but for injection into the forepaw primary somatosensory cortex (fpS1), showing no significant effect, thus serving as an injection control. (C) Same as A, but for RSC inactivation, which leads to a non-significant positive trend in lick probability for whisker trials in the W- context (hierarchical bootstrapping, p-value = 0.059).

(A) Traces of jaw opening aligned on whisker trials for control trials (grey) or optogenetic trials with inactivation of the target area (blue) in W+ and W- blocks. Each dot represents a mouse that was imaged simultaneously with optogenetic inactivation (4 out of 7 mice from the results presented in Figure 2). (B) Quantification of the area under the curve in the 150 ms following trial onset for control (first bar) and optogenetic trials (for the 6 target areas) for W+ (top line) and W- (bottom line) contexts. Stars indicate p < 0.05 when comparing the AUC for the optogenetic inactivation of a target area to the ‘Ctrl’ AUC (related t-test corrected for multiple comparisons). (C) Grid representation of the average optogenetic effect (change in the area under the curve) on jaw opening compared to control trials.

(A) Image series showing evolution of cortical dynamics following whisker trials in W+ and W- contexts 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.

Top: Image series showing evolution of differential cortical dynamics between whisker hit and auditory hit trials in the W+ context (Red, higher activity in whisker hit trials; Blue, higher activity in auditory hit trials). Bottom: discriminability index d’ associated with the mean difference.

(A) Stimulus aligned responses of wS1, wS2, wM1/2, RSC, ALM and tjS1 for correct whisker trials in W- (magenta) and W+ (green) contexts. The first three rows show session results for one mouse (PB178) where shaded area represents the 95% confidence interval around the trial average. The bottom row shows the mouse average resulting from averaging session averaged data in thick lines, each thin line represents a session average. The rightmost column shows the main effect between context defined by the difference of the W- and W+ context means either at the session level (first three plots) or at the mouse average level (fourth plot). Each color represents a selected cortical area. (B) Difference of mouse average response of wS1, wS2, wM1/2, RSC, ALM and tjS1 between W- and W+ contexts. (C) Left: Difference of population average response of wS1, wS2, wM1/2, RSC, ALM and tjS1 between W- and W+ contexts. Right: Over time discriminability index between context computed from the population (i.e., variance considered between animals). The dashed grey line shows the threshold of 2 used for ranking discriminability between cortical areas in Figure 3H.

(A) Stimulus aligned jaw opening, whisker angle and whisker speed in W+ (green) and W- (magenta) contexts for correct whisker trials (top row) and correct auditory trials (bottom row) (N=24 mice). (B) Stimulus aligned discriminability index d’ between W+ and W- contexts for jaw opening, whisker angle and whisker speed for correct whisker trials (top row) and correct auditory trials (bottom row).

(A) Image series showing the evolution of cortical dynamics following the transition to the W+ context (first row), to the W- context (second row), and the difference between activity maps in the W- and W+ contexts (third row). (B) Average time-course of stimulus-evoked activity in all whisker trials in W+ (green) and W- (magenta) contexts of selected target areas according to the trial index within the context block. (C) Maximal amplitude of the response measured in the 120 ms following the whisker stimulus for each of the selected target area as a function of whisker trial index within context block.

(A) 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). 6 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 a mouse brain atlas optimized for light sheet microscopy (Perens et al., 2021) 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, shown as a maximum projection of the most superficial 2 mm of the brain. Right panel shows branching axon innervating wM1/2 at higher resolution, depicted as a single z-plane with thickness of 5.34 μm and x,y voxel size of 1.58 μm. (B) Sagittal view around the injection site, shown as a maximum projection of 3 mm from the midline extending laterally. (C) Coronal sections of the injection site (bottom) and wM1/2 (top), each shown as a single coronal section resampled to a 20 μm voxel size to improve visualization given the anisotropy of the light sheet images.

(A) Top row: correlation map for wS1, wS2, wM1/2, RSC, ALM, tjM1 and tjS1 seeds in correct whisker trials in the W+ context. 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+ contexts in correct (left) and incorrect (right) trials. The stars indicate correlation values above 1.8 standard deviations of the shuffled distribution. This allows us to identify significantly ‘connected’ regions, such as wS1 and wS2 or ALM and tjM1 in W+ and W- contexts 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- contexts 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 the W- context compared to the W+ context (p <0.05, t-test corrected for multiple comparisons using Bonferroni correction). 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.

(A) 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). (B) Cumulative variance explained by the first 15 components resulting from PCA. (C) Grid representation of the loading on the first 3 PCs of each of the grid locations. (D) Time course of PC1, PC2 and PC3 in W+ and W- contexts for control and selected optogenetic inhibition points for control trials with lick or no lick and optogenetic trials.