Abstract
We propose an automatic spike sorting approach for the data recorded from a microelectrode array during visual stimulation of wild type retinas with 25 spot stimuli. The approach first detects individual spikes per electrode by their signature local minima. With the mixture probability distribution of the local minima estimated afterwards, it applies a minimum-squared-error clustering algorithm to sort the spikes into different clusters. A template waveform for each cluster per electrode is defined, and a number of reliability tests are performed on it and its corresponding spikes. Finally, a divisive hierarchical clustering algorithm is used to deal with the correlated templates per cluster type across all the electrodes. According to the measures of performance of the spike sorting approach, it is very robust even in the cases of recordings with low signal-to-noise ratio.
I. Introduction
As the output layer of the retina, retinal ganglion cells (RGCs) connect in different neural structures that provide a broad repertoire of visual functions. These functions could be well understood by studying how burst activity of individual spikes from RGCs reflects various retina behaviors, such as adaptation to the mean light intensity and temporal contrast. To find the dynamics of individual spikes recorded from a neuronal substrate using extracellular recordings, the problem often exists to sort spikes into different neuronal units. This problem is dealt with by detecting discriminatory features from individual spikes and using those features to identify spatiotemporal similarity among a group of spikes, which is in turn distinctly assigned to a neuronal unit. In most cases this involves a variety of statistical inferences to sort spiking activity of the units and to assess the reliability of the spike sorting [1]-[6].
In a microelectrode array (MEA) system, the interference of spiking activity from individual units in the presence of noise may make the spikes morphology amorphous. This necessitates reliable data preparation and spike detection techniques. In addition, proposing effective similarity measures and basic representative signals to show the collective activity of spikes thereof would reduce the space and time complexities and computational overhead. For example, after detecting the putative spikes from a set of the raw data and clustering them, their template waveforms have been found as the basis to fit the rest of the raw data [1],[2],[4]. This derivation has been useful in resolving overlapping events in which neuronal units proximate to an electrode fire synchronously and the overlap is not representative of any unit activity. However, the clustering techniques in these studies either require user interventions in localizing spatiotemporally distinct regions of spiking activity or in verification of the clustering performance. This point outs the motivation for taking an approach that not only is capable of recovering individual spikes activity combined with noise, but also is implementable automatically with computing resources.
This work considers an MEA system recording raw electrophysiological data from a piece of mouse retina stimulated with alternating black and white spots at 25 tiled locations. Here we propose a clustering-based spike sorting approach that imposes no constraints on the distribution of spikes within each cluster, but gradually reveals such distribution by sorting spikes. The approach starts by finding the signature negative local minima from the filtered data for each electrode. The probability density function of such minima is found and appears to possess a multimodal mixture distribution. This raises the question of how many components (clusters) have originated the mixture distribution, and if there is any structural grouping in the local minima. As the core of spike sorting, an iterative minimum-squared-error clustering algorithm [7] is used for each electrode individually. We next represent collective spiking activity of neuronal units in each cluster per electrode by a template waveform. With the results of spike sorting, we run reliability tests on all the templates per electrode. Then, only for reliable templates, we examine whether templates per cluster type across all the electrodes are correlated. We apply a divisive hierarchical clustering, based on a graph-theoretic search, for this purpose [8],[9]. We assess the robustness of spike approach by calculating false-positive and false-negative errors occurred between the pairs of clusters per electrode [3],[4]. The performance metrics suggest that the spike sorting validation and reliability analysis in this work is effective. The herein approach is robust, automatic, considers measures for the correlation of neuronal spikes in an electrode and among electrodes (spatial), and sorts neuronal units emitting bursts of spikes. Next section provides an overview of the MEA system and our approach.
II. Data Structure and Approach Overview
This study focused on electrophysiological responses of wild type mouse RGCs to light stimulation. All mouse handling procedures during this study were approved by the National Eye Institute Animal Care and Use Committee (ACUC). The retina in vitro recording is performed with a standard MEA: 100 μm spacing, Multi Channel Systems Mcs GmbH. This MEA allows simultaneous light stimulation and recording of 60 electrodes. The layout of the MEA is configured to be a standard grid. We represent the discrete-time stochastic data in each electrode by xij (n), where i denotes column index, and j is row index. Henceforth, we refer to this as the raw data. Fig. 1 shows the arrangement of the grid and spatial distribution of 25 projected spot stimuli. In an experiment, at each spot location 10 repeats of 2 s white and 2 s black stimuli are presented on a gray background. A 1 s full field gray period separates each spot stimulus. A customized optical path then projects each spot onto the excised retina placed on the MEA.
Figure 1.

