A dendritic disinhibitory circuit mechanism for pathway-specific gating

While reading a book in a noisy café, how does your brain ‘gate in' visual information while filtering out auditory stimuli? Here we propose a mechanism for such flexible routing of information flow in a complex brain network (pathway-specific gating), tested using a network model of pyramidal neurons and three classes of interneurons with connection probabilities constrained by data. We find that if inputs from different pathways cluster on a pyramidal neuron dendrite, a pathway can be gated-on by a disinhibitory circuit motif. The branch-specific disinhibition can be achieved despite dense interneuronal connectivity, even with random connections. Moreover, clustering of input pathways on dendrites can naturally emerge through synaptic plasticity regulated by dendritic inhibition. This gating mechanism in a neural circuit is further demonstrated by performing a context-dependent decision-making task. The model suggests that cognitive flexibility engages top-down signalling of behavioural rule or context that targets specific classes of inhibitory neurons.

D istinct classes of inhibitory interneurons form cell-typespecific connections among themselves and with pyramidal neurons in the cortex 1,2 . Interneurons expressing parvalbumin (PV) specifically target the perisomatic area of pyramidal neurons. Interneurons expressing somatostatin (SOM) specifically target thin basal and apical tuft dendrites of pyramidal neurons 3,4 . Interneurons expressing vasoactive intestinal peptide (VIP) avoid pyramidal neurons and specifically target SOM neurons 5 . Long-range connections from cortical 6,7 or subcortical 8 areas can activate VIP neurons, which in turn suppress SOM neurons, and disinhibit pyramidal dendrites. Such dendritic disinhibitory circuit is proposed to gate excitatory inputs targeting pyramidal dendrites [9][10][11] (Fig. 1a).
Insofar as any cortical area receives inputs from tens of other areas and projects to many other areas, information flow across the complex cortical circuit needs to be flexibly gated (or routed) according to behavioural demands. Broadly speaking, there are three types of gating in terms of specificity. First, all inputs into a cortical area may be uniformly modulated up or down. Recent research in mice demonstrated that such gating involves the disinhibitory motif mediated by VIP and SOM interneurons 6,8,[12][13][14][15] . These studies generally found that VIP neurons are activated, and SOM neurons are inactivated, in response to changes in the animals' behavioural states, such as when mice receive reinforcement 14 , or start active whisking 6,15 or running 8 . The reported state change-related activity responses can be remarkably homogeneous across the local population of the same class of interneurons 12,13 .
Second, gating may involve selective information about a particular stimulus attribute or spatial location (for instance, in visual search or selective attention 7 ). Whether SOM or VIP neurons are endowed with the required selectivity remains insufficiently known. In sensory cortex, SOM neurons exhibit greater selectivity to stimulus features (such as orientation of a visual stimulus) than PV neurons 16 . Furthermore, in motor cortex, SOM neurons have been shown to be highly heterogeneous and remarkably selective for forward versus backward movements 17 .
Third, for a given task, neurons in a cortical area may need to 'gate in' inputs from one of the afferent pathways and 'gate out' other afferent pathways 18,19 , which we call 'pathway-specific gating'. For instance, imagine yourself sitting in a noisy café and trying to focus on your book. Your associational language areas receive converging inputs from both auditory and visual pathways. Opening the gate for the visual pathway while closing the gate for the auditory pathway allows you to focus on reading (Fig. 1b). In the classic Stroop task, the subject is shown a coloured word, and is asked to either name the colour or read the word. One possible solution to this task is for a decisionmaking area to locally open its gate for the deliberate pathway (colour-naming) while closing its gate for the more automatic pathway (word-reading).
Using computational models, we propose that the dendritic disinhibitory circuit can instantiate pathway-specific gating. Each of the many branches of a pyramidal dendrite processes its inputs quasi-independently 20 and nonlinearly 21 . Feedforward and feedback pathways target different regions (for example, basal or apical tuft) of dendritic trees of pyramidal neurons 22 . We hypothesize that excitatory inputs from different pathways can cluster onto parts of dendrites of pyramidal neurons, which we term 'branch-specific' even though inputs from a particular pathway may target multiple branches. This hypothesis is supported by mounting evidence for synaptic clustering on dendritic branches [23][24][25] . A pathway can presumably be 'gated-on' by specifically disinhibiting the branches targeted by this pathway (Fig. 1c), that is, by a disinhibition pattern aligned with the excitation. This branch-specific disinhibition is motivated by findings showing that synaptic inhibition from SOM neurons can act very locally on dendrites, even controlling individual excitatory synapse by targeting the spine 4 or the pre-synaptic terminal 26 . In this work, we developed a network model with thousands of pyramidal neurons and hundreds of interneurons for each (VIP, SOM and PV) type, and show that pathwayspecific gating can be accomplished by the disinhibitory motif, even though the connectivity from SOM neurons to pyramidal neurons is dense: each SOM neuron on average targets 460% of neighbouring pyramidal neurons (o200 mm) 27 .
We first characterized how branch-specific disinhibition can efficiently gate excitatory inputs onto pyramidal dendrites. We then investigated the plausibility of branch-specific disinhibition in a dendritic disinhibitory circuit model constrained by experimentally measured single-neuron physiology and circuit connectivity. We found that, although SOM-topyramidal connectivity is dense at the level of neurons, at the level of dendrites it is sufficiently sparse to support branchspecific disinhibition, and therefore pathway-specific gating, given  1 | Dendritic disinhibitory circuit as a mechanism for pathway-specific gating. (a) Subcellular microcircuit motif for gating through dendritic disinhibition. Dendrites of pyramidal neurons are inhibited by SOM interneurons, which are themselves inhibited by VIP interneurons. A control input (representing a context or a task rule) targeting VIP interneurons (and potentially SOM neurons) can thereby disinhibit pyramidal neuron dendrites, opening the gate for excitatory inputs targeting these dendrites. (b) Circuit configuration for pathway-specific gating. Pyramidal neurons receive converging inputs from multiple pathways, for example, visual and auditory. Single neurons in these areas are selective to multiple stimulus features, indicated here by colour and frequency. The processing of each pathway is regulated by the control input. (c) Inputs from different pathways target distinct subsets of dendrites of these pyramidal neurons. A pathway can be gated-on by specifically disinhibiting the dendrites that it targets, corresponding to an alignment between excitation and disinhibition. Disinhibition is represented by dashed lines. that SOM neurons can be selectively controlled. We then showed control inputs targeting both VIP and SOM neurons can selectively suppress SOM neurons as needed. Notably, we drew these conclusions under some 'worst-case' assumptions to our model such as random interneuronal connectivity. Using a calcium-based synaptic plasticity model, we found that disinhibitory regulation of plasticity can give rise to an appropriate alignment of excitation and disinhibition, which is required for pathway-specific gating in our scheme. Finally, we demonstrated the functionality of this mechanism in a circuit model performing an example context-dependent decision-making task 28 .
Our results suggest that, in addition to the proposal that SOM neurons provide a 'blanket of inhibition' 29 , they can indeed subserve pathway-specific gating. This work argues that top-down behavioural control may involve rule signals targeting specific interneuron types rather than, or in addition to, pyramidal neurons, and that the disinhibitory motif could play a major role in synaptic plasticity.

