Title: A Unified, Scalable Framework for Neural Population Decoding
Venue: NeurIPS 2023
Accepted: yes
Keywords: neural population

brain decoder

transformer

tokenization

sequence-to-sequence

electrophysiology

brain-computer interfaces
Abstract: Our ability to use deep learning approaches to decipher neural activity would likely benefit from greater scale, in terms of both the model size and the datasets. However, the integration of many neural recordings into one unified model is challenging, as each recording contains the activity of different neurons from different individual animals. In this paper, we introduce a training framework and architecture designed to model the population dynamics of neural activity across diverse, large-scale neural recordings. Our method first tokenizes individual spikes within the dataset to build an efficient representation of neural events that captures the fine temporal structure of neural activity. We then employ cross-attention and a PerceiverIO backbone to further construct a latent tokenization of neural population activities. Utilizing this architecture and training framework, we construct a large-scale multi-session model trained on large datasets from seven nonhuman primates, spanning over 158 different sessions of recording from over 27,373 neural units and over 100 hours of recordings. In a number of different tasks, we demonstrate that our pretrained model can be rapidly adapted to new, unseen sessions with unspecified neuron correspondence, enabling few-shot performance with minimal labels. This work presents a powerful new approach for building deep learning tools to analyze neural data and stakes out a clear path to training at scale for neural decoding models.

A Unified, Scalable Framework for Neural Population Decoding

Abstract

Our ability to use deep learning approaches to decipher neural activity would likely benefit from greater scale, in terms of both model size and datasets. However, the integration of many neural recordings into one unified model is challenging, as each recording contains the activity of different neurons from different individual animals. In this paper, we introduce a training framework and architecture designed to model the population dynamics of neural activity across diverse, large-scale neural recordings. Our method first tokenizes individual spikes within the dataset to build an efficient representation of neural events that captures the fine temporal structure of neural activity. We then employ cross-attention and a PerceiverIO backbone to further construct a latent tokenization of neural population activities. Utilizing this architecture and training framework, we construct a large-scale multisession model trained on large datasets from seven nonhuman primates, spanning over 158 different sessions of recording from over 27,373 neural units and over 100 hours of recordings. In a number of different tasks, we demonstrate that our pretrained model can be rapidly adapted to new, unseen sessions with unspecified neuron correspondence, enabling few-shot performance with minimal labels. This work presents a powerful new approach for building deep learning tools to analyze neural data and stakes out a clear path to training at scale.

1 Introduction

Recent advances in machine learning, particularly in the context of large-scale pretrained models like GPT [1, 2, 3, 4], have showcased the immense potential of scaling up, both the terms of the size of datasets and models [5, 6]. Similarly, in neuroscience, there is a growing need for a foundational model that can bridge the gaps between diverse datasets, experiments, and individuals, allowing for a more holistic understanding of brain function and information processing [7]. The development of such a model would allow researchers to uncover underlying patterns and interactions within neural populations [8], and potentially allow for more robust decoding of brain states.

However, creating a large-scale neural decoding model that can effectively combine spiking datasets from various sources is a complex challenge [9]. One of the central challenges is the lack of a shared 'vocabulary' in neural recordings. Unlike the case for text-wherein every document written in a given language shares a basic lexicon for tokenization-there is no one-to-one correspondence between neurons in different individuals. As such, every recording from a different individual involves a unique set of neurons that cannot be easily aligned with another set. An additional core challenge lies in the inherent variability of neuron sets observed across different days [10]. Even when monitoring the same individual, variability in electrode/tissue interface can lead to distinct

neuron sets which, despite advanced sorting methods, can lead to inconsistencies in input channels across sessions [11, 12, 9]. Overall, this lack of correspondence across recordings complicates the integration of information from different experiments and individuals, ultimately hampering efforts to construct a unified perspective on population-level interactions and dynamics in the brain.

In response to these challenges, we propose a new framework for large-scale training on neural spiking data called POYO ( P re-training O n man Y neur O ns). 2 This framework is designed to enable scalable and efficient training across multiple sessions of neural recordings, even when spanning different sets of neurons with no known correspondence. Our approach centers around a novel tokenization scheme that transforms individual neural action potentials, or 'spikes', into discrete tokens, thereby preserving the neural code's finest temporal structure while simultaneously enhancing computational efficiency. The resulting tokenization not only allows for a more effective representation of neural activity but also paves the way for training on larger volumes of data. We combine this input tokenization method with an architecture that builds on the PerceiverIO [13] to compress the input spikes into a latent space and learns interactions across spikes in time and across neurons.

We evaluate the performance of our proposed approach on data from over 158 sessions from open electrophysiology datasets from seven non-human primates (NHPs), spanning over 27,373 units and 100 hours of recordings. We demonstrate that through pretraining on large amounts of data, we can transfer with very few samples (few-shot learning) and thus improve overall brain decoding performance. Our work not only presents an innovative framework for training large models on neuroscience datasets, but also offers insights into the scaling laws that govern decoding from neural populations. By enabling the development of large pretrained models for neural decoding, our approach advances the field of brain-machine interfaces and other decoding applications.

The main contributions of this work include:

A framework for large-scale training on neural recordings: We present a novel framework for training transformer models end-to-end on multi-session and across-individual electrophysiology datasets derived from neural populations, enabling efficient and effective decoding from a diverse range of neural recordings.

Innovative spike-based tokenization strategies: We introduce a fundamentally different way to tokenize neural population activity. Our approach tokenizes individual spikes (events) across neural populations, preserving fine temporal structure and enhancing computational efficiency by adopting a sparse representation of the data.

Pre-trained models for neural decoding: We build two large pretrained models ( POYO-1 , POYO-mp ) that can be fine-tuned on new sessions and across recordings from different animals and new behavioral tasks. We will make the weights and code available, and provide both pretrained models as a resource to the community.

2 Approach

The transformer architecture [14], originally introduced in the context of natural language processing (NLP), has shown remarkable flexibility and effectiveness in various domains, especially in the presence of large and diverse datasets [15, 3]. In this work, we explore how to leverage this versatility in the neural data domain.

2.1 Tokenizing neural population activity

Neurons communicate asynchronously using electrical impulses called spikes. The timing and frequency of spikes encode signals that convey information about the external world and coordinate the internal dialogue within the brain. In many neuroscience experiments, neural activity is recorded from the brain through multiple electrodes, and then processed [16] to extract the spiking events for a set of neural 'units' [17]. 3 The resulting data are multi-variate event-based sequences that are typically very sparse relative to the number of recorded time points.

dataset1

unitids

unit ids

Behavior Queries

sess id

sessid

Raw Spikes

dataset2

H