Spatial projections of 25 spots stimuli onto the microelectrode array with 60 electrodes identified by a two-digit index. First index refers to the column number, and the second one points to the row number. We refer to electrodes throughout by their index in the square box (x- and y- axes represent microns in retinal plane).
The block diagram of the spike sorting approach is shown in Fig. 2. The clustering approach finds the most reliable template waveforms representing individual neuronal units per electrode. The inter-electrode correlation per cluster type is dealt with on the reliable templates per cluster. Error assessment gives a measure of the quality of the approach.
Figure 2.

Block diagram synopsis of the stages of spike sorting approach implemented in this work per electrode. After initial filtering and spike detection, a clustering-based approach is applied for spike sorting. Extracted templates per cluster per electrode are tested for reliability. Final number of templates is found by characterizing their correlation across all electrodes. Performance is measured in terms of false-positive and false-negative errors.
II. Data Preparation
Recording at sampling rate of fs=25 kHz from lowimpedance electrodes yields a typically low signal-to-noise ratio (based on our analysis for the spot stimuli <6). In another context, when the dendrite-soma axes of the proximate cells are aligned, the signals from cells on an electrode overlay, and a compound fluctuating signal (local field potential) is generated. To ameliorate these existing physiological and bioelectrical constraints, respectively, the data preparation stage processes the raw data at two levels: (1) the periodogram estimate of power spectral density of the data was found; this estimate showed that low-frequency dominant range for local field potentials appeared to exist below 200 Hz, beyond which the power spectral density decreased notably. A zero phase-shift finite impulse response(FIR) high-pass filter with cutoff frequency of 200 Hz was defined to counter the baseline fluctuation caused by local field potentials, and (2) Eigendecomposition technique was applied. This technique has been a key tool in the theme of discrete-time linear filter theory. An FIR filter designed with the optimization criterion as maximizing the output signal-to-noise ratio is an eigenfilter [10]. The coefficient vector of the impulse response of such optimum FIR filter is the eigenvector corresponding to the largest eigenvalue of the sample correlation matrix of the input stochastic process. We denote the filtered data by in the following.
III. Spike Detection
Spike detection was based on finding the signature negative local minima of the filtered data. The result was discrete-time random signal, mij (k), where k is index of minima. Local minima detection finds the candidate spikes for each electrode individually. Such candidate spikes were clearly visually distinguishable from the minima detected due to noise fluctuations. We thus kept only minima from the candidate spikes, which differed from the average by more than two standard deviations. Fig. 3 shows a sample segment of raw data and filtered data for an electrode (i=3, j=5) on which all the characteristic local minima are shown. The demonstrations herein are all for spot 8 projection to the retina.
Figure 3.

