Main

The behaviour of each individual in a species is driven by the coordinated activity of neural populations throughout the brain. This activity emerges from the latent dynamics, which are the time-dependent activation of the dominant patterns of neural covariation9,11. These latent dynamics seem to be shaped by circuit and biophysical constraints5,6,7,8. Given the large differences in brain circuitry across individuals from the same species—including in some type-specific neurons, dendritic morphology and receptor distribution15,16,17,18,19—it remains unclear how similar adaptive behaviours emerge from such idiosyncratic neural circuitry. One possibility is that unique circuits in each individual generate unique latent dynamics that produce the same behavioural output. Indeed, the high degrees of freedom of neural activity relative to behaviour20,21 could allow distinct latent dynamics to produce similar behaviour. Alternatively, the same behaviour performed by two individuals could be produced by preserved latent dynamics. This preservation would emerge from the common organization of neural circuits across individuals resulting from a species-specific developmental programme.

Here, we adopt the last hypothesis: different individuals from the same species engaged in the same behaviour generate preserved latent dynamics. We posit that preserved circuit constraints give rise to a species-wide neural landscape and the individual-specific latent dynamics observed during a behaviour are different instantiations of a common trajectory through this landscape (Fig. 1). Our hypothesis provides several testable predictions. First, because low-level details of neural circuits are idiosyncratic, they should not be necessary to account for the emergence of species-typical behaviours. Accordingly, different animals of the same species engaged in the same behaviour should exhibit preserved latent dynamics. Second, the extent of preservation of the latent dynamics across individuals should be constrained by the similarity of the behavioural output. Third, because low-dimensional latent dynamics are found throughout the brain, not just in cortical regions22,23,24, we should also observe preserved latent dynamics in structures that have co-evolved with cortex for hundreds of millions of years such as the basal ganglia14. Fourth, because covert behaviours seem to be mediated by the same neural circuits as overt behaviours25, we should find shared latent dynamics across animals performing the same cognitive task.

Fig. 1: Hypothesis.
figure 1

a,b, Different individuals from the same species performing the same behaviour will generate preserved neural population latent dynamics by instantiating a species-wide ‘neural landscape’ embedded in dimensions (Dim) of neural activity. c, These preserved latent dynamics can be revealed by ‘aligning’ the latent dynamics estimated from neural population recordings of each individual (NA1–3 and NB13 illustrate three neurons recorded from monkey A and monkey B, respectively).

Preserved latent dynamics across animals

We tested the four predictions outlined above using neural population recordings from monkeys and mice as they performed upper limb tasks. First, we analysed motor cortical recordings from monkeys engaged in an instructed-delay centre-out reaching task with eight targets (Fig. 2a,b and Extended Data Fig. 1a; Methods). All three monkeys were well-trained in the task and exhibited highly stereotyped hand trajectories (mean trajectory correlation for each monkey: r = 0.89, 0.90 and 0.92; Extended Data Fig. 1b). For each session, we used principal component analysis (PCA) to estimate the latent dynamics underlying overt movement execution by projecting the firing rates of each recorded neuron (or multi-unit, for monkey J) onto the leading ten PCA axes (the neural modes; examples in Fig. 2c; Extended Data Fig. 1c). We then aligned the latent dynamics of each pair of experimental sessions from two different animals using canonical correlation analysis (CCA26), a method that maximizes the correlations between two sets of signals through linear transformations (similar to refs. 26,27,28).

Fig. 2: Preserved latent dynamics across animals performing the same behaviour.
figure 2

a, Monkeys performed an eight-target instructed-delay centre-out reaching task using a planar manipulandum. b, Example normalized neural firing rates aligned to movement onset (top) and hand trajectories (bottom) for two monkeys. Each column shows one reach to the eight targets indicated by the arrows. Note that monkey C received two sets of motor cortical implants, CL and CR, with CL denoting the implant in the left hemisphere and CR the implant in the right hemisphere. ce, Three-dimensional representation of the motor cortical latent dynamics for the two monkeys plotted in b before (c) and after (e) alignment with CCA (d). f, Correlations of the aligned (red) latent dynamics for the example comparison in ce compared to within-monkey correlations (grey) and a lower-bound control (orange). g, Preserved latent dynamics across all pairs of 21 sessions (n = 126 comparisons) from three different monkeys. Histograms show the mean correlation across the leading four dimensions. Line and shaded area, mean ± s.d. h, Decoders trained on aligned latent dynamics from one monkey predict continuous hand kinematics of a different monkey (blue). Results compared to decoders trained and tested within the same session (grey) and without alignment (green). Data points, individual comparisons (n = 126) between sessions from different monkeys. Error bars, mean ± s.d. Statistical tests: two-sided Wilcoxon’s rank sum test, P = 3.1 × 10−6 for decoding performance between across-animal correlation and within-animal correlation, P = 2.0 × 10−22 between across-animal correlation and lower bound. i, Mice grasped and pulled a joystick in two positions (left or right). j, Preserved latent dynamics across mice performing the grasping and pulling task. Data include six sessions across four different mice (n = 13 comparisons), formatted as in g. k, Preserved latent dynamics across animals is related to the similarity of their behaviour. For each session pair, the mean of the top four canonical correlations (CCs) between the latent dynamics against the mean behavioural correlation. Single dots, pairs of sessions colour-coded by species. Inset: behavioural correlations for all pairs of trials from different mice and monkeys. Circles, mean.

This linear method revealed that the ostensibly different latent dynamics of two different monkeys are indeed highly preserved (Fig. 2e). The across-animal correlations greatly exceeded two lower-bound controls. The first was established by aligning randomly selected behavioural epochs (‘control’ in Fig. 2f) and the second was based on surrogate data that conserved the statistical structure of the neural activity29 (tensor maximum entropy (TME); Extended Data Fig. 2a,b). Most importantly, these correlations were nearly as high as values obtained by aligning two subsets of trials within a single session from the same animal (‘within’ in Fig. 2f; further examples in Extended Data Fig. 3a). This result further held across all pairs of sessions from all three monkeys (n = 126 sessions; Fig. 2g). The aligned neural modes captured a large fraction of neural variance (Extended Data Fig. 2e) and the results did not depend on the assumed dimensionality of the neural manifold (Extended Data Fig. 2f) or the alignment method (Extended Data Fig. 2g,h).