spike[il.timestamp

querylj.timestamp

SessEmb[query[j].sess_id]

UnitEmb[spike[i].unit_id]

sample 1

sample 2

sample 1

sample 2

Batch

Batch

POYO

(°么)

KV

Q

Predicted Behavior

Learned Latents

Attention

Linear

Cross

Z1

Self

ZLK

Cross

Attention

Attention

e31

x(L-1)

Neurons and their spikes are of course not independent of one another. Rather, they are part of a complex, interwoven tapestry of neural activity, with each spike contributing to a collective dialogue across billions of neurons. The true challenge and opportunity lie in interpreting these spikes not in isolation, but in the context of this broader 'conversation.'

When trying to scale up and train on many sessions of data, we are faced with the challenge of having recordings of neural conversations with completely different set of 'speakers' for which we don't know the identity or their functional tuning (or what they respond to). This is because each time we record from the brain, we are tuning into a conversation between a new set of speakers. However, as with language, there is some reason to think that neurons are ultimately communicating on similar topics, e.g. sensations from the external world, internal states of the body, muscle commands, etc. In other words, the lexicon may be different, but everyone is talking about similar subjects. Despite the variability of our data, our aim is to decipher these 'conversations' in a way that generalizes to new neural datasets without fixed or known correspondence across their inputs.

The neural tokenizer. Based upon these motivations, we propose a novel approach for tokenizing neural population activity where each spike is represented as a token (see Figure 1). In this case, each token can be defined in terms of which unit it came from (via a learnable embedding) and the time that the spike event was detected. By representing our data in this way, we never define or fix the expected number of units, and the model can ingest populations of arbitrary size, and thus can be trained across many datasets. At the same time, this approach also avoids having to specify a specific time resolution for the neural code, as is the case with binning, and gets rid of the accumulation of a lot of sparse tokens containing no events.

More concretely, we assign each unit a unique identifier and a corresponding D -dimensional learnable embedding. Let UnitEmbed( · ) denote a lookup table that associates each unit to its unit embedding. Akin to word embeddings that encode semantic meaning and relationship between words, the unit embedding space encodes something about the 'speaker's' identity and role in neural computation. A unit fires a sequence of spikes in a context window of time [0 , T ] . Each spike will be represented by a token characterized by ( x i , t i ) , where

is the learned embedding associated with the unit that emitted the spike and t i is the event timestamp.

Collectively, and for an arbitrary set of units, we combine all the spikes into a sequence of length M . The neural population activity is represented by [ x 1 , . . . , x M ] and their corresponding times [ t 1 , . . . , t M ] . While the size of our context window T stays fixed, M will vary depending on the number of units in the population and their firing rates (see Figure 1). Note that all spikes from a specific unit have the same unit embedding, and only differ in their timing.

2.2 Building the latent space

Compressing the input sequence. Rather than processing the input sequences with self-attention, which is quadratic in sequence length and can be expensive for long sequences, we use a perceiver encoder module [18] that summarizes the input sequence into a shortened 'latent' sequence. Let's consider a sequence of M input tokens X = [ x 1 , . . . , x M ] and a sequence of learned latent tokens Z 0 = [ z 0 , 1 , . . . , z 0 ,N ] , where z 0 ,i ∈ R D and N ≪ M . We use cross-attention to pull information from the input sequence into a compressed latent sequence. The queries Q = W q Z 0 are a projection of the learned latent tokens Z 0 and the keys and values are a projection of the input tokens: K = W k X and V = W v X , respectively. The cross-attention operation can be expressed as follows:

We use the standard transformer block with pre-normalization layers and feed-forward nets.

Attention in the latent space. Following the compression of the input sequence through crossattention, we apply multiple self-attention blocks on the latent token sequence, which now costs O ( N 2 ) instead of O ( M 2 ) with N ≪ M . Let Z l denote the embedding of the latent tokens at the l th layer. The self-attention operation can be expressed as follows:

We denote the final latent sequence obtained after L layers as Z L = [ z L, 1 , . . . , z L,N ] .

2.3 Encoding relative timing information

To incorporate timing information, we leverage rotary position encoding (RoPE) [19] across all attention layers in the architecture. Unlike traditional position encoding methods that inject absolute position information into the token's embedding, RoPE applies a rotation operation in the query, key embedding space, allowing each token in a sequence to attend to others based on its relative positional information.

Recall that each input token i has an associated timestamp t i . We will also assign a timestamp to each of the latent tokens: we divide the latent tokens into groups of equal size and spread each group uniformly over the context window [0 , T ] . This method allows us to capture temporal relationships between the latent tokens and the input tokens, enabling a temporal understanding of the encoded sequence. By distributing the latent tokens evenly within the context window [0 , T ] , we create a structured temporal representation, which preserves and propagates temporal information all the way through the model. A detailed formulation of the relative encoding can be found in Appendix A.1.

2.4 Querying the latent space

Having built a latent space which can encode and model any population of units, we now want a flexible way to readout behavioral variables. The output of the latent encoder is the latent sequence of size N , while the desired output can be any arbitrary sequence of length P . Let us consider the task of hand velocity decoding for example, in the context window [0 , T ] , the length of the output sequence will depend on the sampling frequency. Since we aspire to train on datasets sourced from various labs, the sampling rate can differ significantly. We thus need a flexible mechanism for predicting outputs of varying lengths and querying from the neural activity at specific points in time.

We define a sequence of output tokens Y 0 = [ y 0 , 1 , · · · , y 0 ,P ] , where P is the number of output time points, which can change across sequences. Each output token is defined by ( y 0 ,i , t out i ) . Initially all the output tokens within a session are set to the same learned embedding y 0 ,i = y 0 ∈ R D ∀ i . The output Y is obtained by querying the latent space through cross-attention:

Since we use rotatary embeddings, and both the latent and output tokens have assigned timestamps, the querying mechanism can leverage the relative position of latent and output tokens to extract the temporally relevant context that enable prediction of the behavioral variable of interest.

Session embeddings. To account for variability of the experimental setups in real world settings, we propose to define a learnable session embedding which captures the hidden experimental variables. This information is injected into the output query y 0 , where again we use a lookup table to register each new session we encounter. To illustrate how we probe the model to generate an output, we can think about it as asking a question of the form:

"Predict [BEHAVIOR] at time [TIMESTAMP] under the experimental conditions of [SESSION ID]".

This produces a set of output tokens of the dimension of the number of queries which we then pass through an MLP to generate the behavioral variables of the desired dimension (e.g., 2D for hand velocities in a planar movement task).

2.5 Unit identification in new sessions

Our design of the unit embedding space allows our model to learn latent information about the units it encounters, as well as capture the relationship between units in the population. Given a new recording with unidentified units, we can transfer our model by mapping these new units into the unit embedding space. To do this, we introduce an approach that we call 'unit identification', which leverages gradient descent to learn the embeddings of new units. In this approach, we freeze all existing weights of the model and simply add new rows to the UnitEmbed( · ) lookup table for each of the new units, as well as a new session embedding. Notably, the bulk of our model which maps the neural population activity to behavior is unchanged and is simply transferred to the new dataset. In our experiments, we find that this approach is surprisingly effective and allows us to rapidly integrate new datasets into the same underlying model. Further details and analysis on the robustness of this approach are presented in Appendix C.2.

3 Experiments

In this section, we demonstrate the promise of our approach for large-scale training and examine the benefit of scaling in neural population decoding.

3.1 Datasets and experiment setup

One of the key advantages of our approach is its ability to scale to handle large amounts of neural data, including sessions from different numbers of neurons, across different tasks and recording setups, and from different animals. Thus we set out to build a diverse dataset large enough to test our approach. We curated a multi-lab dataset with electrophysiological recordings from motor cortical regions, where neural population activity has been extensively studied [10], and deep learning tools and benchmarks have recently been established [27]. In total, we aggregated 178 sessions worth of data, spanning 29,453 units from the primary motor (M1), premotor (PMd), and primary somatosensory (S1) regions in the cortex of 9 nonhuman primates (see Table 1). We place this in the context of standard analyses within a single lab or paper which typically involve 10's of sessions and a few hundred neurons.

All of these neural recordings were collected while the animals performed various motor tasks that vary in their inherent complexity (see Figure 2A-B). The center-out (CO) task is relatively stereotyped, with the animal making a reach to one of eight targets after receiving a go cue, and

.924

A

Monkey C

06/26/2014

10/23/2013

C

Perich et al.Monkeys: C, M, J Task: CO

98

98

工

口口

Ground Truth

POYO-MP

96

6

96

0.0

1.0

2.0

3.0

0.0

1.0

2.0

3.0

92

94

MonkeyC

MonkeyJa

Center-outreach

88

90

。

86

93.47

95.12

88

O Training set size

0.0

1.0

2.0

3.0

0.0

1.0

2.0

3.0

[Single Session]

POYO-

POYO-MP

88

R² x 100 (Single-Session model)

90

92

94

96

86

B

Monkey C

12/09/2013

01/16/2014

D

Perich et al. Monkeys: C, M Task: RT

06

95

T

T

R²× 100 (Multi-Session model)

90

85

0.0

1.0

2.0

3.0

0.0

1.0

2.0

85

Monkey C

03/17/2015

02/24/2014

80

Random target

>

1

0.0

1.0

2.0

3.0

0.0

1.0

2.0

3.0

75

70

[Single Session]

84.02

POYO-

POYO-MP

87.88

75

R2 x 100 (Single-Session model)

75

80

85

06

then returning to the center. In contrast, the random target (RT) task is significantly more complex. The animals make continuous and self-paced movements with new targets appearing in succession at random locations in the workspace. In addition to the greater exploration of the workspace and heterogeneity in movements, this task allows individual to plan their next movement while finishing the execution of the current movement leading to greater complexity in neural dynamics. Other sources of variability that we find across labs include the: choice of pre-processing algorithms (spike sorting or threshold crossing analysis), type of controller (manipulandum, touch screen), and sampling rate when recording behavior (100Hz to 1kHz). We do not re-process the data or attempt to standardize it across labs or tasks. Further details on the datasets are provided in Appendix B.

Experiment setup. Throughout all of our experiments, we use a context window of 1 s and do not segment data into trials during training. We only use the trial structure when reporting the decoding performance, in particular, center-out sessions are evaluated during the reaching movement. We train the model with N = 512 latent tokens and a dimension D = 128 . We use the LAMB optimizer [28], and employ a cosine decay of the learning rate at the end of training. For every session, we holdout 20% of the trials for testing, and 10% for validation. We use 1-GPU and 8-GPU setups for single-session and multi-session models, respectively. All details can be found in Appendix A.

3.2 Testing the model on single sessions

To first investigate the performance of our architecture when trained on a single session, we trained single-session models on 100 different recording sessions acquired from three nonhuman primates (Monkey C, Monkey M, Monkey Ja), each containing anywhere from 10 to 106 minutes of data [29]. In all of these recordings, the same behavioral task setup, behavioral recording apparatus (10 ms temporal resolution), and spike sorting procedure was used.

Across all 100 single-session models, we obtained an average R2 of 0.9347 on CO and 0.8402 for RT sessions. When we compared these single-session results with existing models for neural decoding, including a Wiener Filter, GRU and MLP [30], we found that our approach consistently outperforms these baselines, with even greater improvements observed on the RT task. Additionally, we found that our single-session models are stable for a wide range of hyperparameters (Appendix C.3).

3.3 POYO-mp : Building a large pretrained across-animal, multi-session model

To investigate the question of how training with more sessions of data can improve brain decoding, we trained a large model ( POYO-mp , 24 layers) on all 100 sessions that we studied in our single-session analysis. In total, we used 9,789 units and 4,367 neuron-hours (number of neurons × amount of time recorded) to train our POYO-mp model.

This model achieves an average test R 2 of 0.9512 on the center-out tasks and 0.8738 on the random target tasks, which is a marked improvement over the single-session average. When we compared the performance of our multi-session model to single-session models head-to-head (see Figure 2C-D), we found that across the board, multi-session training improves over single-sessions, and we observed even greater improvements for datasets with fewer trials (indicated by the size of the circles in the plot). On RT sessions, we observe an even bigger improvement over the single session models. These results suggest that there are significant benefits in joint-training across multiple sessions, especially when decoding more complex behaviors like the random target task.

Scaling analysis. By enabling multisession training, we can start to ask questions about the extent to which having more data or more parameters can improve decoding (Figure 3). Thus, we studied the improvements obtained for three different depths of models, with L=6 (3.8M), L=14 (7.4M), and L=26 (13M) layers (parameters). For both CO and RT tasks, we find that even at the same depth (L=6), our 1 multi-session model shows an improvement over the average performance of 100 single-session models. We see further improvements with increasing the model depth, with the RT task benefiting even fur-

Center-Out

RandomTarget

RandomTarget

96.0

89

89

6layers

95.5

88

88

24 layers

00

Moreparameters

1

95.0

Scalingmodel

87

87

×

2

94.5

86

86

vera

e

94.0

Training with

85

85

All RT

more data

AddCO

93.5

Multi-Session

Single-session

84

Multi-Session

Single-session

84

Single-session

93.0

83

83

3.8M

7.4M

13M

3.8M

7.4M

13M

1.2M

26M

134M

Num of parameters

Num of parameters

Num of tokens

ther from scaling. When we fix the model depth to L=6, and study how training jointly with more data contributes to improvement in performance, we find an improvement in performance when comparing single-session training (average 1.2M tokens) to training jointly on all RT sessions (26M tokens). When we also train jointly with other CO sessions (134M tokens in total), and increase model depth to help in accommodating the more growing and diverse training set, we continue seeing improvement in the decoding performance on RT sessions, accumulating to 4% over our single-session baseline.

3.4 Transferring to new sessions

After pretraining, we can then test on new sessions with unknown neurons using either the (i) unit identification approach we described in Section 2.5, or (ii) full finetuning of the model weights. Recall that when we use a unit identification approach, we freeze the weights of the model and only learn new unit and session embeddings.

Results on held out sessions from the same animals. We first tested the unit identification approach on held-out sessions from Monkey C that are unseen during training (Table 2, Left). In this case, we don't have correspondence between units in the training and the testing conditions. Surprisingly, we find that we can achieve comparable performance with unit identification on the pretrained model (0.9675) with that of the single-session models trained fully from scratch (0.9682). With further finetuning of the rest of the model's weights, we can improve the accuracy further (0.9708) to go beyond the accuracy of the single-session models. This highlights the robustness

SampleEfficiency

ComputeEfficiency

SampleEfficiency

ComputeEfficiency

1.0

1.00

0.8

0.8

0.9

0.75

0.7

0.6

2

0.8

0.50

460 steps

90召

0.4

460 steps

0.7

0.6

GRU

Single-Session model

0.25

Unitidentification

0.5

Single-Session model

0.2

Unit identification

0.5

Finetuned model

0.00

Trained from sratch

0.4

Finetuned model

0.0

Trained from sratch

4

8

16

32

64

128 167

0

1000

2000

3000

4

8

16

32

64

86

0

1000

2000

3000

4000

Numberofsample trials

Number of training steps

Numberofsample trials

(b) MonkeyT(new subject),RT session

of our model and its flexibility to accommodate fresh data with even a simple input mapping (unit identification).

We compare with the single session model and a GRU baseline (Figure 4A) with our multi-session model trained on the same number of trials. Both our single-session and finetuning approach achieve good performance scaling as we increase the number of samples, with the finetuning maintaining a gap over the single session models over the entire sampling space.

Results on a new animal performing the same tasks. Next we tested our model on 12 sessions from a completely new animal (6 CO sessions, 6 RT sessions from Monkey T) that was not included in the training of the model (Table 2, Right). When we applied our unit identification approach on the multi-session model ( POYO-mp + Unit ID), we see a bit of a dip in overall accuracy from the single-session model ( POYO -[Single-session]); however, when we fine-tune the weights of the model further, we achieve an accuracy of 0.9379 on CO, which is a significant improvement over all of the other baselines. For the RT task, the single session model is 0.7569 and with unit identification we achieve 0.7669 and with full fine-tuning we get up to 0.7916 (Figure 4B). These results are promising and show that we can use our pretrained model on new animals with only a few minutes of labeled data.

Performance on the Neural Latents Benchmark (NLB). To understand how well our pre-trained model performs on data collected from new animals performing novel tasks with different equipment (example: touch screen vs. manipulandum), we applied our pretrained model to the MC-Maze (Monkey L) and MC-RTT (Monkey I) datasets from the NLB (Table 3)[27]. The NLB serves as a benchmark for neural representation learning and decoding and thus we can include other single-session baselines to our comparisons, including self-supervised models AutoLFADS [31] and NDT [32] which produce denoised firing rate estimates over which we fit a linear layer (+ Linear), a supervised variant of NDT

[33] (NDT-Sup), and EIT [33]. Both datasets contain single sessions from new animals performing movement tasks that we haven't seen during training.

On the NLB-Maze dataset, we obtain a R2 of 0.8952 after unit identification, which is competitive with the baselines. These results are surprising since we do not modify the model's weights, and yet our pretrained model yields competitive results on a dataset collected under very different conditions. When we finetune the model, we boost the performance even further establishing a 4.4% gap over the best baseline. Similar trends can be observed for the RTT task (Monkey I), with even larger (2%) improvement after finetuning.

3.5 POYO-1 : A multi-lab, multi-task model for neural decoding

Given the impressive transfer results of POYO-mp to datasets from different labs, we ask whether we can use our approach to build a model that spans even more diverse recording setups that we expect

A

Monkey1

04/11/2016

02/27/2017

C.i

Perich et al.

Perich et al.

Makin et al.

Monkeys: C, M, J Task: CO

Monkeys: C, M Task: RT

Monkeys: 1, L Task: RT

Ground Truth

POYO-1

96

98

06

95

06

85

T

6

0.0

1.0

2.0

3.0

0.0

1.0

2.0

3.0

2×100

92

85

80

Monkey

09/27/2016

MonkeyL

03/02/2017

忍

90

80

75

70

Controller:Touch screen

Randomtarget

A

88

86

93.47

POYO-

94.46

POYO-1

75

70

84.02

POYO-

86.64

POYO-1

65

60

77.75

POYO-

79.76

POYO-1

00

1.0

2.0

3.0

0.0

1.0

2.0

3.0

[Single Session]

[Single Session]

[Single Session]

B

MonkeyJe

C.ii

Monkeys: Je, N Task: CO

Churchland et al.

D

Learned Session Embeddings

in POYO-1

100

POYO-1 + Finetune

Ground Truth

95

06

6

Monkey

M

C

N

00

1.0

2.0

3.0

00

1.0

2.0

0'E

R² ×100

85

80

PC2

2

MonkeyJe

75

0

70

-2

65

Maze

60

85.23

87.11

Controller:Touch screen

POYO-

POYO-1

0

5

10

0.0

1.0

2.0

3.0

1.0

2.0

3.0

[Single Session]

PC1

0.0

to encounter when trying to unify data from many sources. In total, we used datasets from seven nonhuman primates spanning three different labs, with a total of 27,373 units and 16,473 neuron-hours for training our model. We call this pretrained multi-lab, multi-task model POYO-1 .

Even in light of the high amounts of variability across these different datasets, POYO-1 provides consistent improvements over the single-session models (Figure 5C). When tested on a number of different transfer tasks (Tables 2, 3), we again find that the unit identification and finetuning approaches provide effective strategies for adapting our pretrained model to new datasets. We obtain notable performance on the NLB-Maze, where we find that we obtain a R 2 of 0.9329 with only unit identification remapping, an almost 4% improvement over the unit identification result for our POYO-mp pretrained model, suggesting that we cover more of the task space with POYO-1 .

When comparing the POYO-1 model with POYO-mp model, it is clear that both methods have their strengths. POYO-mp excels on the datasets sourced from the same lab, with 0.8788 on RT sessions compared to POYO-1 's 0.8664. On the other hand, both models exhibit great transfer capabilities, with POYO-1 having the edge especially when using unit identification, indicating its ability to generalize better across diverse experimental conditions. This flexibility and scalability make these methods promising tools for future research in analyzing neural data from diverse sources.

Visualizing the session embedding space. We visualized the learned task embeddings to see if the model learns relationships between sessions seen during training (Figure 5D), even though it was not explicitly trained with this information. This analysis revealed clusters corresponding to different data sources and tasks, suggesting that our model has not only learned to identify patterns within each session but also recognized overarching structures across sessions. In particular, we find that the datasets collected in the Miller Lab (C,M,J) used to train the POYO-mp model are mapped into similar regions of the session latent space, and (I and L) sessions are mapped to their own distinct clusters.

4 Related Work

Transformer architectures for time-series data. Transformers have emerged as a powerful model for processing time-series data due to their ability to capture long-range dependencies [34, 35]. The key to their success lies in the self-attention mechanism [14], which allows the model to weigh the importance of each time step in the input sequence when producing an output. A typical approach in applying transformers to time-series data involves discretizing the continuous time domain into discrete bins [35], and treating the binned data as a sequence of tokens. Each bin is then linearly projected into a high-dimensional embedding, which is input to the transformer model. The Perceiver framework [18, 13] moves away from the idea of patches, by directly processing the input bytes,

using cross-attention layers to reduce the complexity of attention. In addition to regular timeseries, there has been interest in applying transformers to model irregular timeseries including event stream and point process data [36, 37, 38]. However, many of these models work on univariate event streams and when they extend to multivariate cases, they assume fixed and known input channels.

Transformers applied to neural data. With the recent advances in transformers for sequence modeling in many different time-series, transformers have also recently found successful applications in building representations of neural population activity [32, 33, 39]. In these models, the spiking activity is first binned and then the estimated bin counts are tokenized. In the neural data transformer (NDT) model [32], the firing rates of all neurons in the population are embedded jointly in one token (time step or bin). In the embedded interaction transformer (EIT) [40], neurons are considered independently in one stage of processing and at a population level in a second stage, and thus the whole dataset is tokenized over both neurons and time. In the spatiotemporal (STNDT) model [39], two different tokenizations are also considered, one in space and one in time, and two representations are learned jointly for both tokenizations. In all cases, binned data are used and the models are trained on a single session and fixed set of neurons.

Multi-session training and alignment. The idea of decoding across multiple sessions has been explored in previous work [41, 42, 43, 44]. In many of these works, an initial baseline representation is formed on one day and alignment-based approaches are used to transfer a model trained on one session across recording days [23, 45, 12, 46, 47]. A subset of these methods [41, 43] can be trained on many sessions jointly, but rely on the assumption of shared dynamics or structure of a single task to achieve alignment. To the best of our knowledge, our work is the first to demonstrate multi-session transfer across subjects performing different tasks, and the first to demonstrate scaling across different data and model sizes.

5 Discussion

In this paper, we introduce a novel framework for training transformers on large multi-session, multi-task neural activity datasets. To tackle the challenges of training on such large heterogeneous sources, we introduce a novel spike-level tokenization scheme and architecture that enables the model to learn from populations with varying numbers of neurons. We show that training a single unified model on multiple recordings is possible, and find that it leads to improved decoding performance. Finally, we build two large pretrained models ( POYO-1 , POYO-mp ) that can be efficiently fine-tuned on new datasets, and make them available as a resource to the community.

In contrast to models trained on a single dataset, the pretrained models that we have developed provide a potential way to compare and contrast datasets, and also understand common motifs of activity and dynamics that may be shared across different sessions, tasks, and individuals. Thus, it will be critical to develop tools to probe the patterns and motifs learned by such models and characterize the neural mechanisms underlying different tasks and computations. In particular, we look to understand how spike tokens are grouped across different latent tokens and how the dynamics of the population are modeled in this latent space. Additionally, our proposed unit embedding space allows us to map units into a high-dimensional space; thus understanding how unit projections are organized might help reveal the similarities between different neurons and the nature of their interactions. Similarly, we can analyse the session embeddings to glean insights into inter-session and across-animal differences.

Our work shows how pretraining on diverse data, including datasets from animals performing different tasks and across different laboratories, can all help to improve our ability to decode from novel and unseen neural datasets. Already, our results demonstrate the positive effect of scale for neural data analysis. However, to scale this approach further and integrate even more diverse brain regions and tasks, it will be critical to move toward a self-supervised objective. Thus, our current architecture and multi-session framework could be also extended to self-supervised tasks like generative next-event prediction or masked modeling to allow for even larger datasets to be ingested.

This framework has the potential to advance neuroscience research in several ways. By enabling the development of large pretrained models that can be fine-tuned for various downstream tasks, our work can accelerate progress in brain-machine interfaces and disease modeling applications. The ability to quickly and effectively decode neural activity from diverse datasets and modalities can have significant implications for improving our understanding of the brain and developing new therapeutic interventions.

References

A. Radford, K. Narasimhan, T. Salimans, I. Sutskever, et al. , 'Improving language understanding by generative pre-training,' 2018. 1

A. Chowdhery, S. Narang, J. Devlin, M. Bosma, G. Mishra, A. Roberts, P. Barham, H. W. Chung, C. Sutton, S. Gehrmann, et al. , 'Palm: Scaling language modeling with pathways,' arXiv preprint arXiv:2204.02311 , 2022. 1

M. Dehghani, J. Djolonga, B. Mustafa, P. Padlewski, J. Heek, J. Gilmer, A. Steiner, M. Caron, R. Geirhos, I. Alabdulmohsin, et al. , 'Scaling vision transformers to 22 billion parameters,' arXiv preprint arXiv:2302.05442 , 2023. 1, 2

A. Radford, J. W. Kim, T. Xu, G. Brockman, C. McLeavey, and I. Sutskever, 'Robust speech recognition via large-scale weak supervision,' arXiv preprint arXiv:2212.04356 , 2022. 1

R. Bommasani, D. A. Hudson, E. Adeli, R. Altman, S. Arora, S. von Arx, M. S. Bernstein, J. Bohg, A. Bosselut, E. Brunskill, et al. , 'On the opportunities and risks of foundation models,' arXiv preprint arXiv:2108.07258 , 2021. 1

J. Kaplan, S. McCandlish, T. Henighan, T. B. Brown, B. Chess, R. Child, S. Gray, A. Radford, J. Wu, and D. Amodei, 'Scaling laws for neural language models,' arXiv preprint arXiv:2001.08361 , 2020. 1

A. E. Urai, B. Doiron, A. M. Leifer, and A. K. Churchland, 'Large-scale neural recordings call for new insights to link brain and behavior,' Nature neuroscience , vol. 25, no. 1, pp. 11-19, 2022. 1

C. Hurwitz, N. Kudryashova, A. Onken, and M. H. Hennig, 'Building population models for large-scale neural recordings: Opportunities and pitfalls,' Current Opinion in Neurobiology , vol. 70, pp. 64-73, 2021. Computational Neuroscience. 1

M. Dabagia, K. P. Kording, and E. L. Dyer, 'Aligning latent representations of neural activity,' Nature Biomedical Engineering , pp. 1-7, 2022. 1, 2

C. Pandarinath, K. C. Ames, A. A. Russo, A. Farshchian, L. E. Miller, E. L. Dyer, and J. C. Kao, 'Latent factors and dynamics in motor cortex and their application to brain-machine interfaces,' Journal of Neuroscience , vol. 38, no. 44, pp. 9390-9401, 2018. 1, 5, 16

W. M. Grill, S. E. Norman, and R. V. Bellamkonda, 'Implanted neural interfaces: biochallenges and engineered solutions,' Annual review of biomedical engineering , vol. 11, pp. 1-24, 2009. 2

J. Jude, M. Perich, L. Miller, and M. Hennig, 'Robust alignment of cross-session recordings of neural population activity by behaviour via unsupervised domain adaptation,' in Proceedings of the 39th International Conference on Machine Learning (K. Chaudhuri, S. Jegelka, L. Song, C. Szepesvari, G. Niu, and S. Sabato, eds.), vol. 162 of Proceedings of Machine Learning Research , pp. 10462-10475, PMLR, 17-23 Jul 2022. 2, 10

A. Jaegle, S. Borgeaud, J.-B. Alayrac, C. Doersch, C. Ionescu, D. Ding, S. Koppula, D. Zoran, A. Brock, E. Shelhamer, et al. , 'Perceiver io: A general architecture for structured inputs & outputs,' arXiv preprint arXiv:2107.14795 , 2021. 2, 9, 15

A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin, 'Attention is all you need,' Advances in neural information processing systems , vol. 30, 2017. 2, 9

T. Brown, B. Mann, N. Ryder, M. Subbiah, J. D. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, et al. , 'Language models are few-shot learners,' Advances in neural information processing systems , vol. 33, pp. 1877-1901, 2020. 2, 16

H. G. Rey, C. Pedreira, and R. Q. Quiroga, 'Past, present and future of spike sorting techniques,' Brain research bulletin , vol. 119, pp. 106-117, 2015. 2

M. Pachitariu, N. A. Steinmetz, S. N. Kadir, M. Carandini, and K. D. Harris, 'Fast and accurate spike sorting of high-channel count probes with kilosort,' Advances in neural information processing systems , vol. 29, 2016. 2

A. Jaegle, F. Gimeno, A. Brock, O. Vinyals, A. Zisserman, and J. Carreira, 'Perceiver: General perception with iterative attention,' in International conference on machine learning , pp. 4651-4664, PMLR, 2021. 4, 9, 14

J. Su, Y. Lu, S. Pan, A. Murtadha, B. Wen, and Y. Liu, 'Roformer: Enhanced transformer with rotary position embedding,' arXiv preprint arXiv:2104.09864 , 2021. 4, 14

M. G. Perich, J. A. Gallego, and L. E. Miller, 'A neural population mechanism for rapid learning,' Neuron , vol. 100, no. 4, pp. 964-976, 2018. 5, 6, 16, 17

M. G. Perich and L. E. Miller, 'Altered tuning in primary motor cortex does not account for behavioral adaptation during force field learning,' Experimental brain research , vol. 235, no. 9, pp. 2689-2704, 2017. 5, 17

J. I. Glaser, M. G. Perich, P. Ramkumar, L. E. Miller, and K. P. Kording, 'Population coding of conditional probability distributions in dorsal premotor cortex,' Nature communications , vol. 9, no. 1, p. 1788, 2018. 5, 17

J. A. Gallego, M. G. Perich, R. H. Chowdhury, S. A. Solla, and L. E. Miller, 'Long-term stability of cortical population dynamics underlying consistent behavior,' Nature neuroscience , vol. 23, no. 2, pp. 260-270, 2020. 5, 10, 17

M. M. Churchland, J. P. Cunningham, M. T. Kaufman, J. D. Foster, P. Nuyujukian, S. I. Ryu, and K. V. Shenoy, 'Neural population dynamics during reaching,' Nature , vol. 487, no. 7405, pp. 51-56, 2012. 5, 18

J. G. Makin, J. E. O'Doherty, M. M. Cardoso, and P. N. Sabes, 'Superior arm-movement decoding from cortex with a new, unsupervised-learning algorithm,' Journal of neural engineering , vol. 15, no. 2, p. 026010, 2018. 5, 18

R. D. Flint, E. W. Lindberg, L. R. Jordan, L. E. Miller, and M. W. Slutzky, 'Accurate decoding of reaching movements from field potentials in the absence of spikes,' Journal of neural engineering , vol. 9, no. 4, p. 046006, 2012. 5, 18

F. Pei, J. Ye, D. Zoltowski, A. Wu, R. H. Chowdhury, H. Sohn, J. E. O'Doherty, K. V. Shenoy, M. T. Kaufman, M. Churchland, et al. , 'Neural latents benchmark'21: evaluating latent variable models of neural population activity,' arXiv preprint arXiv:2109.04463 , 2021. 5, 8, 16, 18

Y. You, J. Li, S. Reddi, J. Hseu, S. Kumar, S. Bhojanapalli, X. Song, J. Demmel, K. Keutzer, and C.-J. Hsieh, 'Large batch optimization for deep learning: Training bert in 76 minutes,' arXiv preprint arXiv:1904.00962 , 2019. 6, 15

M. G. Perich, L. E. Miller, M. Azabou, and E. L. Dyer, 'Long-term recordings of motor and premotor cortical spiking activity during reaching in monkeys.' https://dandiarchive.org/dandiset/000688 , 2023. 6, 17

J. I. Glaser, A. S. Benjamin, R. H. Chowdhury, M. G. Perich, L. E. Miller, and K. P. Kording, 'Machine learning for neural decoding,' Eneuro , vol. 7, no. 4, 2020. 6, 18

M. R. Keshtkaran, A. R. Sedler, R. H. Chowdhury, R. Tandon, D. Basrai, S. L. Nguyen, H. Sohn, M. Jazayeri, L. E. Miller, and C. Pandarinath, 'A large-scale neural network training framework for generalized estimation of single-trial population dynamics,' Nature Methods , pp. 1-6, 2022. 8, 19

J. Ye and C. Pandarinath, 'Representation learning for neural population activity with neural data transformers,' arXiv preprint arXiv:2108.01210 , 2021. 8, 10

R. Liu, M. Azabou, M. Dabagia, J. Xiao, and E. Dyer, 'Seeing the forest and the tree: Building representations of both individual and collective dynamics with transformers,' Advances in Neural Information Processing Systems , vol. 35, pp. 2377-2391, 2022. 8, 10

G. Zerveas, S. Jayaraman, D. Patel, A. Bhamidipaty, and C. Eickhoff, 'A transformer-based framework for multivariate time series representation learning,' in Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining , pp. 2114-2124, 2021. 9

Y. Nie, N. H. Nguyen, P. Sinthong, and J. Kalagnanam, 'A time series is worth 64 words: Long-term forecasting with transformers,' in International Conference on Learning Representations , 2023. 9

X. Shou, T. Gao, D. Subramanian, D. Bhattacharjya, and K. Bennett, 'Influence-aware attention for multivariate temporal point processes,' in 2nd Conference on Causal Learning and Reasoning , 2023. 10

X. Shou, T. Gao, S. Subramaniam, D. Bhattacharjya, and K. Bennett, 'Concurrent multi-label prediction in event streams,' in AAAI Conference on Artificial Intelligence , 2023. 10

S. Zuo, H. Jiang, Z. Li, T. Zhao, and H. Zha, 'Transformer hawkes process,' in International conference on machine learning , pp. 11692-11702, PMLR, 2020. 10

T. Le and E. Shlizerman, 'Stndt: Modeling neural population activity with a spatiotemporal transformer,' arXiv preprint arXiv:2206.04727 , 2022. 10

R. Liu, M. Azabou, M. Dabagia, C.-H. Lin, M. Gheshlaghi Azar, K. Hengen, M. Valko, and E. Dyer, 'Drop, swap, and generate: A self-supervised approach for generating neural activity,' Advances in neural information processing systems , vol. 34, pp. 10587-10599, 2021. 10

C. Pandarinath, D. J. O'Shea, J. Collins, R. Jozefowicz, S. D. Stavisky, J. C. Kao, E. M. Trautmann, M. T. Kaufman, S. I. Ryu, L. R. Hochberg, et al. , 'Inferring single-trial neural population dynamics using sequential auto-encoders,' Nature methods , vol. 15, no. 10, pp. 805-815, 2018. 10

A. Farshchian, J. A. Gallego, J. P. Cohen, Y. Bengio, L. E. Miller, and S. A. Solla, 'Adversarial domain adaptation for stable brain-machine interfaces,' in International Conference on Learning Representations , 2019. 10

S. Schneider, J. H. Lee, and M. W. Mathis, 'Learnable latent embeddings for joint behavioural and neural analysis,' Nature , pp. 1-9, 2023. 10

E. L. Dyer, M. Gheshlaghi Azar, M. G. Perich, H. L. Fernandes, S. Naufel, L. E. Miller, and K. P. Körding, 'A cryptography-based approach for movement decoding,' Nature biomedical engineering , vol. 1, no. 12, pp. 967-976, 2017. 10

A. D. Degenhart, W. E. Bishop, E. R. Oby, E. C. Tyler-Kabara, S. M. Chase, A. P. Batista, and B. M. Yu, 'Stabilization of a brain-computer interface via the alignment of low-dimensional spaces of neural activity,' Nature biomedical engineering , vol. 4, no. 7, pp. 672-685, 2020. 10

X. Ma, F. Rizzoglio, K. L. Bodkin, E. Perreault, L. E. Miller, and A. Kennedy, 'Using adversarial networks to extend brain computer interface decoding accuracy over time,' eLife , vol. 12, p. e84296, aug 2023. 10

M. Safaie, J. C. Chang, J. Park, L. E. Miller, J. T. Dudman, M. G. Perich, and J. A. Gallego, 'Preserved neural population dynamics across animals performing similar behaviour,' bioRxiv , 2022. 10

M. Azabou, M. G. Azar, R. Liu, C.-H. Lin, E. C. Johnson, K. Bhaskaran-Nair, M. Dabagia, B. AvilaPires, L. Kitchell, K. B. Hengen, W. Gray-Roncal, M. Valko, and E. L. Dyer, 'Mine your own view: Self-supervised learning through across-sample prediction,' arXiv preprint arXiv:2102.10106 , 2021. 16

H. Banville, O. Chehab, A. Hyvarinen, D. Engemann, and A. Gramfort, 'Uncovering the structure of clinical EEG signals with self-supervised learning,' Journal of Neural Engineering , 2020. 16

Appendix

A Additional Model Details

A.1 Rotary position encoding

Rotary Position Embeddings (RoPE) are used to incorporate relative positional information into transformer models in a memory and compute efficient manner[19]. Unlike absolute position embeddings which are added or appended to the input embeddings, these are directly incorporated in the attention mechanism.

First, we define a 2 × 2 rotation matrix R 2 × 2 ( t, T ) for a given timestamp t and time-period T :

R 2 × 2 ( t, T ) provides a time/positional encoding with a time period T . Intuitively, the sinusoidal values in this rotation matrix can help the model learn and distinguish variations in timestamps at a timescale T .

Given the head dimension of the attention block D , we create a D × D rotary embedding matrix R ( t ) for a timestamp t by constructing a block-diagonal matrix of rotation matrices R 2 × 2 , where the time-periods are varied logarithmically between T min and T max

Given D , T min , and T max , we generate T i by the following equation:

In our models, T min and T max were set to 1 ms and 4 s respectively.

This rotation matrix is incorporated into the attention mechanism by replacing the attention score calculation with the following equation:

Since R ( t i ) T R ( t j ) = R ( t j -t i ) , the attention score a ij depends only on the relative timing between the query and key tokens. This is what makes RoPE relative in nature.

What is explained above has been introduced in [19], and use successfully in many models [18]. In our experiments, we found an interesting extension of RoPE. In addition to incorporating RoPE in calculating the attention scores, we also incorporate it in the weighted-summation of values inside the attention mechanism. We do this to encode the relative timing between values and queries in the output of the attention block. A direct, but computationally inefficient, way of doing so would be:

This is inefficient since it requires us to explicitly compute R ( t i -t j ) for all N 2 values of ( t i -t j ) . We use the fact that R ( t i -t j ) can be factorized as R ( -t j ) R ( t i ) to reach the following, much more efficient, implementation:

That is, we first apply rotation matrices R ( t i ) to all values v i before passing them to as inputs to the attention block. Then we apply the rotation matrices R ( -t j ) to its outputs.

This value-rotation mechanism captures relative-timing information more explicitly in the output of the attention block, allowing the feedforward network to take advantage of timing information. In the absence of this mechanism, the only way timing information is added to the latent tokens is through the attention scores. We observed in early experiments that our model performed better with value-rotation enabled for the input cross-attention and all self-attention layers.

As discovered in the Perceiver framework [13], we observed an improvement in performance upon rotating only half of the head dimensions. That is, half of the R 2 × 2 matrices in R were replaced by 2 × 2 identity matrices.

A.2 Time-based context window

We consider an arbitrary window of time [ t, t + T ] , meaning that we do not use the trial structure when training our model. In our experiments, we set T equal to 1 second. At inference time, we use a sliding window of step 500ms and average the predicted output in overlapping segments.

In language models, and more generally transformer-based models, the context window is defined with respect to the number of tokens. The neural data modality is a bit more complex, as the number of spikes scales with the number of units: Across multiple datasets, we record a variable number of units, ranging from tens of units to hundreds of units. Defining the context window with respect to number of tokens will result in a variable time duration, long for small populations and short for larger ones. Our context window is defined with respect to time (fixed to 1 s ), each sequence will have a variable number of tokens ( M ). When creating batches, we pad to the largest sequence in the batch, and appropriately use an attention mask in the first cross-attention layer. GPU hardware is optimized to process fixed-size tensors, to make computation more efficient, we introduce a distributed training load balancing mechanism, which deals with variable-length input sequences (Appendix A.4.4).

A.3 Further details on tokenization

Delimiters. When extracting the spike data in a window of time [ t, t + T ] , we include delimiters for each unit, indicating to the model that we are tuning into the activity of that unit between times t and t + T . This choice is important because: 1) we are using relative position encoding, so the beginning or the end of the window is not clear, and 2) our tokenization only captures activity and not inactivity. If we consider a unit that is inhibited and does not fire in that window of time, the model would be unaware of the presence of that unit, unless we add [START] and [END] tokens. We learn two embedding vectors for these delimiters x start and x end . For each unit in the population, we add these two tokens with embedding equal to the sum of the delimiter embedding and the unit embedding, and assign each token timestamps t and t + T respectively.