An example of raw data for whole spot 8 stimulation and detected spikes shown on filtered data from electrode 35. (a) Raw data x35 tuned to spot 8 clock. (b) Detection of negative local minima on the filtered data in 6 s starting at 20 s. (c) Estimated density function of all the detected local minima shown as well as an interval of such minima, emphasized to show the multimodal nature of the distribution.
In order to infer effective statistics from this random minima distribution, we started by finding its underlying probability mass function. We used a kernel density estimator with a clipped Gaussian function [4]. The kernel width was set 0.05 times the interquartile range of the local minima. Fig. 3 shows the estimated density function of all the local minima for the same electrode. With the mixture, multimodal distribution of the local minima generated here, we searched for the techniques to reliably separate minima into different disjoint clusters. A possible idea is to find regions of high local density (modes) of the estimated density function and relate each one to an underlying cluster. This problem has been addressed for maxima signatures by adaptive template matching for the case of separating one prominent mode from the other modes due to noise and less prominent neuronal units [4].
IV. Spike Sorting
Model selection procedures for making inferences about mixture densities have been investigated extensively in the field of cluster analysis. In this field, mixture model-based clustering entails two parts: the component density selection, and estimating number of components. First, given the long-tailed, skewed distribution of the local minima at previous stage, a proper choice would be to use skew-normal or skew-t-mixture distribution. Specifically, if the true component distributions capture skewness and excess kurtosis, t-distribution provides a more robust model for fitting asymmetric mixture densities [11],[12]. Second, finding the number of components in a mixture density will be a key part of model selection procedures. Statistical methods such as log-likelihood ratio test statistics and Bayes factors may overestimate the number of components and are sensitive to sample size. It is suggested that the most appropriate model of the component distribution in a mixture would require considering several statistics in addition to pragmatic and theoretical considerations [11].
A. Minimum-Squared-Error Clustering
An alternative to the model-based clustering thus is chosen based on clustering by sum-of-squared-error criterion. The basic iterative minimum-squared-error clustering [7] algorithm was applied to the mixture density of the local minima found previously. To find an optimal partition as one that minimizes the criterion, the procedure starts from an initial set of clusters. For any sample point (local minimum), the algorithm first finds the closest cluster to it; then, it would reassign the point to another cluster if that reassignment further minimizes the criterion function. This algorithm requires careful choice of initial number of clusters together with their centers.
Instead of choosing random samples as the initial centers for a chosen number of clusters, we applied the basic leader- follower clustering algorithm [7] for this purpose. After initialization of the clusters centers, this algorithm finds the most similar cluster to any sample point (of a subset of local minima) on the minimum distance basis. If the distance measure is lower than a threshold θ; then, it updates the center of the chosen cluster by a learning rate η. If not, it creates a new cluster centered at that sample point. Reiterating for the total number of samples, it finally returns the total number of clusters and their centers. We chose θ to be a third of the distance between the largest mode peak's abscissa and the most negative local minima. The learning rate was defined as η=(0.4)h, where h is the iteration number. In addition, the algorithm was initialized with two centers for clusters. This was rationalized by inference from the mixture distribution of local minima for all of the electrodes. One center was set at the largest mode peak's abscissa, while the other was set to be greater than the most negative local minimum by a sixth of the distance between it and the largest mode peak's abscissa. With the initial learning phase for number of clusters and their centers given by the basic leader-follower clustering algorithm, the basic iterative minimum-squared-error clustering algorithm was poised to find clusters among the local minima [7]. After the assignment by the algorithm and due to the updating of the centers at the last step, we realized that centers of some clusters became close to each other. Therefore, we implemented a merging mechanism for such clusters. The metric was based on calculating the difference between the centers of each pair of clusters and checking if this value was less than a threshold for merging them. Fig. 4 demonstrates the result of spike sorting for the detected spikes on the sample electrode shown in Fig. 3b,c. There were initially three clusters generated by basic leader-follower clustering algorithm. The minimum-squared-error clustering, with merging addendum, resulted in two clusters, each of which integrates the spikes of the close temporal similarity.
Figure 4.