Although we have demonstrated the preservation of latent dynamics across animals, these shared dynamics may not necessarily be relevant to behaviour. To address this, we trained neural network decoders30 (long short-term memory networks (LSTMs)) to predict the hand trajectories of one animal and tested their performance on a second animal. The across-animal decoding accuracy approached the upper bound provided by the performance of decoders trained and tested on the same animal (Fig. 2h; example predictions in Extended Data Fig. 4). Thus, the preserved motor cortical dynamics across animals contain detailed information about the ongoing movement kinematics.

We then analysed data from four mice trained to perform a reaching and pulling joystick task (Fig. 2i and Extended Data Fig. 5). We found that both within and across individuals, the behavioural output was less similar from trial to trial than for the monkey dataset (compare Extended Data Figs. 1a,b to  5a,b). As predicted, our alignment procedure revealed that motor cortical latent dynamics were largely preserved across mice both when reaching to two different targets (Fig. 2j and Extended Data Figs. 3b and  2c; example in Extended Data Fig. 3e) and when subsequently pulling at two different force levels (Extended Data Fig. 6a). Yet, these correlations were lower than those of monkeys (compare Fig. 2g to  2j), which directly impacted our ability to decode movement kinematics across animals (Extended Data Fig. 6b). This difference could be explained by the more highly stereotyped behaviour of the monkeys compared to the mice (Fig. 2k inset). Comparing between species confirmed that behavioural stereotypy was associated with both the preservation of the latent dynamics across individuals (Fig. 2k) and across-animal decoding accuracy (Extended Data Fig. 6f). These results demonstrate in two evolutionarily divergent species that there is a direct correspondence between the similarity of behavioural output and the preservation of motor cortical latent dynamics across individuals.

Necessity of behavioural similarity

In the preceding analyses, we studied tasks comprising a few conditions that inadvertently imposed a topological structure in the produced movements12,26. We sought to establish that preserved latent dynamics do not merely reflect this structure. First, we tested whether this topological structure is sufficient to produce preserved latent dynamics and found that the preservation across individuals was significantly impaired (Extended Data Fig. 7). We then further demonstrated the existence of preserved latent dynamics during a continuous and less-structured task in which monkeys rapidly generated sequences of random reaches31,32 (Fig. 3a). The produced movements were highly varied with little organization (Fig. 3b and Extended Data Fig. 8a). To facilitate alignment, we parcellated the workspace to match movements across individuals on the basis of the initial hand position and reach direction to generate as many as 29 similar reaching conditions (Fig. 3c). Despite the dramatic increase in number of conditions and behavioural variability, we could still uncover preserved latent dynamics across individuals (Fig. 3d,e and Extended Data Fig. 2d). The increased complexity of behavioural output in this task allowed us to directly study the relationship between the number of conditions and the preservation of latent dynamics. We subsampled the conditions and found that latent dynamics across individuals were preserved for the entire range (up to 29) considered (Fig. 3f and Extended Data Fig. 8b) even when as few as about 20 neurons are included (Fig. 3g and Extended Data Fig. 8c). The preservation of latent dynamics across individuals decreased when we shuffled the conditions (Extended Data Fig. 8d), thereby reducing behavioural similarity. This agrees with the previous comparison of mice and monkeys: monkeys performing a more complex task (eight conditions) than mice (two to four conditions) had higher preservation of latent dynamics because of the more stereotyped behavioural output.

Fig. 3: Preserved latent dynamics in a sequential reaching task with higher behavioural complexity.
figure 3

a, Monkeys were trained to perform sequences of four reaches to randomly placed target locations using the planar manipulandum. b, Example hand positions in the workspace for all reaching movements made during a session from two example monkeys. c, We matched similar movements between the two monkeys on the basis of their starting location, duration and direction. Each colour represents a different representative condition and matched reaching trajectories are overlaid for the two monkeys. Circles, starting position. d, Preserved motor cortical latent dynamics across monkeys performing matched reaches for the example sessions in c. Note that the correlation between aligned latent dynamics across monkeys was quite close to the within-monkey correlations (grey) and largely exceeded our lower-bound control (orange). e, Preserved motor cortical latent dynamics across all pairs of sessions from three different monkeys. Data include n = 10 comparisons and are presented as in Fig. 2g. Line and shaded area, mean ± s.d. f, Preserved latent dynamics hold for a wide range of conditions. The plot shows, for each pair of sessions, the mean of the top four CCs between the latent dynamics as a function of the number of conditions subsampled from the total available in each session. Dark trace, example session from bd. g, Preserved latent dynamics can be uncovered from even sparsely sampled neural populations. The plot shows, for each pair of sessions, the mean of the top four CCs between the latent dynamics as a function of the number of neurons subsampled from the total available in each session. Dark trace, example session from bd.

We performed more control analyses to confirm that this relationship between behavioural stereotypy and preservation of latent dynamics across individuals from the same species is not a trivial consequence of our methodology. First, we compared our results with a previous study that investigated the dynamics of motor cortical activity within an individual across different but related wrist manipulation and reach-to-grasp tasks33 (Extended Data Fig. 9). During each task, individuals activated the same muscles in a slightly different manner (Extended Data Fig. 9b–d). Accordingly, the latent dynamics of the same monkey performing two distinct but related behaviours were much less preserved than those of different monkeys performing the same behaviour (Extended Data Fig. 9g). Last, as we have previously shown, preserved latent dynamics cannot be explained by stable movement tuning26, nor do they persist following nonlinear transformations26. These analyses demonstrate that the alignment method alone is not sufficient to uncover preserved latent dynamics, even within individuals.

Preserved dynamics in dorsal striatum

Given that the motor cortex is the main cortical output to the spinal circuits that generate movement, the close correspondence between motor cortical latent dynamics and behavioural output may uniquely result from the architecture and projections of this region. To test whether preserved latent dynamics exist across the brain, we studied the subcortical nuclei of basal ganglia, which do not directly project to spinal cord but are crucial for various aspects of behaviour34,35,36,37,38. We predicted that basal ganglia latent dynamics would also be preserved across animals performing the same task. Replicating our alignment analysis on neural population recordings from mouse dorsolateral striatum during a reaching and pulling task (Fig. 4a) revealed preserved latent dynamics across individuals (Fig. 4b and Extended Data Fig. 3c; example in Extended Data Fig. 3f).

Fig. 4: Preserved latent dynamics in the basal ganglia and during covert behaviour.
figure 4

