Full text
46,636 characters
· extracted from
preprint-html
· click to expand
HuiduRep: A Robust Self-Supervised Framework for Learning Neural Representations from Extracellular Recordings | bioRxiv /* */ /* */ <!-- <!-- /*! * yepnope1.5.4 * (c) WTFPL, GPLv2 */ (function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0];var j=d.createElement(s);var dl=l!='dataLayer'?'&l='+l:'';j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;j.type='text/javascript';j.async=true;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-M677548'); Skip to main content Home About Submit ALERTS / RSS Search for this keyword Advanced Search New Results HuiduRep: A Robust Self-Supervised Framework for Learning Neural Representations from Extracellular Recordings View ORCID Profile Feng Cao , View ORCID Profile Zishuo Feng , Wei Shi , View ORCID Profile Jicong Zhang doi: https://doi.org/10.1101/2025.07.22.666242 Feng Cao 1 Beihang University Find this author on Google Scholar Find this author on PubMed Search for this author on this site ORCID record for Feng Cao Zishuo Feng 2 Beijing University of Posts and Telecommunications Find this author on Google Scholar Find this author on PubMed Search for this author on this site ORCID record for Zishuo Feng Wei Shi 1 Beihang University Find this author on Google Scholar Find this author on PubMed Search for this author on this site For correspondence: shiweilab{at}buaa.edu.cn Jicong Zhang 1 Beihang University Find this author on Google Scholar Find this author on PubMed Search for this author on this site ORCID record for Jicong Zhang Abstract Full Text Info/History Metrics Data/Code Preview PDF Abstract Extracellular recordings are transient voltage fluctuations in the vicinity of neurons, serving as a fundamental modality in neuroscience for decoding brain activity at single-neuron resolution. Spike sorting, the process of attributing each detected spike to its corresponding neuron, is a pivotal step in brain sensing pipelines. However, it remains challenging under low signal-to-noise ratio (SNR), electrode drift, and cross-session variability. In this paper, we propose HuiduRep , a robust self-supervised representation learning framework that extracts discriminative and generalizable features from extra-cellular recordings. By integrating contrastive learning with a denoising autoencoder, HuiduRep learns latent representations robust to noise and drift. With HuiduRep, we develop a spike sorting pipeline that clusters spike representations without ground truth labels. Experiments on hybrid and real-world datasets demonstrate that HuiduRep achieves strong robustness. Furthermore, the pipeline outperforms state-of-the-art tools such as KiloSort4 and MountainSort5. These findings demonstrate the potential of self-supervised spike representation learning as a foundational tool for robust and generalizable processing of extracellular recordings. Introduction Neuroscientists frequently record extracellular action potentials, known as spikes, to monitor brain activity at single-cell resolution. These spikes, the extracellular voltage deflections from individual neurons, are considered the “fingerprints” of single-cell activity. By analyzing spike trains, sequences of temporally ordered spike times, researchers can infer neuronal coding and dynamics with millisecond precision ( Bod et al. 2022 ). However, each electrode often captures spikes from many nearby neurons, so it is crucial to sort or cluster spikes by their source ( Dallal et al. 2016 ; Banga et al. 2022 ). Spike sorting is the process of assigning each detected spike waveform to its originating neuron. ( Guzman et al. 2021 ) In practice, spike sorting is treated as a clustering problem on waveform features, often following initial steps of filtering and spike detection. ( Souza et al. 2019 ) It is a foundational step in electrophysiology that enables single-unit analysis and studies of neuronal function ( Rey, Pedreira, and Quian Quiroga 2015 ). In classical spike sorting pipelines, data are first preprocessed, typically filtered and normalized. Spikes are then detected, typically via threshold crossings or template matching. Subsequently, features such as waveform principal components or wavelet coefficients are extracted. The resulting feature vectors are then clustered using methods like k-means, Gaussian Mixture Model (GMM), or density-based algorithms to identify putative single units. Early automated sorters such as KlustaKwik ( Kadir, Goodman, and Harris 2013 ) often required extensive manual curation due to imperfect clustering. More recent frameworks like Mountain-Sort ( Chung et al. 2017 ) and KiloSort ( Vishnubhotla et al. 2023 ) have improved throughput. For instance, Mountain-Sort introduced an automatic clustering approach with accuracy comparable to or exceeding manual sorting. Likewise, KiloSort4 ( Pachitariu et al. 2024 ) uses template matching and deconvolution to scale sorting to hundreds of channels with high accuracy. These tools represent the state-of-the-art in spike sorting, but they still rely on conventional clustering paradigms and presuppose stable, high-quality signals. Despite recent advances, spike sorting remains challenging under realistic conditions. Low SNR signals make spikes hard to detect or distinguish. Nearby neurons often produce overlapping or morphologically similar waveforms, leading to “compound” spikes that violate the assumption of one spike per neuron. Electrode drift, slow movement of neurons relative to the probe, causes spike waveforms to change over time, violating the stationarity assumption. Electrode drift has been identified as a major contributor to sorting errors, and correcting for drift substantially improves sorting performance. Spatial overlap of neurons also complicates sorting: dense, high–channel-count probes produce many overlapping electrical fields, worsening the “collision” problem. In practice, even the best algorithms degrade under such conditions: for example, methods without explicit drift correction such as SpyKING CIRCUS ( Yger et al. 2018 ) and earlier versions of MountainSort lose accuracy when drift is large. Conventional methods also struggle with diverse waveform shapes, and cross-session variability may result in inconsistent unit identities across different recording sessions ( Brockhoff et al. 2025 ). Thus, robustly clustering spikes in noisy, drifting data remains a key open problem. To address these issues, we propose HuiduRep, a self-supervised representation learning framework for extract-ing representations of spike waveforms for spike sorting. HuiduRep learns features that are discriminative of neuron identity while being less affected by noise and drift. Inspired by recent trends in extracellular recordings representation learning ( Vishnubhotla et al. 2023 ), HuiduRep combines contrastive learning with a denoising autoencoder (DAE) ( Vincent et al. 2008 ). As a result, HuiduRep can learn robust and informative spike representations without any manual labeling. We then cluster the learned representations using the Gaussian Mixture Model to perform spike sorting. Building upon this, we further design a complete pipeline for spike sorting. The pipeline achieves robustness to low SNR and drift, and outperforms state-of-the-art sorters such as KiloSort4 and MountainSort5 on accuracy and precision across diverse datasets. In summary, our main contributions are as follows: We propose HuiduRep, a novel self-supervised framework that integrates contrastive learning and DAE with physiologically inspired view augmentations for robust spike representation learning. We design a complete pipeline for spike sorting requires no ground truth labels and supports high-density probes. We evaluate our method on datasets from distinct neural structures, demonstrating its robustness, and show that it outperforms state-of-the-art sorters. Related Work Template-based Spike Sorters Template-based spike sorting algorithms remain one of the most widely used methods for processing extracellular recordings. These approaches typically detect spikes and then cluster them by matching their waveforms to a set of learned templates. Kilosort is one of the most widely adopted template-matching sorters. It performs spike detection and sorting in a unified framework using a template matching approach combined with drift correction. Operating directly on raw data, Kilosort can handle large-scale recordings, such as those produced by high-density Neuropixels probes ( Steinmetz et al. 2021 ). Its core idea is to model the recorded signals as a superposition of spatiotemporally localized templates and to iteratively infer spike times and unit identities. Despite the success of Kilosort and other template-based methods, which often rely on handcrafted heuristics or static templates that may not generalize well to low SNRs or rare waveform variations. These limitations have motivated the development of recent deep learning-based methods, including our proposed HuiduRep, which aims to learn robust representations directly from data without relying on fixed tem-plates. Representation Learning Models In spike sorting, effective representation of spike waveforms plays a crucial role in enabling accurate clustering, particularly in noisy and drifting recordings. Recent methods have therefore adopted representation learning frameworks to learn spike features. Among these, CEED ( Vishnubhotla et al. 2023 ) and SimSort ( Zhang et al. 2025 ) have emerged as two representative approaches that leverage contrastive learning to derive meaningful spike features without manual labeling. CEED is a SimCLR-based ( Chen et al. 2020 ) contrastive representation learning framework for extracellular recordings. It is trained and evaluated on the IBL dataset ( Laboratory et al. 2021 ), achieving promising performance in embedding spike features. Nevertheless, CEED is limited in this scope: it functions solely as a feature extractor and does not design a complete spike sorting pipeline. Moreover, its performance degrades sharply in embedding multiple neuron types, indicating its difficulty in capturing fine-grained inter-class distinctions. Compared to CEED, SimSort not only proposes a representation learning model but also introduces a complete spike sorting pipeline. However, SimSort also has several limitations. For instance, it only supports 4-channel inputs, which limits its applicability to high-density probes such as Neuropixels recordings ( Steinmetz et al. 2021 ). Moreover, due to its relatively small model size, the performance improvement over existing sorters remains limited, especially in noisy and drifting recording conditions. Method Architecture of HuiduRep The overall architecture of HuiduRep is illustrated in Figure 1 . Inspired by BYOL ( Grill et al. 2020 ), our framework also consists of two main branches: an online network and a target network. The target network is updated via a momentum update based on the online network’s parameters, which are frozen during training. Download figure Open in new tab Figure 1: Overall architecture of HuiduRep and the pipeline. During training, the contrastive learning branch adapts the MoCo v3 style framework, where the query is compared with key and other in-batch samples (not shown in the figure due to the limited space). Only the View 1 is passed to the DAE branch for reconstruction. During inference, only the transformer encoder and DAE module are used to extract representations. The key difference lies in the introduction of a DAE within the online network, which is designed to reconstruct the original signals from the augmented views generated by the view generation module. This DAE serves as an auxiliary module to guide representation learning. Moreover, we replace the original ResNet encoder ( He et al. 2015 ) in BYOL with a Transformer encoder ( Vaswani et al. 2023 ). Before feeding the input views into the encoder, we also apply cross-channel convolution to better capture the characteristics of spike waveforms. During training, only View 1 is fed into the DAE branch, while View 2 does not participate in the denoising task. Furthermore, the contrastive learning branch adapts the MoCo v3 style ( Chen, Xie, and He 2021 ), where representations from positive pairs ( query and key ) and in-batch negative samples are compared. For contrastive learning, we adopt the InfoNCE loss ( van den Oord, Li, and Vinyals 2019 ), while for denoising, we employ the mean squared error (MSE) loss: Here q denotes the query vector output by the prediction head of the online network, k + represents the positive key generated by the target network for the same sample and k − refers to the negative keys, which are the outputs of other samples in the same batch passed through the target network. τ is a temperature hyper-parameter. For MSE loss, v is the embedded feature obtained from the original input, while is the reconstruction produced by the DAE. We apply a standard MSE loss to measure the reconstruction quality.( Wu et al. 2018 ) for l 2 -normalized q and k . The overall loss function of the model is a weighted sum of the denoising loss and the contrastive loss. To generate input views, several augmentation strategies are employed to the original spike waveforms. These include: (1) Voltage and temporal jittering, which introduces small perturbations in both voltage amplitude and timing; (2) Channel cropping, where a random subset of channels is selected to create partial views of the original waveforms; (3) Collision, where noisy spikes are overlapped onto the original waveforms to simulate spike collisions; and (4) Noise, where temporally correlated noise is added to the waveforms to generate noised views. This Noise method is employed only for generating View 1 , enhancing the robustness and performance of the DAE. The detailed view augmentation strategy is provided in the supplementary material. During inference, HuiduRep uses the encoder from the contrastive learning branch to extract representations of input spikes for downstream tasks. In certain cases, the DAE can be optionally applied before the encoder to further enhance the overall performance of the model. Spike Sorting Pipeline Based on HuiduRep, we propose a complete pipeline for spike sorting. As illustrated in Figure 1 , our pipeline consists of the following steps: (1) Preprocessing the raw recordings by removing bad channels and applying filtering; (2) Detecting spike events from the preprocessed recordings; (3) Extracting waveforms around the detected spike events; (4) Using HuiduRep to extract representations of individual spike waveforms; and (5) Clustering the spike representations to obtain their unit assignments. In the pipeline, the preprocessing and threshold-based detection modules of SpikeInterface were employed to process the recordings ( Buccino et al. 2020 ). Following extraction, the spike representations were clustered using GMM from the scikit-learn library ( Pedregosa et al. 2018 ) to produce the final sorting results. Our pipeline is modular, meaning that each component can be replaced by alternative methods. For example, the threshold-based detection module can be substituted with more accurate detection algorithms. In the following experiments, we demonstrate that even when using a threshold-based detection module with relatively low accuracy, our pipeline still outperforms the state-of-the-art and most widely used models such as Kilosort4. Algorithm 1: Pytorch Style Pseudocode of HuiduRep Download figure Open in new tab Datasets In this section, the datasets used for training and evaluating our model are presented, as well as their characteristics. International Brain Laboratory (IBL) Dataset The International Brain Laboratory (IBL) ( Laboratory et al. 2021 ) is a global collaboration involving multiple research institutions, aiming to uncover the neural basis of decisionmaking in mice through standardized behavioral and electrophysiological experiments. DY016 and DY009 recordings are selected from the datasets released by IBL to train and evaluate HuiduRep. Both recordings were recorded from the hippocampal CA1 region and anatomically adjacent areas. Similar to the processing in CEED ( Vishnubhotla et al. 2023 ), we used Kilo-Sort2.5 ( Pachitariu, Sridhar, and Stringer 2023 ) to preprocess the recordings and extracted a subset of spike units labeled as good according to IBL’s quality metrics ( Banga et al. 2022 ) to construct our dataset. For every unit, we randomly selected 1,200 spikes for training and 200 spikes for evaluation. For each spike, we extracted a waveform with 121 samples across 21 channels, centered on the channel with the highest peak amplitude. All selected units from the DY016 and DY009 recordings were used for constructing the training set. For evaluation, we randomly sampled 10 units from the IBL evaluation dataset for each random seed ranging from 0 to 99, resulting in a total of 100 data points. These two subsets are referred to as the IBL train dataset and the IBL test dataset in the following sections. Hybrid Janelia Dataset HYBRID_JANELIA is a synthetic extracellular recording dataset with ground truth spike labels, designed to evaluate spike sorting algorithms. It was generated by using the Kilosort2 eMouse ( Pachitariu, Sridhar, and Stringer 2023 ). The simulation includes a sinusoidal drift pattern with 20 µm amplitude and 2 cycles over 1,200 seconds, as well as waveform templates from high-resolution electrode recordings. We evaluated model performance on both the static and drift recordings of this dataset. To ensure a fair comparison, we reported results only on spike units with SNR greater than 3 for all models. Paired MEA64C Yger Dataset Paired_MEA64C_Yger is a real-world extracellular recording dataset ( Yger et al. 2018 ) that includes ground-truth spike times, which were obtained using juxtacellular recording ( Pinault 1996 ). The dataset recorded from isolated retinal tissues primarily targets retinal ganglion cells. It was collected using a 16 × 16 microelectrode array (MEA) and an 8 × 8 sub-array was extracted for spike sorting evaluation. For each recording, there is one ground-truth unit. We randomly selected 9 recordings in which the ground-truth unit has SNR greater than 3, and used them to evaluate our method with other baseline models. Experiments In this section, we will introduce the key experimental procedures, including hyperparameter search, performance evaluation, and ablation studies. Implementation Details For training HuiduRep, we used the AdamW optimizer ( Loshchilov and Hutter 2019 ) with a weight decay of 1 × 10 −2 to regularize the model and reduce overfitting. Additionally, we employed a cosine annealing learning rate scheduler with a linear warm-up phase during the first 10 epochs, where the learning rate increased to a maximum of 1 × 10 −4 . To balance the contrastive learning branch and the DAE branch, we assigned a weight factor α to the denoising loss to control its contribution during training: The model’s performance is evaluated across different values of α to determine the optimal trade-off on the IBL test dataset. For each α setting, the learned representations were clustered using GMM, and the Adjusted Rand Index (ARI) was computed against the ground truth labels. We report the mean ± standard error (SEM), along with the max and min ARI values of each model across the 100 data points. The result of each data point is averaged over 50 independent GMM runs. As shown in Table 1 , the best over-all performance was achieved when α = 0.2, with the highest ARI score and the highest max value. Notably, both very low ( α = 0.0) and high values ( α ≥ 0.8) led to decreased performance, indicating that a moderate contribution of the denoising branch is essential for improving robustness and the overall performance of HuiduRep. View this table: View inline View popup Download powerpoint Table 1: ARI scores (Mean ± SEM, Max, Min) across different weight factor α of HuiduRep, evaluated with IBL test dataset. In addition, using the same IBL test dataset and evaluation method, we also evaluated the effect of different representation dimensions on the model’s performance with α = 0.2. As shown in Table 2 , with the representation dimension increasing, the model’s performance generally improves, suggesting enhanced representational capacity. However, higher-dimensional representation also leads to greater computational costs. To balance efficiency and performance, we set the representation dimension to 32 and fixed α at 0.2 in all subsequent experiments. View this table: View inline View popup Download powerpoint Table 2: ARI scores and time cost per data point (Mean ± SEM) across different representation (Rep) dimensions of HuiduRep, evaluated with IBL test dataset. All models under different settings were trained for 300 epochs with a batch size of 4096 and a fixed random seed on a server with a single NVIDIA L40s GPU and CUDA 12.4. A local evaluation server with a single NVIDIA RTX 5080 GPU and CUDA 12.8 is used to perform all experiments. A complete list of training hyperparameters is provided in the supplementary material. Performance Evaluation To evaluate the performance of HuiduRep and other models, we created datasets where each data point includes 15 units, using the same construction method as the IBL test dataset. As shown in Table 3 , HuiduRep significantly outperforms CEED and MoCo-v3 on both the 10-unit and 15-unit test datasets, indicating superior representation learning capability. Furthermore, during testing, HuiduRep has a lower number of active parameters (0.6M) compared to CEED (1.8M). These results demonstrate that HuiduRep not only achieves better performance with reduced model complexity, but also adapts more effectively to downstream tasks such as spike sorting, which require strong representational ability. View this table: View inline View popup Download powerpoint Table 3: ARI scores and time cost per data point (Mean ± SEM) of HuiduRep and other models across varying counts of selected units, evaluated with random seeds from 0 to 99. To evaluate the performance of the HuiduRep Pipeline in real-world spike sorting tasks, two publicly available datasets, Hybrid Janelia and Paired MEA64c Yger, are selected as test sets. Multiple spike sorting tools, including Kilosort series ( Pachitariu, Sridhar, and Stringer 2023 ) and MountainSort series ( Chung et al. 2017 ), were evaluated. The performance of Kilosort4 and MountainSort5 was evaluated on our local evaluation server. The results for SimSort were cited from its original publication ( Zhang et al. 2025 ), while the performance data for the remaining methods were obtained from the results provided by SpikeForest ( Magland et al. 2020 ). We recorded three metrics: accuracy (Acc), precision, and recall of different models across various test sets. Moreover, we adopted the SpikeForest definitions for computing these metrics, which slightly differ from the conventional calculation methods. The accuracy balances precision and recall, and it is similar to the F1-score. These metrics are computed based on the following quantities: n 1 : The number of ground-truth events that were missed by the sorter; n 2 : The number of ground-truth events that were correctly matched by the sorter; n 3 : The number of events detected by the sorter that do not correspond to any ground-truth event. Based on these definitions, the metrics are calculated as: As shown in Tables 4 and 5 , HuiduRep Pipeline consistently outperforms other models on the Hybrid Janelia dataset in terms of accuracy and precision, under both static and drift conditions. However, its recall is slightly lower than that of IronClust but significantly higher than that of the other models. This phenomenon is potentially due to threshold-based spike detection missing low-amplitude true spikes or Iron-Clust detecting an excessive number of spikes, which leads to a high recall and lower precision. View this table: View inline View popup Download powerpoint Table 4: Spike sorting results (Mean ± SEM) on the HYBRID JANELIA dataset. Results for other methods are obtained from SpikeForest. Best-performing values are highlighted in bold . * denote that the method performs significantly better than HuiduRep Pipeline without DAE. (Wilcoxon test, p < 0.05). View this table: View inline View popup Download powerpoint Table 5: Spike sorting results (Mean ± SEM) on the Paired_MEA64C_Yger dataset. Results for other methods are obtained from SpikeForest.* and † denote that the HuiduRep Pipeline with DAE performs significantly ( p < 0.05) and marginally significantly (0.05 ≤q < 0.10) better than other methods. Note: KiloSort2 was evaluated on 8 out of 9 recordings, as it is failed to run on one recording. On the high-density, multi-channel Paired MEA64C Yger dataset, the HuiduRep Pipeline also achieves slightly higher accuracy and precision compared to other models, with statistically significant or marginally significant improvements. However, the recall remains slightly lower. Detailed Wilcoxon test results are provided in supplementary material. The performance on both datasets demonstrates the practical applicability of the HuiduRep pipeline for real-world spike sorting tasks. Notably, applying the DAE, originally an auxiliary module during training, before the contrastive learning encoder during inference leads to significant improvements in both accuracy and recall scores. We will provide an in-depth analysis of this effect in the next ablation study section. Ablation Study To investigate why the DAE enhances model performance during inference and to gain insights into its underlying mechanism, we randomly selected 500 spike samples per unit from each test dataset and the IBL training dataset. For each test dataset, the same set of samples was processed using two different methods: one with the DAE and one without. Principal Component Analysis (PCA) was then applied to reduce the dimensionality of the spike data to two dimensions. We computed the Euclidean distance between the centroid of the test samples and that of the IBL training samples in the reduced feature space. Furthermore, we applied HuiduRep followed by GMM to both groups and calculated the silhouette scores along with ARI of the resulting clusters. Since each recording in the Paired MEA64C yger dataset contains only one ground truth unit, the ARI becomes in-applicable. Each experiment was repeated 20 times, and the mean and standard deviation (STD) were reported. As shown in Table 6 and Figure 3 , applying the DAE to spike waveforms from out-of-distribution (OOD) datasets (Paired MEA64C Yger and Hybrid Janelia) significantly reduces their Euclidean distance to the IBL training set in the reduced feature space. This indicates that the DAE has learned to capture the feature distribution of the original training data. By aligning OOD data closer to the training data, the DAE effectively performs domain alignment, improving the overall ARI. Consequently, as shown in Table 3 , applying the DAE before the contrastive learning encoder enables HuiduRep to better handle distribution shifts, resulting in improved accuracy and recall scores, especially on noisy and drifting recordings. View this table: View inline View popup Download powerpoint Table 6: Euclidean distances between the IBL training dataset and other datasets, along with silhouette score and ARI of each dataset with and without the DAE. The features of each dataset are reduced to 2 dimensions using PCA. Download figure Open in new tab Figure 2: (a): Boxplot of HuiduRep and other models. (b): Clustering results, visualized after reduction via PCA. Download figure Open in new tab Figure 3: Reduced feature space of IBL training dataset and other datasets. The centroid of each dataset is marked with a black X. However, this benefit comes with a potential trade-off: the DAE may compress spike waveforms into a more compact space, reducing inter-class variability and thereby making them less distinguishable and slightly reducing precision scores in the subsequent spike sorting task. This effect is reflected in the decreased silhouette scores observed after applying DAE. Moreover, for in-distribution (ID) test datasets such as the IBL test dataset, the use of DAE may distort the original data distribution, resulting in increased distance to the IBL training dataset along with lower ARI. This suggests that while DAE effectively aligns OOD data, it may negatively impact performance when applied to data already well-aligned with the training distribution. Therefore, when processing a new dataset, one may first examine the data distribution with and without the DAE to assess its impact on the alignment of the data. Conclusion In HuiduRep, the view generation strategy not only produces augmented views that preserve semantic invariance but also maintains genuine physiological significance. This strategy simulates the jitters occurring during the firing process of real neural signals, as well as the overlapping and interference between signals from different neurons. In essence, it models the natural variability present in real neural recordings. Thus, the view generation strategy encourages the model to learn spike representations under more realistic conditions, enhancing its overall performance. Furthermore, DAE learns to reconstruct augmented inputs back onto the original spike waveforms. This component is also remarkably biologically intuitive: many cortical circuits effectively perform noise suppression and normalization. For example, computational models show that topographic recurrent networks in the cortex can amplify signal-to-noise by adjusting the excitation–inhibition balance ( Zajzon et al. 2023 ). In other words, cortex exhibits a denoising behavior that preserves stimulus features while suppressing irrelevant fluctuations. The DAE plays a similar role: it is trained to reconstruct a clean waveform from an augmented input. In our framework, this means that HuiduRep is encouraged to represent only the stable, informative representations, effectively filtering out the noise. Overall, HuiduRep demonstrates strong robustness in spike representation learning, outperforming state-of-the-art sorters across a wide range of datasets from distinct neural structures. By integrating contrastive learning with a denoising autoencoder, it maintains high performance under low SNR, electrode drift, and overlapping conditions. Its architecture draws inspiration from neuroscience, offering greater resilience to real-world variability than conventional methods. While HuiduRep is designed for extracellular recordings, the core methodology, self-supervised representation learning with physiologically inspired augmentations, can generalize to other bioelectrical signals such as EMG, ECoG, and EEG. These signals share similar challenges, including low SNR, temporal variability, and inter-subject drift. Future work may explore extending HuiduRep to a broader range of electrophysiological data as well as incorporating richer biological priors and integrating more advanced signal detection techniques to further improve generalization and interpretability. Funder Information Declared Beihang University, https://ror.org/00wk2mp56 , S202510006278 Footnotes kohaku{at}buaa.edu.cn , akatukifzs{at}bupt.edu.cn , shiweilab{at}buaa.edu.cn , jicongzhang{at}buaa.edu.cn Update corresponding author. No updates in paper. https://github.com/IgarashiAkatuki/HuiduRep References ↵ Banga , K. ; Boussard , J. ; Chapuis , G. A. ; Faulkner , M. ; Harris , K. D. ; Huntenburg , J. ; Hurwitz , C. ; Lee , H. D. ; Paninski , L. ; Rossant , C. ; et al. 2022 . Spike sorting pipeline for the International Brain Laboratory . ↵ Bod , R. B. ; Rokai , J. ; Meszéna , D. ; Fiáth , R. ; Ulbert , I. ; and Márton , G. 2022 . From End to End: Gaining, Sorting, and Employing High-Density Neural Single Unit Recordings . Frontiers in Neuroinformatics , Volume 16 - 2022. ↵ Brockhoff , M. ; Träuble , J. ; Middya , S. ; Fuchsberger , T. ; Fernandez-Villegas , A. ; Stephens , A. ; Robbins , M. ; Dai , W. ; Haider , B. ; Vora , S. ; Läubli , N. F. ; Kaminski , C. F. ; Malliaras , G. G. ; Paulsen , O. ; and Schierle , G. S. K. 2025 . PseudoSorter: A self-supervised spike sorting approach applied to reveal Tau-induced reductions in neuronal activity . Science Advances , 11 ( 11 ): eadr4155 . OpenUrl PubMed ↵ Buccino , A. P. ; Hurwitz , C. L. ; Garcia , S. ; Magland , J. ; Siegle , J. H. ; Hurwitz , R. ; and Hennig , M. H. 2020 . SpikeInterface, a unified framework for spike sorting . Elife , 9 : e61834 . OpenUrl CrossRef PubMed ↵ Chen , T. ; Kornblith , S. ; Norouzi , M. ; and Hinton , G. 2020 . A Simple Framework for Contrastive Learning of Visual Representations . arxiv: 2002.05709 . ↵ Chen , X. ; Xie , S. ; and He , K. 2021 . An Empirical Study of Training Self-Supervised Vision Transformers . arxiv: 2104.02057 . ↵ Chung , J. E. ; Magland , J. F. ; Barnett , A. H. ; Tolosa , V. M. ; Tooker , A. C. ; Lee , K. Y. ; Shah , K. G. ; Felix , S. H. ; Frank , L. M. ; and Greengard , L. F. 2017 . A fully automated approach to spike sorting . Neuron , 95 ( 6 ): 1381 – 1394 . OpenUrl CrossRef PubMed ↵ Dallal , A. H. ; Chen , Y. ; Weber , D. ; and Mao , Z.-H. 2016 . Dictionary learning for sparse representation and classification of neural spikes . In 2016 38th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC) , 3486 – 3489 . IEEE . ↵ Grill , J.-B. ; Strub , F. ; Altché , F. ; Tallec , C. ; Richemond , P. H. ; Buchatskaya , E. ; Doersch , C. ; Pires , B. A. ; Guo , Z. D. ; Azar , M. G. ; Piot , B. ; Kavukcuoglu , K. ; Munos , R. ; and Valko , M. 2020 . Bootstrap your own latent: A new approach to self-supervised Learning . arxiv: 2006.07733 . ↵ Guzman , E. ; Cheng , Z. ; Hansma , P. K. ; Tovar , K. R. ; Petzold , L. R. ; and Kosik , K. S. 2021 . Extracellular detection of neuronal coupling . Scientific Reports , 11 ( 1 ): 14733 . OpenUrl PubMed ↵ He , K. ; Zhang , X. ; Ren , S. ; and Sun , J. 2015 . Deep Residual Learning for Image Recognition . arxiv: 1512.03385 . Hilgen , G. ; Sorbaro , M. ; Pirmoradian , S. ; Muthmann , J.-O. ; Kepiro , I. E. ; Ullo , S. ; Ramirez , C. J. ; Puente Encinas , A. ; Maccione , A. ; Berdondini , L. ; Murino , V. ; Sona , D. ; Cella Zanacchi , F. ; Sernagor , E. ; and Hennig , M. H. 2017 . Unsupervised Spike Sorting for Large-Scale, High-Density Multielectrode Arrays . Cell Reports , 18 ( 10 ): 2521 – 2532 . OpenUrl PubMed Jun , J. ; and Magland , J. 2020 . IronClust: Terabytescale, drift-resistant spike sorter . https://github.com/flatironinstitute/ironclusts . Accessed: 2025-07-19 . Jun , J. J. ; Mitelut , C. ; Lai , C. ; Gratiy , S. L. ; Anastassiou , C. A. ; and Harris , T. D. 2017 . Real-time spike sorting plat-form for high-density extracellular probes with ground-truth validation and drift correction . bioRxiv . ↵ Kadir , S. N. ; Goodman , D. F. M. ; and Harris , K. D. 2013 . High-dimensional cluster analysis with the Masked EM Algorithm . arxiv: 1309.2848 . ↵ Laboratory , T. I. B. ; Aguillon-Rodriguez , V. ; Angelaki , D. ; Bayer , H. ; Bonacchi , N. ; Carandini , M. ; Cazettes , F. ; Chapuis , G. ; Churchland , A. K. ; Dan , Y. ; Dewitt , E. ; Faulkner , M. ; Forrest , H. ; Haetzel , L. ; Häusser , M. ; Hofer , S. B. ; Hu , F. ; Khanal , A. ; Krasniak , C. ; Laranjeira , I. ; Mainen , Z. F. ; Meijer , G. ; Miska , N. J. ; Mrsic-Flogel , T. D. ; Murakami , M. ; Noel , J.-P. ; Pan-Vazquez , A. ; Rossant , C. ; Sanders , J. ; Socha , K. ; Terry , R. ; Urai , A. E. ; Vergara , H. ; Wells , M. ; Wilson , C. J. ; Witten , I. B. ; Wool , L. E. ; and Zador , A. M. 2021 . Standardized and reproducible measurement of decision-making in mice . eLife , 10 : e63711 . OpenUrl CrossRef PubMed ↵ Loshchilov , I. ; and Hutter , F. 2019 . Decoupled Weight Decay Regularization . arxiv: 1711.05101 . Magland , J. 2022 . MountainSort 4: Spike sorting software . https://github.com/magland/mountainsort4 . Accessed: 2025-07-19 . Magland , J. 2024 . MountainSort 5: Spike sorting software . https://github.com/flatironinstitute/mountainsort5 . Accessed: 2025-07-19 . ↵ Magland , J. ; Jun , J. J. ; Lovero , E. ; Morley , A. J. ; Hurwitz , C. L. ; Buccino , A. P. ; Garcia , S. ; and Barnett , A. H. 2020 . SpikeForest, reproducible web-facing ground-truth validation of automated neural spike sorters . eLife , 9 : e55167 . OpenUrl CrossRef PubMed Pachitariu , M. ; Rossant , C. ; Steinmetz , N. ; Colonell , J. ; Winter , O. ; Bondy , A. G. ; Banga , K. ; Bhagat , J. ; Sosa , M. ; O’Shea , D. ; Nakamura , K. C. ; Contributors , G. L. ; Saxena , R. ; Liddell , A. ; Guzman , J. ; Botros , P. ; Denman , D. ; Karamanlis , D. ; and Beau , M. 2020 . MouseLand/Kilosort2: 2.0 final . https://github.com/MouseLand/Kilosort/releases/tag/ v2.0. Zenodo DOI: 10.5281/zenodo.4147288 ; Accessed: 2025-07-19 . OpenUrl CrossRef ↵ Pachitariu , M. ; Sridhar , S. ; Pennington , J. ; and Stringer , C. 2024 . Spike sorting with Kilosort4 . Nature methods , 21 ( 5 ): 914 – 921 . OpenUrl PubMed ↵ Pachitariu , M. ; Sridhar , S. ; and Stringer , C. 2023 . Solving the spike sorting problem with Kilosort . bioRxiv . Pachitariu , M. ; Steinmetz , N. ; Kadir , S. ; Carandini , M. ; and Kenneth D. , H. 2016 . Kilosort: realtime spike-sorting for extracellular electrophysiology with hundreds of channels . bioRxiv . ↵ Pedregosa , F. ; Varoquaux , G. ; Gramfort , A. ; Michel , V. ; Thirion , B. ; Grisel , O. ; Blondel , M. ; Müller , A. ; Nothman , J. ; Louppe , G. ; Prettenhofer , P. ; Weiss , R. ; Dubourg , V. ; Van-derplas , J. ; Passos , A. ; Cournapeau , D. ; Brucher , M. ; Perrot , M. ; and Édouard Duchesnay . 2018 . Scikit-learn: Machine Learning in Python . arxiv: 1201.0490 . ↵ Pinault , D. 1996 . A novel single-cell staining procedure performed in vivo under electrophysiological control: morpho-functional features of juxtacellularly labeled thalamic cells and other central neurons with biocytin or Neurobiotin . Journal of Neuroscience Methods , 65 ( 2 ): 113 – 136 . OpenUrl CrossRef PubMed Web of Science Pouzat , C. ; and Garcia , S. 2015 . Tridesclous: Offline/on-line spike sorting toolkit . https://github.com/tridesclous/ tridesclous. Accessed: 2025-07-19 . ↵ Rey , H. G. ; Pedreira , C. ; and Quian Quiroga , R. 2015 . Past, present and future of spike sorting techniques . Brain Research Bulletin , 119 : 106 – 117 . Advances in electrophysio-logical data analysis . OpenUrl CrossRef PubMed ↵ Souza , B. C. ; Lopes-dos Santos , V.; Bacelo , J. ; and Tort , A. B. 2019 . Spike sorting with Gaussian mixture models . Scientific reports , 9 ( 1 ): 3627 . OpenUrl PubMed ↵ Steinmetz , N. A. ; Aydin , C. ; Lebedeva , A. ; Okun , M. ; Pachitariu , M. ; Bauza , M. ; Beau , M. ; Bhagat , J. ; Böhm , C. ; Broux , M. ; Chen , S. ; Colonell , J. ; Gardner , R. J. ; Karsh , B. ; Kloosterman , F. ; Kostadinov , D. ; Mora-Lopez , C. ; O’Callaghan , J. ; Park , J. ; Putzeys , J. ; Sauerbrei , B. ; van Daal , R. J. J. ; Vol-lan , A. Z. ; Wang , S. ; Welkenhuysen , M. ; Ye , Z. ; Dudman , J. T. ; Dutta , B. ; Hantman , A. W. ; Harris , K. D. ; Lee , A. K. ; Moser , E. I. ; O’Keefe , J. ; Renart , A. ; Svoboda , K. ; Häusser , M. ; Haesler , S. ; Carandini , M. ; and Harris , T. D. 2021 . Neuropixels 2.0: A miniaturized high-density probe for stable, long-term brain recordings . Science , 372 ( 6539 ): eabf4588 . OpenUrl Abstract / FREE Full Text ↵ van den Oord , A. ; Li , Y. ; and Vinyals , O. 2019 . Representation Learning with Contrastive Predictive Coding . arxiv: 1807.03748 . ↵ Vaswani , A. ; Shazeer , N. ; Parmar , N. ; Uszkoreit , J. ; Jones , L. ; Gomez , A. N. ; Kaiser , L. ; and Polosukhin , I. 2023 . Attention Is All You Need . arxiv: 1706.03762 . ↵ Vincent , P. ; Larochelle , H. ; Bengio , Y. ; and Manzagol , P.-A. 2008 . Extracting and composing robust features with denoising autoencoders . In Proceedings of the 25th international conference on Machine learning , 1096 – 1103 . ↵ Oh , A. ; Naumann , T. ; Globerson , A. ; Saenko , K. ; Hardt , M. ; and Levine , S. Vishnubhotla , A. ; Loh , C. ; Srivastava , A. ; Paninski , L. ; and Hurwitz , C. 2023 . Towards robust and generalizable representations of extracellular data using contrastive learning . In Oh , A. ; Naumann , T. ; Globerson , A. ; Saenko , K. ; Hardt , M. ; and Levine , S. , eds., Advances in Neural Information Processing Systems , volume 36 , 42271 – 42284 . Curran Associates, Inc . OpenUrl ↵ Wu , Z. ; Xiong , Y. ; Yu , S. ; and Lin , D. 2018 . Unsupervised Feature Learning via Non-Parametric Instance-level Discrimination . arxiv: 1805.01978 . ↵ Yger , P. ; Spampinato , G. L. ; Esposito , E. ; Lefebvre , B. ; Deny , S. ; Gardella , C. ; Stimberg , M. ; Jetter , F. ; Zeck , G. ; Picaud , S. ; Duebel , J. ; and Marre , O. 2018 . A spike sorting toolbox for up to thousands of electrodes validated with ground truth recordings in vitro and in vivo . eLife , 7 : e34518 . OpenUrl CrossRef PubMed ↵ Zajzon , B. ; Dahmen , D. ; Morrison , A. ; and Duarte , R. 2023 . Signal denoising through topographic modularity of neural circuits . eLife , 12 : e77009 . OpenUrl PubMed ↵ Zhang , Y. ; Han , D. ; Wang , Y. ; Lv , Z. ; Gu , Y. ; and Li , D. 2025 . SimSort: A Data-Driven Framework for Spike Sorting by Large-Scale Electrophysiology Simulation . arxiv: 2502.03198 . View the discussion thread. Back to top Previous Next Posted August 02, 2025. Download PDF Data/Code Email Thank you for your interest in spreading the word about bioRxiv. NOTE: Your email address is requested solely to identify you as the sender of this article. Your Email * Your Name * Send To * Enter multiple addresses on separate lines or separate them with commas. You are going to email the following HuiduRep: A Robust Self-Supervised Framework for Learning Neural Representations from Extracellular Recordings Message Subject (Your Name) has forwarded a page to you from bioRxiv Message Body (Your Name) thought you would like to see this page from the bioRxiv website. Your Personal Message CAPTCHA This question is for testing whether or not you are a human visitor and to prevent automated spam submissions. Share HuiduRep: A Robust Self-Supervised Framework for Learning Neural Representations from Extracellular Recordings Feng Cao , Zishuo Feng , Wei Shi , Jicong Zhang bioRxiv 2025.07.22.666242; doi: https://doi.org/10.1101/2025.07.22.666242 Share This Article: Copy Citation Tools HuiduRep: A Robust Self-Supervised Framework for Learning Neural Representations from Extracellular Recordings Feng Cao , Zishuo Feng , Wei Shi , Jicong Zhang bioRxiv 2025.07.22.666242; doi: https://doi.org/10.1101/2025.07.22.666242 Citation Manager Formats BibTeX Bookends EasyBib EndNote (tagged) EndNote 8 (xml) Medlars Mendeley Papers RefWorks Tagged Ref Manager RIS Zotero Tweet Widget Facebook Like Google Plus One Subject Area Bioinformatics Subject Areas All Articles Animal Behavior and Cognition (7619) Biochemistry (17641) Bioengineering (13865) Bioinformatics (41860) Biophysics (21408) Cancer Biology (18545) Cell Biology (25434) Clinical Trials (138) Developmental Biology (13357) Ecology (19863) Epidemiology (2067) Evolutionary Biology (24288) Genetics (15587) Genomics (22466) Immunology (17701) Microbiology (40301) Molecular Biology (17142) Neuroscience (88441) Paleontology (666) Pathology (2825) Pharmacology and Toxicology (4814) Physiology (7633) Plant Biology (15108) Scientific Communication and Education (2042) Synthetic Biology (4285) Systems Biology (9811) Zoology (2268)
Text is read by the "Ask this paper" AI Q&A widget below.
Extraction quality varies by source — PMC NXML preserves structure
cleanly, OA-HTML may include some navigation residue, and OA-PDF can
have broken hyphenation. The publisher copy
(via DOI)
is the canonical version.