# Deep Learning-Based Template Matching Spike Classification for Extracellular Recordings
## 4 Discussion  
Detection and classification of action potentials from extracellular recording is essential for analysis of single neural signal activity. The template matching method is a classic spike sorting method that can resolve many of the issues that comes along with it. It classifies by measuring the similarities between each spike and the templates, and it shows high performance depending on the quality of extracted templates. We propose an unsupervised deep learning-based classification model that can learn spike waveforms without labels and classify each spike. Our model learned the characteristics of spike clusters by using the representative spikes of the cluster as the training data and showed superior classification performance compared to other template matching methods. Our proposed method showed higher classification accuracy in both simulation data and in-vivo data especially under high levels of noise. Because MSE and cross-correlation sums all the sampling points of a signal individually, it is susceptible to noise. This is apparent in both Simulation dataset 1 and Dataset 2. On Simulation dataset 1, our method showed the highest performance on the most challenging Difficult 2 with  
Figure 4: In-vivo result in the PCA feature domain. (**A**) PCA feature plot of in-vivo data (**B**) manually labeled data by expert (**C**) The result of our proposed method (**D**) The result of MSE-based template matching (**E**) The result of correlation-based template matching (**F**) The result of PCA + K-means. Figure 3: The results of four spike classification methods for simulation dataset 2.  
noise level of 0.20 data and had the least amount of performance drop with the addition of noise on simulation dataset 2 independent of cluster count. However, using a deep learning model does have higher computational cost compared to other machine learning algorithms. For our model, due to the simple structure of the model, the classification of 3526 spikes required approximately only 12 s.  
With increasing number of clusters, probability of similarly shaped waveforms appearing rises and the distance between each cluster in PCA feature domain may decrease, making spike classification more difficult. For Simulation dataset 2 without noise, although all methods showed high accuracy of above 99.8% when the cluster count was two, none were able to score over 97% when the cluster count rose to four. This, however, does not mean that classification accuracy always drops with increasing number of clusters. On Simulation dataset 2 with cluster count of five, all methods showed accuracy of above 98.5%. This shows that data with four clusters contained comparatively more challenging data for classification. The performance of the deep learning classification model heavily depends on the goodness of the training data. And because PCA + K-means clustered data, used as the pseudo-label for our model, is not a perfect clustering algorithm where error rates increase for data points near the cluster boundaries, increasing the amount of training data also increases the risk of using mislabeled training data. Moreover, the cluster centers chosen by the K-means clustering may fail to correctly find true cluster centers. As shown in Figure 5A, when oval shaped clusters are closely located to each other, the cluster centers may be positioned at the boundary of the clusters. In such cases, using large number of spikes for the training data increases the risk of using misclassified spikes as the training data even more. According to our results shown in Figure 5B, using 10% of the data nearest to the cluster centers as the training data showed the highest performance for such data. For well PCA + K-means clustered data, there were nearly no differences in the performance when more than 10% of the data was used for training. Therefore, our experiment was performed using 10% of data nearest to cluster centers for training.