Latent tokens. Recall that we divide the latent tokens into groups of n and spread each group uniformly over the context window. Specifically, we use a total of 256 latent tokens and divide them into groups of 8, this means that there will be 32 tokens that share the same timestamp. We experiment with weight-sharing, where we set the learned latent tokens in the same group to have the same weights ( e 0 , . . . , e 31 in Fig 1). This means that tokens in the same group (size 8) will have the same embedding z 0 ,i = e ( i mod 32) , but different timestamps ( t l 0 , . . . , t l 7 in Fig 1). We believe this is a reasonable inductive-bias to architecturally enforce since, intuitively, we want all sets of latent tokens that share a timestamp to query the spike tokens in the exact same manner, just with a different timestamps. These tokens will evolve independently once the information is pulled from the input space (after the first cross-attention).

A.4 Training details

The model is trained using the LAMB optimizer [28] with weight decay. The learning rate is held constant, then decayed towards the end of training (last 25% of epochs), using a cosine decay schedule. Single-session models are trained on a single GPU with a batch size of 128 while large models are trained with 8 GPUs with a total batch size of 1400. Note that we didn't see any benefits in increasing the batch size when training single-session models.

A.4.1 Compute

The large models are trained on a machine with an AMD EPYC 7452 32-Core Processor and 8 Nvidia A40 GPUs (48Gb memory), POYO-mp was trained for 2 days, and POYO-1 was trained for 5 days (both for a total of 400 epochs). Single-session models are trained with a single Nvidia GeForce RTX 3090 GPU, and take less than an hour to train. Finetuning models is also done with a single GPU. Unit identification converges very quickly and takes less than a minute on a single GPU or a few minutes on the CPU.

