Distinct contributions of mouse cortical areas to visual discrimination

Sensory decisions involve multiple cortical areas, but the specific roles of these areas are not well understood. We trained head-fixed mice to discriminate visual contrast and report their decision with a wheel turn. Widefield calcium imaging revealed task-related activity in multiple cortical areas: visual (VIS), secondary motor (MOs), primary motor and somatosensory. Optogenetic inactivation, however, impaired performance only in VIS and MOs. The animal’s choices could be related to cortical activity using a simple neurometric model that weighed activity in VIS and MOs. The model’s weights revealed different roles for these regions: VIS promotes contraversive and suppresses ipsiversive choices, whereas MOs promotes both contraversive and ipsiversive choices. With no further parameter adjustments, the same model predicted the effect of local optogenetic inactivation. These results indicate that neocortex causally supports visual discrimination through visual and frontal but not primary motor areas, and provides a quantitative framework relating cortical activity to decisions.


INTRODUCTION
Decision-making in humans and animals can often be described by probabilistic models. Although we may respond to a sensory stimulus differently on different occasions, the probabilities of our choices often depend regularly on quantities such as stimulus strength or expected reward. Mathematical formulae relating the probabilities of different choices to sensory variables are known as psychometric models, and include signal detection theory (Green and Swets, 1966;Sridharan et al., 2014), logistic regression (Greene, 2011), and drift diffusion (Gold and Shadlen, 2001;Ratcliff et al., 2016).
To relate a psychometric model of behavior to brain circuits, one must demonstrate both correlation and causation. First, one must correlate quantities appearing in the model with neural measurements (Corrado and Doya, 2007). For example, quantities in the drift-diffusion model have correlates in macaque sensory and parietal cortex (Britten et al., 1992;Roitman and Shadlen, 2002), and in rat parietal and frontal cortex (Brunton et al., 2013;Hanks et al., 2015). Such correlations allow one to build "neurometric" models, which predict behavior directly from brain activity (Newsome et al., 1989). Neurometric models can go beyond psychometric models by predicting not just the probabilities of each choice, but also accounting for trial-to-trial variability in choices to identical stimuli. However, such predictions still do not provide causal evidence, which require one to perturb neural activity and test if behavioral changes conform to the model. For example, the changes seen when perturbing sensory and frontal regions conform with the predictions of the drift-diffusion model (Erlich et al., , 2011Katz et al., 2016;Liu and Pack, 2017). However, behavioral changes are less clear when one perturbs parietal areas Hanks et al., 2006;Katz et al., 2016), suggesting that these areas may not play a causal role in those tasks.
Perceptual decision making appears to engage multiple cortical areas, but the nature of their interaction is debated (Cisek and Kalaska, 2010). Some aspects of sensory processing are consistent with a sequential process, where the stimulus sequentially activates early sensory, premotor, and frontal cortical areas (Guo et al., 2014;Hernández et al., 2010;Le Merre et al., 2018;Ledberg et al., 2007;Siegel et al., 2015). However, choice-predictive activity can emerge simultaneously in several cortical areas (Hernández et al., 2010;Siegel et al., 2015), suggesting that decisions can arise from parallel interaction among these areas.
Here we provide both correlative and causal evidence for a simple neurometric model of decision making involving multiple cortical areas. We used widefield calcium imaging and scanning optogenetic inactivation in mice performing a visual discrimination task (Burgess et al., 2017). The imaging revealed sequential activation of multiple areas in dorsal cortex, but the inactivation revealed that only visual and secondary motor cortex played a causal role. We developed a simple neurometric model summarizing the parallel contribution of these two regions towards a decision. This model accounted for the relationship of activity to behavior and also predicted the effects of inactivations, despite the inactivation data playing no part in fitting the model. The results provide a quantitative and causal framework for modeling how cortical activity relates to decisions.

RESULTS
We begin by describing the task and a simple psychometric model. We then introduce measurements of cortical activity and results from cortical inactivations. Finally, we return to the psychometric model and replace parts of it with neural substrates, thus obtaining a neurometric model of visual decision making.