Results of the spike sorting approach for the same electrode and demonstrations in Fig. 3. (a) Three clusters are identified on the mixture distribution of minima based on the basic leader-follower clustering algorithm run on a subset of data. Highlighted interval of minima illustrates the level of minima, nearly − 8.6 μV, at which clusters 1 and 2 are separated. (b) Detected spikes are sorted into two different clusters shown by different markers. Note that the merging at the end of the minimum-squared-error clustering combined clusters 2 and 3 in (a). (c) Spike cutout (2.5 ms) overlay and generated template (bold) for each cluster (left: cluster 1 with 947 spikes, and right: cluster 2 with 34 spikes).
In order to test the reliability of our spike sorting algorithm, we represented all the spikes in one cluster per electrode by a template waveform. We first informed our definition of spike event. Each spike event in the filtered data was cast around the corresponding minimum for Ts = 2.5 ms in which the depolarization was set 1.15 ms and repolarization was set 1.35 ms. Therefore, each spike temporal cutout was represented by a vector of size ⎡f sT s⎤=63. Following this, a template waveform was defined as the point-wise median of all the spikes per cluster per electrode, denoted by , in which at this point the superscript c stands for the cluster index. Fig. 4 shows two templates, each of which generated from the corresponding spikes per cluster for the whole duration of recording (41.2 s) on the sample electrode. It is notable how the morphology of spikes and thus their corresponding template per cluster is distinguishable by the amplitudes.
B. Reliability Analysis
We assessed the robustness of the spike sorting through reliability analysis of the templates per electrode in three steps as follows. First, we found the distribution of interspike interval (ISI) individually for each cluster per electrode. Also, we defined a refractory period violation when the ISI is less than 2 ms. Thus, for all acceptable spikes per cluster per electrode there should not be any ISI laid below 2 ms. We checked for refractory violation, and, upon detecting one, we removed the two adjacent spikes for which the ISI was below 2 ms from the corresponding cluster. We also recorded the rate of violations per cluster per electrode that will be a metric in finding the false-positive error in overall performance assessment. Fig. 5a shows the ISI function for cluster 1 on Fig. 4. In the second step, inter-cluster (spike-time) cross-correlation function can be found for different pairs of clusters per electrode to check if spikes in each cluster have emitted from a unique neuronal unit [3]. For two independent clusters, this function should appear constant (no gap around the time lag of zero). We found this function for different pairs of clusters per electrode and inspected if there was any gap about zero in time lag between spike times of one cluster and those of all the spikes of the other. Fig. 5b displays this function for the two clusters found from electrode 35. There is no gap around time lag of zero. In the third step, we found the histogram of the amplitude scale factor between each spike amplitude and the corresponding template amplitude. This distribution has shown to be unimodal around unity for reliable templates [1]. A normal distribution centered at unity with standard deviation of amplitude scale factor was compared with the normalized histogram to assess the accuracy and variance thereof. Then, we run a test on the mean absolute error between the normalized histogram and the normal distribution. If the test outcome was significant at a level of 10% for the null hypothesis, then we excluded from the cluster the spikes for which the amplitude scale factors were less than a threshold. This refinement of the cluster was necessary only for a few electrodes.
Figure 5.