A.4.2 Data augmentation

Previous work [48, 49] explores the use of augmentations when training neural population models. In our experiments, we use the unit dropout augmentation which randomly samples a subset of the population. We set a minimum population size of 30 for this augmentation to ensure that it is not too destructive (note that our model is still trained with any number of units, this limit is only imposed for the augmentation). We did not explore the use of other augmentations, but believe it could be a promising direction to further improve the capabilities of the model.

A.4.3 Loss

We train our model using a mean-squared error loss over the hand velocity sequence. We normalize the velocity data using z-scoring at the lab level, this means that all velocity data in datasets from the same lab is rescaled using the same scalar.

Dealing with variable sampling rate. When training on mixtures of datasets from multiple labs, any given batch will contain behavior sequences that have different sampling rates. In a window of 1s, some sequence will have more timepoints over which we will evaluate the MSE compared to other sequences. To avoid the over-representation of samples that simply have a high sampling rate, we evaluate the error on a randomly sampled 100 timepoints (these points are randomly sampled at each pass).

Weight in training mix. While behavior during random target tasks can be more complex and noisy, behavior during center-out reaching tasks is more structured, the monkey usually gets a preparation phase, where the movement can be planned [20]. The latter task has been studied extensively for that reason. Knowing that neural activity is very salient during center-out reaching, we increase the weight of the prediction loss during the reaching segments by a factor of 5 . The idea of over-weighing samples of "good quality" is not novel and is commonly used when training language models [15].