Visual discrimination task and psychometric model of behavior
We trained mice to perform a two-alternative unforced-choice visual discrimination task (Burgess et al., 2017). Mice were head-fixed and their forepaws rested on a steering wheel surrounded by three screens (Fig. 1a). Each trial began after a quiescence period during which the mice refrained from any wheel movements for a minimum duration. Grating stimuli appeared in the left and right hemifields together with an auditory Go cue (Fig. 1b-d). Mice were rewarded with water for rotating the wheel Left or Right to bring the higher-contrast stimulus into the center, or for holding the wheel still (NoGo) if no stimulus was present. Mice became proficient in the task, achieving 86 ± 9% correct choices (mean ± SD, n=34 sessions in 6 mice) on trials with single high contrast gratings, and the probability of their choices varied smoothly with the contrasts of the two gratings ( Fig. 1e-h).
To account for the mouse's choices we employed a simple logistic model (Burgess et al., 2017) (Fig. 1i-j), related to multiple-choice models used in econometrics (Greene, 2011) and in psychophysics (Sridharan et al., 2014). In this model, the probabilities of the three possible choices ( , , ) depend on two decision variables, and , which measure the log probability ratio for a Left or Right choice relative to NoGo, We modeled each decision variable as the sum of a bias term and a term depending on visual contrast on the corresponding side: ( ) The contrast-dependent terms were the product of a visual sensitivity factor and a saturating function of contrast ( ) = with exponent < 1 (Fig. 1j). The dependence of the two decision variables on contrast was therefore summarized by two sensitivity parameters ( , ) and one exponent ( ). Bias parameters ( , ) controlled the tendency to make a choice independently of sensory evidence.
To fit the model, we used a multi-level Bayesian approach that allowed parameters to vary across sessions and mice (see Methods). The fits accounted for the mean probabilities of choice both averaged across all mice and sessions , and across individual sessions (e.g. Fig.  1k-m).