a, We studied whether shared latent dynamics can also be found in subcortical regions by analysing recordings from mouse dorsolateral striatum during a reaching and pulling task. b, Preserved striatal latent dynamics across mice performing the same grasping and pulling task. Data include n = 13 comparisons across four mice and are presented as in Fig. 2g. Line and shaded area, mean ± s.d. c, Hand trajectories can be decoded across mice using their preserved striatal latent dynamics. Data presented as in Fig. 2g. Error bars, mean ± s.d. Statistical tests: two-sided Wilcoxon’s rank sum test, P = 3.0 × 10−8 for decoding performance between across-animal correlation and within-animal correlation, P = 7.3 × 10−4 between across-animal correlation and lower bound. d, To investigate the preservation of latent dynamics during covert behaviour, we examined the preparatory period preceding movement execution in the monkey centre-out task. e, Preserved motor cortical latent dynamics when preparing to reach to a target. Data include 18 sessions and n = 72 comparisons across two different monkeys and are presented as in Fig. 2g. Line and shaded area, mean ± s.d. f, Preserved latent dynamics during covert behaviour contain behaviourally relevant information. Naïve Bayes classifiers trained on the aligned latent dynamics (blue) predicted the intended target in a different monkey virtually as well as classifiers trained and tested on the same monkey (grey), whereas classification was poor without alignment (green). Error bars, mean ± s.d. Statistical tests: two-sided Wilcoxon’s rank sum test, P = 1.6 × 10−4 for classifier performance between across-animal correlation and within-animal correlation, P = 1.7 × 10−13 between across-animal correlation and lower bound.

Moreover, despite the vast differences in circuit and cellular architecture between motor cortex and striatum38,39, both the across-animal correlations (compare Fig. 4b and Fig. 2j) and the across-animal decoding performance of hand trajectories (Fig. 4c and Extended Data Fig. 6f) were equally large for both regions (Extended Data Fig. 6c–e). Therefore, stable latent dynamics across animals performing the same behaviour are not confined to motor cortex—they extend to different regions throughout the brain, including an evolutionarily older structure that is shared among all vertebrates13.

Preserved dynamics during covert behaviour

We have shown the preservation of latent dynamics across brain regions during active, overt behaviour. However, animals also engage in a variety of covert behaviours such as deliberation and planning. These processes require neural activity that is predominantly internally generated by the brain. Given that such covert behaviours involve brain regions that also mediate overt behaviours25,40, we predicted that the latent dynamics underlying these more cognitive processes would also be shared across individuals of the same species. We tested this prediction by analysing motor cortical activity as monkeys planned an upcoming movement before executing it (Fig. 4d). The latent dynamics during the instructed-delay period were highly correlated across animals (Fig. 4e and Extended Data Fig. 3d; example in Extended Data Fig. 3g) and were virtually identical to those during overt reaching behaviour (compare Fig. 2g). Moreover, these aligned latent dynamics were also predictive of behaviour: Bayesian models predicting the upcoming reaching target based on the aligned latent dynamics from one monkey generalized to another (Fig. 4f). Thus, different individuals use preserved latent dynamics not only to execute the same movement but also to perform the same covert mental process. This result also strengthens our previous observation of preserved latent dynamics during overt behaviour. Afferent feedback arriving at the motor cortex41,42 could partially explain the observed similarity in latent dynamics during overt movement, yet the latent dynamics are entirely internally generated during covert processes such as movement planning.

Behavioural similarity is not sufficient

Our hypothesis requires that behavioural similarity is necessary but not sufficient to allow for alignment of latent dynamics. To test this, we trained recurrent neural networks (RNNs) to produce similar behavioural output while generating distinct latent dynamics. We devised an RNN simulation in which we had control over the degree of preservation of latent dynamics by varying a parameter of the cost function, α (Fig. 5a and Extended Data Fig. 10). We thus created pairs of models that generated highly similar behaviour (Fig. 5b–d) but exhibited distinct latent dynamics as evidenced by the relative lack of alignment (Fig. 5e). We predicted that this decrease in preservation of latent dynamics would be driven by differences in underlying circuit properties. When we reverse-engineered the weights of the different networks, we found that more dissimilar latent dynamics corresponded to larger changes in the variance and dimensionality of the weights changes during training (Fig. 5f). Thus, preservation of latent dynamics is not just a trivial consequence of behavioural similarity; instead, it probably reflects fundamental organization and constraints in the underlying circuit implementation.

Fig. 5: Similar behavioural output is necessary but not sufficient for the preservation of latent dynamics.
figure 5

a, We trained two sets of RNN models to perform the monkey centre-out reaching task. The first set of models were standard RNNs, whereas the second were constrained to produce distinct latent dynamics from the standard networks. The weight of this extra constraint was controlled by parameter α. b, Example movement trajectories for standard and constrained networks. c,d, Both standard and constrained networks produced similar behavioural output, as shown by the error (c) and the correlation between ‘reach trajectories’ across networks (d). Data show ten networks initialized from different random seeds for each type of network (n = 45 comparisons within each network condition). Error bars, mean ± s.d. e, Increasing the value of α decreased the preservation of latent dynamics, establishing that behavioural similarity is necessary but not sufficient to have preserved latent dynamics. Line and shaded area, mean ± s.d. f, Networks with distinct latent dynamics show differences in underlying connectivity. The variance and the dimensionality of the weight changes increased as the latent dynamics were constrained to be more distinct from those of standard networks by increasing α. Variance values are scaled by 10−5. Line and shaded area, mean ± s.d.

Discussion

Neural population latent dynamics have been proposed as first-level explainers of behavioural and cognitive functions9,11, a view that has shed light onto the neural basis of numerous phenomena, such as processes underlying covert25,40,43 and overt behaviour33,44,45, how learning may happen in neural circuits5,46,47 and how information may flow between different brain regions42,48,49. Here, we extend recent works20,50,51,52 to show that latent dynamics are shared across different individuals engaged in the same behaviour for a range of behavioural complexity. The discovery of preserved latent dynamics across individuals will impact both fundamental and applied neuroscience, in particular the development of brain-controlled devices such as neuroprosthetics53,54: with proper alignment, decoders trained on one participant could be readily translated to other individuals55,56,57,58,59 to minimize training and deployment time.