A.4.4 Load Balancing

We distribute our training over multiple GPUs. Note that, in our experiments, the input sequence length ( M ) can vary anywhere between 1k and 20k tokens. Because of the variability in the length of the input sequences, we distribute sequences that have close length to same GPU node.

We now provide further details on our load balancing strategy:

Each GPU node has a local batch size. A GPU that is assigned large sequences will have a smaller local batch size than one that is assigned shorter sequences.

We create a number of data buckets equal to the number of GPUs. Each bucket i is assigned sequences that are of length M ∈ [ M i min , M i max ] , and a local batch size B i .

We select these parameters in such a way that we effectively utilize all available compute capacity, and minimize the amount of padding used.

A.5 Evaluation Details

During training, we train on any 1s segment of the recording, but at evaluation we report the decoding performance using the same evaluation strategy used in previous work [27, 10]: for center-out reaching datasets, we report the decoding score during the reaching movement (only when the trial is completed successfully), for random target datasets that are trialized (hold period followed by 3/4 random reaches), we report the decoding score during the reaching as well, and finally for all other continuous random target datasets, we report the decoding score for all segments. Note that none of the segments used for testing are seen during training.

AS

Monkey C (Right M1)

Perich, et al.

PMd

S1

PCD

Monkey T (Left PMd)