Results
Pathway-specific gating with dendritic disinhibition. To study dendritic disinhibition, we first built a simplified neuron model with a reduced morphology ( Fig. 2a; Supplementary Fig. 1). It comprises one spiking somatic compartment and multiple dendritic compartments, which are electrically coupled to the soma but otherwise independent of each other. The somatic and dendritic compartments have no spatial extent themselves. This choice of morphology is inspired by previous studies showing that different dendritic branches can integrate their local input independently from one another 20 .
A prominent feature of active processing in thin dendritic branches is their ability to produce NMDA (N-methyl-Daspartate) plateau potentials 30 , also called NMDA spikes. The NMDA plateau potential is a regenerative event in which the membrane potential increases nonlinearly and sometimes sharply with the NMDAR (N-methyl-D-aspartate receptor) input, due to the release of voltage-dependent magnesium block of NMDARs. The reduced neuron model can exhibit NMDA plateau potential in dendrites (Fig. 2b), in line with simulations of morphologically reconstructed neuron models ( Supplementary Fig. 1). The mean dendritic voltage in response to a Poisson spike train input is a sigmoidal function of the input rate, due to the NMDA plateau potential (light blue curve in Fig. 2c).
The NMDA plateau potential can be prevented by applying a moderate synaptic inhibition, mediated by GABA A Rs (g-aminobutyric acid receptors), to the same dendrite (dark blue curve in Fig. 2c). Inhibition is particularly effective in controlling this dendritic nonlinearity when excitatory inputs are mediated by NMDARs with experimentally observed saturation, in stark contrast to AMPARs (a-amino-3-hydroxy-5-methyl-4-isoxazolepropionic acid receptors; Supplementary Fig. 1) or NMDARs without saturation ( Supplementary Fig. 2). Inhibitory input also linearizes the relationship between mean dendritic voltage and excitatory input rate (Fig. 2c), due to stochastic transitions into or out of NMDA plateau potential induced by low-rate inhibition ( Supplementary Fig. 2). Therefore, excitatory inputs to a dendritic branch can be efficiently gated by inhibition 31 .
We now consider multiple pathways of inputs targeting distinct sets of dendrites. In the default condition, all dendritic branches receive a high baseline inhibition from dendritetargeting SOM neurons 6,15 , closing gates for all pathways. Disinhibiting the branches targeted by one pathway can selectively open the gate for this pathway while keeping the gates closed for other pathways (Fig. 2d). When a gate is open, the neuron's output firing rate transmits the stimulus selectivity of the corresponding input pathway most effectively (Fig. 2e). When two excitatory pathways are activated simultaneously, we can plot the neuron's response to stimulus variables of both pathways, that is, the two-dimensional tuning curve (Fig. 2f,g). In the default condition when all gates are closed, there is little response to either pathway (Fig. 2f). By specifically disinhibiting the branches targeted by pathway 1, we can open the gate for pathway 1. With gate 1 opened, the neuron is primarily selective to pathway 1 stimuli (Fig. 2g). The remaining impact of pathway 2 stimuli is due to the fact that the impact of excitatory inputs can never be fully counteracted by dendritic inhibition.
The gating mechanism worsens when a fraction of excitatory input is mediated by AMPARs, but improves when a fraction of inhibitory input is mediated by GABA B Rs ( Supplementary Fig. 3). Under in vivo conditions, the relative contribution of AMPAR-mediated inputs is likely quite low, as a result of a lower glutamate affinity and a stronger desensitization 21 . For parsimony, in the following sections, excitatory synaptic inputs are mediated only by NMDARs, which are critical to the nonlinear dendritic computations, and inhibitory inputs are mediated only by GABA A Rs.
Performance of gating in pyramidal neurons. Which circuit properties determine the effectiveness of pathway-specific gating in our model? A neuron responds to its optimal stimulus from an input pathway with (baseline-corrected) firing rate (r on ) when the pathway is gated-on, and (r off ) when the pathway is gated-off, which could be readily measured experimentally. The gating selectivity is then quantified, which ranges from 0 (no gating) to 1 (perfect gating). We developed a multi-compartmental rate model 20 that greatly improves the efficiency of the circuit model simulation. The rate model is fitted to quantitatively reproduce the activity of the spiking neuron model (Supplementary Fig. 4; see Supplementary Information for details). We first tested how gating selectivity depends on our assumption of branch-specific disinhibition in a single-neuron setting. Here we assume an alignment of excitation and disinhibition patterns, which can be achieved through synaptic plasticity as shown later. Each excitatory pathway targets N disinh randomly chosen dendrites, out of N dend total dendrites, and this pathway is gated-on by specifically disinhibiting these same N disinh dendrites (Fig. 3a). Due to the random-independent selection of targeted dendrites for each pathway, inputs from two different pathways often overlap.
We found that gating selectivity depends critically on the sparseness of the disinhibition (Fig. 3b), defined as the proportion of targeted/disinhibited dendrites N disinh /N dend . Gating selectivity improves when disinhibition patterns are sparsened, because the proportion of dendrites that receive overlapping inputs is reduced. We can approximate the limit of N disinh /N dend -0 with non-overlapping disinhibition pattern (diamonds in Fig. 3b,c). In this case, the gating selectivity is highest but below 1, due to the remaining impact of inputs targeting inhibited dendrites, and is therefore modulated by the level of disinhibition (Fig. 3c).
Pathway-specific gating with SOM neurons. We have shown that a key determinant of gating performance is the sparseness of innervation patterns onto the dendritic tree. Yet, the connectivity from SOM interneurons to pyramidal neurons is dense 27 . Is it possible for the proposed gating mechanism to function in a cortical microcircuit limited by the dense interneuronal connectivity? To address this issue, we built an interneuronal circuit model, containing hundreds of VIP and SOM interneurons and thousands of pyramidal neurons. We considered 'worst-case' conditions in which interneuronal connectivity is completely random (as our gating mechanism can be facilitated by structured connectivity). Surprisingly, we found that relatively high gating performance is achievable under these conditions. We analysed gating in this circuit in two steps: first, assuming SOM neurons are context-selective, we characterized how the SOM-pyramidal subcircuit can support high gating selectivity. Second, we characterized how SOM neurons can become contextselective in the VIP-SOM-pyramidal circuit.
First, we built a simplified model of a SOM-pyramidal subcircuit (Fig. 4a), which corresponds roughly to a cortical L2/3 column (400 Â 400 mm). (a) Schematic of gating, presenting pathway 1 input when gate 1 is opened (left) or gate 2 is opened (right). There are N dend available dendrites in total. Each input pathway targets N disinh dendrites. To gate a pathway on, these exact N disinh dendrites are disinhibited, creating an aligned pattern of disinhibition. Each pathway selects dendrites randomly and independently from other pathways, which can result in overlap of the excitationdisinhibition patterns across pathways. When N disinh is large, projections from different pathways are more likely to overlap. The neuron's firing rate is r on and r off in response to the preferred stimulus of the gated-on (left) and gated-off (right) pathway, respectively. The gating selectivity is defined as (r on À r off )/(r on þ r off ), which is 1 for perfect gating and 0 for no gating. (b) Gating selectivity increases as excitation/disinhibition patterns become sparser, that is, with a smaller proportion of targeted and disinhibited dendrites for a pathway (N disinh /N dend ). Diamonds mark the case of nonoverlapping excitatory projections, corresponding to the limit of maximal sparseness. (c) Gating selectivity is higher with stronger disinhibition, for all sparseness levels. ARTICLE NATURE COMMUNICATIONS | DOI: 10.1038/ncomms12815 Table 1). Here we analyse the dependence of gating selectivity on the connectivity from SOM to pyramidal neurons. We consider worst-case conditions in which these connections are random, subject to the SOM-to-pyramidal connection probability of P SOM-pyr (E0.6). Assuming that a SOM neuron chooses to target each pyramidal dendrite independently with a SOM-to-dendrite connection probability of P SOM-dend , then we have Under this assumption, a SOM neuron on average targets N dend Á P SOM-dend /P SOM-pyr E1.5 dendrites of a pyramidal neuron given that the two are connected. Each SOM-dendrite connection can correspond to multiple (3-5) clustered synapses 32 . So each SOM neuron can make on average 5-8 synapses onto a pyramidal neuron. The connection probability between two neurons is higher at closer proximity 27 , leading to a even higher number of contacts. In a default state, SOM neurons fire at a relatively high baseline rate around 10 Hz (refs 6,15), closing the gates to all inputs. To open the gate for pathway 1, a randomly chosen subset (50%) of SOM neurons is suppressed, resulting in a pattern of disinhibition across dendrites. Again, we assume the excitatory input pattern of pathway 1 is aligned with the corresponding disinhibition pattern. Notably, disinhibition patterns for different pathways generally overlap due to the random selection of SOM neurons and the random connectivity. This overlap can be reduced with either structured connections or inhibitory plasticity.
Under the above assumptions, the circuit achieves a mean gating selectivity B0.5, equivalent to r on E3r off . We found that the impact of these circuit parameters is determined by one critical parameter: the number of SOM neurons targeting each dendrite N SOM-dend ¼ N SOM Á P SOM-dend E5 (Fig. 4b, see also Supplementary Note 1). When we vary parameters while keeping N SOM-dend fixed, the gating selectivity remains largely constant ( Fig. 4c-e). We found that gating selectivity is highest when N SOM-dend is small (Fig. 4f), and decreases as we increase N SOM-dend . Because the overall strength of inhibition has a simple scaling effect on the gating selectivity ( Fig. 3c), we keep it fixed when varying other parameters.
Each dendrite should more appropriately be interpreted as an independent computational unit. When inhibitory connections control individual excitatory connection through pre-synaptic receptors 26 or by targeting spines 4 , the independent unit would be single excitatory synapses. This leads to a lower effective value of N SOM-dend , then a higher gating selectivity.
Pathway-specific gating with SOM and VIP neurons. Having analysed the SOM-pyramidal connectivity, we next examined how SOM neurons can be context-selective, and characterized the gating selectivity in a circuit model containing VIP, SOM and pyramidal neurons. On top of the previous SOM-pyramidal subcircuit, We added N VIP VIP neurons that only target SOM neurons 5 . Here we assume VIP neurons target all SOM neurons with connection probability P VIP-SOM . Broadly speaking, we found two scenarios in which SOM neurons can be suppressed selectively based on the context, depending on the targets of the top-down or locally generated control inputs (Fig. 5).
In the first scenario, control inputs target VIP neurons solely (Fig. 5a). In this intuitive scenario, control inputs excite VIP neurons, which in turn inhibit SOM neurons thereby disinhibiting pyramidal dendrites. Gating selectivity is high only if a small proportion of VIP neurons is targeted by control (Fig. 5b), indicating that VIP neurons must be context-selective, and VIPto-SOM connections need to be sparse (Fig. 5c). VIP-to-SOM connectivity could possibly be effectively sparse on the scale of a cortical column, since the axonal arbour of VIP neurons are rather spatially restricted 33 . When varying parameters, we kept The model is subject to experimentally measured constraints of the following parameters: number of SOM neurons (N SOM ), connection probability from SOM to pyramidal neurons (P SOM-pyr ), and the number of dendrites on each pyramidal neuron (N dend ). We consider the 'worst-case' scenario that the SOM-to-dendrite connections are random. Finally, we assume for now that control input for each pathway suppresses a random subset of SOM neurons. The different contrasts used are for illustration purpose only. (b) A critical parameter for the SOM-topyramidal circuit is the number of SOM neurons targeting each dendrite (N SOM-dend ). This parameter can be calculated using other experimentally measured parameters under the assumption of random connectivity, Gating selectivity only weakly depends on N dend (c), N SOM (d) and P SOM-pyr (e) if N SOM-dend is kept constant by co-varying another parameter. The plotted curve marks the mean and the shaded region marks the bottom 10% to top 10% of the neuronal population. (f) Gating selectivity is high when each dendrite is targeted by a few SOM neurons. Given experimental measurements of P SOM-pyr E0.6, N dend E30 and N SOM E160, we obtained N SOM-dend E5, leading to relatively high gating selectivity B0.5. Total strength of inhibition onto each pyramidal dendrite is always kept constant when varying parameters.
fixed the overall baseline inhibition received by each SOM neuron and the overall strength of control inputs.
In the second scenario, excitatory control inputs target both VIP and SOM neurons (Fig. 5d). If the VIP-to-SOM connectivity is dense, then VIP neurons activated by control inputs will provide nearly uniform inhibition across all SOM neurons ( Supplementary Fig. 5). However, SOM neurons can receive selective excitation if the control inputs only directly target a randomly chosen subset of SOM neurons. If the inhibition is on average stronger, then the overall effect is a selective suppression of SOM neurons ( Supplementary Fig. 5). As a result, gating selectivity no longer depends on the proportion of VIP neurons targeted by control inputs, but does depend on the proportion of SOM neurons targeted (Fig. 5e). Therefore, SOM neurons need to be context-selective, but VIP neurons need not be. Similarly, gating selectivity does not depend on the connection probability from VIP to SOM neurons, P VIP-SOM (Fig. 5f).
In summary, to achieve branch-specific disinhibition, control inputs targeting interneurons have to be selective. Notably, the level of specificity required for the control inputs depends strongly on the neurons they target. When targeting only VIP neurons, the control inputs have to be highly selective (Fig. 5a,b). However, when control inputs target both VIP and SOM neurons, high gating selectivity can be achieved in a much broader range of parameters, reducing the level of specificity required (Fig. 5d,e).
Pathway-specific gating with SOM, VIP and PV neurons. PV neurons receive inhibition from themselves and SOM neurons, and project to perisomatic areas of pyramidal neurons 1 . Suppression of SOM neurons therefore also leads to the disinhibition of PV neurons and an increase of somatic inhibition onto pyramidal neurons. We included PV neurons into our interneuronal circuit model (Fig. 6a) and found that this inclusion and the consequent increase in somatic inhibition strictly improve gating selectivity in a wide range of parameters (Fig. 6b). Since the SOM-to-PV and PV-to-pyramidal neuron connections are dense 29 , a selective pattern of SOM suppression will result in an elevated somatic inhibition that is almost uniform across pyramidal neurons ( Supplementary Fig. 6). Furthermore,  Fig. 5d. Gating selectivity increases as a function of the SOM-to-PV connection weights (w SOM-PV ) in a wide range (see Supplementary Note 1 for a proof). However, when gating selectivity is low without PV neurons (light curve), the peak of this increase is lower and the slope is sharper. Gating selectivity starts to decrease when the SOM-to-PV connection, therefore the somatic inhibition, is too strong that the responses of many pyramidal neurons are completely suppressed.
we proved that a uniform increase in somatic inhibition will always improve gating selectivity, except when the somatic inhibition is unreasonably strong (Supplementary Note 2).
For an intuitive explanation, consider a linear input-output function in the soma. Gating selectivity is based on the relative difference between the pyramidal neuron responses when the gate is open (r on ) and when the gate is closed (r off ). Providing an equal amount of somatic inhibition in these two conditions is equivalent to subtracting both values by the same constant, which will enhance the relative difference.
Learning pathway-specific gating. A critical feature of our scheme is the alignment between excitation and disinhibition patterns (Fig. 1c): pyramidal dendrites targeted by an excitatory input pathway are also disinhibited when the gate is open for that pathway. Dendritic disinhibition can regulate synaptic plasticity 34,35 . We hypothesized that such an alignment can naturally arise as a result of the regulated plasticity. To test this hypothesis, we first established a realistic calcium-based plasticity model for dendrites in our reduced spiking neuron model. Pre-and postsynaptic spikes induce calcium transients in dendrites, which determine the synaptic weight changes 36 (Fig. 7a). We fitted parameters of the model to capture experimental data 37 ( Supplementary Fig. 7). Our model also quantitatively predicts findings that were not used in the fitting.
The calcium-based plasticity model allows us to naturally study the effects of dendritic disinhibition on synaptic plasticity and their functional implications. Again, we assume that pre-and post-synaptic firings are Poisson spike trains with specified rates. We found that dendritic inhibition can shift the plasticity from potentiation to depression, even when the pre-synaptic excitatory input rate and the post-synaptic firing rate are both kept constant (Fig. 7b), consistent with the previous modelling findings 35 . We note that plasticity models based solely on pre-and post-synaptic neuronal firing would not predict the inhibitory modulation of synaptic plasticity.
We then tested whether disinhibitory regulation of plasticity can support the development of excitation-disinhibition alignment, as needed for pathway-specific gating (Fig. 7c). Importantly, the strength of disinhibition is realistic, similar to those used throughout this paper. Initially, excitatory synapses from each pathway are uniformly distributed across the dendritic branches of single neurons. Different excitatory pathways are then activated one at a time. Whenever a pathway is presented, a particular subset of dendrites is disinhibited, while the rest of the dendrites remain inhibited. Through calcium-based excitatory plasticity, the activated excitatory synapses targeting the disinhibited dendrites become strengthened, whereas those targeting the inhibited dendrites become weakened. Synapses not activated remain the same regardless of the inhibition level (Fig. 7b). After learning, the alignment of excitation and disinhibition patterns support pathway-specific gating ( Pre-and post-synaptic spikes both induce calcium influx. The overall synaptic weight change is determined by the amount of time the calcium level spends above thresholds for depression (y d ) and potentiation (y p ) 36 . The model is fitted to the experimental data, and is able to quantitatively predict results not used in the fitting. (b) Dendritic inhibition makes potentiation harder to induce. With background-level inhibition (light blue), synaptic weight change shows three regimes as a function of excitatory input rate: no change for low rate, depression for medium rate and potentiation for high rate. With a medium level of inhibition (dark blue), potentiation requires a higher excitatory input rate. With relatively strong inhibition (black), potentiation becomes impossible within a reasonable range of excitatory input rates. The post-synaptic rate is fixed at 10 Hz. with a gating selectivity B0.7. These findings show that a key aspect of the gating architecture, namely, the alignment of excitation and disinhibition patterns, can emerge naturally from the interaction between excitatory synaptic plasticity and contextdependent disinhibition.
Modelling a flexible behaviour with pathway-specific gating.
How is gating at the neural level related to gating at the behavioural level? Is moderate gating selectivity (for example, B0.5 as above) sufficient to explain performances in flexible cognitive tasks? To address these issues, we applied our model to a contextdependent decision-making task 28 . In this task, the behavioural response should be based on either the motion direction or the colour of a random-dots motion stimulus, depending on the context cued by a rule signal (Fig. 8a).
We built a stylized neural circuit model to implement this task using pathway-specific gating through dendritic disinhibition (Fig. 8b). The local circuit comprises a sensory network and a decision network. The sensory network contains pyramidal neurons that receive convergent sensory inputs from both motion and colour pathways, and they group into four pools according to their selectivities to colour and motion evidence. The dendrites of pyramidal neurons are controlled by the VIP-SOM interneuronal circuit described above (Figs 8c,5d). A subset of pyramidal neurons with high gating selectivity projects to the decision network. Pyramidal neurons representing colour and motion evidence for the same target project to the corresponding decision neural pool. The decision network, as modelled previously 38 , is a strongly recurrent network that generates a winner-take-all decision based on its inputs.
We fitted the performance of the model to a monkey's psychometric behavioural data from ref. 28, using three free parameters in the model, namely, the proportion of sensory neurons that project to the decision network, and the overall connection strengths from the input pathways to the sensory network and from the sensory network to the decision network. By fitting these three parameters, we obtained a quantitative match of the empirical psychometric performance, as a function of relevant (Fig. 8d) and irrelevant (Fig. 8e) features. Our model shows that the impact of the irrelevant information should be stronger when the relevant information is more ambiguous (with lower motion coherence, for instance; Fig. 8f). Although at its default parameters the interneuronal circuit model can show similar task performance as the empirical data, we found that it can no longer fit the empirical performance if we significantly degrade the neural gating selectivity (Supplementary Fig. 8). This simulation therefore serves as a proof of principle to demonstrate the potential of dendritic disinhibition as a mechanism for pathway gating, and as a link to assess the utility of neural gating selectivity in terms of flexible behavioural performance.

Discussion
A canonical cortical microcircuit motif specialized for disinhibition of pyramidal neuron dendrites was proposed theoretically 9 and has received strong empirical support from a series of recent experiments [5][6][7][8]14,15,39 . Here we explored the functional roles of dendritic disinhibition using computational modelling, at both the single-neuron and circuit levels. In contrast to somatic disinhibition, dendritic disinhibition can gate the inputs to a neuron 9,11,31 . We propose that dendritic disinhibition can be utilized to gate inputs from separate pathways, by specifically disinhibiting dendrites that receive inputs from a target pathway. We studied the effectiveness of gating in an interneuronal circuit model. Most data used to constrain the model have become available only in recent years thanks to the advance of optogenetics and other experimental tools. Where data are not available, we considered the 'worst-case scenario', namely, connections from VIP to SOM neurons, and from SOM to pyramidal dendrites are completely random, which is most likely not the case 40 and any specificity would facilitate our proposed mechanism. Although the SOM-to-pyramidal connections are dense, we found that the connectivity from SOM neurons to pyramidal dendrites is actually sparse enough to support branchspecific disinhibition. We found that the increase of somatic inhibition mediated by the SOM-PV-pyramidal neuron connections further improves gating selectivity. We demonstrated that branch-specific clustering of excitatory pathways can naturally emerge from disinhibitory regulation of synaptic plasticity. As proof of principle, we applied this mechanism to a model for a recent experiment using a context-dependent decision-making task 28 .
Inhibitory connections in the cortex tend to be dense 27 . This finding has led to the proposal that cortical inhibition functions as a locally non-selective 'blanket of inhibition' 29 . Our study offers an alternative perspective, which is compatible with dense interneuronal connectivity, but has different implications for circuit functions. The dense connectivity is measured on a cell-tocell level. Nonetheless, connections from dendrite-targeting SOM interneurons can be sparse at the level of the dendritic branch, and therefore potentially selective as required for our gating scheme. Our alternative proposal is fundamentally grounded in consideration of dendritic branches as functional units of computation 20 .
Our hypothesis has three essential requirements. First, dendritic inhibition must be able to effectively regulate dendritic processing of excitatory inputs. This has been shown in our simulation of a fully reconstructed and a simplified neuron model (Supplementary Fig. 1; Fig. 2), as well as in previous models 31 .
The second requirement states that dendritic disinhibition should be specific at the level of dendritic branches. In a simplified interneuronal circuit model, we showed that the SOM-to-pyramidal neuron circuit can very well support branchspecific disinhibition, mainly because the connectivity from SOM neurons to pyramidal dendrites is effectively sparse. Several circuit components are identified as critical to this requirement and subjects to experimental tests, including the number of SOM neurons targeting each dendrite, and the proportion of SOM neurons targeted by top-down control inputs.
The third and final requirement is an alignment between excitation and disinhibition, which we found can be achieved through synaptic plasticity on excitatory synapses. This feature could also potentially be achieved through inhibitory plasticity 41 , by adapting the disinhibition pattern to align with fixed excitatory inputs. These two forms of plasticity are complementary, and both are likely at play. Indeed, a recent study found that during motor learning, spine reorganization on dendrites of pyramidal neurons is accompanied by change in the number of SOM-neuron synapses onto these dendrites 40 . One appeal of studying excitatory plasticity here is that our calcium-based plasticity model could be quantitatively constrained by data, and therefore tested in a biologically plausible regime. At present, much less is known experimentally about the dependence of inhibitory plasticity on pre-and post-synaptic spike timing, dendritic calcium levels or the class of interneuron 42 .
Although all necessary, the three requirements only need to be fulfilled to a certain degree. For example, dendritic inhibition needs to effectively regulate, but need not abolish, the effects of excitatory inputs. It would be of interest to investigate which requirements pathway-specific gating is most sensitive to, in future research.
A direct consequence of the branch-specific disinhibition and excitation-disinhibition alignment is branch-specific excitation, namely, clustering of excitatory pathways onto pyramidal neuron dendritic branches. The computational benefits of input clustering have been previously proposed 43 . There is mounting experimental evidence for input clustering, from anatomical and physiological studies 23,24 (for a review see ref. 25). Consistent with our model, experimental studies have shown that input clustering can emerge through NMDAR-dependent synaptic plasticity 44 , and that clustering is functionally related to learning 24,45 . Our model prediction that branch-specific clustering can occur at the level of pathways remains to be directly tested.
We focused on whether the disinhibitory circuit motif can support pathway-specific gating. Our model contains only the minimal elements to answer this question. We did not include all known connections between the four major classes of neurons. In particular, among the missing connections are the pyramidal-tointerneuron and the SOM-to-VIP connections. These connections are unlikely to influence our results, since none affect our essential requirements. It remains to be tested whether the pyramidal-to-pyramidal recurrent excitation will interfere with the plasticity-based induction of excitation-disinhibition alignment. We did not model synaptic dynamics or short-term plasticity, because we focused on the steady-state behaviour.
Our model makes specific, experimentally testable predictions. One of the most straightforward and testable predictions is that SOM neurons should show context/rule selectivity in some context-dependent or rule-based tasks. Surprisingly, we found that VIP neurons need not be context-selective, as long as SOM neurons are directly receiving context-selective excitatory control inputs (Fig. 5d-f). Experimental disruption of these contextselective interneurons should impair the animal's ability to perform context-or rule-dependent choice tasks. The contextselectivity of SOM or VIP neurons is not necessarily present in every behavioural task. For instance, a recent study, recording in mouse prefrontal cortex during a auditory discrimination task, found highly homogeneous responses within SOM and VIP populations 12 . We propose that SOM neurons are more likely to exhibit selectivity to context or task in experiments in which the animal performs multiple tasks and branch-specific dendritic spikes also exhibit task selectivity 17,46 . A direct test of our model awaits future experiments in a task-switching paradigm to examine gating of different pathways into association cortical areas and the selective changes of activity in SOM neural subpopulations. We emphasize that interneuron classes in our model should be more appropriately interpreted according to their projection targets rather than their biochemical markers.
Branch-specific dendritic spikes are already observed experimentally, and SOM neurons are critical for this branchspecificity 46 . It is however unknown whether SOM-mediated inhibition is also branch-specific. Direct patch-clamping of pyramidal neuron dendrites in vivo 47 can isolate inhibitory currents on individual branches, and provide a direct test for our hypothesis, although such an experiment is technically difficult at present. Our plasticity model predicts that SOM interneurons play a critical role in the learning-related emergence of branchspecific clustering of excitatory synapses on pyramidal neuron dendrites 24 .
Flexible gating, or routing, of information has been a longstanding problem in computational neuroscience 48 , for which a number of models have been proposed. Among proposed ideas are dynamic synaptic weight modulation 49 , gain modulation 48 , synchrony in the input signals 18 , perfect balance of excitation and inhibition 19 , up/down state-switch in dendrites 50 , switching between different neural pools that receive inputs from distinct pathways 51 and rule signalling as a selection vector 28 . Notably, most of these models implement a form of soft gating, which modulates the effective strength of incoming pathways instead of performing a binary on-off switch on them.
These prior models did not exploit the computational power of dendrites (except for ref. 50) or the roles of specialized classes of interneurons. Harnessing dendrites rather than populations of intermediate neurons saves the number of neurons needed by manyfold. Only in the limit of one dendrite per pyramidal neuron does our mechanism become conceptually similar to gating mechanisms operating on the neuronal level 51 .
The gating mechanism as studied here is nonlinear but not binary. Typically, the gating selectivity is 0.5 or lower (Figs 4 and  5), whereas it would be one if gating was perfect. In the biologically plausible regime of inhibitory strength studied here, shunting inhibition on a dendritic branch still allows synaptic input to appreciably elevate the dendritic voltage and thus impact the soma, which decreases the gating selectivity of the neuron. Gating selectivity is also limited by the number of dendritic branches (or more generally, quasi-independent computational units) on a pyramidal neuron, which is about two dozen. Thus, the proposed mechanism may be especially suitable for 'pathwayspecific gating'. Multiple mechanisms may jointly contribute to gating function, and our proposed mechanism is most likely compatible with the aforementioned proposals.
A testable prediction of our model is that a behavioural context or rule guiding routing of information engages top-down signalling that targets specific classes of VIP and SOM inhibitory neurons. This is in contrast to the conventional thinking of executive control as mediated by top-down control signals to pyramidal cells. The present model suggests that a context signal can correspond to a top-down input from a brain area presenting task context onto VIP and SOM cells (leading to effective excitation or inhibition, respectively, of pyramidal neurons).
To conclude, our findings suggest a microcircuit architecture that harnesses dendritic computation and diverse inhibitory neuron types to subserve cognitive flexibility.

Methods
All models. A summary of all types of models used and where they are used can be found in Supplementary Table 2.
Spiking pyramidal neuron models. For the fully reconstructed multi-compartmental pyramidal neuron model ( Supplementary Fig. 1a-d), we adapted a previously developed model based on a layer 2/3 pyramidal neuron in the rat somatosensory cortex reported by Branco et al. 52 . We used the passive membrane parameter set; results are essentially the same with the active membrane parameter set. Simulations were implemented with the NEURON simulator 53 .
The reduced multi-compartmental spiking neuron model is comprised of multiple dendritic compartments and one somatic compartment. All dendritic compartments are equivalent, not directly coupled to each other, and coupled to the soma. There are 10 dendritic compartments for all simulations using this model (Figs 2 and 7). The number of dendrites does not change the results as long as we normalize the dendrite-soma coupling strength with respect to the number of dendrites. The soma is modelled as a leaky-integrate-and-fire compartment with dynamics following: where the subscripts S and D correspond to soma and dendrites, respectively. V i,D is the membrane potential of the ith dendrite. C S is the membrane capacitance, E L is the resting potential, g L is the leak conductance and g c is the coupling between each dendritic compartment and the somatic compartment. We set C S ¼ 50.0 pF and g L,S ¼ 2.5 nS, producing a 20-ms membrane time constant for the soma. We also set E L ¼ À 70 mV and g c ¼ 40 nS. The somatic spiking mechanism is integrateand-fire, with spike threshold À 50 mV, reset potential À 55 mV and refractory period 2 ms. The dynamics of the dendritic membrane potential (V D ) follows whereV S is the somatic shadow potential 54 , which follows the same equation as V S , except with no spiking and resetting. We set C D ¼ 20.0 pF and g L,D ¼ 4.0 nS, producing a 5-ms membrane time constant 55 . After a somatic spike, the backpropagating action potential is modelled as a 3-ms delayed voltage increase of 10 mV in all dendrites 56 .
The main free parameters of the reduced compartmental model, g c and g L,D , were chosen to match in vitro properties reported by Nevian et al 55 . Specifically, a single-synapse dendritic EPSP of 1-mV peak is attenuated to B0.05 mV in the soma, and a dendritic NMDA plateau potential evokes a somatic depolarization with the peak B10 mV. We also made several efforts to adapt our model to mimic physiological in vivo conditions, including excitation-inhibition balanced background inputs and reduced soma-dendrite coupling. We used an in vivo set of parameters whenever appropriate (Fig. 2d-g; Fig. 7c,d). The soma-dendrite coupling is reduced fivefold to g c,vivo ¼ 0.8 nS, to achieve the stronger signal attenuation observed in high-conductance state 57 . In this regime, the soma also receives excitatory and inhibitory background inputs, 500 Hz of 2.5-nS AMPAR input and 150 Hz of 4.0-nS GABAR input, to approximate the excitationinhibition balanced background input that gives the neuron a baseline Poisson-like firing rate B3 Hz. Reduced spiking neuron simulations were implemented with the BRIAN neural simulator 58 .
We used four types of synapses, AMPAR, NMDAR, GABA A R and GABA B R. Since GABA B Rs are only used briefly in (Supplementary Fig. 3), we denote GABA A simply as GABA. AMPAR and GABAR synapses are modelled as linear: where s syn is the gating variable representing the proportion of open channels,g syn is the maximum synaptic conductance, E syn is the synaptic reversal potential, t syn is the synaptic time constant and t i are pre-synaptic spike times. We set For dendrite-targeting inhibitory synapses, t GABA,dend ¼ 20 ms, whereas t GABA,soma ¼ 10 ms for soma-targeting inhibitory synapses. These are based on the observations that dendrite-targeting inhibition tend to be slower 59,60 . In Supplementary Fig. 1d,h,g AMPA ¼ 2:5 nS. In Supplementary Fig. 3,g AMPA ranges from 0 to 2.5 nS. Otherwiseg AMPA is set as 0 nS (no AMPAR input). GABA B R synapses are post-synaptic. Each spike at time t i increases the gating variable s GABAB ðtÞ by g GABAB ½exp½ðt À t i Þ=t GABAB;decay À exp½ðt À t i Þ=t GABAB;rise , where g GABAB is a normalizing factor such that the peak of the above expression is 1. Then, the total input current voltage dependent is where f GABAB ðVÞ ¼ 33:33mV Á ð0:5 À 2=ð1 þ expððV þ 98:73Þ=12:5ÞÞÞ, as obtained from ref. 61. NMDAR synapses include a voltage-dependent magnesium block f Mg (V) and saturating gating variable s NMDA : with t NMDA,decay ¼ 100 ms, t NMDA,rise ¼ 2 ms and a NMDA ¼ 0.3 ms À 1 . This choice of a NMDA sets s NMDA to be B0.4 at its peak after a single spike 63,64 . With this value of a NMDA , the saturation of NMDA starts to get prominent around firing rate r ¼ 1/(a NMDA t NMDA,rise t NMDA,decay )E16 Hz. By default in simulations with the reduced spiking model, the excitatory inputs are 15 independent NMDAR synapses with the same rate. Fewer number of excitatory synapses can become insufficient to elicit NMDA plateau potential. Since GABAR and AMPAR synapses are linear, their inputs are directly represented by the overall rates. Each excitatory synapse also has a calcium concentration level with arbitrary unit, which consists of two components, one NMDAR dependent and one voltagegated calcium channel (VGCC) dependent: The NMDAR-dependent component is modelled as leaky integration of the NMDAR current: where k NMDA is a scaling parameter with unit per pA. The VGCC component is evoked by post-synaptic spikes that back-propagate into dendrites. Each spike induces a bi-exponential increase: Here g Ca is a normalizing constant so that the peak response to one spike is k VGCC . And k VGCC is again a scaling parameter. NMDA plateau potential. The voltage of a dendrite receiving NMDAR and GABAR inputs follows where j and k are indices of NMDAR and GABAR synapses, respectively. Denote as the total NMDA input conductance onto this dendrite. The maximum value of g NMDA (t) is simply g NMDA;max ¼ P jg NMDA ¼ N NMDAgNMDA , where N NMDA is the number of NMDAR synapses. Similarly, If we ignore the coupling between this dendrite and its soma for now, and consider constant synaptic conductances g NMDA ¼ g NMDA (t), g GABA ¼ g GABA (t). Then, we have Since we have E I ¼ E L , the steady-state dendritic voltage V D,ss satisfies This equation can be solved numerically, resulting in the curve in Supplementary Fig. 2d.
Pathway-specific gating in a single pyramidal neuron. Gating is performed by disinhibiting a specific subset of dendrites. Disinhibited dendrites always receive 5 Hz background inhibition. The disinhibition level is defined as the difference between the rates of inhibition received by inhibited and disinhibited dendrites.
In Fig. 2d-g, each pathway targets two dendrites with 15 NMDAR synapses on each dendrite. The dendrites targeted by each pathway do not overlap. For each pathway, the input rate (u E ) follows a bell-shaped tuning to the stimulus value (z): u E ¼ 40 exp( À z 2 ) Hz, where z ranges between À 2.4 and 2.4. The disinhibition level is 30 Hz (from 35 to 5 Hz).
Presented alone, the preferred stimulus (z ¼ 0) from one pathway increases the output firing rate by r on (r off ) when the pathway is gated-on (off). The gating selectivity is defined as r on À r off r on þ r off ; ð19Þ For Fig. 3, excitatory pathways can overlap. In the context with gate 1 open, N disinh dendrites are disinhibited. Excitatory pathway 1 targets these N disinh dendrites, each with strength 25 nS, and similarly for gate 2 and pathway 2. The N disinh dendrites disinhibited for gate 2 are chosen randomly and independently from the N disinh dendrites disinhibited for gate 1. For each N disinh and N dend , r on and r off are averaged across all possible projection patterns.
Rate pyramidal neuron model. The rate model is fitted with simulation data from the spiking model with in vivo parameters (Supplementary Fig. 4). The timeaveraged voltage of a dendritic compartment ðV D Þ is modelled as a sigmoidal function of total excitatory input conductance ( g E , see below for definition) following: The mid-point g 1/2 is proportional to the total inhibitory conductance g I plus the leak conductance of the dendrite g L,D , as expected from the constant conductance scenario (Supplementary Fig. 2c) On the basis of our observation of the reduced spiking model, we modelled the width b as an exponentially increasing function of inhibition: This increase of width b as a function of g I captures the linearization effect of sparse inhibition on the voltage input function (Fig. 2c). Fit values of the parameters are b g ¼ 5.56, k ¼ 9.64 nS, g ¼ 6.54 nS and V 0 ¼ 0.78 mV. The model is fitted to a simulated 10-dendrite spiking neuron model. When simulating dendrites of the spiking model, somatic shadow voltage is clamped at À 60 mV, and back-propagating action potential is fixed as a Poisson spike train of 10 Hz. This phenomenological model allows us to interpolate the dendritic voltage for a large range of excitatory and inhibitory inputs very rapidly.
The firing rate of the soma is modelled as a power law function of input current I: Here I is the sum of the input current from dendrites and also the somatic inhibition from PV neurons whenever applicable. The parameters are fitted from simulation of the reduced spiking model. We assume the somatic voltage fluctuates around E reset , and denote the mean dendritic voltage hV D i. Then, the input current from dendrites is I dend-soma ¼ G c Á (hV D i À E reset ), where G c is the total dendritesoma coupling of all dendrites. G c ¼ 8 nS. Since we assume G c is fixed whenever we vary the number of dendrites (Figs 3 and 4), the somatic function does not depend on the number of dendrites and need not be re-parametrized. So I ¼ I dend-soma þ DI PV-soma , where DI PV-soma is the change in somatic inhibition from PV neurons. For inputs to the rate model, g E and g I are the time-averaged total conductance of all excitatory and inhibitory synapses, respectively. For NMDAR-only excitatory input, the approximated time-averaged gating variable s NMDA of a single synapse receiving input rate r E follows, s NMDA ¼ 1 À ð1 þ r E t NMDA;rise t NMDA;decay a NMDA Þ À 1 : ð24Þ For N NMDA synapses each with maximal conductanceg NMDA , the total excitatory conductance is ð25Þ Therefore, g E saturates as s NMDA does. Because the GABAR conductance is linear in its input rate, the total inhibitory conductance is where r I is the overall inhibitory input rate onto that dendrite.
Interneuron models. SOM neurons are modelled as simple rate neurons with a rectified linear f-I curve. The firing rate of a SOM neuron is where max(x,0) is a rectified linear function of x. I rh,SOM ¼ 40 pA is the rheobase, that is, the minimum current required to activate the neuron, and b SOM ¼ 90 Hz/ nA is the f-I curve slope for SOM neurons, which we matched to data from ref 65. SOM neurons typically display adapting responses to constant input and the synapses of SOM neurons show short-term plasticity. We ignored these aspects of temporal dynamics because here we are interested in the steady-state response. SOM neurons receive 150 pA input current in the default state, leading to a baseline firing of SOM neurons B10 Hz as observed experimentally 6,15 .
For VIP neurons, we assume that the control input targets N control,VIP ¼ round(N VIP Á P control,VIP ) of them. On average, VIP neurons are assumed to fire at r VIP ¼ 5 Hz. Therefore, the VIP neurons non-activated by the control input fire at 0 Hz, while those targeted by the control input fire at (5 Á N VIP /N control,VIP ) Hz.
PV neurons are modelled simply as linear rate neurons with a f-I curve slope of b PV ¼ 220 Hz nA À 1 , because their activities never reach zero in our model. Since we are only interested in their change of activities in response to SOM neuron suppression, the spontaneous activity of PV neurons is irrelevant to our model.
Interneuronal network. The full interneuronal network model contains pyramidal, SOM, VIP and PV neurons. The network model is roughly based on a L2/3 cortical column microcircuit, and contains 3,000 pyramidal neurons, 160 SOM neurons, 140 VIP neurons and 200 PV neurons 66 . However, the analysis applies more generally. Pyramidal neurons are modelled as multi-compartmental rate neurons as described above. We typically used N dend ¼ 30 dendrites, approximately corresponding to pyramidal neurons in associative areas 67 . The number of pyramidal neurons does not affect our results.
The SOM-to-dendrite connections are set randomly. Instead of drawing each connection randomly and independently with a fixed probability, we assume that each dendrite is targeted by precisely N SOM-dend SOM neurons, when N SOM-dend is an integer, so that each dendrite receives the same amount of net inhibition in the default state. The identities of SOM neurons targeting each dendrite are randomly chosen. The total inhibitory conductance received by each dendrite is denoted and fixed as G SOM-dend ¼ 40 nS, then for each SOM-dendrite connection the conductance is G SOM-dend /N SOM-dend . Each SOM-dendrite connection can contain multiple synapses, which we are not explicitly modelling here because GABAergic synapses are linear such that we only need to consider the total conductance. When N SOM-dend is not an integer, we interpolate. Each dendrite is targeted by JN SOM-dend n SOM neurons, where all synapses but one have weights G SOM-dend /N SOM-dend , while one has weight G SOM-dend Á (1 À IN SOM-dend m/ N SOM-dend ). Given the connection probability from SOM to pyramidal neurons P SOM-pyr , the number of SOM neurons N SOM , and the number of dendrites on each pyramidal neuron N dend , we set ð28Þ This is the mean number of SOM neurons targeting each dendrite if the SOM-to-pyramidal connections were completely independent and random.
The VIP-to-SOM connections are set in the same way as the SOM-to-dendrite connections. Since SOM neurons only have one compartment each, we have N VIP-SOM ¼ N VIP Á P VIP-SOM . When control inputs target both VIP and SOM neurons, we have P VIP-SOM ¼ 0.6. When control inputs only target VIP neurons, we have P VIP-SOM ¼ 0.1. Within 100 mm, the connection probability is measured to be B0.6 (Supplementary Table 1). However, note that the connection probability from VIP to SOM neurons on a column scale is unknown. The spatially restricted axonal arbours of VIP neurons 33 suggest that the connection probability may fall quickly as a function of the VIP-SOM distance. Therefore, on the scale of a column, the connection probability could still be as low as 0.1. Total inhibitory connection weight from VIP neurons received by each SOM neuron is 30 pA Hz À 1 , and is distributed onto each synapse the same way SOM-to-dendrite connection weights are set. For N VIP ¼ 140 and P VIP-SOM ¼ 0.6, the connection strength of each synapse is B0.4 pA/Hz. This is close to the unitary VIP-to-SOM inhibitory post-synaptic charge (IPSQ) of 0.7 pA Hz À 1 measured in ref. 5. Notice here the connection is current-based because SOM neurons are described by a f-I curve.
The SOM-to-PV, PV-to-PV and PV-to-pyramidal soma connections are all set similar to the connections above. We set P SOM-PV ¼ 0.8, P PV-PV ¼ 0.9 and P PV-soma ¼ 0.6 (ref. 5). The total inhibitory connection strength from SOM neurons to each PV neuron is varied in Fig. 6b. The total inhibitory connection from PV neurons to each PV neuron is 30 pA Hz À 1 , and from PV neurons to each pyramidal neuron is 30 pA Hz À 1 . Denote the resulting connection weight matrix W SOM-PV , W PV-PV and W PV-soma , then in steady state the change in somatic inhibition DI pyr across pyramidal neurons is where Dr PV is the change in PV activities. And we have where Dr SOM is the change in SOM activities before and after control inputs. 1 is identity matrix. The precise values of these PV-related parameters do not matter. Control inputs are excitatory. Here we are agnostic about their origin. They could be locally generated or from long-range projections. Control inputs can target subsets of SOM and VIP neurons. The mean strength of the control inputs across the whole population is always kept as a constant. When control inputs target SOM neurons, N control,SOM ¼ round(N SOM Á P control,SOM ) of SOM neurons are targeted, with current 75 Á N SOM /N control,SOM pA. Therefore, across the whole population, the averaged current input is 75 pA. When control inputs target VIP neurons, each of the N control,VIP targeted VIP neurons fire at (5 Á N VIP /N control,VIP ) Hz. For Fig. 5a-c when control inputs only target VIP neurons, we set P control,SOM ¼ 0 and P control,VIP ¼ 0.1. P control,VIP has to be low otherwise the gating selectivity would be very close to 0. For Fig. 5d-f, when control inputs target both SOM and VIP neurons, P control,SOM ¼ 0.5 and P control,VIP ¼ 0.5. Setting P control,SOM ¼ 0.5 does not result in the highest gating selectivity. We did not make particular efforts to fine-tune these parameters.
Finally, excitatory inputs carrying stimulus information for one pathway target the corresponding disinhibited dendrites. When we opened the gate for pathway 1, suppose one dendrite receives averaged inhibitory conductance g I . Then, the total excitatory conductance g E from pathway 1 onto this dendrite is g E ¼ ð1 À g I =g I;th Þ Á g E;max ; g I og I;th 0 ; g I ! g I;th & : ð31Þ g I,th is a inhibitory conductance threshold we defined. Therefore, when inhibition is weak (disinhibition is strong), excitation is inversely proportional to inhibition level. However, when disinhibition is weak, there will be no excitatory input at all. Having a cutoff threshold g I,th prevents excitatory inputs from targeting every dendrite and therefore being overly dense. We set g I,th ¼ 4.0 nS. Since we have set the sum of conductances of all inhibitory synapses to be G SOM-dend ¼ 40 nS, each SOM neuron fires B10 Hz before disinhibition, and t GABA,dend ¼ 20 ms, the time-averaged conductance received by each dendrite in default is g I ¼ r I t GABA;dend G SOM!dend ¼ 8:0 nS. Therefore, by setting g I,th ¼ 4.0 nS, excitatory synapses only target dendrites that are at least disinhibited by half. We set the maximum time-averaged excitatory conductance targeting each dendrite to be g E,max ¼ 25 nS. This value is chosen so that excitation is strong enough to excite a disinhibited dendrite, but not strong enough to excite a strongly inhibited dendrite ( Supplementary Fig. 4).
In Supplementary Table 1, we summarized the raw experimental data used to constrain the model.
Synaptic plasticity model and learning protocol. The synaptic plasticity model is calcium-based. The calcium dynamics is described above, and the synaptic weight change given these calcium dynamics is modelled with the formalism from ref. 36, restated below for clarity with slightly modified notations.
Over the time of stimulation, the calcium trace spends time a p above the potentiation threshold y p , and time a d above the depression threshold y d . Then, the average potentiation is G p ¼ g p a p , and the average depression is G d ¼ g d a d , where g p and g d are the potentiation and depression strengths, respectively. Since the synapse is assumed to be bistable (DOWN or UP states), denote r as the probability of the synapse staying in the UP state, which evolves over time in response to the calcium trace crossing thresholds. Then, define r as the long-term time average of r, and s 2 r as the s.d. of r. Then, where s is the amplitude of noise and t is the time constant of weight change. In long term, the probability to switch from DOWN to UP state U and from UP to DOWN states D are given by erf( Á ) is the s.e. function. For convenience, we set the weight of DOWN state to w 0 ¼ 0 and the weight of UP state w 1 ¼ 3. Then, following stimulation, the weight after learning w post ¼ w pre ð1 À DÞ þ ðw 1 À w pre ÞU, given the weight before learning w pre . We fitted the free parameters of the model with experimental data from ref. 37. In simulation of the plasticity experiment, we modelled the pre-synaptic extracellular stimulation by 40 NMDAR synapses simultaneously receiving one spike. This stimulation alone causes a 2.8 mV depolarization on the soma, which is within the range of observed values (1-3 mV) for that experiment. It also brings the dendrite close to the NMDA plateau threshold, allowing for strong interaction between pre-and post-synaptic spikes. As in the experiment, all pairings are repeated 60 times. The somatic shadow voltage is clamped at À 60 mV.
The model is fitted to data points from Figs 2 and 3d in ref. 37, and is used to predict the data from Fig. 3b therein. Notice that two data points in the test data set (their Fig. 3b) are already included in their Figs 2 and 3d. In all of these cases, there is one pre-synaptic spike, and usually a burst of post-synaptic spikes. The time lag in Supplementary Fig. 7a is defined as the timing difference between the first postsynaptic spike in the burst and the pre-synaptic spike. In Supplementary Fig. 7a,b, there are three post-synaptic spikes. In Supplementary Fig. 7b,c, the pre-synaptic spike is either 10 ms earlier than the first post-synaptic spike in the burst or 10 ms later than the last post-synaptic spike. In Supplementary Fig. 7a,c, the post-synaptic burst, when there is one, has frequency of 50 Hz (inter-spike interval of 20 ms). The fit parameters are the following. The scaling parameters for calcium traces, k NMDA ¼ 0.371 and k VGCC ¼ 0.957. The depression and potentiation rates are g d ¼ 39.9 and g p ¼ 177.6. The potentiation threshold for calcium is y p ¼ 2.78. In fitting this particular data set, we found that there is a certain level of redundancy in parameters; the number of parameters needed to be free is less than the total number of potentially free parameters. We therefore fixed two parameters using values in ref 36, which were fitted to another data set: the amplitude of the noise s ¼ 3.35 and the time constant of synaptic weight change t ¼ 346.36 s. The depression threshold is y d ¼ 1. Before the plasticity-inducing experiment, we have w pre ¼ 1 that corresponds tog NMDA ¼ 2:5 nS for each NMDAR synapse. So after learning, the actual synaptic conductances areg NMDA ¼ w post Á 2:5 nS.
Just like the spiking pyramidal neuron model, the plasticity model fitted with in vitro data needs to be recalibrated to behave properly under in vivo-like conditions 68 . We reduced the scaling parameters for calcium traces tô k NMDA ¼ 0:75k NMDA , mimicking a reduced extracellular calcium concentration, and tok VGCC ¼ 0:2k VGCC , resembling attenuated effect of back-propagating action potentials in high-conductance in vivo state. These changes also ensure the weights of non-activated synapses do not change substantially throughout the simulation. In Fig. 7b, the plasticity-inducing protocol is 300-s long. The post-synaptic firing is fixed at 10 Hz.
In Fig. 7c-e, inputs from both pathways initially target every dendrite with 15 synapses of the same weightg NMDA ¼ 2:5 nS. Each gate is opened by disinhibiting two distinct dendritic branches. During learning, all synapses from the gated-on pathway are activated at 50 Hz, whereas the gated-off pathway is not activated. The post-synaptic rate is set at 10 Hz. To measure gating selectivity before learning, 8 of the 15 synapses on each dendrite are activated for both pathways. After learning 5 of 15 synapses were activated, the number is chosen so that before and after learning the total excitatory conductance is the same.
Context-dependent decision-making network. We modelled the contextdependent decision-making task from ref. 28. In the experimental task, the stimulus is a mixture of random dots that are leftward-or rightward-moving, and are red or green. The stimulus can be described by its motion and colour coherence. Motion coherence for rightward motion can take six values ( À 0.5, À 0.15, À 0.05, 0.05, 0.15 and 0.5). Colour coherence for colour red also takes six values ( À 0.5, À 0.18, À 0.06, 0.06, 0.18 and 0.5). On each trial, the colour and motion coherence are independently and randomly chosen, resulting in 36 possible stimuli. In Fig. 8d, the performance with respect to motion coherence is averaged across all colour coherences. Similarly for Fig. 8e, the performance with respect to colour coherence is averaged across all motion coherences. In Fig. 8f, the curve for strong motion coherence is averaged across motion coherence À 0.5 and 0.5. Similarly for medium and weak coherences.
The context-dependent decision-making circuit model contains two components. The first is a mixed-selective sensory network, which uses the VIP-SOM-pyramidal neuron circuit model described above. The mixed-selective sensory neurons receive motion and colour inputs from the sensory stimulus. Here the motion and colour inputs do not signal the actual motion and colour of the stimulus, but rather the motion and colour evidence for a particular target. For convenience, the motion direction corresponding to target 1 is denoted left, and the colour corresponding to target 1 is denoted red, and similar for motion right and colour green. This treatment follows the analyses and modelling of ref. 28. There are four pools of neurons in this network. Each pool prefers a particular combination of motion and colour, for example, left and red. Each neuron pool is modelled exactly as those in Fig. 5d, where the circuit connectivity is random and control inputs target both VIP and SOM neurons, using the base parameter set described above. The input to each dendrites is 15 NMDAR synapses with rate determined by the coherence (coh) of their preferred motion and colour input, as 40 Á (1 þ coh) Hz (refs 38,69). For example, a neuron that prefers left and red inputs would receive 40 Á (1 þ coh left ) Hz input on its dendrites targeted by motion pathway, and 40 Á (1 þ coh red ) Hz on its dendrites targeted by colour pathway. Note that coh left ¼ À coh right . The excitatory input for each pathway is set the same way as it is above, however now the maximum conductance of these input synapses g sen is one free parameter.
The second component of the network is a decision network. This network is a two-pool rate model 38 , using the parameter set therein with no recurrent AMPAR current. The pool representing choice 1 receives input from a subset of the left-red neuron pool in the mixed-sensory network. Sensory neurons are sorted according to their gating selectivity, and only the top P project fraction of these sensory neurons project to the decision networks. P project is also a free parameter. The right-green pool projects to the choice 2 pool. The other two pools do not project to the decision network because only the left-red and the right-green pools have congruent preferences for choice 1 and choice 2, respectively, based on the how colour and motion evidence are defined. To fit experimental behavioural choice data efficiently, we further approximated the decision network with a decision function. We assumed that the probability of selecting choice 1 (P 1 ) is determined by the difference DI dec (pA) between the input currents to the two choice pools. We fitted this function by simulating the decision network with mean input current 15.6 pA to both pools, yielding with s ¼ 0.99 pA. The second free parameter of the model is the projection strength J dec of the mixed-sensory input, such that DI dec ¼ J dec (r left,red À r right,green ). r left,red is the average firing rate of the left/red-preferring pool.
The three free parameters g sen , P project and J dec are fitted to behavioural data of each monkey in ref. 28. The fit parameter values are g sen ¼ 1.21 nS, P project ¼ 0.36 and J dec ¼ 15.0 pA Hz À 1 for monkey F, and are g sen ¼ 1.80 nS, P project ¼ 0.083 and J dec ¼ 4.37 pA Hz À 1 for monkey A. Importantly, the data used to fit the model are far from being sufficient. Also, our circuit model is simplistic. Therefore, these fitted parameter values do not reflect our estimates of these quantities in the brain. Rather, these fittings demonstrate that the proposed circuit architecture can potentially capture behavioural performance. As shown in Supplementary Fig. 8, if neural gating is strongly degraded, then no set of these fit parameters can capture behavioural performance.
Model fitting in general. Model parameters are fitted to experimental or simulation data in various contexts. These fitted models include the rate pyramidal neuron, the calcium-based plasticity model and the context-dependent decisionmaking network. In all these cases, parameters are chosen to minimize the squarederror between the model and data using sequential least squares programming method from the SciPy library (scipy.optimize.minimize, with method 'sequential least squares programming').
Data availability. Code that supports the findings of this study is publicly available on Github: https://github.com/gyyang/DisinhibitoryCircuit2016. All other data can be found within this article and its Supplementary Material.