Sequential activation of cortical areas
To reveal how the activity of different cortical areas correlates with task performance, we trained mice expressing GCaMP6s/f (see Methods) in excitatory neurons (n=4) or in all neurons (n=2) and performed widefield calcium imaging during task performance.  Presentation of the grating stimulus elicited a reliable sequence of activation in the hemisphere contralateral to the stimulus side ( Fig. 2a,b). Activity started in primary visual cortex (VISp) at 47±2 ms (time to 30% of peak; median ± m.a.d. across 6 mice), spread to secondary visual cortex (e.g. VISal at 54±4 ms), and then to secondary motor cortex (MOs at 97±6 ms). This activity was observed both for trials where mice made a correct Left or Right choice, and on NoGo trials, suggesting that activity in these regions was related to stimuli more than to actions.
In trials where mice responded to the stimulus by moving the wheel, this stimulus-related activity was followed by broad movement-related bilateral activity (  cortices arrived in both hemispheres nearsimultaneously (Fig. 2f).

Causal roles of visual and secondary motor cortex
Having observed that the task activates virtually all of dorsal cortex, we asked which specific regions play a causal role in the task. To test for causality, we inactivated each of 52 sites across dorsal cortex by shining a blue laser in transgenic mice expressing ChR2 in Parvalbuminexpressing inhibitory neurons (Olsen et al., 2012), using transcranial laser scanning (Guo et al., 2014). Laser illumination onset coincided with 6 the onset of visual stimuli and lasted until a choice (or NoGo) was registered.
Inactivation only affected the mice's choices when targeted at visual cortex (VIS) and secondary motor cortex (MOs) -the two regions that are activated earliest by sensory stimuli (Fig.  3a,b). We illustrate the results by showing the effects of inactivation in trials when the two stimuli had equal contrast (Fig. 3b). Inactivation of sites in VIS (due to light diffusion we could not target individual visual areas selectively) decreased the proportion of choices contralateral to the inactivated site by 35% (p<0.0002, permutation test). Inactivation of MOs had similar effects, decreasing contralateral choices by 22% (p<0.0002). These reductions were accompanied by increases in ipsiversive choices: by 35% following inactivation of VIS (p<0.0002) and by 18% following inactivation of MOs (p<0.0002; Supplementary Figure 2). These effects could be to some extent increased by increasing laser power, but not to the point of abolishing contralateral choices completely (Supplementary Figure  2). Furthermore, inactivation of other regions such as primary motor cortex (MOp), primary somatosensory cortex (SSp), and retrosplenial cortex had no apparent effect, despite strong activity seen in those regions using calcium imaging. This was true even for increased laser powers tested on MOp. Thus, much of the widespread cortical activity preceding the subject's choice is not causally necessary for it.
Surprisingly, inactivation of VIS increased ipsiversive choices even when the ipsilateral stimulus was absent ( Fig. 3c-e). If cortical inactivation simply rendered a subject unable to see on the contralateral side, and there was no ipsilateral stimulus, one would expect the subject to respond with a NoGo. We found effects consistent with this when inactivating MOs: the significant decrease in contraversive choices ( Fig. 3d) was mostly matched by an increase in NoGo choices, not by an increase in ipsiversive choices (Fig. 3e). In these same conditions, instead, VIS inactivation increased ipsiversive choices (Fig. 3e), as if it conjured a non-existent visual stimulus ipsilateral to the inactivated site.
The times at which inactivating VIS and MOs maximally disrupted task performance matched the times at which these areas were most strongly activated by the stimuli (Fig. 3f-h). To study the effect of timing, we performed further experiments where we inactivated VIS or MOs with a brief laser pulse (25 ms, 15 mW) at different times relative to stimulus onset (Fig. 3f). The critical time windows for VIS and MOs inactivation were different (Fig. 3g). Inactivation of VIS significantly affected the percentage of correct choices around the time of stimulus onset (-110 to +130 ms). While it may seem paradoxical that inactivation prior to stimulus onset can affect behavior, optogenetic pulse activation of Pvalb cells inhibits cortical firing for at least 100 ms (Supplementary Figure 3), so the time during which VIS activity is causally required is likely near the end of this window. Inactivation of MOs significantly impaired performance in a later window (+52 to +174 ms). Inactivation of either VIS or MOs during similar time windows also delayed choices (-34 to +79 ms for VIS, and +32 to +130 ms for MOs, Fig. 3h). By contrast, applying this pulsed inactivation to MOp caused no significant impairment (Supplementary Figure  2).

Neurometric model predicts single-trial decisions and effect of inactivations
To relate the results of neural recordings and inactivations to the mouse's decisions, we modified the psychometric model to obtain a neurometric model (Fig. 4a). Just as in the psychometric model (Fig. 1i), we assumed that the probabilities of each choice were based on two decision variables and (Equation 1). However, rather than computing these decision variables as a function of the stimulus on the screen (Equation 2), we now compute them as a weighted sum of cortical activity in VISp and MOs: where , are the trial-by-trial population firing rates in the left and right primary visual cortex (VISp), and , are the population firing rates in the left and right secondary motor cortex (MOs). These firing rates are multiplied by weights and applied to the contralateral cortices, and by factors and applied to the ipsilateral cortices. The weights from cortical activity to the decision variables could be interpreted mechanistically as the strength of cortical input to a downstream circuit that probabilistically determines the mouse's choice. Finally, the parameters and measure a bias  To fit this model, we inferred the population firing rates from widefield calcium imaging, calibrated using separately-measured spiking data (see Methods; Supplementary Figure 4). Each region's activity was taken over the last 50 ms of the critical time windows determined by pulse inactivation experiments, adding 30 ms to account for slower GCaMP6s onset (VISp: 105-155 ms, MOs: 155-205 ms; Fig. 3g,h). The model's 6 free parameters ( , , , , and ) were then fit by a multi-level Bayesian method similar to the one used for the psychometric model.
The weights obtained by fitting the model indicated a distinct role for VISp and MOs in determining the value of the contraversive and ipsiversive decision variables (Fig. 4b). Each hemisphere's VISp had a positive weight onto the contraversive decision variable and a negative weight onto the ipsiversive decision variable (i.e. higher activity in left VISp correlated with higher likelihood of Right choices and lower likelihood of Left choices, and the opposite for right VISp). By contrast, each hemisphere's MOs was positively weighted towards both the contraversive and ipsiversive decision variables, with larger weight to the contraversive variable.
The neurometric model captured not only the mean psychometric curves, but also the apparently random choices made in trials with identical stimulus conditions ( Fig. 4c-f). The model fitted the mean psychometric curves averaged across sessions and mice to a degree that was comparable to the psychometric model ( Fig. 4c-e). Moreover, the decision variables in the neurometric model could do something that the decision variables in the psychometric model would not be able to do: they correlated with trailby-trial variations in choices to the same stimuli. For example, on trials with medium contrast on one side only, trial-to-trial variation in the decision variable associated with that side correlated with the choice eventually made by the mouse (Fig.  4f). Thus, a single weighted sum of cortical activity not only captures how the subject's choices depend on stimulus contrast, but also captures how fluctuations in cortical responses to an identical stimulus relate to behavioral choice.
We finally asked if the same model -with weights fit only from widefield imaging experimentscould also predict the behavioral effects of optogenetic inactivation, and found that it could predict them to a large extent (Fig. 4g-i). To simulate the effect of laser inactivation we recomputed psychometric curves using the weights previously estimated from the widefield dataset, but setting activity in the inactivated region to zero. Although the inactivation trials were not used to constrain any model parameters, we nevertheless found that the model successfully predicted the primary features of the effect of optogenetic inactivation on real behavior, including the result that VIS but not MOs inactivation increases the probability of ipsiversive choices. The model explains this effect by applying negative weights from VIS activity to the ipsilateral decision variable. Indeed, the decision variables are subtractively comparing activity in right and left visual cortex, so that even without any visual stimulation, suppressing baseline activity on one side would lead to increased ipsilateral choices.

DISCUSSION
We found that a simple equation can quantitatively summarize the causal role of cortex in a two-alternative unforced-choice task. We started from a model of the mouse's average choices, in which decision variables were functions of visual contrast. Using widefield imaging, we were able to replace the visual processing stages of this psychometric model with actual neural recordings, to obtain a neurometric model, where the decision variables are weighted sums of activity in cortical areas VIS and MOs. This model was able to additionally account for trial-to-trial fluctuations in the subjects' choices. Furthermore, it could quantitatively predict the behavioral effects of optogenetic cortical inactivation, even though optogenetic data were not used to fit its parameters.
The neurometric model's success suggests that it captures the role of cortex in this task. It is therefore natural to hypothesize that a circuit downstream of VIS and MOs computes a similarly weighted sum of cortical activity, uses it to compute probabilities according to a logistic function, and selects a behavior according to these probabilities. The current data do not constrain what the downstream circuit might be, but a related paper studying the same behavioral task  suggests that basal ganglia and midbrain regions likely play a role.
These inferences were made possible by our unforced choice design. Had we employed a Go/NoGo design, we would have inferred from our neurometric model that VIS and MOs play similar functional roles in the task, as both regions would have positive weights onto the one decision variable required for a model of such a task. Without a competing choice, we would have missed that VIS activity correlates negatively with the ipsilateral choice, whereas MOs activity correlates positively with both. Likewise, had we employed a 2-alternative forced choice design, we could not have observed the effect that MOs inactivation suppressed contraversive choices without affecting ipsiversive choices, since with only two alternatives a decrease in one choice is identical to an increase in the other.
Despite the model's success, there are several opportunities for further improvement. First, the model predicted behavior based on widefield calcium signal, which corresponds to a single measure of population activity in each region. However, cortical neurons are diverse in their responses (Chen et al., 2017;Goard et al., 2016;Murakami et al., 2014;Raposo et al., 2014), and it is likely that behavior could be better predicted by fitting weights to individual cortical neurons. Second, the model assumes that inactivation of one region of cortex has no effect on firing in another region of cortex, which may not be the case. Related to this, we were limited in the spatial precision of the inactivation effect, and therefore we do not distinguish different visual areas, nor target posterior parietal cortex independently of visual cortex or somatosensory cortex. Finally, we have assumed a feedforward model, in which information is fed from cortex to a decision making circuit. Electrophysiological recordings of MOs neurons in the same task  implicate MOs in a recurrent loop rather than a feedforward system. Despite these simplifications, the model accurately captures multiple experimental results and therefore comprises a credible working hypothesis for the role of cortex in this task. Moreover, though the effects of inactivating brain regions in some behaviors may arise from off-target effects (Otchy et al., 2015), the combination of approaches employed here argue that this is not the case for this behavior: a model of the behavior constructed with imaging measurements can predict the effects of inactivation via a simple mechanism, without any additional parameters. Thus, the effects of cortical inactivation in this behavior are straightforward to interpret in the context of the neurometric model.
Many regions active in the task were not necessary for task performance. The most striking such area is MOp, for which inactivation produced no detectable effect on choice or reaction time, despite fluorescence activity larger than VIS and MOs. Our present data cannot rule out that MOp controls aspects of task performance we did not measure, such as fine control of distal muscles (Gharbawie et al., 2005) or learning . Alternatively, it is possible that MOp is involved in producing some other behaviors that the subject produces together with the wheel turn but are not necessary for it, such as whisking (Auffret et al., 2018). However, it is also possible that this activity simply plays no role in the task at all. Electrophysiological recordings in this task show that movement is accompanied by increased firing over many brain regions . This activity therefore appears to be a noncausal correlate of movement.
Our results suggest that in this task, frontal-motor areas are involved in high-level decision making, rather than low-level motor control. Microstimulation of homologous areas in rats leads to a combined set of eye, eyelid, vibrissa, and head movements consistent with orienting (Tennant et al., 2011), suggesting this cortical area interfaces with circuitry generating complex behavioral patterns. However, in our experiment inactivation of MOs did not unilaterally paralyze forelimb movements. Instead, for certain contrast conditions, the wheel was turned in the wrong direction, and reaction times were increased, suggesting that MOs may have more of role in sensory-motor planning (Ebbesen et al., 2018). A role for secondary motor (and nearby) regions in behavioral tasks has been suggested by several previous studies Goard et al., 2016;Guo et al., 2014;Hanks et al., 2015;Kopec et al., 2015), although many of these have suggested this region is important specifically for tasks requiring evidence accumulation or shortterm memory. Our task required neither, suggesting that MOs may be more generically involved in perceptual decision-making.
In summary, we have proposed and tested a theoretical account of the neural basis of visual contrast discrimination in mice. By combining measurements and manipulations with quantitative models, we provide direct evidence for the sequential and distinct roles of multiple cortical areas in this behavior.

