identical sensory stimuli , for example , can lead to very different behavioral responses depending on  context , which includes goals , prior expectations about upcoming events , and relevant past experiences . animals can switch rapidly between behavioral contexts , implying the existence of rapid modulation , or gating , mechanisms within the brain that select relevant sensory information for decision - making and action . a large attention literature suggests that relevant information is selected by top - down modulation of neural activity in early sensory areas , which may take the form of modulation of firing rates , or modulation of response synchrony within or across areas . the top - down signals underlying such  early modulations of sensory activity arise , in part , from prefrontal cortex ( pfc ) , which is known to contribute to representing and maintaining contextual knowledge , ignoring irrelevant information , and suppressing inappropriate actions . these observations have led to the hypothesis that early selection may account for the larger effect of relevant as compared to irrelevant sensory information on contextually - sensitive behavior . here we test this hypothesis with a task requiring context - dependent selection and integration of visual stimuli . we trained two macaque monkeys ( a and f ) to perform two different perceptual discriminations on the same set of visual stimuli ( fig . the monkeys were instructed by a contextual cue to either discriminate the direction of motion or the color of a random - dot display , and to report their choices with a saccade to one of two visual targets ( fig . while monkeys performed this task , we recorded extracellular responses from neurons in and around the frontal eye field ( fef ) ( extended data fig . 1a , f ) , an area of pfc involved in the selection and execution of saccadic eye movements , the control of visuo - spatial attention , and the integration of information toward visuo - motor decisions . surprisingly , we find no evidence that irrelevant sensory inputs are gated , or filtered out , prior to the integration stage in pfc , as would be expected from early selection mechanisms . instead , the relevant input appears to be selected late , by the same pfc circuitry that integrates sensory evidence towards a choice . selection within pfc without prior gating is possible because the representations of the inputs , and of the upcoming choice , are separable at the population level , even though they are deeply entwined at the single neuron level . an appropriately trained recurrent neural network model reproduces key physiological observations and suggests a new mechanism of input selection and integration . the mechanism reflects just two learned features of a dynamical system : an approximate line attractor and a  selection vector , which are only defined at the level of the population . the model mechanism is readily scalable to large numbers of inputs , suggesting a general solution to the problem of context - dependent computation . the monkeys successfully discriminated the relevant sensory evidence in each context , while largely ignoring the irrelevant evidence ( fig . 2a - d , monkey f ) . to vary the difficulty of the discrimination , we changed the strength of the motion and color signals randomly from trial to trial ( fig . the choices of the monkeys depended strongly on the direction of motion of the dots ( fig . 1c ) , while depending only weakly on color in the same trials ( fig . 1d ) . the opposite pattern held in the color context : the now relevant color evidence exerted a large effect on choices ( fig . as is common in pfc , the recorded responses of single neurons appeared to represent several different task - related signals at once , including the monkey s upcoming choice , the context , and the strength of motion and color evidence ( extended data figs . rather than attempting to understand the neural mechanism underlying selective integration by studying the responses of single pfc neurons , we focus on analyzing the responses of the population as a whole . to construct population responses , we pooled data from both single and multi - unit recordings , which yielded equivalent results . the great majority of units were not recorded simultaneously , but rather in separate sessions . units at all recording locations appeared to contribute to the task - related signals analyzed below ( extended data fig . 1 ) and were thus combined . overall , we analyzed 388 single - unit and 1014 multi - unit responses from the two monkeys . to study how the pfc population as a whole dynamically encodes the task variables underlying the monkeys behavior , we represent population responses as trajectories in neural state space . each point in state space corresponds to a unique pattern of neural activations across the population . since activations are dynamic , changing over time , the resulting population responses form trajectories in state space . we focus our analyses on responses in a specific low - dimensional subspace that captures across - trial variance due to the choice of the monkey ( choice 1 or 2 ) , the strength and direction of the motion evidence , the strength and direction of the color evidence , and context ( motion or color ) . first , we used principal component analysis ( pca ) to obtain an unbiased estimate of the most prominent features ( i.e. patterns of activations ) in the population response . to  de - noise the population responses , we restricted subsequent analyses to the subspace spanned by the first 12 principal components . second , we used linear regression to define the four orthogonal , task - related axes of choice , motion , color , and context . the projection of the population response onto these axes yields de - mixed estimates of the corresponding task variables , which are mixed both at the level of single neurons ( extended data fig . 3 ) and at the level of individual principal components ( extended data fig . 4c , g , see also ) . this population analysis yields highly reliable average response trajectories ( fig . 2 and extended data fig . 4q , r ) that capture both the temporal dynamics and the relationships among the task variables represented in pfc . in particular , four properties of the population responses provide fundamental constraints on the mechanisms of selection and integration underlying behavior in our task . first , integration of evidence during dots presentation corresponds to a gradual movement of the population response in state space along the axis of choice ( fig . the trajectories start from a point in state space close to the center of the plots (  dots on , purple point ) , which corresponds to the pattern of population responses at baseline . during the dots presentation the responses then quickly move away from this baseline level , along the axis of choice ( red line ; fig . overall , the population response moves in opposite directions on trials corresponding to the two different saccade directions ( fig . 5b , f ) is largely analogous to the  choice - predictive signals that have been identified in past studies as approximate integration of evidence during direction discrimination tasks . second , the sensory inputs into pfc produce patterns of population responses that are very different from those corresponding to either choice , meaning that these signals are separable at the level of the population . indeed , the population response does not follow straight paths along the choice axis , but instead forms prominent arcs away from it ( figs . the magnitude of each arc along the axes of motion or color reflects the strength of the corresponding sensory evidence ( see scale ) , while its direction ( up or down ) reflects the sign of the evidence ( towards choice 1 or 2 , filled or empty symbols ) . while the integrated evidence continues to be represented along the axis of choice even after dots offset , the signals along the axes of motion and color are transient  the arcs return to points near the choice axis by the time of dots offset . these signals thus differ from integrated evidence both in terms of the corresponding patterns of activation and in their temporal profile . for these reasons , this interpretation is also consistent with the observed population responses on error trials , for which the momentary evidence points towards the chosen target , but is weaker than on correct trials ( extended data fig . third , context appears to have no substantial effect on the direction of the axes of choice , motion , and color , and only weak effects on the strength of the signals represented along these axes . when estimated separately during the motion and color contexts , the two resulting sets of axes span largely overlapping subspaces ( see supplementary information , table 1 ) ; thus a single set of three axes ( the red , black , and blue axes in fig . 2a - f , estimated by combining trials across contexts ) is sufficient to capture the effects of choice , motion and color on the population responses in either context . 2a - c vs. d - f ) reveals that a single , stable activity pattern is responsible for integrating the relevant evidence in both contexts ( the choice axis ) , while similarly stable activity patterns represent the momentary motion and color evidence in both contexts ( motion and color axes ) . surprisingly , motion and color inputs result in comparable deflections along the motion and color axes , respectively , whether they are relevant or not ( compare fig . fourth , while the directions of the axes of choice , motion , and color are largely invariant with context , their location in state space is not . the responses during the motion and color contexts occupy different parts of state space , and the corresponding trajectories are well separated along the axis of context ( extended data fig . 3a , can be compared to the predictions of current models of context - dependent selection and integration ( fig . we first focus on three fundamentally different mechanisms of selection that could each explain why the motion input , for example , influences choices in the motion context ( fig . 3b - d ) , and can thus be validated or rejected by our pfc recordings ( fig . 3b ) is based on two widely accepted hypotheses about the mechanisms underlying selection and integration of evidence . first , it assumes that inputs are selected early , such that a given input drives pfc responses when relevant ( gray arrow in fig . 3b 
 top ) , but is filtered out before reaching pfc when irrelevant ( no gray arrow in fig . second , it assumes that the relevant input directly elicits a pattern of activation in pfc resembling those corresponding to a choice ( the gray arrow in fig . 3b , top , points along the axis of choice ) , as would be expected by current models of integration . both hypotheses are difficult to reconcile with the recorded pfc responses . while the strength of each input is somewhat reduced when it is irrelevant compared to when it is relevant , the magnitude of the observed reduction seems too small to account for the behavioral effects . 2d 
 black ) , elicits a larger deflection along the motion axis ( relative to baseline , magenta dot ) than relevant motion of intermediate coherence ( fig . 2a , dark gray ) . 1d , f ) , strongly suggesting that the magnitude of the momentary evidence alone does not determine whether the corresponding input is integrated . furthermore , the actual momentary motion input is represented along a direction that has little overlap with the choice axis , resulting in curved trajectories ( fig . 3a ) that differ markedly from the straight trajectories predicted by the early selection model ( fig . 3 . in the absence of early selection , a motion input might be selected within pfc by modifying the angle between the choice and motion axes ( i.e. the similarity between patterns of neural activity representing choice and momentary motion evidence ) across contexts . this angle could be modified either by changing the direction of the motion axis between contexts while keeping the choice axis fixed ( fig . the motion input would elicit movement of the population along the axis of choice in the motion context ( top row ) , but not in the color context ( bottom row ) since the motion and choice axes have little or no overlap in the color context . at the single neuron level , variable axes that change direction across contexts would be reflected as complex , nonlinear interactions between context and the other task - variables , which have been proposed in some task - switching models . however , our data ( fig . 3c ) axes . more generally , the pfc data from monkey a rule out any model of integration for which the degree of overlap between the direction of the momentary evidence and the axis of choice determines how much the corresponding input affects behavior . the representation of task variables in pfc of monkey f replicates all but one key feature observed in monkey a. most importantly , population responses along the choice and motion axes ( extended data fig . 2a , d ) ; thus physiological data from both monkeys are consistent in rejecting current models of selection and integration of motion inputs ( fig . the color signal in monkey f , however , is equivocal . on the one hand , the representation of the color input closely resembles that of a choice ( extended data fig . 1g , i ) , as expected from the early selection model described above ( fig . the color input is also weakly represented along the color axis in both contexts ( vertical displacement of trajectories , extended data fig . 7c , f ) . for the color input in monkey f , therefore , we can not with confidence accept or reject the early selection model . finally , as in monkey a , context is represented in monkey f along a separate axis of context ( extended data fig . the population responses in both monkeys are difficult to reconcile with current models of selection and integration ( see also extended data fig . 8) . rather , the selective integration of the motion input in monkeys a and f , and of the color input in monkey a , must rely on a mechanism for which the very same input into pfc leads to movement along a fixed axis of choice in one context but not another . to identify such a mechanism , we trained a network of recurrently connected , nonlinear neurons to solve a task analogous to the one solved by the monkeys ( fig . thus the solution achieved by the network is not hand - built into the network architecture . on each trial , neurons in the network receive two independent sensory inputs that mimic the momentary evidence for motion and color in a single random dot stimulus . the network also receives a contextual input that mimics the contextual signal provided to the monkeys , instructing the network to discriminate either the motion or the color input . the network activity is read out by a single linear readout , corresponding to a weighted sum over the responses of all neurons in the network ( see supplementary information ) . as in pfc we trained the network to make a binary choice on each trial  an output of + 1 at the end of the stimulus presentation if the relevant evidence pointed leftward , or a 1 if it pointed rightward . after training , the model qualitatively reproduces the monkeys behavior , confirming that the model solves the selection problem at the  behavioral level ( extended data fig . 2e - h ) . we first analyzed model population trajectories in the subspace spanned by the axes of choice , motion , and color , and found that they reproduce the four main features of the pfc population responses discussed above ( fig . , integration of evidence corresponds to gradual movement of the population response along the choice axis . second , momentary motion and color evidence  push the population away from the choice axis , resulting in trajectories that are parametrically ordered along the motion and color axes . third , the direction of the axes of choice , motion , and color are largely invariant with context , as are the strength of the motion and color inputs , since these are not gated before entering the network . fourth , the trajectories during motion and color contexts are separated along the axis of context ( extended data fig . signals along the input axes are transient in the physiology , but not in the model , yielding pfc trajectories that curve back to the choice axis before the end of the viewing interval ( compare fig . this difference suggests that the sensory inputs to pfc are attenuated after a decision is reached . additional differences between the model and the physiological dynamics can be readily explained by previously proposed imperfections in the evidence integration process , such as  urgency signals or instability in the integrator ( extended data fig . the global features of the model activity are easily explained by the overall arrangement of fixed points of the dynamics ( fig . fixed points ( red crosses ) correspond to patterns of neuronal activations ( i.e. , locations in state space ) that are stable when the sensory inputs are turned off . first , we find that the model generates a multitude of fixed points , which are approximately arranged to form two lines along the choice axis . the two sets of fixed points are separated along the axis of context ( extended data fig . second , the responses around each fixed point are approximately stable only along a single dimension pointing towards the neighboring fixed points ( red lines ) , while responses along any other dimension rapidly collapse back to the fixed points . therefore , each set of fixed points approximates a line attractor . finally , two stable attractors ( large red crosses ) , corresponding to the two possible choices , delimit each line attractor . the integration of the relevant evidence is thus implemented in the model as movement along an approximate line attractor . the model population response , however , does not move strictly along the line attractor . like the physiological data , model trajectories move parallel to the line attractors ( the choice axis ) at a distance proportional to the average strength of the sensory inputs , reflecting the momentary sensory evidence ( fig . , the responses rapidly relax back to the line attractor . to understand how the relevant input is selected for integration along a line attractor , we analyzed the local dynamics of model responses around the identified fixed points ( fig . , we studied how the model responds to brief pulses of motion or color inputs ( fig . 6a ) , rather than the noisy , temporally extended inputs used above . before a pulse , we initialize the state of the network to one of the identified fixed points ( fig . locally around a fixed point , the responses of the full , nonlinear model can then be approximated by a linear dynamical system ( see supplementary information ) , whose dynamics can be more easily understood . both the motion and color inputs ( i.e. the corresponding pulses ) have substantial projections onto the line attractor ( fig . 6a ) but , crucially , the size of these projections does not predict the extent to which each input will be integrated . for instance , in both contexts the motion pulses have similar projections onto the line attractor ( fig . 6a , left panels ) , and yet they result in large movement along the attractor in the motion context ( top ) but not in the color context ( bottom ) . the selection of the inputs instead relies on context - dependent relaxation of the network dynamics after the end of the pulse , which reverses movement along the line attractor caused by the irrelevant pulse ( fig . 6a , top right and bottom left ) and enhances the effects of the relevant pulse ( fig . these relaxation dynamics , while counterintuitive , nevertheless follow a very simple rule . for a given context , the relaxation always occurs on a path that is orthogonal to a specific direction in state space , which we call the the direction of the selection vector , like the direction of the line attractor , is a property of the recurrent synaptic weights learned by the model during training ( see supplementary information ) . unlike the line attractor , however , the orientation of the selection vector changes with context  it projects strongly onto the relevant input , but is orthogonal to the irrelevant one ( fig . this mechanism explains how the same sensory input can result in movement along the line attractor in one context but not the other ( fig . 6b ) . the line attractor and the selection vector are sufficient to explain the linearized dynamics around each fixed point ( see supplementary information ) , and approximate well the responses of the full model ( magenta curves , fig . the line attractor and the selection vector correspond to the right and left zero - eigenvector of the underlying linear system . within a context , these locally defined eigenvectors point in a remarkably consistent direction across different fixed points the selection vector , in particular , is always parallel to the relevant input and orthogonal to the irrelevant input ( fig . 10q - s ) . as a result , the two line attractors ( fig . 6c ) exhibit relaxation dynamics appropriate for selecting the relevant input along their entire length . we describe a novel mechanism underlying flexible , context - dependent selection of sensory inputs and their integration towards a choice ( see for related concepts ) . this mechanism is sufficient to explain the selection and integration of motion inputs in both monkeys , and of color inputs in monkey a , which are not filtered out by context before they reach pfc . a randomly initialized , recurrent neural network trained to solve a task analogous to the monkeys task reproduces the main features of the data , and analysis of the trained network elucidates the novel selection mechanism . integration along line attractors , and its relation to the selection vector , has been described before . however , our model demonstrates for the first time how a single non - linear model can implement flexible computations by reconfiguring the selection vector and the corresponding recurrent dynamics based on a contextual input . counter - intuitively , in the model the projection of an input onto the line attractor does not determine the extent to which it is integrated , a manifestation of  non - normal dynamics ( see supplementary information ) . our results show that the modulation of sensory responses is not necessary to select among sensory inputs ( see also ) . consistent with this conclusion , two studies employing tasks similar to ours , as well as our own recordings in area mt of monkey a ( data not shown ) , have found no evidence for consistent firing rate modulations in the relevant sensory areas . the dynamical process outlined in this paper is fully sufficient for context - dependent selection in a variety of behavioral paradigms , but it need not be exclusive . , our results suggest that computations in prefrontal cortex emerge from the concerted dynamics of large populations of neurons , and are best studied in the framework of dynamical systems . remarkably , the rich dynamics of pfc responses during selection and integration of inputs can be characterized and understood with just two features of a dynamical system  the line attractor and the selection vector , which are defined only at the level of the neural population . this parsimonious account of cortical dynamics contrasts strikingly with the complexity of single neuron responses typically observed in pfc and other integrative structures , which reveal multiplexed representation of many task - relevant and choice - related signals . in light of our results , these mixtures of signals can be interpreted as separable representations at the level of the neural population . a fundamental function of pfc may be to generate such separable representations , and to flexibly link them through appropriate recurrent dynamics to generate the desired behavioral outputs .
summaryprefrontal cortex is thought to play a fundamental role in flexible , context - dependent behavior , but the exact nature of the computations underlying this role remains largely mysterious . 
 in particular , individual prefrontal neurons often generate remarkably complex responses that defy deep understanding of their contribution to behavior . here 
 we study prefrontal cortex in monkeys trained to flexibly select and integrate noisy sensory inputs towards a choice . 
 we find that the observed complexity and functional roles of single neurons are readily understood in the framework of a dynamical process unfolding at the level of the population . 
 the population dynamics can be reproduced by a trained recurrent neural network , which suggests a previously unknown mechanism for selection and integration of task - relevant inputs . 
 this mechanism implies that selection and integration are two aspects of a single dynamical process unfolding within the same prefrontal circuits , and potentially provides a novel , general framework for understanding context - dependent computations .