Reliability analysis and performance assessment of the spike sorting algorithm. (a) Histogram of the interspike interval for cluster 1 in electrode 35; the violation rate for this cluster with 947 spikes was 3.1%. The refractory period violation range (ISI<2 ms) is zoomed (bin width: 0.5 ms). (b) Cross-correlation function between the spike times for the two clusters (various firing rates) shown on Fig. 4 (bin width: 5ms). (c) Seven unique templates of spiking activity in cluster 1 in a gird of 3×3 centered around electrode 35 (see Fig. 1). Two dominant sets (first row, label 2, and third row, label 7) are categorized. (d) Total error against estimated SNR for four different stimuli measured in terms of false-positive and false-negative errors from the approach for cluster 1.
C. Resolving Correlated Templates
An aspect that circumscribes every robust spike sorting algorithm is finding correlated templates representing one neuronal unit whose spikes are spread among very few nearby electrodes. There is inferential evidence that correlated templates are similar in shape and their relevant receptive field. The maximum number of nearby templates with very similar shape has been found three on the basis of normalized cross-correlation greater than 0.9 [2]. In pursuit of an algorithm to detect correlated templates across all electrodes, we started this stage by speculating the geometrical relations between an electrode map and a graph. If an electrode map is perceived as an edge-weighted graph in this context, then the electrodes are the vertices, and, with edges representing similarity relations, then weights can be assigned to the edges. If we pursue to find the correlated templates with distinct similarities between them, then we would consider this as a search for a cluster that groups them together. Altogether, then, we can solve our problem by a graph-theoretic clustering algorithm that searches for certain correlated templates in a similarity graph. A divisive hierarchical clustering algorithm based on a graph-theoretic concept, that is, dominant set is delineated [8],[9]. Each dominant set corresponds to a unique cluster. which here unifies correlated templates. Formulization of the similarity matrix and other specifics for this algorithm will appear in another work. After the correlated templates per cluster had been found, we retrieved the first spike of the spike train recorded from the corresponding electrode for each of the correlated templates. Among all such first appeared spikes, the one that had the least latency was found. Its respective electrode then was selected as the electrode that represented all the electrodes having recorded the spiking activity of one neuronal unit. Figure 5c shows seven unique templates for spiking activity from nine electrodes centered at electrode 35.
V. Performance Assessment
We examined the total error of spike sorting against the raw data signal-to-noise (SNR) ratio for all spot stimuli. The noise process was estimated by removing all the spikes from the data (2.5 ms long). The analysis showed that noise is an approximately stationary and colored process. The cross-correlation function of noise showed that it is isotropic in x and y direction with a significant decay at minimum inter-electrode distance of 100 μm. Because here we estimated the noise signature based on the sorted spikes, the SNR will be as well an estimated SNR [4]. It can be defined as the difference between the sum of averaged variance of all spike types and the sample variance of estimated noise, divided by the sample variance of estimated noise. The total error for single-unit recording is defined in [4]. We extended this definition to the MEA system. The total error of spike sorting per cluster c per electrode ij was realized as the ratio . The false-positive error, false-negative error, and true-positive probability are represented by , , and , respectively. The false- positive error for each cluster per electrode is defined to be the maximum of single- cluster error and the multiple-cluster errors [3]. The single-cluster error is the ISI violation rate, whereas the multiple-cluster errors factor in the probability that overlap between a cluster and the others has made a false positive. Between each pair of clusters this probability was calculated by fitting a multivariate normal distribution to the spikes in each of the clusters [3]. Aside from this, the false-negative error for each cluster per electrode is calculated by combining the terms of the single-cluster error and multiple-cluster errors. In [3] an amplitude threshold detection technique is used for spike sorting, and the single-cluster error is formed based on that. The multiple-cluster errors deal with the overlap between pairs of clusters by expressing the errors in terms of the probability that a sample spike from one cluster is misassigned to another cluster. In addition, the true-positive probability is calculated by finding the probability that spikes in a cluster indeed belong to that cluster. We calculated this probability as well as fractional false-positive and false-negative errors for each cluster per electrode to find the corresponding total error. We found that the total error was dominated by false-positive error per cluster type across the electrodes. The false-negative error turned out to be very low. The algorithm performed optimally in the sense that it minimized the probability of false-negative errors. Fig. 5d shows the total error for cluster 1 as a function of the estimated SNR across all electrodes for four different stimuli. It can be seen that the total error remains quite low for the range of estimated SNR for these experiments. Initial number of clusters from the spike sorting ranged from 127 to 149 across all 25 spot stimuli. With the reliability tests passed and after dealing with correlated templates, the total number of clusters reduced to 68 to 85 (median: 78). Here the MEA recording area was 0.49 mm2, and, with an approximate density of mouse RGCs estimated from 4,000 to 8,000/mm2, there had been potentially from 1,960 to 3,920 individual cells to detect and characterize. With the median as representative of final number of cells found here it follows that our implementation revealed at most nearly 4% of the total number of cells. Retina excitation with more types of stimuli would increase this fraction.
Spike sorting is considered a classic of the era of spike frequency analysis in the cortex, thalamus, and hippocampus. A recent software suite (Klusta) is provided for spike sorting for spike sorting in dense electrode arrays [13]. The clustering program by appealing to a heuristic masked expectation-maximization algorithm has been robust and resolved the temporally overlapping spikes. To run the Klusta one needs to assign a data file, a parameter file and a probe file as necessary. Here, for initial use of the Klusta, we included 10 s recording of the raw data for 32 electrodes in the data file. We configured the probe file to include 32 electrodes arranged in four rows starting from electrode 12 through electrode 85 (see Fig. 1). The adjacency graph in the probe file was changed so that the neighboring electrodes are connected crosswise and vertically. The parameter file remained unchanged. Klusta initiated the clustering with three clusters and through its dynamic merging and splitting it finished the process by rendering one cluster. There were 18,010 spikes detected from all the 32 electrodes. Sample spike stamps are shown for electrode 35 on the filtered data. We will compare our approach with Klusta for data mining and analytics in the full MEA.
Figure 6.