Ethics
These experimental procedures were conducted at UCL according to the UK Animals Scientific Procedures Act (1986) and under personal and project licenses granted by the Home Office following appropriate ethics review.
Mice and session numbers were as follows,

Group
Mice (

Surgery
For both widefield imaging and optogenetic inactivation experiments, mice were prepared with a clear skull cap similar to that of Guo et al. (2014) and described previously (Burgess et al., 2017). The implantation surgery proceeded as follows. The dorsal surface of the skull was cleared of skin and periosteum, and the junction between cut skin and skull was sealed with cyanoacrylate. The exposed skull was prepared with a brief application of green activator to ensure strong connection between cement and bone (Super-Bond C&B, Sun Medical Co, Ltd, Japan). The junction between skin and skull was again covered, using dental cement (Super-Bond C&B). In most cases, a 3D printed 'cone' was attached to the head with cyanoacrylate and dental cement at this stage, surrounding the exposed skull and providing light isolation. A thin layer of cyanoacrylate was applied to the skull and allowed to dry. Two to four thin layers of UVcuring optical glue (Norland Optical Adhesives #81, Norland Products Inc., Cranbury, NJ; from ThorLabs) were applied to the skull and cured (~10 s per layer) until the exposed skull was covered (thin layers were used to prevent excessive heat production). A head-plate was attached to the skull over the interparietal bone with SuperBond polymer.

Behavioral task
Apparatus: The two-alternative unforced choice task design was described previously (Burgess et al., 2017). In this task, mice were seated on a plastic apparatus with forepaws on a rotating wheel, and were surrounded by three computer screens (Adafruit, LP097QX1) at right angles covering 270 x 70 degrees of visual angle (d.v.a.). Each screen was ~11cm from the mouse's eyes at its nearest point and refreshed at 60 Hz. The screens were fitted with Fresnel lenses (Wuxi Bohai Optics, BHPA220-2-5) to ameliorate reductions in luminance and contrast at larger viewing angles near their edges, and these lenses were coated with scattering window film ("frostbite", The Window Film Company) to reduce reflections. The wheel was a ridged rubber Lego wheel affixed to a rotary encoder (Kubler 05.2400.1122.0360). A plastic tube for delivery of water rewards was placed near the subject's mouth. Full details of the experimental apparatus including detailed parts list can be found at http://www.ucl.ac.uk/cortexlab/tools/wheel. Pre-stimulus quiescence: For two experiments, trials began after a period of no wheel movement (widefield imaging sessions: 0.3-0.7 s, 52coordinate inactivation experiment: 0.2-0.6 s). For all other behavioral sessions, there was no constraint however trials were excluded post-hoc if wheel movement was detected -150 to +50ms from stimulus onset.
Stimulus onset: At trial initiation, a visual stimulus was presented on the left, right, both, or neither screen. The stimulus was a Gabor patch with orientation 45 degrees, sigma 9 d.v.a., and spatial frequency 0.1 cycles/degree. The grating stimuli on the left and right screens displayed at all combinations of four contrast levels, totaling 16 contrast conditions. The proportion of trials of each stimulus type were weighted towards easy trials (high contrast vs zero, high vs low, medium vs zero, and no-stimulus trials) to encourage high overall reward rates and sustained motivation. For all experiments except for widefield imaging (see 'open-loop period' below), the onset of the visual stimulus also coincides with the onset of an auditory 'go cue' (12 kHz tone, 100ms duration), marking the time at which the mouse can respond.
Wheel movements: Wheel turns in which the top surface of the wheel was moved to the subject's right led to rightward movements of stimuli on the screen, i.e. a stimulus on the subject's left moved towards the central screen. Put another way, clockwise turns of the wheel, from the perspective of the mouse, led to clockwise movement of the stimuli around the subject. A left or right choice was registered when the wheel was turned by an amount sufficient to move the visual stimuli by 90 d.v.a. in either direction. When at least one stimulus was presented, the subject was rewarded for driving the higher contrast visual stimulus to the central screen (if both stimuli had equal contrast, Left/Right choices were rewarded with 50% probability). When no stimuli were presented, the subject was rewarded if no turn (NoGo) was registered during the 1.5 s following the go cue.
Open-loop period: For widefield calcium imaging sessions, there was a random delay interval of 0.5-1.2 sec, during which time the subject could turn the wheel without penalty, but visual stimuli were locked in place and rewards could not be earned. The subjects nevertheless typically responded immediately to the stimulus onset, and trials were excluded if choices were made after 0.5 s. At the end of the delay interval, an auditory go cue was delivered (8 kHz pure tone for 0.2 sec) after which the visual stimulus position became coupled to movements of the wheel. This small task modification was important to ensure that stimulus-related cortical activity was not inter-mixed with activity related to the auditory go cue, and that movement-related activity was not inter-mixed with signals related to visual motion of the stimulus on the screen.
Feedback: Immediately following registration of a choice or expiry of the 1.5 s window, feedback was delivered. If correct, feedback was a water reward (0.7 -2.5 µL) delivered by the opening of a valve on the water tube for a calibrated duration. If incorrect, feedback was a white noise sound played for 1 s. During the 1 s feedback period, the visual stimulus remained on the screen. After a subsequent inter-trial interval of 1 s (or 2 s for the 52-coordinate inactivation experiment; Fig. 3a), the mouse could initiate another trial by again holding the wheel still for the prescribed duration.
Training: Mice were trained on this task with the following shaping protocol. First, high contrast stimuli (50 or 100%) were presented only on the left or the right, with an unlimited choice window, and repeating trial conditions following incorrect choices ('repeat on incorrect'). Once mice achieved high accuracy and initiated movements rapidly -approximately 70 or 80% performance on non-repeat trials, and with reaction times nearly all < 1 second -trials with no stimuli were introduced, again repeating on incorrect. Once subjects responded accurately on these trials (70 or 80% performance, at experimenter's discretion), lower contrast trials were introduced without repeat on incorrect. Finally, contrast comparison trials were introduced, starting with high vs low contrast, then high vs medium and 13 medium vs low, then trials with equal contrast on both sides. The final proportion of trials presented was weighted towards easy trials (high contrast vs zero, high vs low, medium vs zero, and nostimulus trials) to encourage high overall reward rates and sustained motivation.

Widefield calcium imaging
Mice and apparatus: Imaging was performed in transgenic mice expressing GCaMP6 in excitatory neurons (tetO-G6s x CaMK2a-tTA; mouse ID 3,4,5; VGlut1-cre x Ai95; mouse ID 6) or all neurons (Snap25-GCaMP6s; mouse ID 1,2). Imaging data was also acquired in 3 more VGlut1-cre x Ai95 mice, but due to the small number of sessions these mice are not shown in Fig. 2. However, the data for all 9 mice were included in the neurometric model fit (Fig. 4b-f). Aberrant epileptiform activity has not been observed in these mouse lines . Details of the imaging have been described before (Jacobs et al., 2018) and are reproduced here. We imaged using a macroscope (Scimedia THT-FLSP) with sCMOS camera (PCO Edge 5.5) and dual-wavelength illumination (Cairn OptoLED). The macroscope used 1.0x condenser lens (Leica 10450028) and 0.63x objective lens (Leica 10450027). Images were acquired from the PCO Edge with ~10 ms exposures and 2 x 2 binning in rolling shutter mode. Images were acquired at 70 Hz, alternating between blue and violet illumination (35 Hz each). The light sources were 470 nm and 405 nm LEDs (Cairn OptoLED, P1110/002/000; P1105/405/LED, P1105/470/LED). Excitation light passed through excitation filters (blue: Semrock FF01-466/40-25; violet: Cairn DC/ET405/20x), and through a dichroic (425 nm; Chroma T425lpxr). Excitation light then went through 3 mm core optical fiber (Cairn P135/015/003) and reflected off another dichroic (495 nm; Semrock FF495-Di03-50x70) to the brain. Emitted light passed through the second dichroic and an emission filter (Edmunds 525/50-55 (86-963)) to the camera. Alternation was controlled with custom code on an Arduino Uno, and illumination was restricted to the 'global' phase of the rolling shutter exposures, i.e. only the times when all pixels of a frame were being exposed together.
Preprocessing: We de-noised the signal with singular value decomposition and normalized the signal to the mean fluorescence at each pixel. The signal from the 405 nm illumination frames was used to correct for parts of the 470 nm signal that were due to changes in blood flow that obstruct the fluorescence signal (Ma et al., 2016) and the correction was performed with custom Matlab code (https://github.com/cortex-lab/widefield). We then low-pass filtered the signal at 8.5 Hz and applied a derivative filter to the fluorescence trace to approximate deconvolution of the calcium sensor's time course from the underlying neural activity. When computing event-triggered averages of the fluorescence, pre-event baseline activity was removed, removing impact of longterm trends.
ROI selection: All ROIs were selected on the right hemisphere, based on the Allen CCF atlas aligned manually to each mouse, guided by skull features and retinotopic maps. ROI positions were manually adjusted to account for inter-mouse differences. VISp was selected as the peak of the most posterior-medial activated site in visual cortex in response to a contralateral stimulus. VISal was selected as the center of VISal according to the Allen CCF. VISal was taken as an exemplary secondary visual cortical area because it was furthest from the part of VISp activated by our visual stimuli, ensuring minimal contamination of fluorescence between these two ROIs. The MOs ROI was selected as the most anterior site activated by the contralateral stimulus. MOp and SSp ROIs were selected as the most anterior-medial and posterior-lateral regions of the region that spanned the MOp-SSp border and was active during wheel movements.

Optogenetic inactivation
While mice performed the task, we optogenetically inactivated several cortical areas through the skull using a blue laser. In the 52coordinate experiment (Fig. 3a-b), unilateral inactivation was achieved by mounting a fiberoptic cable on a moving manipulator (Scientifica, Patch-Star). On every trial, custom code drove the manipulator to set the position of the fiberoptic cable to one of 52 different coordinates distributed across the cortex. Inactivation coordinates were defined stereotaxically from bregma. On ~75% of trials, the laser was switched on (473 nm, 1.5 mW, 40 Hz sine wave) to inactivate the cortical site. Laser and non-laser trials, and the location of the cortical inactivation, was randomized. The duration of the laser was from visual stimulus onset, until a behavioral choice was made. For any given session, a single cortical site on the inactivation grid may only be inactivated a handful of times. This discouraged any adaptation effects that may occur on more frequent inactivation paradigms, however this approach does require combining data across sessions. The laser positioning was independent of laser power, so auditory noise from the manipulator did not predict inactivation.
In subsequent inactivation experiments, a pair of mirrors mounted on galvo motors were used to orient the laser (462 nm) to different points on the skull. We also introduced improved light isolation to ensure no light could reflect from the skull surface and be seen by the mouse. In the higherpower inactivation experiment (Fig. 3c-e), we inactivated visual and secondary motor and primary motor areas (-0.5 mm AP, ±0.5 mm ML) for a fixed duration 1.5 s, 40 Hz sine wave using different laser powers (1.5, 2.9, 4 mW). Trials of different laser powers were pooled together. In the pulse inactivation experiment (Fig. 3f-h), we inactivated only visual (-4 mm AP, ±2 mm ML) and secondary motor areas (+2 mm AP, ±0.5 mm ML), using a brief 25 ms DC pulse at 15 mW power. The onset time of the laser pulse was set randomly trial by trial, ranging -300 ms to +300 ms relative to stimulus onset.

Electrophysiological recordings
Hardware: Recordings were made using Neuropixels "Phase3A" electrode arrays (Jun et al., 2017). Probes were mounted to a custom 3Dprinted PLA piece and affixed to a steel rod held by a micromanipulator Sensapex Inc.). To allow later track localization, prior to insertion probes were coated with a solution of DiI (ThermoFisher Vybrant V22888 or V22885) by holding 2 µL in a droplet on the end of a micropipette and touching the droplet to the probe shank, letting it dry, and repeating until the droplet was gone, after which the probe appeared pink.
Procedure: On the day of recording or within two days before, mice were briefly anaesthetized with isoflurane while one or more craniotomies were made, either with a dental drill or a biopsy punch. The craniotomies for VISp were targeted in some cases using measured retinotopic maps in the same mice, and in other cases to the same position stereotaxically (-4 mm AP, 1.7 mm ML, left hemisphere). The craniotomies for MOs were targeted stereotaxically (+2 mm AP, 0.5 mm ML, left hemisphere). After at least three hours of recovery, mice were head-fixed in the setup. Probes had a soldered connection to short external reference to ground; the ground connection at the headstage was subsequently connected to an Ag/AgCl wire positioned on the skull. The craniotomies as well as the wire were covered with saline-based agar. The agar was covered with silicone oil to prevent drying. In some experiments a saline bath was used rather than agar. Probes were advanced through the agar and through the dura, then lowered to their final position at ~10 µm/s. Electrodes were allowed to settle for ~15 min before starting recording. Recordings were made in external reference mode with LFP gain = 250 and AP gain = 500. Recordings were repeated on multiple subsequent days. All recordings were made in the left hemisphere.
Preprocessing: The data were automatically spike sorted with Kilosort (Pachitariu et al., 2016) (https://github.com/cortex-lab/Kilosort) and then manually curated with the 'phy' gui (https://github.com/kwikteam/phy). Extracellular voltage traces were preprocessed commonaverage referencing: subtracting each channel's median to remove baseline offsets, then subtracting the median across all channels at each time point to remove artifacts. During manual curation, each set of events ('unit') detected by a particular template was inspected and if the events ('spikes') comprising the unit were judged to correspond to noise (zero or nearzero amplitude; non-physiological waveform shape or pattern of activity across channels), the entire unit was discarded. Units containing lowamplitude spikes, spikes with inconsistent waveform shapes, and/or refractory period contamination were labeled as 'multi-unit activity' and not included for further analysis. Finally, each unit was compared to similar, spatially neighboring units to determine whether they should be merged, based on spike waveform similarity, drift patterns, or cross-correlogram features.

Psychometric model
We modeled probabilistic choice behavior using multinomial logistic regression. For each trial , the probability of choice on each trial by the softmax function of two decision variables , and , : Choices ∈ ( , ℎ , ) were drawn from a categorical probability distribution with these parameters: We denote the session in which trial occurred as [ ] , and the subject (mouse) that performed session as [ ] . The decision variables depended on parameters which varied between sessions (and thus also between subjects) according to the following formulae: Here, , and , are bias parameters, which capture stimulus-independent choice behavior in session , while , and , are sessiondependent sensitivity parameters scaling the visual input on the left and right. The visual input consists of the contrast presented on trial ( , and , on the left and right), raised to a sessiondependent exponent < 1 to allow for a saturating non-linear contrast transformation.
To model variability in the parameters across sessions and subjects, we used a hierarchical prior. Let be a 5-element vector containing the 5 session-specific parameters stated above, = [ , , , , , , , , ] We model each session's parameter vector as drawn from a multivariate Gaussian distribution whose mean ̅ [ ] depends on the subject, with a common covariance matrix ,

~ ( ̅ [ ] , )
The covariance matrix is given the following prior by first converting to a correlation matrix. The correlation matrix given a (2) prior (Lewandowski et al., 2009), which penalizes large positive or negative parameter correlations across sessions. The standard deviation terms for each parameter are given a ℎ (0,1) prior which penalizes large variability in each parameter across sessions.
The subject-level mean vector ̅ is drawn from a Gaussian grand-average mean * , with a covariance matrix * which quantifies covariation in the parameters across subjects, The covariance matrix * is given the same prior as . Finally, the grand-average parameters are given the following weakly-informative hyperprior, * ~ The full joint posterior distribution of all parameters was numerically estimated with Hamiltonian Monte Carlo sampling, using the Stan programming language (Carpenter et al., 2017). Sampling was performed in 4 chains, each with 500 warm up iterations and 500 sampling iterations. The samples were checked manually to ensure convergence within and between chains. The posterior prediction from the model is constructed by computing the model prediction from each of the posterior distribution samples, and then computing the mean and 95% credible intervals on the prediction across samples. All model predictions shown in the figures use the grand-average parameter values * , unless specified otherwise.

Neurometric model
The containing the firing rate of activity in the four regions on trial . The weights and offset parameters are given a hierarchical prior allowing for variation between sessions and subjects similar to in the psychometric model, with hyperpriors * , * ~ (0,4 2 ) * , * ~ ( , × 4 2 ) The neural activity contained within is the estimated population firing rate of the four cortical regions on each trial. The population firing rate is estimated from widefield calcium imaging at the four ROIs. Since the baseline activity in widefield calcium fluorescence is poorly defined, the calcium fluorescence was transformed to approximate population firing rates. To achieve this, we recorded extracellular spiking activity in VISp and MOs using Neuropixels probes in separate sessions, and computed trial-averaged firing rates for each of the contrast conditions over a time window (Supplementary Figure 4; VIS: 75-125 ms, MOs: 125-175 ms). Calcium fluorescence was also averaged over the same windows but 30 ms later to allow for slower GCaMP6s kinetics. The transformation from widefield fluorescence to firing rate was computed by simple linear regression over the 16 contrast conditions. This linear transformation was then applied to the fluorescence value for each individual trial, thereby providing a population firing rate estimate for the four cortical regions on every trial. To improve fit stability, we enforced parameter symmetry between the left and right hemispheres (e.g. the weight of left VISp onto the log odds of Left vs. NoGo was the same as right VISp onto Right vs. NoGo).
To demonstrate that the neurometric model could predict behavior during optogenetic inactivation, the model was modified in two ways. Firstly, since neural activity in VIS and MOs was not measured during optogenetic inactivation sessions, the trialby-trial activity in was replaced with the trialaveraged firing rate measured electrophysiologically for each contrast condition. Secondly, since the overall tendency to NoGo differed idiosyncratically between widefield imaging and optogenetic inactivation sessions, the model offset parameters ( and ) were refit to the non-laser trials contained within optogenetic inactivation sessions.
To simulate the effect of optogenetic inactivation of a single cortical area, one element of the firing rate vector was set to zero. This effect propagates forward through the model based on the fixed weights, thereby affecting the decision variables and the probability associated with each choice. Importantly, the behavioral prediction obtained from the model when simulating inactivation did not depend on any empirical data involving actual optogenetic inactivation. In this sense, the neurometric model cross-predicted behavior in a new dataset on which it was not fit.

Statistical tests
For the 52-coordinate inactivation experiment ( Fig. 3b; Supplementary Figure 2B), statistical significance of the inactivation effect was assessed using a shuffle test. The test statistic used was the difference in the proportion of a specific choice type, between laser and non-laser off trials (on trials with equal left and right contrast) for each of the inactivated coordinates. The null distribution of the test statistic was computed by repeated shuffling of laser and nonlaser trial identities, pooling across all sessions and subjects. All other statistical tests are specified in the main text.