M1

Midline

Churchland, et al.

Monkey N (Left M1)

M1

Makin et al.

Monkey I (Right M1 & S1)

S1

PMd

(estimatedlocations)

Flint, et al.

A.6 Fine-tuning Details

When finetuning the model, we perform gradual unfreezing of the weights. For the first few steps, we optimize the unit embeddings and the session embedding only (unit identication) and then unfreeze the rest of the weights. We use the LAMB optimizer with batch size 128 , learning rate 10 -4 and weight decay 10 -4 . We use the exact same hyper parameters and finetuning process for all experiments we report. This strongly suggests that our method is general, and easy to adapt to new data, without the need for expert neural network training knowledge, or expensive hyperparameter search.

B Datasets

To train and evaluate our framework, we curated a large number of open and publicly available datasets that represent a range of neural and behavioral recording platforms.

B.1 Datasets used for training

Datasets used to train POYO-mp . To build our first large-scale model ( POYO-mp ), we acquired 100 sessions of unique recordings from three non-human primates performing two different movement tasks that were previously studied in four publications [21, 22, 20, 23]. We make these datasets publicly available on the DANDI open repository [29]. In all of these datasets, a nonhuman primate is seated in a primate chair and executes movements using a custom 2-D planar manipulandum to control a cursor on a computer screen. They performed one of two tasks within a session.