We studied two regions (motor cortex and dorsolateral striatum) whose functions are tightly linked to the production of limb movements. In the behaviours studied here, we demonstrated preserved latent dynamics using a relatively few dimensions. This low dimensionality could be attributed in part to the temporally smooth and relatively constrained movements in these datasets. Further, the limbs of different individuals from the same species share similar biomechanical properties that, throughout evolution and development, have imposed extra constraints enforcing the preservation of latent dynamics. By contrast, highly sensory-driven regions with rapidly changing inputs may require a higher level of granularity in the analysis but we nonetheless expect to see similar preservation of latent dynamics across individuals. ‘Higher’ brain regions (for example, frontal cortex) that serve more abstract cognitive functions may show less preservation of latent dynamics across animals because of differences in their internal states (attention, motivation, satiation and so on). Even if the most task-relevant aspects of the latent dynamics were preserved across individuals, the influence of these more abstract internal states60,61 could alter the overall latent dynamics, making the activity of these regions less amenable to alignment. Moreover, different animals may also use different covert strategies to solve the same cognitive task based on their biases acquired through learning and past experience62. Yet, we expect that the neural population latent dynamics would still be preserved if it were possible to appropriately match the internal states or strategies across individuals.

The influence of learning and experience on neural circuit organization and the resulting latent dynamics is a fascinating open question. Throughout an individual’s lifetime, new skills are acquired through practice, which are consolidated through changes in neural circuitry63,64. What, if any, differences should exist in the latent dynamics produced by the motor cortices of, say, a virtuoso guitarist and a first-year guitar student? Regardless of whether those circuits were shaped by practice or even development, we propose that neural circuits are tuned to produce latent dynamics as a solution for behavioural output. In this way, preserved latent dynamics across individuals reflect a fundamental property of the neural basis of behaviour.

Here, we introduced two competing possibilities to explain how similar behaviour can emerge from different neural circuitry. In the first hypothesis, each individual’s brain must learn during development to produce latent dynamics within their idiosyncratic neural circuits to enable the desired behaviour, with no guarantee that both individuals arrive at the same ‘solution’. In the second hypothesis, the generated latent dynamics for the desired behaviour are constrained by the genetically specified organization at the circuit level shared by each individual of a given species. Our results support this second hypothesis and raise an intriguing possibility: given that in higher vertebrates the genome does not specify the implemented architecture in great detail, for example, to the level of the synapse2,3,4, the genome may provide a ‘generative model’ that is instantiated by each individual’s brain. This generative model may constrain low-level details of the neural circuitry such that the appropriate neural population latent dynamics required for the behavioural repertoire emerge throughout development.

Methods

Subjects and behavioural tasks

Monkeys

We trained four monkeys (monkeys C, M and J: male, Macaca mulatta; monkey T: male, M. fascicularis; aged 6–10 years) to sit in a primate chair and make reaching movements using a customized planar manipulandum. The movement of a cursor on a computer screen was mapped to the motion of the handle of the manipulandum and the behavioural task was run through custom software in Matlab (The Mathworks). Monkeys C, M and J were trained to perform a two-dimensional centre-out reaching task for at least several months before the neural recordings, ensuring they had reached expert performance. Monkeys C, M and T were trained on a more complex random target sequential reaching task. In the centre-out task, the monkey moved its hand to the centre of the workspace to begin each trial. After a variable waiting period, the monkey was presented with one of eight outer targets. The targets were equally spaced in a circle and selected randomly with uniform probability. Then, an auditory go cue signalled the animals to reach to the target. Monkeys were required to reach the target within 1 s after the go cue and hold for 0.5 s to receive a liquid reward, except for monkey J, who was trained without the instructed-delay period or the 0.5 s target hold time and therefore made larger movements (Extended Data Fig. 1a, right). For the centre-out task, there were 12 sessions for monkey C, 6 sessions for monkey M and 3 sessions for monkey J.

In the random target task, the monkeys made four consecutive reaches to random targets within a 10 × 10 cm2 workspace in each trial. Each target was presented sequentially in a random location within an annulus with 5 cm inner radius and 15 cm outer radius of the previous target to enforce minimum and maximum reach lengths. Monkeys received a liquid reward during a short break after each successful sequence of four random target acquisitions. There was no explicit auditory go cue and only a brief hold period within the target (100 ms) and then a brief delay period (100 ms) before the next target was presented. These short constraints helped to enforce that the monkeys made separate, directed movements but did not require that the monkey necessarily stop between movements. For the random target task, there was one ‘reference’ session for monkey C, six sessions for monkey M and four sessions for monkey T. As the monkeys performed these tasks, we recorded the position of the endpoint at a sampling frequency of 1 kHz using encoders in the joints and digitally logged the timing of task events, such as the go cue. Portions of the centre-out reaching data have been previously published and analysed in refs. 26,28,46,65. Portions of the random target data have been previously published and analysed in refs. 31,32.

Mice

