Duo Xu
Current Organizations / Institutes
The organizations/institutes from the scholar's latest article
Previous Organizations / Institutes
The organizations / institutes from the scholar's other articles in the past ten years
Research Subjects
Duo Xu has a total of 101 co-authors. Here are the top co-authors by number of shared publications:
- Edward F. Chang
Department of Neurological Surgery, University of California, San Francisco, San Francisco, CA, USA
7 shared publications - Daniel H. O'Connor
Johns Hopkins University School of Medicine
6 shared publications - Alexander Budugur Silva
Department of Neurological Surgery, University of California, San Francisco, San Francisco, USA
3 shared publications - Jason E. Chung
Department of Neurological Surgery, University of California, San Francisco, San Francisco, USA
3 shared publications - Kristin K. Sellers
Department of Neurological Surgery, University of California, San Francisco, San Francisco, USA
3 shared publications - Matthew K. Leonard
Department of Neurological Surgery, University of California, San Francisco, San Francisco, CA, USA
3 shared publications
Latest Publications
- 19 November 2026
- Published by American Association for the Advancement of Science (AAAS) in Science
- Vol. 394 (6826)
A neural code for generative speech production in human Wernicke’s area
Wernicke’s area in the posterior temporal lobe is classically defined by its role in speech comprehension, yet a paradox remains: Why does damage here also profoundly impair speech production? Using direct human brain recordings, cortical stimulation, and lesion analysis, we found that this region is not solely for perception. A discrete subzone within Wernicke’s area, the left posterior superior temporal gyrus (lpSTG), becomes active before speech, is causally necessary for speech production, and codes features of whole upcoming words rather than low-level acoustics or articulatory information. Its neural activity is distinct from the auditory-feedback responses nearby and can decode intended speech in people with paralysis. Thus, while Wernicke’s area is a key part of auditory cortex, it contains a dedicated subregion for speech generation.
- 19 November 2026
- Published by American Association for the Advancement of Science (AAAS) in Science
- Vol. 394 (6826)
A neural code for generative speech production in human Wernicke’s area
Wernicke’s area in the posterior temporal lobe is classically defined by its role in speech comprehension, yet a paradox remains: Why does damage here also profoundly impair speech production? Using direct human brain recordings, cortical stimulation, and lesion analysis, we found that this region is not solely for perception. A discrete subzone within Wernicke’s area, the left posterior superior temporal gyrus (lpSTG), becomes active before speech, is causally necessary for speech production, and codes features of whole upcoming words rather than low-level acoustics or articulatory information. Its neural activity is distinct from the auditory-feedback responses nearby and can decode intended speech in people with paralysis. Thus, while Wernicke’s area is a key part of auditory cortex, it contains a dedicated subregion for speech generation.
- Open Access
- 30 April 2026
- Published by Springer Nature in Nature Neuroscience
- Vol. 29 (6) , 1462-1475
Laminar organization of cellular microcircuits modulating human interictal epileptiform discharges
Interictal epileptiform discharges (IEDs) are pathological bursts of brain activity between seizures in people with epilepsy. Despite their importance in diagnosis, cognitive comorbidities and therapeutic implications as biomarkers for neurostimulation, it is unknown how IEDs arise from structured large-scale neuronal firing across human cortical lamina. We used high-density Neuropixels probes to record from epileptogenic tissue in patients undergoing resective surgery, sampling 1,152 neurons during 1,094 IEDs across nine neocortical sites. We identified microcircuits for IEDs organized by firing pattern, neocortical depth and putative cell type. Regular-spiking cells, concentrated in superficial cortical lamina, initiated and coded the amplitude of the sharp discharge and excitatory–inhibitory imbalances across neocortical lamina preceded IEDs, enabling IED prediction up to 1,000 ms in advance. Most neurons that were modulated during IEDs also encoded cognitive information and adhered to physiological rhythms at baseline. Thus, neocortical IEDs are generated from predictable laminar–cellular interactions, providing the groundwork for new neurostimulation therapies that harness the granularity of single neurons.
- 30 April 2026
- Published by Springer Nature in Nature Neuroscience
- Vol. 29 (6) , 1462-1475
Open AccessLaminar organization of cellular microcircuits modulating human interictal epileptiform discharges
Interictal epileptiform discharges (IEDs) are pathological bursts of brain activity between seizures in people with epilepsy. Despite their importance in diagnosis, cognitive comorbidities and therapeutic implications as biomarkers for neurostimulation, it is unknown how IEDs arise from structured large-scale neuronal firing across human cortical lamina. We used high-density Neuropixels probes to record from epileptogenic tissue in patients undergoing resective surgery, sampling 1,152 neurons during 1,094 IEDs across nine neocortical sites. We identified microcircuits for IEDs organized by firing pattern, neocortical depth and putative cell type. Regular-spiking cells, concentrated in superficial cortical lamina, initiated and coded the amplitude of the sharp discharge and excitatory–inhibitory imbalances across neocortical lamina preceded IEDs, enabling IED prediction up to 1,000 ms in advance. Most neurons that were modulated during IEDs also encoded cognitive information and adhered to physiological rhythms at baseline. Thus, neocortical IEDs are generated from predictable laminar–cellular interactions, providing the groundwork for new neurostimulation therapies that harness the granularity of single neurons.
- Open Access
- 12 June 2025
- Published by MIT Press in Neurobiology of Language
- Vol. 6
Role for Left Dorsomedial Prefrontal Cortex in Self-Generated, but not Externally Cued, Language Production
The left dorsomedial prefrontal cortex (dmPFC) is known to be associated with volition and motor function but is often overlooked in models of the neural bases of language. In this retrospective study, we reveal a robust statistical association between a rare language profile disproportionately affecting self-generated, but not externally cued, language production and damage to left dmPFC in a large (n = 307) neurosurgical database using both voxel-based and multivariate lesion-symptom mapping (VLSM, MLSM). This profile was not attributable to motivational or motor speech deficits. We further demonstrate that the probability of presenting with this profile is nearly 15 times higher following a resection in the dorsomedial prefrontal cortex than a resection elsewhere in the brain. Finally, we present a first person account of recovery from this language syndrome by a professionally trained linguist in the Supplementary Materials. These findings leverage a large dataset to add to the predominantly case-dominated literature demonstrating that damage specific to the dmPFC can cause a unique linguistic disturbance disproportionately affecting spontaneous speech, and provide a rare person-centered narrative of the experience of aphasia that is informative to scientists and clinicians alike. Overall, this work highlights the role of the left dmPFC, rarely included in dominant models of the neural bases of language, in the volitional control of fluent, self-generated speech.
- 12 June 2025
- Published by MIT Press in Neurobiology of Language
- Vol. 6
Open AccessRole for Left Dorsomedial Prefrontal Cortex in Self-Generated, but not Externally Cued, Language Production
The left dorsomedial prefrontal cortex (dmPFC) is known to be associated with volition and motor function but is often overlooked in models of the neural bases of language. In this retrospective study, we reveal a robust statistical association between a rare language profile disproportionately affecting self-generated, but not externally cued, language production and damage to left dmPFC in a large (n = 307) neurosurgical database using both voxel-based and multivariate lesion-symptom mapping (VLSM, MLSM). This profile was not attributable to motivational or motor speech deficits. We further demonstrate that the probability of presenting with this profile is nearly 15 times higher following a resection in the dorsomedial prefrontal cortex than a resection elsewhere in the brain. Finally, we present a first person account of recovery from this language syndrome by a professionally trained linguist in the Supplementary Materials. These findings leverage a large dataset to add to the predominantly case-dominated literature demonstrating that damage specific to the dmPFC can cause a unique linguistic disturbance disproportionately affecting spontaneous speech, and provide a rare person-centered narrative of the experience of aphasia that is informative to scientists and clinicians alike. Overall, this work highlights the role of the left dmPFC, rarely included in dominant models of the neural bases of language, in the volitional control of fluent, self-generated speech.
- Top Cited Papers
- 6 March 2025
- Published by Springer Nature in Nature Methods
- Vol. 22 (4) , 788-800
DREDge: robust motion correction for high-density extracellular recordings across species
High-density microelectrode arrays have opened new possibilities for systems neuroscience, but brain motion relative to the array poses challenges for downstream analyses. We introduce DREDge (Decentralized Registration of Electrophysiology Data), a robust algorithm for the registration of noisy, nonstationary extracellular electrophysiology recordings. In addition to estimating motion from action potential data, DREDge enables automated, high-temporal-resolution motion tracking in local field potential data. In human intraoperative recordings, DREDge’s local field potential-based tracking reliably recovered evoked potentials and single-unit spike sorting. In recordings of deep probe insertions in nonhuman primates, DREDge tracked motion across centimeters of tissue and several brain regions while mapping single-unit electrophysiological features. DREDge reliably improved motion correction in acute mouse recordings, especially in those made with a recent ultrahigh-density probe. Applying DREDge to recordings from chronic implantations in mice yielded stable motion tracking despite changes in neural activity between experimental sessions. These advances enable automated, scalable registration of electrophysiological data across species, probes and drift types, providing a foundation for downstream analyses of these rich datasets.
- 6 March 2025
- Published by Springer Nature in Nature Methods
- Vol. 22 (4) , 788-800
Top Cited PapersDREDge: robust motion correction for high-density extracellular recordings across species
High-density microelectrode arrays have opened new possibilities for systems neuroscience, but brain motion relative to the array poses challenges for downstream analyses. We introduce DREDge (Decentralized Registration of Electrophysiology Data), a robust algorithm for the registration of noisy, nonstationary extracellular electrophysiology recordings. In addition to estimating motion from action potential data, DREDge enables automated, high-temporal-resolution motion tracking in local field potential data. In human intraoperative recordings, DREDge’s local field potential-based tracking reliably recovered evoked potentials and single-unit spike sorting. In recordings of deep probe insertions in nonhuman primates, DREDge tracked motion across centimeters of tissue and several brain regions while mapping single-unit electrophysiological features. DREDge reliably improved motion correction in acute mouse recordings, especially in those made with a recent ultrahigh-density probe. Applying DREDge to recordings from chronic implantations in mice yielded stable motion tracking despite changes in neural activity between experimental sessions. These advances enable automated, scalable registration of electrophysiological data across species, probes and drift types, providing a foundation for downstream analyses of these rich datasets.
- Open Access
Human precentral gyrus neurons link speech sequences from listening to speaking
Summary: Speech perception and production are interconnected processes, but the underlying neural mechanisms remain unclear. We investigated this relationship by recording large-scale single-neuron activity in the human brain during a delayed sentence repetition task. Contrary to the traditional view that the precentral gyrus is solely responsible for motor execution, we found that neurons there encoded activity across all task phases of listening, delay, initiation, and speaking. Notably, we discovered “mirror” neurons that activated transiently after hearing and before producing specific speech sounds, and “bridge” neurons that maintained activity between the same speech elements during listening and speaking. Population analysis revealed distinct latent components for each task phase and persistent dynamics for specific sentences. Overall, this study provides novel insights into the neuronal basis of speech processing, emphasizing the intricate interplay between perception, production, and verbal working memory.
Open AccessHuman precentral gyrus neurons link speech sequences from listening to speaking
Summary: Speech perception and production are interconnected processes, but the underlying neural mechanisms remain unclear. We investigated this relationship by recording large-scale single-neuron activity in the human brain during a delayed sentence repetition task. Contrary to the traditional view that the precentral gyrus is solely responsible for motor execution, we found that neurons there encoded activity across all task phases of listening, delay, initiation, and speaking. Notably, we discovered “mirror” neurons that activated transiently after hearing and before producing specific speech sounds, and “bridge” neurons that maintained activity between the same speech elements during listening and speaking. Population analysis revealed distinct latent components for each task phase and persistent dynamics for specific sentences. Overall, this study provides novel insights into the neuronal basis of speech processing, emphasizing the intricate interplay between perception, production, and verbal working memory.
- Open Access
- 6 June 2024
- Published by eLife Sciences Publications, Ltd in eLife
- Vol. 12
Rule-based modulation of a sensorimotor transformation across cortical areas
Flexible responses to sensory stimuli based on changing rules are critical for adapting to a dynamic environment. However, it remains unclear how the brain encodes and uses rule information to guide behavior. Here, we made single-unit recordings while head-fixed mice performed a cross-modal sensory selection task where they switched between two rules: licking in response to tactile stimuli while rejecting visual stimuli, or vice versa. Along a cortical sensorimotor processing stream including the primary (S1) and secondary (S2) somatosensory areas, and the medial (MM) and anterolateral (ALM) motor areas, single-neuron activity distinguished between the two rules both prior to and in response to the tactile stimulus. We hypothesized that neural populations in these areas would show rule-dependent preparatory states, which would shape the subsequent sensory processing and behavior. This hypothesis was supported for the motor cortical areas (MM and ALM) by findings that (1) the current task rule could be decoded from pre-stimulus population activity; (2) neural subspaces containing the population activity differed between the two rules; and (3) optogenetic disruption of pre-stimulus states impaired task performance. Our findings indicate that flexible action selection in response to sensory input can occur via configuration of preparatory states in the motor cortex.
- 6 June 2024
- Published by eLife Sciences Publications, Ltd in eLife
- Vol. 12
Open AccessRule-based modulation of a sensorimotor transformation across cortical areas
Flexible responses to sensory stimuli based on changing rules are critical for adapting to a dynamic environment. However, it remains unclear how the brain encodes and uses rule information to guide behavior. Here, we made single-unit recordings while head-fixed mice performed a cross-modal sensory selection task where they switched between two rules: licking in response to tactile stimuli while rejecting visual stimuli, or vice versa. Along a cortical sensorimotor processing stream including the primary (S1) and secondary (S2) somatosensory areas, and the medial (MM) and anterolateral (ALM) motor areas, single-neuron activity distinguished between the two rules both prior to and in response to the tactile stimulus. We hypothesized that neural populations in these areas would show rule-dependent preparatory states, which would shape the subsequent sensory processing and behavior. This hypothesis was supported for the motor cortical areas (MM and ALM) by findings that (1) the current task rule could be decoded from pre-stimulus population activity; (2) neural subspaces containing the population activity differed between the two rules; and (3) optogenetic disruption of pre-stimulus states impaired task performance. Our findings indicate that flexible action selection in response to sensory input can occur via configuration of preparatory states in the motor cortex.
- Open Access
- 20 May 2024
- Published by eLife Sciences Publications, Ltd in eLife preprints
- Vol. 12
Rule-based modulation of a sensorimotor transformation across cortical areas
Flexible responses to sensory stimuli based on changing rules are critical for adapting to a dynamic environment. However, it remains unclear how the brain encodes rule information and uses this information to guide behavioral responses to sensory stimuli. Here, we made single-unit recordings while head-fixed mice performed a cross-modal sensory selection task in which they switched between two rules in different blocks of trials: licking in response to tactile stimuli applied to a whisker while rejecting visual stimuli, or licking to visual stimuli while rejecting the tactile stimuli. Along a cortical sensorimotor processing stream including the primary (S1) and secondary (S2) somatosensory areas, and the medial (MM) and anterolateral (ALM) motor areas, the single-trial activity of individual neurons distinguished between the two rules both prior to and in response to the tactile stimulus. Variable rule-dependent responses to identical stimuli could in principle occur via appropriate configuration of pre-stimulus preparatory states of a neural population, which would shape the subsequent response. We hypothesized that neural populations in S1, S2, MM and ALM would show preparatory activity states that were set in a rule-dependent manner to cause processing of sensory information according to the current rule. This hypothesis was supported for the motor cortical areas by findings that (1) the current task rule could be decoded from pre-stimulus population activity in ALM and MM; (2) neural subspaces containing the population activity differed between the two rules; and (3) optogenetic disruption of pre-stimulus states within ALM and MM impaired task performance. Our findings indicate that flexible selection of an appropriate action in response to a sensory input can occur via configuration of preparatory states in the motor cortex.
- 20 May 2024
- Published by eLife Sciences Publications, Ltd in eLife preprints
- Vol. 12
Open AccessRule-based modulation of a sensorimotor transformation across cortical areas
Flexible responses to sensory stimuli based on changing rules are critical for adapting to a dynamic environment. However, it remains unclear how the brain encodes rule information and uses this information to guide behavioral responses to sensory stimuli. Here, we made single-unit recordings while head-fixed mice performed a cross-modal sensory selection task in which they switched between two rules in different blocks of trials: licking in response to tactile stimuli applied to a whisker while rejecting visual stimuli, or licking to visual stimuli while rejecting the tactile stimuli. Along a cortical sensorimotor processing stream including the primary (S1) and secondary (S2) somatosensory areas, and the medial (MM) and anterolateral (ALM) motor areas, the single-trial activity of individual neurons distinguished between the two rules both prior to and in response to the tactile stimulus. Variable rule-dependent responses to identical stimuli could in principle occur via appropriate configuration of pre-stimulus preparatory states of a neural population, which would shape the subsequent response. We hypothesized that neural populations in S1, S2, MM and ALM would show preparatory activity states that were set in a rule-dependent manner to cause processing of sensory information according to the current rule. This hypothesis was supported for the motor cortical areas by findings that (1) the current task rule could be decoded from pre-stimulus population activity in ALM and MM; (2) neural subspaces containing the population activity differed between the two rules; and (3) optogenetic disruption of pre-stimulus states within ALM and MM impaired task performance. Our findings indicate that flexible selection of an appropriate action in response to a sensory input can occur via configuration of preparatory states in the motor cortex.
- Top Cited PapersOpen Access
- 13 December 2023
- Published by Springer Nature in Nature
- Vol. 626 (7999) , 593-602
Large-scale single-neuron speech sound encoding across the depth of human cortex
Understanding the neural basis of speech perception requires that we study the human brain both at the scale of the fundamental computational unit of neurons and in their organization across the depth of cortex. Here we used high-density Neuropixels arrays1–3 to record from 685 neurons across cortical layers at nine sites in a high-level auditory region that is critical for speech, the superior temporal gyrus4,5, while participants listened to spoken sentences. Single neurons encoded a wide range of speech sound cues, including features of consonants and vowels, relative vocal pitch, onsets, amplitude envelope and sequence statistics. Neurons at each cross-laminar recording exhibited dominant tuning to a primary speech feature while also containing a substantial proportion of neurons that encoded other features contributing to heterogeneous selectivity. Spatially, neurons at similar cortical depths tended to encode similar speech features. Activity across all cortical layers was predictive of high-frequency field potentials (electrocorticography), providing a neuronal origin for macroelectrode recordings from the cortical surface. Together, these results establish single-neuron tuning across the cortical laminae as an important dimension of speech encoding in human superior temporal gyrus.
- 13 December 2023
- Published by Springer Nature in Nature
- Vol. 626 (7999) , 593-602
Top Cited PapersOpen AccessLarge-scale single-neuron speech sound encoding across the depth of human cortex
Understanding the neural basis of speech perception requires that we study the human brain both at the scale of the fundamental computational unit of neurons and in their organization across the depth of cortex. Here we used high-density Neuropixels arrays1–3 to record from 685 neurons across cortical layers at nine sites in a high-level auditory region that is critical for speech, the superior temporal gyrus4,5, while participants listened to spoken sentences. Single neurons encoded a wide range of speech sound cues, including features of consonants and vowels, relative vocal pitch, onsets, amplitude envelope and sequence statistics. Neurons at each cross-laminar recording exhibited dominant tuning to a primary speech feature while also containing a substantial proportion of neurons that encoded other features contributing to heterogeneous selectivity. Spatially, neurons at similar cortical depths tended to encode similar speech features. Activity across all cortical layers was predictive of high-frequency field potentials (electrocorticography), providing a neuronal origin for macroelectrode recordings from the cortical surface. Together, these results establish single-neuron tuning across the cortical laminae as an important dimension of speech encoding in human superior temporal gyrus.
- Open Access
DREDge: robust motion correction for high-density extracellular recordings across species
High-density microelectrode arrays (MEAs) have opened new possibilities for systems neuroscience in human and non-human animals, but brain tissue motion relative to the array poses a challenge for downstream analyses, particularly in human recordings. We introduce DREDge (Decentralized Registration of Electrophysiology Data), a robust algorithm which is well suited for the registration of noisy, nonstationary extracellular electrophysiology recordings. In addition to estimating motion from spikes in the action potential (AP) frequency band, DREDge enables automated tracking of motion at high temporal resolution in the local field potential (LFP) frequency band. In human intraoperative recordings, which often feature fast (period <1s) motion, DREDge correction in the LFP band enabled reliable recovery of evoked potentials, and significantly reduced single-unit spike shape variability and spike sorting error. Applying DREDge to recordings made during deep probe insertions in nonhuman primates demonstrated the possibility of tracking probe motion of centimeters across several brain regions while simultaneously mapping single unit electrophysiological features. DREDge reliably delivered improved motion correction in acute mouse recordings, especially in those made with an recent ultra-high density probe. We also implemented a procedure for applying DREDge to recordings made across tens of days in chronic implantations in mice, reliably yielding stable motion tracking despite changes in neural activity across experimental sessions. Together, these advances enable automated, scalable registration of electrophysiological data across multiple species, probe types, and drift cases, providing a stable foundation for downstream scientific analyses of these rich datasets.
Open AccessDREDge: robust motion correction for high-density extracellular recordings across species
High-density microelectrode arrays (MEAs) have opened new possibilities for systems neuroscience in human and non-human animals, but brain tissue motion relative to the array poses a challenge for downstream analyses, particularly in human recordings. We introduce DREDge (Decentralized Registration of Electrophysiology Data), a robust algorithm which is well suited for the registration of noisy, nonstationary extracellular electrophysiology recordings. In addition to estimating motion from spikes in the action potential (AP) frequency band, DREDge enables automated tracking of motion at high temporal resolution in the local field potential (LFP) frequency band. In human intraoperative recordings, which often feature fast (period <1s) motion, DREDge correction in the LFP band enabled reliable recovery of evoked potentials, and significantly reduced single-unit spike shape variability and spike sorting error. Applying DREDge to recordings made during deep probe insertions in nonhuman primates demonstrated the possibility of tracking probe motion of centimeters across several brain regions while simultaneously mapping single unit electrophysiological features. DREDge reliably delivered improved motion correction in acute mouse recordings, especially in those made with an recent ultra-high density probe. We also implemented a procedure for applying DREDge to recordings made across tens of days in chronic implantations in mice, reliably yielding stable motion tracking despite changes in neural activity across experimental sessions. Together, these advances enable automated, scalable registration of electrophysiological data across multiple species, probe types, and drift cases, providing a stable foundation for downstream scientific analyses of these rich datasets.
- Open Access
Rule-based modulation of a sensorimotor transformation across cortical areas
Flexible responses to sensory stimuli based on changing rules are critical for adapting to a dynamic environment. However, it remains unclear how the brain encodes rule information and uses this information to guide behavioral responses to sensory stimuli. Here, we made single-unit recordings while head-fixed mice performed a cross-modal sensory selection task in which they switched between two rules in different blocks of trials: licking in response to tactile stimuli applied to a whisker while rejecting visual stimuli, or licking to visual stimuli while rejecting the tactile stimuli. Along a cortical sensorimotor processing stream including the primary (S1) and secondary (S2) somatosensory areas, and the medial (MM) and anterolateral (ALM) motor areas, the single-trial activity of individual neurons distinguished between the two rules both prior to and in response to the tactile stimulus. Variable rule-dependent responses to identical stimuli could in principle occur via appropriate configuration of pre-stimulus preparatory states of a neural population, which would shape the subsequent response. We hypothesized that neural populations in S1, S2, MM and ALM would show preparatory activity states that were set in a rule-dependent manner to cause processing of sensory information according to the current rule. This hypothesis was supported for the motor cortical areas by findings that (1) the current task rule could be decoded from pre-stimulus population activity in ALM and MM; (2) neural subspaces containing the population activity differed between the two rules; and (3) optogenetic disruption of pre-stimulus states within ALM and MM impaired task performance. Our findings indicate that flexible selection of an appropriate action in response to a sensory input can occur via configuration of preparatory states in the motor cortex. HIGHLIGHTS: Task rules are reflected in preparatory activity in sensory and motor cortices. Neural subspaces for processing tactile signals depend on the current task rule. Motor cortical activity tracks rule switches and is required for flexible rule-guided behavior.
Open AccessRule-based modulation of a sensorimotor transformation across cortical areas
Flexible responses to sensory stimuli based on changing rules are critical for adapting to a dynamic environment. However, it remains unclear how the brain encodes rule information and uses this information to guide behavioral responses to sensory stimuli. Here, we made single-unit recordings while head-fixed mice performed a cross-modal sensory selection task in which they switched between two rules in different blocks of trials: licking in response to tactile stimuli applied to a whisker while rejecting visual stimuli, or licking to visual stimuli while rejecting the tactile stimuli. Along a cortical sensorimotor processing stream including the primary (S1) and secondary (S2) somatosensory areas, and the medial (MM) and anterolateral (ALM) motor areas, the single-trial activity of individual neurons distinguished between the two rules both prior to and in response to the tactile stimulus. Variable rule-dependent responses to identical stimuli could in principle occur via appropriate configuration of pre-stimulus preparatory states of a neural population, which would shape the subsequent response. We hypothesized that neural populations in S1, S2, MM and ALM would show preparatory activity states that were set in a rule-dependent manner to cause processing of sensory information according to the current rule. This hypothesis was supported for the motor cortical areas by findings that (1) the current task rule could be decoded from pre-stimulus population activity in ALM and MM; (2) neural subspaces containing the population activity differed between the two rules; and (3) optogenetic disruption of pre-stimulus states within ALM and MM impaired task performance. Our findings indicate that flexible selection of an appropriate action in response to a sensory input can occur via configuration of preparatory states in the motor cortex. HIGHLIGHTS: Task rules are reflected in preparatory activity in sensory and motor cortices. Neural subspaces for processing tactile signals depend on the current task rule. Motor cortical activity tracks rule switches and is required for flexible rule-guided behavior.