Center-out Task (CO): They performed a standard center-out reaching task involving eight outer targets arranged around a circle with a radius of 8 cm. The monkeys were required to move to the center target, wait for a variable hold period, and then move to one of the outer targets upon receiving an auditory go cue. The task aimed to study neural activity during movement planning, preparation, and execution.

Random Target Task (RT): The setup is similar, the targets are not arranged around a circle but are randomly placed. The monkeys were required to move between 4 targets upon receiving an auditory go cue.

After extensive training, the monkeys were implanted with chronic multi-electrode arrays in the primary motor cortex (M1) and the dorsal premotor cortex (PMd). Neural activity was recorded using

a Blackrock Cerebus system, and the data was manually processed offline to identify single neurons. To ensure only independent channels were included, steps were taken to identify and disable potential candidates with high crosstalk and to exclude cells with a high percentage of coincident spikes.

Datasets used to train the multi-lab, multi-session model ( POYO-1 ). When training POYO-1 , we acquire more data as shown in Table 1, adding all of the datasets outlined from Churchland et al., [24], Makin et al., [25], and Flint et al., [26]. We still hold out the 12 sessions from Monkey T, 2 sessions from Monkey C, and the two Neural Latents Benchmark (NLB) [27] datasets from training.

As depicted in Figure 5, instead of using a manipulandum like in the previous experiments, these new datasets use a touch screen and have different sampling rates for their behavioral outputs. In addition, in the Churchland, et al. datasets, they use threshold crossing based processing rather than applying spike sorting to identify single units. We refer the reader to the listed publications for more details about how these datasets were collected.

We would like to reiterate that there are major differences in the way the datasets were collected. Yet, in spite of this variability, it is important that our method works without having to standardize the datasets across sites further and apply specialized techniques to one dataset but not other. Thus we did not attempt to homogenize or standardize the data. The only processing that we perform is on the behavior to clip outliers in the behavior based upon times of high acceleration. We use a simple threshold heuristic to avoid training on periods with extremely high acceleration.

This means that:

We do not filter units based on a presence ratio, or reject multi-units.

We do not re-apply the same spike sorting algorithm on all datasets, and use the data as is. In [24], the spiking events obtained through threshold crossings (i.e. all units are multi-units), and in [25], we have both threshold crossing units and spike sorted isolated single units, and we use both. Each algorithm used in each lab was tuned differently, but we consider this a good example of diversity that a general model needs to deal with.

We do not resample or process the velocity timeseries.

Minimizing the amount of processing needed to integrate new datasets into our model is key for more easily scaling to more datasets, and also providing an accessible model that the community at large can use out of the box, without having to adapt to a specific standard.

B.2 Datasets for evaluation and fine-tuning

In addition to holding out 20% of the data from each session, we hold out all sessions from Monkey T (6 CO, 6 RT). We also use two datasets from the Neural Latents Benchmark [27], MC-Maze and RTT. The Maze dataset consists of recordings from primary motor and dorsal premotor cortices of a monkey performing reaches with instructed delays to visually presented targets while avoiding the boundaries of a virtual maze. This dataset offers a variety of behavioral configurations, with each configuration using a different combination of target position, number of virtual barriers, and barrier positions, resulting in a variety of straight and curved reach trajectories. With thousands of trials, the Maze dataset allows for a rich investigation into the structure of population activity, while its instructed delay paradigm enables a clear separation of neural processes related to preparation and execution. On the other hand, the RTT dataset introduces different modeling challenges, as it contains continuous, point-to-point reaches that start and end in various locations, have highly variable lengths, and few repetitions. We report the performance of our models on the same segments of data used to evaluate models in the NLB benchmark.

C Additional Results

C.1 Comparison with single-session baselines

In our comparisons in Table 2, we compared POYO against existing baseline models that are commonly used for neural decoding [30]. In particular, we applied a Wiener Filter (WF), Feed Forward Network (MLP), and a Gated Recurrent Unit (GRU). These models predict the behavior at each timestamp t given a history window of neural activity [ t -T, t ] . For the NLB datasets, we also compare with

Auto-LFADS [31], an unsupervised approach that can be used to obtain single trial smoothed rate estimates for a population of neurons before applying a linear layer on top of the inferred rates to obtain an estimate of the behavior. While this model isn't designed for decoding per se, it is frequently used for denoising for BMI decoding applications.

For the NLB, we use a 5 ms binning of the neural activity for training models and for evaluation of the behavioral output as this is the finest resolution used in the benchmark. For the rest of the MP datasets, we use a 10 ms binning rate for the neural data and behavior as this corresponds to the behavior sampling rate for these datasets.

The hyperparameters we used for training our single-session POYO model can be found in Table 4.

C.2 Robustness of Unit-identification

Unit-identification, introduced in Section 2.5, can be seen as an approach for identifying units from a new dataset. To evaluate the robustness of this process, we ran unit-identification on a session that was already seen during pre-training. We test whether finetuning on this 'new' set of units, will map them close to their true embedding (found during pre-training). We use our largest model, POYO-1 , start with randomly initialized unit embeddings and run unit-identification.

We perform this experiment on two different animals. In Figure 7, we show the evolution of unitembeddings during training. To compare the newly calibrated set of units with its pre-trained version, we normalize the unit-embeddings and report the cosine similarity averaged over the set of units. Note that normalization is done because POYO 's first cross-attention layer applies layer norm to these embeddings. We also report the 'unit identification accuracy' which we define as the ratio of tuned unit embeddings that have their true unit embedding as their nearest neighbor. Results for these experiments are present in Table 5.

Overall, this analysis suggests that the unit-identification approach is robust and reliable for identifying units. We believe that understanding the functional similarities of units that are mapped close to each other in the unit embedding space will be an interesting avenue for future work.

C.3 Hyperparameter sensitivity

When initially training the single-session models, we selected a subset of datasets (out of the 100 sessions) and performed a random hyperparameter search and selected the set of hyperparameters with the best performance on the validation set. These experiments quickly revealed that the model was very stable to a wide range of hyperparameters. In Figure 8, we report some examples of this for

MonkeyM,CO 2014/02/03

Pretrained

Epoch 10

Pretrained

Epoch 100

Pretrained

Epoch 400

Finetuned

Fnetuned

Finetuned

0.4

0.4

0.4

0.2

0.2

0.2