Detection and sorting of spikes for the electrode 35 run on the Klusta and shown on 1.8 s of the filtered data. ISI violation rate for 10 s data in this electrode was 2.67% among 562 spikes.
Footnotes
Research supported by the National Eye Institute.
References
- 1.Prentice JS, Homann J, Simmons KD, TkaČik G, Balasubramanian V, Nelson PC. Fast, scalable, Bayesian spike identification for multi-electrode arrays. PLoS ONE. 2011 Jul;6(7) doi: 10.1371/journal.pone.0019884. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 2.Marre O, et al. Mapping a complete neural population in the retina. J Neurosci. 2012 Oct;32(43):14859–73. doi: 10.1523/JNEUROSCI.0723-12.2012. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 3.Hill DN, Mehta SB, Kleinfeld D. Quality metrics to accompany spike sorting of extracellular signals. J Neurosci. 2011 Jun;31(24):8699–8705. doi: 10.1523/JNEUROSCI.0971-11.2011. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 4.Kim S, McNames J. Automatic spike detection based on adaptive template matching for extracellular neural recordings. J of Neurosci Methods. 2007;165(2):165–74. doi: 10.1016/j.jneumeth.2007.05.033. [DOI] [PubMed] [Google Scholar]
- 5.Harris K, Henze D, Csicsvari J, Hirase H, Buzsaki G. Accuracy of tetrode spike separation as determined by simultaneous intracellular and extracellular measurements. J Neurophys. 2000;84(1):401–14. doi: 10.1152/jn.2000.84.1.401. [DOI] [PubMed] [Google Scholar]
- 6.Franke F, Quian Quiroga R, Hierlemann A, Obermayer K. Bayes optimal template matching for spike sorting – combining fisher discriminant analysis with optimal filtering. J of Computational Neurosc. 2015;38(3):439–459. doi: 10.1007/s10827-015-0547-7. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 7.Duda R, Hart P, Stork D. Pattern Classification. New York: John Wiley and Sons; 2000. ch. 10. [Google Scholar]
- 8.Pavan M, Pelillo M. Dominant Sets and Pairwise Clustering. IEEE Transactions on Pattern Analysis and Machine Intelligence. 2007 Jan;29(no.1):167–172. doi: 10.1109/tpami.2007.250608. [DOI] [PubMed] [Google Scholar]
- 9.Pavan M, Pelillo M. Dominant sets and hierarchical clustering. Proc 9th IEEE Int Conf on Computer Vision; Nice, France. 2003. pp. 362–369. [Google Scholar]
- 10.Makhoul J. On the eigenvectors of symmetric Toeplitz matrices. IEEE Trans Acoust Speech Signal Process. 1981;ASSP-29:868–872. [Google Scholar]
- 11.Everitt BS, Landau S, Leese M. Cluster Analysis. Hoboken: NJ: John Wiley & Sons; 2010. ch. 6. [Google Scholar]
- 12.McLachlan GJ, Bean RW, Jones LB. A simple implementation of a normal mixture approach to differential gene expression in multiclass microarrays. Bioinformatics. 2006;22(13):1608–15. doi: 10.1093/bioinformatics/btl148. [DOI] [PubMed] [Google Scholar]
- 13.Rossant C, et al. Spike sorting for large, dense electrode arrays. Nature Neuroscience. 2016;19:634–641. doi: 10.1038/nn.4268. [DOI] [PMC free article] [PubMed] [Google Scholar]