Four 8–16-week-old mice were trained to perform a forelimb reaching and pulling task (similar to refs. 38,66) for approximately one month, following habituation to head-fixation and the recording setup. In each trial, mice had to reach and pull a joystick positioned about 1.5 cm away from the initial hand position. The joystick appeared, without any cue, in one of two positions (left or right, less than 1 cm apart). Mice could then self-initiate a reach to the joystick and pull it inwards to get a liquid reward. The joystick was weighted with either a 3 or a 6 g load (light or heavy), making up a total of four trial types (two joystick positions by two loads). Each trial type was repeated 20 times before task parameters were switched to the next trial type without any cue. Each session consisted of two repetitions of each set of four trial types presented in the same order, making up 2 × 4 × 20 = 160 trials. Trials with incorrect responses (for example, pushing the joystick past a threshold, 5 mm) or timeout (the lack of pull or push for 10 s) were marked as unsuccessful. All joystick operations were programmatically controlled using a custom-written open-source Python package: (https://github.com/janelia-pypi/mouse_joystick_interface_python). Mice were maintained on a 12/12 h (08:00–20:00) light/dark cycle and recordings were made between 09:00 and 15:00. The holding room temperature was maintained at 21 ± 1 °C with a relative humidity of 30–70%.

There were two sessions for mouse 38, one session for mouse 39, two sessions for mouse 40 and one session for mouse 44. Movement kinematics were tracked using markerless video-based pose estimation. Annotation of behaviour was accomplished using Janelia Automatic Animal Behavior Annotator67. Briefly, behaviour was recorded using two synchronized high-speed (500 frames s−1), high-resolution monochrome cameras (Point Grey Flea3; 1.3 MP Mono USB3 Vision VITA 1300; Point Grey Research) with 6–15 mm (f/1.4) lenses (C-Mount), placed perpendicularly in front and to the right of the animal. A custom-made near-infrared light-emitting diode light source was mounted on each camera. Video was recorded using custom-made software developed by the Janelia Research Campus Scientific Computing Department and IO Rodeo. This software controlled and synchronized all facets of the experiment. For the main analyses, light and heavy trials were pooled together because we focused on the reaching phase of the task and the location of the joystick does not depend on its weight. Note that in Extended Data Fig. 6a we repeated the main analysis to demonstrate preserved latent dynamics during the pulling phase, considering all four conditions.

Neural recordings

Monkeys

All surgical and experimental procedures were approved by the Institutional Animal Care and Use Committee of Northwestern University under protocol no. IS00000367. We implanted 96-channel Utah electrode arrays in the primary motor cortex (M1) or dorsal premotor cortex (PMd) using standard surgical procedures. Throughout the paper, neural recordings from these two subregions were pooled together and denoted as motor cortex. This allowed us to ensure that we could evaluate overt and covert dynamics within the same population. Implants were done in the opposite hemisphere of the hand animals used in the task. Monkeys M and T received two arrays in M1 and PMd simultaneously. Monkey J received a single array in M1. Monkey C received two sets of implants: one array in the right M1 while performing the task using the left hand and, following removal of this original implant, two arrays simultaneously in the left M1 and PMd while using the right hand (respectively, monkeys CR and CL in our previous work26). Note that for all across-individual analyses, CR and CL are considered the same animal.

Neural activity was recorded during the behaviour using a Cerebus system (Blackrock Microsystems). The recordings on each channel were band-pass filtered (250 Hz–5 kHz) and then converted to spike times on the basis of threshold crossings. The threshold was set to 5.5× the root-mean-square activity on each channel. We also manually spike sorted the recordings from monkeys C, M and T to identify putative single neurons. Monkey J had fewer well-isolated single units than the other monkeys, so rather than spike sorting we directly applied the multi-unit threshold crossings acquired on each electrode. However, it has been shown that the latent dynamics estimated from multi-unit and single neuron activity are similar68, an observation that holds true for aligning latent dynamics with CCA26 (note that we refer to both single neurons and multi-units simply as units). We included multiple experimental sessions from each monkey: for the centre-out reaching task, eight from monkey CL, four from monkey CR, six from monkey M and three from monkey J (example data in Extended Data Fig. 1); for the random target task, one ‘reference session’ from monkey C, six from monkey M and four from monkey T (example data in Extended Data Fig. 8). These experimental sessions were chosen on the basis of the high number of units or trials and blind to the behaviour of the animal. For the centre-out reaching task, the average number of units included for each monkey was: monkey CL, 277 ± 14 (mean ± s.e.m.; range, 210–345); monkey CR, 85 ± 4 (range, 73–92); monkey M, 117 ± 4 (range, 106–130); and monkey J, 63 ± 9 (range, 54–81). For the random target task, the average number of units included was: monkey CL, 280 (one session only); monkey M, 127 ± 9 (range, 101–153); and monkey T, 49 ± 8 (range, 30–66). A more detailed description of the behavioural and neural recording methods is presented in ref. 26.

Mice

All surgical and experimental procedures were approved by the Institutional Animal Care and Use Committee of Janelia Research Campus. A brief (less than 2 h) surgery was first performed to implant a three-dimensional-printed headplate69. Following recovery, the water consumption of the mice was restricted to 1.2 ml per day, to train them in the behavioural task. Following training, a small craniotomy for acute recording was made at 0.5 mm anterior and 1.7 mm lateral relative to bregma in the left hemisphere. A neuropixels probe was centred above the craniotomy and lowered with a 10° angle from the axis perpendicular to the skull surface at a speed of 0.2 mm min−1. The tip of the probe was located at 3 mm ventral from the pial surface. After a slow and smooth descent, the probe was allowed to sit still at the target depth for at least 5 min before initiation of recording to allow the electrodes to settle.

Neural activity was filtered (high-pass at 300 Hz), amplified (200× gain), multiplexed and digitized (30 kHz) and recorded using the SpikeGLX 3.0 software (https://github.com/billkarsh/SpikeGLX). Recorded data were preprocessed using an open-source software KiloSort 2.0 (https://github.com/MouseLand/Kilosort) and manually curated using Phy (https://github.com/cortex-lab/phy) to identify putative single units in each of the primary motor cortex and dorsolateral striatum. A total of six experimental sessions (from four mice; Extended Data Fig. 5) with simultaneous motor cortical and striatal recordings were included in this work. The average number of motor cortical units included for each mouse was: mouse 38, 98 ± 4 (range, 95–102); mouse 39, 64; mouse 40, 75 ± 5 (range, 70–80); and mouse 44, 55. The average number of striatal units included for each mouse was: mouse 38, 100 ± 13 (range, 87–112); mouse 39, 108; mouse 40, 74 ± 5 (range, 69–79); and mouse 44, 110.

Data analysis

We used a similar approach for both monkey and mouse data. In all the analyses, we only considered the trials in which the animal successfully completed the task within the specified time and received a reward. We concatenated trials in time for subsequent analyses—that is, no trial-averages were taken. For the monkey centre-out reaching task and the mouse reaching and pulling task, an equal number of trials to each target was randomly selected (eight targets for the monkeys and two targets for mice, except in Extended Data Fig. 6a, for which four targets were considered). Trial order was randomized to eliminate the possible effect of the passage of time. Within each trial, we isolated a window of interest that captured most of the movement, starting 50 ms before movement onset and ending 400 ms after movement onset. To analyse covert behaviour in monkeys, we used a window that spanned the movement planning period, which started 400 ms before movement onset and ended 50 ms after movement onset. Importantly, all of our results held when changing the analysis windows within a reasonable range.

For the monkey random-walk task, each reach could start and end anywhere within the workspace. To define movements (conditions) that could be matched across animals, we first segmented the workspace into 12 circular subsections. Each subsection was then divided into six equal sectors and targets in the same angular sector were grouped together, creating 72 possible target conditions. We separated the sequences of four consecutive reaches and considered each reach as a separate movement. To assign each movement to a target condition, we first assigned each movement to one of the subsections on the basis of the starting position of the given movement, excluding movements that started more than 2 cm from the centre of the subsection. We then recentred the movements so that they started in the centre of each subsection and reached outwards towards their target. The movement was then assigned to a sector and target condition on the basis of the angle of target. To study the preservation of latent dynamics across monkeys performing similar behaviour, we needed to match movements (reach conditions) across sessions for different monkeys. To maximize the number of matched movements, we compared all sessions for Monkey M and Monkey T against a reference session for Monkey CL that had the most successful trials. We matched movements in each pair of sessions by minimizing the mean squared error (MSE) between pairs of movements, excluding matches that had MSEs above the threshold of 2% of MSEs calculated for all possible pairs of movements. If the matched movements had different corresponding target conditions, we used the target condition label from the reference session. After this process was completed, we excluded target conditions with less than six matched movements, such that paired sessions had up to 29 shared target conditions. Because these movements were more ballistic than in the centre-out task, we examined a window starting at movement onset and ending 350 ms after movement onset.

All the analyses were implemented in Python using open-source packages such as numpy, matplotlib, sci-kit, scipy and pandas70,71,72,73,74 and custom code. As we were analysing existing datasets on an individual basis, no explicit planning of sample size, group randomization or blinding was performed.

Behavioural correlation

To assess the behavioural stereotypy of a given animal, we calculated hand trajectory correlations (Pearson’s correlation) of every pair of trials within a session (Extended Data Fig. 1b and Extended Data Fig. 5b). The distributions in Fig. 2k inset illustrate these correlations pooled across all the monkey centre-out and mouse reaching and pulling sessions included in this work. To determine the behavioural similarity across pairs of sessions from different monkeys or mice (Fig. 2k), we similarly calculated correlations to compare all pairs of trials from the two sessions.

Neural population latent dynamics

To estimate the latent dynamics associated with the recorded neural activity in each session for both mice and monkeys, we computed a smoothed firing rate as a function of time for each unit. We obtained these smoothed firing rates by applying a Gaussian kernel (σ = 50 ms) to the binned square-root transformed spike counts (bin size 30 ms) of each unit. We excluded units with a low mean firing rate (less than 1 Hz mean firing rate across all bins) but we did not perform any further exclusions, for example, based on lack of modulation or behavioural tuning. For each session, this produced a neural data matrix X of dimension n by T, where n is the number of recorded units and T the total number of time points from all concatenated trials on a given day; T is thus given by the number of targets per day × number of trials per target × number of time points per trial. We performed this concatenation as described above after randomly subselecting the same number of trials for all targets for each animal (15 trials for monkey centre-out, six for monkey random walk, 22 for mouse reaching and pulling). For each session, the activity of n recorded units was represented as a neural space—an n-dimensional sampling of the space defined by the activity of all neurons in that brain region. In this space, the joint recorded activity at each time bin is represented as a single point, the coordinates of which are determined by the firing rate of the corresponding units. Within this space, we estimated the low-dimensional latent dynamics by applying PCA to X. This yielded n PCs, each a linear combination of the smoothed firing rates of all n recorded units. These PCs are ranked on the basis of the amount of neural variance that they explain. We defined an m-dimensional, session-specific manifold by only keeping the leading m PCs, which we referred to as neural modes. We chose a manifold dimensionality m = 10, based on previous studies examining motor cortical recordings during upper limb tasks5,26,46. Across all datasets, a ten-dimensional manifold explained about 60% of the neural variance for each of the monkey motor cortex (Extended Data Fig. 1c), mouse motor cortex and mouse striatum (Extended Data Fig. 5e). Note, however, that our results held within a reasonable range of dimensionalities, similar to refs. 26,33,46 (Extended Data Figs. 2f and  4b). We computed the latent dynamics within the manifold by projecting the time-varying smoothed firing rates of the recorded neurons onto the m = 10 PCs that span the manifold. This produced a data matrix L of dimensions m by T.

Aligning latent dynamics through CCA

We addressed our hypothesis that different animals performing the same behaviour would share preserved latent dynamics by aligning the dynamics using CCA26,75. CCA was applied to the latent dynamics of each pair of sessions after concatenating the same number of randomly ordered trials to each target (condition, in the case of the sequential reaching task). For details on using CCA to align latent dynamics, see ref. 26.

We measured the similarity in latent dynamics across animals by computing the across-animal correlations as the canonical correlations (CCs) across all pairs of sessions from any two different monkeys or mice. To establish the strength of the across-animal correlations, we computed an upper bound defined by the within-animal correlations, which we calculated as the 99th percentile of the correlations between two randomly selected subsets of trials within any given session over 1,000 samples. The ‘control’ correlations represent a lower bound for the CCs. We computed these by shuffling the targets across the two sessions and using a randomly selected control window (more details in the ‘control analyses’ section below) in each trial, rather than the movement or preparatory epochs.

Note that to summarize each comparison to a single datapoint (for example, in Fig. 2k and Extended Data Figs. 2h and 6d), we computed the mean of the top four CCs of the latent dynamics26. In Fig. 2k, we used this approach to establish a relationship between the strength of preservation of the latent dynamics and the consistency of behaviour, quantified as the mean trajectory correlation of all possible pairs of trials across two animals. Furthermore, when showing pairs of ‘aligned’ trajectories across animals, such as in Fig. 2e and Extended Data Fig. 3, the CCA axes were made orthogonal using singular value decomposition for visualization purposes.

Finally, we showed that preserved latent dynamics could be uncovered across a broad range of manifold dimensionalities. In Extended Data Fig. 2f we repeated the alignment analysis for manifold dimensionalities m = 2–19.

Decoding analysis

To test whether the aligned latent dynamics maintain movement-related information, we built standard decoders to predict hand trajectory during overt behaviour. If the aligned latent dynamics across different animals were behaviourally relevant, they would allow predicting time-varying hand trajectories even if the methods used to identify them (PCA and CCA) are not supervised, that is, they do not attempt to optimize decoding performance. We compared the predictive accuracy of three different types of decoders: (1) a within-animal decoder trained and tested (using ten-fold cross-validation) on two non-overlapping subsets of trials from each session of each animal; (2) an across-animal ‘aligned’ decoder that was trained on the aligned dynamics from one animal and tested on another, a comparison we performed on each pair of sessions from two different animals; (3) an across-animal ‘unaligned’ decoder that was trained on the latent dynamics from one animal and tested on another without aligning the dynamics using CCA. We also performed a similar analysis to predict the upcoming target during covert movement preparation in monkeys (Fig. 4f).

Hand trajectory decoders were LSTM models with two LSTM layers, each with 300 hidden units, followed by a linear output layer. The models were implemented with Pytorch76 and trained for ten epochs with the Adam optimizer, with a learning rate of 0.001. Upcoming target classifiers were Gaussian Naïve Bayes models12 (the GaussianNB class in ref. 72). We included three bins of recent latent dynamics history, for a total of 90 ms, in the input of both the decoders and the classifiers. These extra neural inputs incorporate information about intrinsic neural dynamics and account for transmission delays. The R2 value, defined as the squared correlation coefficient between actual and predicted hand trajectories, was used to quantify decoder performance. Moreover, in Extended Data Fig. 4d we verified that our choice of across-animal decoder accuracy metric did not influence the observation that preserved latent dynamics are informative about behaviour by also computing a variance accounted for (VAF) metric, defined as:

$$\text{VAF}=1-\frac{{\sum }_{i=1}^{n}{(\widehat{{y}_{i}}-\bar{y})}^{2}}{{\sum }_{i=1}^{n}{({y}_{i}-\bar{y})}^{2}}$$

where yi represents the actual value of the predicted variable, ŷi its predicted value and \(\bar{y}\) its mean. For this analysis, we normalized hand trajectories by the length of the reaches (determined by the 99th percentile of their hand positions along each axis) because monkeys had workspaces of different sizes.

The hand trajectory was a two-dimensional signal in monkeys and a three-dimensional signal in mice. We built separate decoders to predict hand trajectories along the x, y (and z for mice) axes. We then reported the average performance across all axes. For target classification, we reported the mean accuracy of the classifier (the score() method).

To test how many dimensions of the aligned latent dynamics were needed for accurate across-animal decoding of behaviour, we repeated the decoding analysis in the monkey centre-out dataset for manifold dimensionalities m = 1, 2…,14 (Extended Data Fig. 4b).

Finally, we performed a control analysis to ensure our across-animal decoding results were not biased by sharing similar trials for both alignment and decoder training. We split the full dataset of one animal into three non-overlapping sets: one to align the latent dynamics, one to train the decoder and one to test the performance across animals. Extended Data Fig. 4c shows the result of this analysis for the monkey centre-out data. Despite having aligned the latent dynamics only using half of the data, the impact on decoding performance is negligible.

Control analyses

Alignment of latent dynamics with random behavioural windows

To establish a ‘behaviourally irrelevant’ window as control, we randomly selected windows of similar length to our behavioural windows (450 ms) along the entire duration of the intertrial and trial periods combined. This ensured we had samples of dynamics in the neural population with realistic statistics but that they were not directly coupled to shared behaviour across individuals. We used this window to provide a lower-bound control for the alignment of neural population latent dynamics (‘control’ in Figs. 2f,g,j, 3d,e and 4b,e and Extended Data Figs. 2bd,g, 3 and 8d).

Aligning latent dynamics through Procrustes analysis

We used CCA to align the latent dynamics in all the analyses. However, to ensure that our results hold regardless of the specific method used for alignment, we replicated the main result using Procrustes analysis77. Procrustes finds the best transformation that minimizes the sum of the squares of the differences between the two input datasets. Following a procedure identical to the CCA analysis, we aligned the dynamics from two different datasets using Procrustes analysis (the scipy.spatial.procrustes class in ref. 73) and then correlated the aligned dynamics to yield a metric comparable to that of the CCA (Extended Data Fig. 2g,h). Note that the degrees of preservation of latent dynamics obtained with CCA and Procrustes analysis are largely similar.

Neural variance explained by aligned latent dynamics

We measured the percentage of neural variance explained by the preserved latent dynamics using a method we devised in ref. 33. Briefly, we ‘reconstructed’ the preserved neural activity by projecting the aligned latent dynamics along the CC axes back to the PCA space (the neural manifold) and then to the original neural state space. We then measured the difference between the total neural variance and the variance of these reconstructed signals using an approach similar to that in ref. 78. By repeating this procedure iteratively for an increasing number of manifold dimensions m, we measured the neural variance explained by each dimension of the aligned latent dynamics. Using this approach, we found that preserved latent dynamics explain a significant fraction of the neural population variance (Extended Data Fig. 2e).

Surrogate datasets with TME

We established a lower-bound control by aligning the latent dynamics from randomly selected windows sampled across different task conditions and behavioural epochs (see above). In addition to this control, we also used TME to generate surrogate neural data as another lower-bound control29. TME produces surrogate data that preserve the second-order statistics of the actual neural data (that is, covariance across time, across neurons or across experimental conditions) but are otherwise random (Extended Data Fig. 2a). Aligning these surrogate data through the same procedure as the original data shows significantly lower correlations for monkey centre-out task, random-walk task and mouse reaching and pulling task (Extended Data Fig. 2b–d).

Aligning topological structure in neural population activity

To test whether the topological structure in the produced movements is sufficient to produce preserved latent dynamics, we quantified the degree of similarity in latent dynamics across individuals that could be uncovered when aligning the static, topological features of the neural population activity, rather than the dynamics of the movements, using a technique developed in ref. 26. To align the topological structure of neural population activity, we time-averaged the activity for each neuron during the execution epoch of each trial in the monkey centre-out reaching task. We then analysed the time-averaged data with the previous methodology by performing PCA to find a neural manifold and using CCA to align each pair of sessions (Extended Data Fig. 7a). This procedure led to well-aligned ‘topological representations’ (example in Extended Data Fig. 7b). To directly test whether aligning the topological structure of neural population activity is sufficient to uncover preserved latent dynamics, we projected the latent dynamics on the CC axes found through this (static) topological alignment and calculated the pairwise correlations of the resultant projected latent dynamics. These correlations were remarkably lower than those obtained through alignment of the time-varying latent dynamics (Extended Data Fig. 7c,d).

Control analyses on the numbers of conditions and neurons

To establish that the preservation of latent dynamics holds across different degrees of task complexity, we calculated the correlations for increasing numbers of subsampled target conditions for each pair of sessions in the monkey random target task (Fig. 3f and Extended Data Fig. 8b). We randomly subsampled different combinations of target conditions and calculated the degree of preservation of the latent dynamics for up to 10,000 combinations for each number of conditions.

To establish that preserved latent dynamics can be uncovered regardless of the specific measured neurons, we also calculated the correlations for varying numbers of neurons in the random target task (Fig. 3g and Extended Data Fig. 8c). For each pair of sessions, we either randomly kept neurons (Fig. 3d) or randomly dropped neurons (Extended Data Fig. 8c) in increments of ten until we ran out of measured neurons for either session and repeated this process 50 times, calculating the degree of preservation at each step. For both analyses, we calculated the mean correlations for the top four CCs across all subsamples for each pair of sessions.

Comparison of different but related tasks

The central hypothesis of this study is that preserved latent dynamics are the basis for the generation of similar behaviour across individuals from the same species. Here, we sought to further support this hypothesis by showing that the latent dynamics produced by two individuals engaged in the same task are more similar than the latent dynamics produced by the same individual performing two different but related tasks. To this end, we compared our results to our previous study on the relationship of neural population activity underlying different but related wrist manipulation or reach-to-grasp tasks in monkeys33 (Extended Data Fig. 9).

Recurrent neural network models

Model architecture

To show that the preservation of latent dynamics across animals engaged in the same task is not a trivial consequence of similar behaviour, we trained RNNs to perform the same centre-out reaching task as the monkeys. These models were implemented using Pytorch76. Similar to previous studies simulating motor cortical dynamics during reaching27,79,80,81, we implemented the dynamical system \(\dot{{\bf{x}}}=F\left({\bf{x}},{\bf{s}}\right)\) to describe the RNN dynamics:

$${\rm{\tau }}\dot{{x}_{i}}\left(t\right)=-{x}_{i}+\mathop{\sum }\limits_{j=1}^{N}{J}_{{ij}}{r}_{j}\left(t\right)+\mathop{\sum }\limits_{k=1}^{I}{B}_{{ik}}{s}_{k}\left(t\right)+{b}_{i}+{{\rm{\eta }}}_{i}\left(t\right)$$

where xi is the hidden state of the ith unit and ri is the corresponding firing rate following tanh activation of xi. All networks had N = 300 units and I = 3 inputs, a time constant τ = 0.05 s and an integration time step dt = 0.01 s. The noise η was randomly sampled from the Gaussian distribution \({\mathscr{N}}(\mathrm{0,0,2})\) for each time step. Each unit had an offset bias, bi, which was initially set to zero. The initial states xt=0 were sampled from the uniform random distribution \({\mathscr{U}}\left(-\mathrm{0.2,0.2}\right)\). All networks were fully recurrently connected, with the recurrent weights J initially sampled from the Gaussian distribution \({\mathscr{N}}\left(0,\frac{g}{\sqrt{N}}\right)\), where g = 1.2. The time-dependent inputs s fed into the network had input weights B initially sampled from the uniform distribution \({\mathscr{U}}\left(-\mathrm{0.1,0.1}\right)\). These inputs consisted of a one-dimensional fixation signal which started at 2 and went to 0 at the go cue and a target signal that remained at 0 until the visual cue was presented. The two-dimensional target signal (2 cos θtarget, 2 sin θtarget) specified the reaching direction θtarget of the target.

The networks were trained to produce two-dimensional outputs p corresponding to x and y positions of the experimentally recorded reach trajectories, which were read-out via the linear mapping:

$${p}_{i}\left(t\right)=\mathop{\sum }\limits_{k=1}^{N}{W}_{{ik}}{r}_{k}\left(t\right)$$

where the output weights W were sampled from the uniform distribution \({\mathscr{U}}\left(-\mathrm{0.1,0.1}\right)\).

Model training

Networks were trained to generate positions of reach trajectories using the Adam optimizer82 with a learning rate l = 0.0005, first moment estimates decay rate β1 = 0.9, second moment estimates decay rate β2 = 0.999 and ϵ = 1 × 10–8. The loss function L was defined as the MSE between the two-dimensional output and the target positions over each time step t, with the total number of time steps T = 400. The first 50 time steps were not included to allow network dynamics to relax:

$$L=\frac{1}{2B\left(T-50\right)}\mathop{\sum }\limits_{b=1}^{B}\mathop{\sum }\limits_{t=50}^{T}\sum _{d=1,2}{\left({p}_{d}^{{\rm{target}}}\left(b,t\right)-{p}_{d}^{{\rm{output}}}\left(b,t\right)\right)}^{2}.$$

To examine whether two networks could have different latent dynamics while producing the same motor output, we devised a network with more constraints to perform the behavioural task with distinct latent dynamics (Fig. 5a). We added a loss term that penalized the CC between the latent dynamics of the ‘constrained’ network being trained and those of another previously trained ‘standard’ network during movement execution:

$${L}_{{\rm{constrained}}}=L+{\rm{\alpha }}\mathop{\sum }\limits_{i=1}^{4}{c}_{i}^{2}$$

where ci is the ith CC. To examine different degrees of preserved latent dynamics, we trained the networks at varying values of α = 0, 0.05, 0.25 or 0.50.

Networks were trained until the average loss of the last ten training trials fell below a threshold of 0.2 cm2, for at least 50 and up to 500 training trials, with a batch size B = 64. Each batch had equal numbers of trials for each reach direction. We clipped the gradient norm at 0.2 before the optimization step. Both standard and constrained training were performed on ten different networks initialized from different random seeds. The same set of random seeds was used for constrained networks at different values of α.

Connectivity analyses

By increasing the value of α, we were able to decrease the preservation of the latent dynamics while keeping behavioural performance constant. To examine how this changed the underlying connectivity, we calculated the variance and dimensionality of the weight changes in the recurrent weights J following training (Fig. 5f,g).

Statistics and reproducibility

We compared the performance of various within-animal and across-animal movement decoders and classifiers using two-sided Wilcoxon’s rank sum tests. We replicated the core findings across two species (mice and monkeys), four behaviours (a centre-out reaching task, a sequential reaching task and a reach, grasp and pull task, along with during covert movement planning) and two brain regions (motor cortex and dorsolateral striatum). Experiments on each species were performed independently in two different laboratories and by different scientists. The mice experiments were done in a single cohort, whereas the monkey data were collected in two sets of experiments (one for the centre-out task, another for the random reaching task), each spanning 2 years. Overall, our neural recordings and behavioural data are in good agreement with related published studies. All attempts at replication were successful.

Reporting summary

Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.