[ wp

0.0

0°0

00

0.2

0.2

0.2

0.4

0.4

0.4

0.4

0'0

PCA dim 0

0.4

0.6

8'0

0.4

0.2

0.0

PCA dim 0

0.2

0.4

0.6

0.8

0.4

0.2

0.0

PCA dim 0

0.2

0.4

0.6

0.8

0.6

Pretrained

Finetuned

Epoch10

0.6

Fnetuned

Pretrained

Epoch 100

0.6

Pretrained

Fnetuned

Epoch400

0.4

0.4

0.4

0.2

0.2

0.2

wp

0.0

0.0

0.0

0.2

0.2

0.2

0.4

0.4

0.4

0.6

0.4

0.2

0°0

0.2

0.4

0.6

0.6

0.4

0.2

0.0

0.2

0.4

0.6

0.6

0.4

0.2

0°0

0.2

0.4

0.6

PCA dim 0

PCA dim 0

PCA dim 0

two sessions. We perform 300 runs for each session, then report the average performance for each hyperparameter.

Given these findings, we selected the best set of hyperparameters for the subset and used the same parameters when training all of the 100 single-session models that we study in Figure 2.

ValidationR^2averagedovermultipleruns

MonkeyC-2016/10/13

MonkeyT-2013/08/19

1.00

0.95

0.90

0.85

0.80

5

10

200

400

100

200

5

10

15

Modeldepth

Batchsize

Embedding dimension

Numberofheads

Peer reviews:
{"IS_META_REVIEW": false, "comments": "SUMMARY:\nNeural population decoding refers to inferring the behavioral output of organisms from a recording of a population of neuronal recordings. This paper introduces a transformer architecture to improve the accuracy of decoding. The efficiency of the system is increased by representing input spike trains with event-based tokens and by switching to a latent representation (to decrease the size of attention matrices).\n\nIn the presence of behavioral data, the model can identify new neurons (units) that are potentially obtained from different experiments. This is done by freezing the parameters of the network during gradient descent except for the encoding of the new units. This is a novel and interesting approach although it depends on the presence of behavioral recordings.\n\nThe method is tested on multiple experiments where neural activity recordings are obtained from motor cortical regions of monkeys while the monkeys are engaged in tasks involving arm movements.\n\nSTRENGTHS:\n- A novel framework for neural population decoding\n- Efficient representation of the recordings via event-based tokenization\n- Identification of units from new experiments in a way that is consistent with previous experiments. i.e., embedding a new unit such that the embedding location is consistent with the locations of other units in previous experiments whose activities/roles are similar to the new unit.\n- Use of multiple experiments done in different labs to demonstrate the method.\n- The inference accuracy of the method seems to improve significantly upon strong baselines.\n\nWEAKNESSES:\n- I oppose alluding to 'foundation models', which have become popular in natural language processing. Importantly, such models are trained in an unsupervised manner and demonstrate emergent abilities to solve multiple downstream tasks. The proposed architecture depends strongly on the presence of joint behavioral recordings. Similarly, it wouldn't make sense to apply this trained model to recordings from, say, the visual cortex.\n\n- [line 165] Are commands given via natural language? If not, please provide mathematical description instead (or in addition).\n\n- One simple experiment to probe the fidelity of \"unit identification\" could be: (i) take a recording, learn embeddings of units, etc. (ii) shuffle the order of units and repeat the experiment by adding rows to Embed as described in text. (iii) Compare and report the similarity between the two embeddings.\n\nQUESTIONS:\n- What is the relationship between the context window T (1s) and Tmax (4s) used in positional encoding? How does Tmax change with respect to T?\n\n- Could you provide more details on extending the model to self-supervised tasks (mentioned at the end of the paper)?\n\nLIMITATIONS:\nYes.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-03"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nDeep learning and transformer models have shown great promise in identifying structure from large datasets. With recent advancements in neural recording methods, it is now possible to generate rich and heterogeneous recordings from large populations of neurons across multiple brain regions and experimental conditions. The proposed work bridges this gap by introducing a new approach to modeling neural dynamics across these recordings. The authors leverage transformer models by tokenizing neural activity, preserving the temporal structure by treating each spike as a discrete token. This strategy allows training across multiple sessions and individuals. The success of the approach was extensively tested in several datasets across multiple labs, brain regions, and tasks, demonstrating increased decoding performance compared to alternative methods.\n\nSTRENGTHS:\nThe paper is presented clearly and is technically sound. The method was tested and shown to work well across multiple datasets. The proposed strategy leverages the success of transformer models and applies it to neuroscience by introducing a novel way to tokenize neural activity. Extracting shared variability across multiple datasets is crucial for neuroscience and biomedical applications, and this approach could provide a framework for analyzing these emerging datasets. The authors demonstrated the success of the approach when trained on multiple neural recordings and tasks, with the ability to pool data across sessions and animals. Decoding results showed that the method outperforms alternative approaches, including lesion versions of the introduced model, when tested within and across sessions and animals. They also investigated the impact of different architectures and numbers of parameters on performance. Importantly, they showed that minimal fine-tuning allows the model to improve decoding performance on other tasks. The proposed strategy could lay the foundation for studying unifying principles of neural computation.\n\nWEAKNESSES:\nHowever, it should be noted that this strategy heavily relies on having access to multiple large neural recordings, which may not be feasible for most basic neuroscience research where datasets are often limited. While the authors tested the method across multiple brain regions and tasks, all of them were motor tasks in motor-related areas. While this choice likely facilitated the identification of shared structure and enabled transfer learning, it would be even more intriguing if this approach could be applied across categorically different tasks, such as sensory encoding and decision-making, spanning from sensory areas to higher cortical regions. This could potentially help identify universal coding principles of neural computation as well as task-specific coding principles related to motor function.\n\nQUESTIONS:\nI would be interested in applying this method to even more diverse recordings throughout the brain and tasks to explore universal computational principles.\nThe models allows for neural variability, but still assumes that all neurons are functionally similar. Could this be a problem when looking at other brain regions? Specially if the proportion of excitatory cells is smaller.\n\nLIMITATIONS:\nThe authors mention some limitations and future work in their paper. However, it would be important to acknowledge the computational costs, training times, and data demands associated with the proposed method.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-07-04"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper introduces a novel method for developing models that can predict the activity of neural populations by learning from data recorded across different sessions, tasks, and animals. The method is uses a custom tokenization procedure for spikes and a deep neural network architecture based on PerceiverIO. The paper presents the core method, then describes a technique to reuse a large pre-trained model to learn efficiently to predict a new neuronal population/condition, and finally presents a series of validation experiments.\n\nSTRENGTHS:\n- the proposed technique is technically solid, elegant, and performs well in the experiments.\n\n- this technique addresses a real need in neuroscience labs, making the paper potentially very high impact.\n\n- I found the scaling analysis (lines 237-257) particularly instructive, and especially relevant because for a new method like this one the reader may wonder what type of performance they may expect on their own data, as a function of the architectural choices they would have to take when deploying the method. This is of course a very hard thing to assess correctly, but this type of analysis is a great starting point.\n\n- the paper is very well written.\n\nWEAKNESSES:\n- I have noticed a few minor issues (mostly related to clarity and plots) in section 3.4. See below under \"questions\".\n\n- The discussion of related literature seems to imply that all spike train analysis has always been done by binning spikes. It would be good to include at least a cursory mention of kernel methods for spikes and other binless measures: see for instance Paiva, A.R.C., Park, I., Príncipe, J.C., 2010. A comparison of binless spike train measures. Neural Comput & Applic 19, 405–419.\n\nQUESTIONS:\n- line 277: \"we see a bit of a dip in overall accuracy\": how much is a bit? is this data shown anywhere?\n\n- in figure 4, the blue/green colors are hard to see in grayscale. Can you choose colors that render better in grayscale?\n\n- in figure 4, the compute efficiency plots don't seem to be cited anywhere in the text?\n\n- line 289: \"is competitive with other baselines\". What other baselines?\n\n- in the paragraph \"Performance on new animals performing new tasks\", it is not clear how much data was using for training and how much for testing. Can you clarify?\n\nLIMITATIONS:\nLimitation of the present work are appropriately discussed. I see no potential issue with societal impact.", "TITLE": "Official Review", "RECOMMENDATION": 8, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-07-06"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThe authors describe a novel method for the task of neural decoding: using the time series of activity recorded from a population of neurons to predict the activity of scientifically relevant target variables. The describe their approach, called POYO, based upon the tokenization of spike data, the application of transformer based models to this data to generate pre-trained models, and the use of these pre-trained models for neural decoding. They demonstrate that this approach allows for accurate generalization across different sessions of neural recordings from the same animal, and across different animals.\n\nSTRENGTHS:\nThe authors present a novel approach for the decoding of neural data, that appears promising in its ability to generalize over different animals and experimental sessions, which is a major problem in neuroscientific data analysis. The performance of their method is impressive, especially in the setting of pretrained models that are finetuned to novel datasets. The ability to combine various datasets in the way described here has the potential to be impactful.\n\nWEAKNESSES:\nMy main concerns are with regard to scientific rigor, and the scope of the claims made in this work.\n- Generalization across brain regions. I believe there needs to be a more thorough discussion of the role of brain regions in tasks where POYO is asked to generalize across individuals with recordings from different brain areas. To what degree will region-specific neural activity impact the ability of POYO to generalize when performing few shot learning? Concretely, what would behavioral decoding results in Table 2 look like if they are broken out per individual brain areas? \n- Lines 37-39: \"Overall, this lack of correspondence across recordings and channels complicates the integration of information from different experiments and individuals, ultimately hampering efforts to construct a unified perspective on population-level interactions and dynamics in the brain.\"It is not clear to me how POYO will address these challenges. While it is clear that POYO allows for highly performant decoding, the lack of recurrent structure within POYO makes it difficult to understand how this model would assist these challenges. Perhaps analysis of the attention mechanism could provide some answers to this question, but that point is not discussed in this work. \n- Comparison with existing baselines. In Table 1, it is unclear to me why the performance of AutoLFADS + Linear only provided for the NLB datasets. It would be useful to see the performance of this model on all datasets, as it is a more powerful and commonly used decoding model than the others provided. Comparison with other transformer based neural decoding approaches like NDT (Ye and Pandarinath 2021) would also provide a better perspective on the value of the methodological advances proposed in this particular work. \n\nI am open to reconsidering my score if my concerns here are addressed.\n\nQUESTIONS:\n- How many steps/epochs are fine tuning and unit identification run for? I was unable to find this information in the appendix. \n- Line 55: the phrase \"neural scaling laws\" is ambiguous. Can it be changed to \"scaling laws\"? \n- Line 349-350: \"AutoLFADS extends the LFADS framework with Population Based Training to perform hyperparameter tuning, but has not been demonstrated for multi-session alignment.\"Is there any reason to believe that AutoLFADS is not capable of performing multi-session alignment? To my knowledge, Auto-LFADS is a optimization routine for LFADS. I would assume that it works for multi-session recordings as well.\n\nLIMITATIONS:\nAs noted by the authors, generalizing this framework across other brain regions (as well as many other conditions) is a key limitation. In general, I have reservations about the use of the phrase \"foundation model\" without qualification in the context of neural decoding. Is the suggestion of this work that neuroscientists should aim to build a general purpose model that performs decoding regardless of model organism, brain area, or recording modality? While the results of this study are impressive, I do not believe that such claims are justified, even as future work.", "TITLE": "Official Review", "RECOMMENDATION": 6, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-07"}