Вы находитесь на странице: 1из 42

ABSTRACT

Action potentials, or spikes, from neurons can be recorded extracellularly with a

variety of microelectrodes. In cases where a single channel recording includes signals

from several neurons it is advantageous to sort the spikes according to size and shape in

order to better estimate the activity of each of the active neurons. Accomplishing this task

involves several subtasks including detection of events, alignment of waveforms,

classification, and, during initialization, learning the number of classes of events and the

rules for classification. Many algorithms have been proposed for these tasks.

An experimental protocol for measuring the performance of detection methods

using probabilistic measures is presented. The protocol reports type I and type II errors

in event detection and waveform classification. Colored Gaussian models of spike shape

and variability are employed for detection, permitting each spike assignment to be given

a confidence level; the errors between model and data probability density functions are

tested for significance.

The protocol is tested using artificial data sets consisting of real spikes which

have been distorted by filtered noise of varying amplitude. The goals of the project are to

provide experimenters with a set of standard statistically based metrics for describing

their data, and to propose a sorting system which uses the metric to improve performance.

iii
ACKNOWLEDGMENTS

Foremost, I would like to thank my advisor, Professor Bruce Wheeler, who not

only made my work possible but provided invaluable assistance and support during a

difficult period. I give special thanks to Harvey Wiggins and Alexandre Kirillov of

Plexon, Inc., for their continuing assistance with recourses and valuable intellectual input,

without which the project would not have been possible.

I want to thank the Department of Electrical and Computer Engineer for its

financial support. I greatly appreciate the attention of Professors Zhi-Pei Liang and

William Perkins, who assisted me in times of need, as well as Ricardo Uribe, who gave

me valuable teaching experience.

Finally, I thank my friends and colleagues Johnny Nam, John Chang, Kumar

Venkateswar, and Marc Kowalski, and my friend Alex d'Erizans for all their support

iv
TABLE OF CONTENTS

Page

1 Introduction.......................................................................................................................1

1.1 Challenges in Spike Sorting.......................................................................................1

1.2 Spike Sorting Framework..........................................................................................2

1.2.1 Detection.............................................................................................................3

1.2.2 Alignment............................................................................................................4

1.2.3 Classification.......................................................................................................5

1.3 Estimating Error Rates...............................................................................................6

1.4 Using Error Rate Estimation in a Knowledge-Based Sorter.....................................7

2 Algorithms........................................................................................................................9

2.1 Detection Techniques ................................................................................................9

2.1.1 Simple threshold.................................................................................................9

2.1.2 Hilbert signal and signal energy.........................................................................9

2.1.3 Principal component energy.............................................................................10

2.1.4 Matched filter, template error, and error-energy ratio.......................................12

2.2 Bayesian Classification with AutoClass..................................................................13

3 Experimental Methods....................................................................................................16

3.1 Dataset Construction................................................................................................16

3.1.1 Spike templates.................................................................................................16

3.1.2 Simulated background noise.............................................................................18

3.2 Detection Error and Evaluation...............................................................................18

3.3 SNR Estimation using AutoClass............................................................................20

v
4 Results and analysis........................................................................................................23

4.1 Comparison of Detection Methods..........................................................................23

4.2 Signal-to-Noise Ratio..............................................................................................24

4.3 Window Size............................................................................................................25

4.4 Dead Time Hazard...................................................................................................28

4.5 Error Rate Estimation..............................................................................................29

5 Conclusions.....................................................................................................................31

5.1 A Knowledge-Based Spike Sorting System.............................................................31

REFERENCES..........................................................................................................33

vi
LIST OF FIGURES

Figure Page

Figure 1.1 Spike Detection Basics.......................................................................................3

Figure 1.2 Default Detection Structure................................................................................4

Figure 1.3 Classification Example.......................................................................................6

Figure 1.4 Detection with Error Estimation........................................................................8

Figure 2.5 Hilbert Signal...................................................................................................10

Figure 2.6 Preprocessed Waveforms 1...............................................................................11

Figure 2.7 Preprocessed Waveforms 2...............................................................................14

Figure 3.8 Template Examples..........................................................................................17

Figure 3.9 Detection Events and Errors.............................................................................20

Figure 3.10 Example Receiver Operator Curves...............................................................21

Figure 4.11 Comparison of Detection Methods with ROCs..............................................23

Figure 4.12 Effect of SNR on ROCs for Several Techniques............................................25

Figure 4.13 Effect of Window Size on Signal Energy ROCs for Several SNRs...............26

Figure 4.14 Dead Time Hazard Illustration.......................................................................28

Figure 4.15 Effect of Dead Time on ROC for Simple Thresholding.................................29

Figure 4.16 Estimating SNR using Histogram of Peak Amplitudes..................................30

Figure 5.17 A Knowledge-Based Spike Sorting System...................................................32

vii
1 INTRODUCTION

The recording of action potentials, the fundamental signal of most neurons, is

critical to observing neural activity. Recordings can be made inside (intracellular) or

outside (extracellular) the cell body. The mechanics of making extracellular recordings

are significantly simpler than for intracellular recording, but this advantage comes at a

cost. The quality of extracellular recordings is far less reliable, making analysis far more

difficult. The analysis of extracellular action potential recording is commonly known as

spike sorting.

The complexity of spike waveforms makes building a general-purpose automatic

spike sorter a very difficult problem. Methods in use tend to work well under certain

conditions, but fail without warning when improperly applied. The overall goal of this

research is to build a spike sorter which can accurately report on its own performance and

maintain good performance under a wide variety of conditions. The immediate goal of

this thesis is to do the same for the first stage, the detection of spikes from extracellular

recordings.

1.1 Challenges in Spike Sorting

To an ideal first approximation, action potentials, or spikes, are unique,

unchanging signatures of the individual neurons, permitting them to be sorted

automatically by waveshape. However, action potentials are not nearly so well behaved

in practice. A recording can contain an unknown number of distinct action potential

types, from an unknown number of contributing neurons [1]. The action potentials are

short, discrete events dispersed in background noise with arrival times that are, in

1
general, not predictable. Spike shapes do change over time as electrodes may shift

position during recordings, and spikes may change shape due the state of the neuron

[2, 3]. In addition, spikes from different units may overlap.

Recordings always contain some noise. Equipment noise and nonspike activity

can be removed with linear filtering. However, in filtered recordings the activity of

background cells is also a significant source of noise. The spikes from more distant

neurons merge into a single nonstationary noise signal. Being derived from cell activity,

this noise is not generally separable in frequency from foreground spikes.

Nonetheless, under most conditions it is possible to reliably extract spikes from

recordings. The challenge is first to identify spikes from the background noise, then to

identify the number of distinct spike types, or classes, in the recording, and finally to

assign each spike to a class.

1.2 Spike Sorting Framework

Spike sorting is typically broken into three functional stages: detection, alignment

and classification. Detection is the process of identifying and extracting spikes from the

background noise. The extracted spikes are then aligned to improve the performance of

the classification, during which spikes are grouped into classes. The sorted spikes are

used for further analysis.

In parallel with the functional framework, spike sorting can be viewed as a problem

of feature extraction and decision-making. A sorter reduces the data to a set of important

features and then makes a decision based on these features.

2
1.2.1 Detection

The first stage of spike sorting separates spikes from the much larger stream of

background noise, thereby compressing the recording by keeping only relevant

information. The goal of detection is to maximize the identification of foreground spikes

and minimize the noise saved for further processing.

Figure 1.1 Spike Detection Basics

The primary distinguishing feature of foreground spikes is amplitude. Therefore,

the most common spike detection method is simple thresholding, which is the

identification of a foreground spike when the signal crosses the threshold amplitude.

Figure 1.1 illustrates the basic elements of spike detection, shown with spikes of three

distinct classes. The detection time is defined as the first sample following threshold

crossing, or the peak after threshold. The detection time, also known as the spike arrival

3
time, is added to the spike train record which locates spikes as discrete events only. The

extraction window is the number of samples before and after the detection time that are

saved for further processing. To ensure that a spike does not trigger multiple detections

there is a dead time following the detection time during which detection is not allowed.

More complex detection methods use this same strategy applied to preprocessed signals.

Detection methods that look for other, more complex, spike features can be

viewed as a preprocessing stage followed by a simple thresholding on the new signal, as

shown in Figure 1.2. This structure is adequate to represent most detection methods and

provides a common framework for comparing performance. The aim of preprocessing is

to increase the apparent signal-to-noise ratio by using prior knowledge of spike attributes.

Here two classes of preprocessing methods are investigated; the first assumes the spike

width is known, while the second uses pre-extracted spikes, or templates.

Method/Parameter
Selection

Spike Signal Preprocessing Thresholding Spike Segments

Figure 1.2 Default Detection Structure

1.2.2 Alignment

The spike segments produced by detection are pre-aligned to the detection point.

However, to improve classification performance, it may be advantageous to align the

4
spikes to a different feature. Alignment involves computing the new alignment point and

shifting each spike segment to align to that point.

1.2.3 Classification

The goal of classification is to discover the number of classes or groups within a

dataset, and to assign each member of the dataset to a class. In spike sorting, the dataset

is aligned spike segments, and classes represent distinctions relevant to the research;

spike classes are typically taken to represent the activity of different neurons.

Classification is typically performed on a reduced-dimension dataset. The full

dimensionality of the spike set is the number of samples in the detection extraction

window (e.g., 40 samples/dimensions). However, classification in the full dimension

space is often undesirable. The variation between spikes is typically captured in a few

dimensions [4]. Reducing dimensionality decreases the risk of over-fitting the data and

reduces the computation time.

Classification can be subdivided into several problems. The first is how to choose

features for dimensionality reduction. Features can be predetermined (e.g., spike

amplitudes, width, etc.) or discovered with principal component analysis, as in Figure

1.3. Another problem is to determine the number and properties of the classes

represented in the data; this a learning problem for which many techniques have been

studied. The final problem is how to assign each data point, a spike in this case, to a

class. Some classification techniques in use include k-means [5], neural networks [6, 7],

template matching, linear filtering [8, 9], and Bayesian methods [10, 11].

5
Spikes in Feature Space Classified Spikes
0 1000

­500 ­1000

Amplitude (mV) 
500 10 20 30 40
PC 2

­1000 0
­500
1000 10 20 30 40
­1500
0
­2000 ­1000
­2000 ­1500 ­1000 ­500 0 500 10 20 30 40
PC 1 Samples 

Figure 1.3 Classification Example

1.3 Estimating Error Rates

Knowing the quality of a sorted set of spike data is an important factor in further

analysis, and reliable error estimation is a necessary first step in improving the

performance of sorting software. Yet, sort quality often is unreported and there is no

standard for error estimation.

Estimating error rates is not a trivial task; if the location of spikes in the recording

were known, sorting would be unnecessary. Therefore, to make error estimation possible,

prior knowledge must be built into the system. This is done by generating a statistical

model relating key waveform and spike attributes to error rates; during the sort process

the statistical model will estimate error rates.

Reliable estimates can be made based on measurable dataset features, such as

signal-to-noise ratio, spike width, etc. Using a previously derived statistical model, error

rates will be reported based upon dataset features. This model is derived from testing

simulated data, designed to represent the variation seen in real spike recordings. The

6
model constitutes background knowledge, rather than specific knowledge. This can be

likened to imparting software with "experience."

1.4 Using Error Rate Estimation in a Knowledge-Based Sorter

Spike sorting techniques generally fall into two categories: feature clustering and

template matching [10]. However, the inherently complex and nonlinear nature of spike

data ensures that any static combination of traditional techniques will not produce the

best performance under all conditions. More general techniques that attempt to model the

recorded waveform directly in order to obtain a probabilistic description have been

proposed [10, 11]. These methods compute the conditional probabilities for each spike,

allowing optimal classifications in the Bayesian sense, but relying upon the accuracy of

the underlying probabilistic model, typically meaning that sufficient waveform variability

must be captured in an analytic form. However, the experimentally derived error rate

models for the traditional techniques make an alternative approach possible.

Rather than modeling the waveform directly, error rate prediction is used to

optimize performance by updating sorting techniques and parameters online. Using this

model, the detection structure in Figure 1.2, p. 4, becomes the structure in Figure 1.4;

here feature estimation is being done on the spike signal and extracted spike segments in

order to generate error rate estimates. Once reliable error estimates are available, the

quality of a spike sort can be judged and action can be taken by a user or software agent

to alter the method and/or parameters to improve the quality of the sort.

7
Statistical Model for
Error Rate Estimation

Feature Feature
Estimation Estimation
Method/Parameter
Selection

Spike Signal Preprocessing Thresholding Spike Segments

Figure 1.4 Detection with Error Estimation

8
2 ALGORITHMS

One advantage of the proposed knowledge-based system is modularity. The system

will work with all types of detection and classification algorithms. Here several detection

techniques are implemented in the MATLAB environment and tested to generate error

rate data.

2.1 Detection Techniques

2.1.1 Simple threshold

The simple thresholding technique is desirable because of its simplicity and

effectiveness at high SNR. When the signal crosses the threshold a spike is detected and

the adjacent points are saved for classification. The SNR is typically the dominant

feature of any dataset, so with a good estimate, the optimum amplitude at which to

threshold can be chosen to minimize the detection errors. Simple thresholding may not

always be sufficient when the SNR is low; therefore, methods depend on attributes other

than spike amplitude.

2.1.2 Hilbert signal and signal energy

Signal energy and Hilbert signal make use of knowledge of spike width, in

addition to amplitude, and are computationally efficient. The Hilbert signal is calculated

using an FIR Hilbert transform filter [12], Figure 2.5. Commonly used in demodulating

signals, the Hilbert transform is an efficient method for envelope detection [7]. Spikes in

the Hilbert signal,Figure 2.6 (b), are characterized by a single large peak, but were

observed to degrade quickly in the presence of noise compared to signal energy.

9
Delay x2
w(n) wH(n)
Hilbert
x2
Transform

Figure 2.5 Hilbert Signal

Signal energy is computed over a sliding widow whose length is set to ensure that

the energy of segments containing spikes is greater than the energy of background noise

segments. By averaging over multiple samples the energy signal is less sensitive to

noise. It is also expected that the optimum window length will be related to the average

spike width. Spikes falling in the energy signal, Figure 2.6(c), are characterized by a

large peak or plateau. Signal energy is given by

wE ( n ) = wn ⋅ wnT (2.1)

wn = [ w( n )  w( n + WL)] (2.2)
where wn is the spike segment of length WL starting at the nth sample.

2.1.3 Principal component energy

Many features, including complex or compound features, can be used in

detection. When previously extracted spikes are available, principal component analysis

will automatically find a feature set that can be used in detection. This is analogous to

generating a linear filter based on the templates [13]. Spikes in the principal component

energy signal, Figure 2.6(d), show up as multiple sharp peaks. The principal components

are calculated from the correlation matrix:

10
(a) Signal
1

0.5
Scaled Amplitude

­0.5

­1
4 5 6 7 8 9 10 11 12
 (b) Hilbert signal
1

0.8
Scaled Amplitude

0.6

0.4

0.2

0
4 5 6 7 8 9 10 11 12
(c) Signal energy
1

0.8
Scaled Amplitude

0.6

0.4

0.2

0
4 5 6 7 8 9 10 11 12
(d) Principal Component Energy
1

0.8
Scaled Amplitude

0.6

0.4

0.2

0
4 5 6 7 8 9 10 11 12
time (ms)

Figure 2.6 Preprocessed Waveforms 1

11
C S = SS T (2.3)
where S is the matrix of pre-extracted spike vectors and CS is the correlation matrix. Then

eigenvalues λi and eigenvectors xi of the correlation matrix are calculated [14]:

λi xi = xi C S (2.4)
The first two principal components, pc1,n and pc2,n, are calculated from the two most

significant eigenvalues, x1 and x2, and the signal segment wn:

[ pc
1,n [
pc2,n ] = wnT x1 wnT x2 ] (2.5)
And finally the principal component energy signal [13] is calculated with

w PC ( n ) = pc12,n + pc 22,n (2.6)


The principal components calculated in (2.5) are also used in classification as spike

features.

2.1.4 Matched filter, template error, and error-energy ratio

When templates are available, they can be used directly in detection. Templates

can be obtained from previous recordings, or during the early stages of the ongoing

recording. Templates can be used as matched filters, or the difference between the signal

and the templates can be computed.

Under good conditions, optimized matched filters are the optimal choice [15].

However, spike variability and noise will degrade matched filter performance in most

cases. In the matched filter signal, Figure 2.7(a), spikes appear as a variable number of

peaks, based on the spikes' shape. The matched filter signal is given by

12
m

∑ (T
i =1
i ⋅ wn )
2

(2.7)
w MF =
TL
where Ti, i = 1...m, are the m previously obtained templates.

Template error measures the difference between the signal and the templates. On

the template error signal, Figure 2.7(b), a spike becomes a tri-phasic pulse; the error

increases just before and after the template aligns with the spike, and goes to zero at the

alignment point. The template error signal is calculated by

m 
wTE = min
( wn − Ti ) ⋅ ( wn − Ti ) T 

i =1 
(2.8)
TL 
 
Error-energy ratio is the ratio of the template error signal to the energy signal

wER ( n ) = wTE ( n ) / wE ( n ) (2.9)


The resulting signal, Figure 2.7(c), is useful for detection because it has a sharper dip at

the alignment point compared to the template error signal.

2.2 Bayesian Classification with AutoClass

Every detection method requires some prior knowledge to operate optimally. The

knowledge can come from the user, or it can be gathered during the sorting process.

Extracting specific knowledge from the data that will improve sorting performance is a

classification problem. Here classification is done on the peak amplitudes of the

waveform to estimate the SNR. Peaks are defined as local maxima within a six-sample

window.

Bayesian classification is an unsupervised method that can extract the underlying

classes in a dataset. This is very useful in spike sorting where the number of classes is not

13
known, but is limited to a small number (<10), ensuring a reasonable computation time

[11]. In Bayesian classification the data are assumed to have been drawn from a

(a) Matched Filter
1
Scaled Amplitude

0.8

0.6

0.4

0.2

0
4 5 6 7 8 9 10 11 12
(b) Template Error
1
Scaled Amplitude

0.8

0.6

0.4

0.2

0
4 5 6 7 8 9 10 11 12

0
(c) Error­Energy Ratio
10
Scaled Amplitude

­2
10

­4
10
4 5 6 7 8 9 10 11 12
time (ms)

Figure 2.7 Preprocessed Waveforms 2

probability distribution; the classification algorithm assumes this distribution is a mixture

of fundamental distributions, e.g., Gaussian. Therefore, in addition to the data, the

algorithm requires knowledge of these distributions. The space of possible mixtures of

14
the distributions is searched to discover the mixture model most likely to have produced

the data.

The AutoClass algorithm [16] is used to fit a mixture of Gaussians to the peak

amplitude data. Classification is done assuming the data have been generated by a

mixture of 1-D Gaussians. The quality of the classification depends on the accuracy of

this assumption for the given data; assuming a Gaussian distribution of waveform and

spike features is a reasonable assumption [2]. Being limited to a mixture of 1-D

Gaussians, AutoClass returns the most likely distribution, reporting the number of

classes. There will be at least one largest class corresponding to the noise, followed by

one or more smaller classes per spike. The number and sizes of the classes depend on the

spikes.

15
3 EXPERIMENTAL METHODS

To generate error rate statistics a series of artificial datasets are constructed and

tested with several detection methods.

3.1 Dataset Construction

Artificially constructed datasets are used to derive error models. Artificial data has

several advantages. It is not labor intensive; real data must be manually sorted to create a

standard by which to judge errors, while artificial data is fully described during creation.

Artificial data can be constructed to the requirements of the experiment, while available

real data may not represent all variation of interest. The parameters to dataset generation

are the spike template (from the library) and the desired SNR. Detection is run on a

dataset with each technique, ranging over the technique's parameters. Error rate

information is generated by evaluating the results of each run.

3.1.1 Spike templates

Spikes, sourced from experimental recordings, are selected to create a template

library representing spike variation of interest. The library is then used to create an

artificial dataset to specification; Figure 3.8 shows four examples from the spike library.

The primary spike attribute is the number of phases, or peaks; Figure 3.8 shows examples

of triphasic, biphasic, and monophasic spikes. Spike phases are also differentiable in

width, from slow to fast, and in amplitude. Spike width is defined as the width at half-

maximum amplitude of the largest phase in the spike.

16
500 500

Amplitude (mV)
Amplitude (mV)
0 0

­500 ­500

­1000 ­1000
10 20 30 40 10 20 30 40
Samples Samples

500 500

Amplitude (mV)
Amplitude (mV)

0 0

­500 ­500

­1000 ­1000
10 20 30 40 10 20 30 40
Samples Samples

Figure 3.8 Template Examples

Artificial data for detection is constructed by inserting well-spaced templates and

adding simulated noise to every data point. All templates in the library are 40 samples

long and are stored as spline functions derived from the original spike samples. Each

simulated waveform consists of 5000 spikes. For each class, a spike train, consisting of a

sequential list of time stamps, is generated. Spike trains are constructed so that no two

spikes will overlap in the final dataset. The detection techniques investigated do not use

arrival time; therefore, spike arrival order is deterministic, with the spikes arriving at a set

interval determined by the template length. The exact arrival times are randomized by a

uniformly distributed shift, less than one sample period, to simulate arrival time jitter.

Using the spike trains and template splines, a noiseless waveform is generated, simulating

a single channel recording sampled at 40 kHz. Each spike is inserted in the waveform at

the time given in the spike train. Finally, background noise is added to the dataset.

17
3.1.2 Simulated background noise

Background noise is simulated using a filtered zero-mean Gaussian process, and

added to the templates. Real background noise is a nonstationary process [1], but

Gaussian noise is a reasonable approximation over average spike lengths. The spike

templates are assumed to be noise free. Background noise is added to create the desired

noise level. A random number for each sample is generated from a zero-mean Gaussian

distribution. Then the noise signal is filtered, using a second-order low-pass Butterworth

filter [12] with a cutoff frequency at 5 kHz to account for linear filtering of real data. The

signal-to-noise ratio is calculated using the mean amplitude of the largest peak (positive

or negative) in the spike segments and the root-mean-square value of the noise:

mean (max( peaks ( spikes )))


SNR = (3.10)
RMS ( background noise)
During data generation the noise is scaled by a multiplicative factor to yield the desired

SNR.

Simulating background noise with a stationary signal is a significant

simplification, but permissible for the evaluation of detection errors. The detection

methods investigated here operate only over short time intervals, in the range of a spike

width, during which the assumption of stationary background noise is acceptable. For

alignment and classification, which operate over the whole signal, the effects of

nonstationary background noise should be considered.

3.2 Detection Error and Evaluation

In order to create a standard model, it is important to precisely define detection

errors. The two basic errors are type I, missed spikes, and type II, false detections.

18
However, instances also occur where a spike is only partially extracted or where spikes

are accidentally detected. Figure 3.9 illustrates seven possible detection events. Errors

are defined based on these seven events. When a false detection occurs and there is little

or no overlap with an actual spike (events 1, 2, 6, 7), the result is clearly a false detection

and the actual spike may also have been missed. Detection occurs when the detection

point is within the actual spike period (events 4, 5). A spike extracted by chance (event

3) is better then a missed spike, but it does not reflect the accuracy of the method and is

not desirable; here a chance extraction is treated as a miss and false detection

The error definitions depend on the beginning and end points of the spikes. Where

a spike begins or ends is open for interpretation; however, with constructed data the

location of the actual spike is known. Therefore, the beginning of a spike is defended to

be the insertion point of the template, and the end point is the final point derived from the

template. For real data the spike endpoints are typically defined with respect to the

detection point or some other feature and should be chosen to make certain the detection

point is well within the extraction window.

The performance of a detection method is visualized using a family of receiver-

operator-curves (ROCs). The ROC curve, exemplified in Figure 3.10, shows the type I

errors plotted against the type II errors. Optimum performance is at the origin and each

point on a curve represents the result of a trial with a particular threshold; the threshold

decreases in amplitude from right to left. Each run through a detection method results in

a number of misses and false detections. In order to make performance comparisons

based on dataset or method parameters, multiple runs are averaged together. First, the

19
Detection Point
Extracted spike waveform
Actual Spike 1) No spike recovered,
triggered by noise
Result: 1 False Detection

2) Partial spike recovered,


triggered by noise
Result: 1 False Detection

3) Full spike recovered,


triggered by noise
Result: 1 Miss
1 False Detection
4) Full spike recovered,
triggered by spike
Result: 1 True Match

5) Partial spike recovered,


triggered by spike
Result: 1 Miss
1 False Detection

6) Partial spike recovered,


triggered by noise
Result: 1 Miss
1 False Detection

7) No spike recovered,
triggered by noise
Result: 1 Miss
1 False Detection

Figure 3.9 Detection Events and Errors

error results for each run are resampled by linearly interpolating the number of misses to

an exponentially spaced vector of false detection values. The resampled misses are then

averaged across the parameters of interest.

3.3 SNR Estimation using AutoClass

SNR estimation is done with a preliminary spike sort. First a type of detection is

run by constructing a histogram of peak amplitudes. Peaks are defined as local maxima

within a window of six samples. Each spike type in the waveform contributes a least one

20
Template 8, SNR = 3, Window Size = 10, Refractory Period = 0
250
SINGLE THRESHOLD 
SIGNAL ENERGY
HILBERT SPACE
PC ENERGY
200
MATCHED FILTER
TEMPLATE ERROR 
ERROR­ENERGY RATIO
% False Detections

150

100

50

0
0 5 10 15
% Misses 

Figure 3.10 Example Receiver Operator Curves

bump in the histogram, and the noise will cause the largest bump, centered near zero.

Then a classification is run on the peak values by fitting a mixture of Gaussian

distributions to the data, deriving the mean peak amplitude of each spike type and the

RMS value of the noise.

The popular Bayesian classification software AutoClass [16] is used to fit a mixture

of Gaussian distributions to the peak amplitude data. This unsupervised method

estimates the most probable classification based on the data and prior expectations.

When properly applied, AutoClass will not over-fit the data because the use of priors

automatically favors the simplest classification that explains the data. AutoClass works

by creating random classifications, subject to user constraints, as starting points in a

search for the most probable classification. AutoClass will find the most probable mean

21
peak values for each class of spikes present in the recoding. The algorithm is very

configurable [17], but for this application the program is simply set to look for

classifications generated by a mixture of conditionally independent one-dimensional

Gaussian distributions, and to first search distributions with 10 or fewer classes. The

assumption that the spikes follow a Gaussian distribution is reasonable [2]. The program

returns mean and variance for each Gaussian in the mixture, from which the mean peak

amplitudes of each spike type and noise RMS value are determined. The final result is an

estimated SNR value for each spike type present.

22
4 RESULTS AND ANALYSIS

4.1 Comparison of Detection Methods

In order to compare the performance of detection methods the results are averaged

across templates and ROCs are plotted for each method at several SNRs, Figure 4.11. At

high SNR, simple thresholding performs well; however, in high noise conditions

matched-filter, error-energy ratio, and signal energy perform better on average than

simple thresholding. These performance advantages are relatively modest but significant

enough

Figure 4.11 Comparison of Detection Methods with ROCs

23
to warrant the use of the methods when possible. Hilbert signal detection performed on

par with simple thresholding, while pc-energy and template error did not perform as well.

Encouragingly, the results also illustrated several important relationships

underscoring the predictive value of error estimation. The results confirmed

hypothesized effects of several parameters, including SNR and window size, on

performance; and a new effect, due to the dead time parameter, was discovered in the

results. These examples show that useful trends do occur in the error estimation model.

The advantage of using a statistical model, as opposed to a rule-based system, is that all

such trends are implicit within the model. The quality of the model is based only on the

data used to generate it.

4.2 Signal-to-Noise Ratio

The SNR has a dramatic detection performance. It is apparent that a lower SNR

should result in lower performance. Moreover, the results bear this prediction out; Figure

4.12 illustrates the effect of SNR on detection errors for the four best techniques. For

each technique, reasonable performance can be obtained down to approximately SNR of

four, below which the performance decreases rapidly. Detection in very noisy signals is a

difficult problem; at the lowest SNRs all the techniques are equally poor, suggesting that

more sophisticated methods should be investigated. The confirmation of the SNR effect

lends credence to the predictive ability of the model. It also underlines the importance of

SNR estimation to spike sorting.

24
Simple Thresholding Signal Energy
600 600
SNR =   2
SNR = 2.5
500 500 SNR =   3
SNR = 3.5
SNR =   4
SNR = 4.5

% False Detections
% False Detections

400 400
SNR =   5

300 300

200 200

100 100

0 0
0 10 20 30 40 50 0 10 20 30 40 50
% Misses % Misses

Matched Filter Error­Energy Ratio
600 600

500 500
% False Detections

% False Detections

400 400

300 300

200 200

100 100

0 0
0 10 20 30 40 50 0 10 20 30 40 50
% Misses % Misses

Figure 4.12 Effect of SNR on ROCs for Several Techniques

4.3 Window Size

The window size parameter has a significant effect on detection with signal energy.

If the window is too long, the energy of the noise segments will not be low enough in

25
comparison to the energy of the spikes. The results, shown for several SNRs in Figure

4.13, suggest that the widow width should be kept under 50% of the spike width; spike

SNR = 2 SNR = 3
100 100
25% Spike Width 
90 90 50% Spike Width 
75% Spike Width 
80 80 100% Spike Width
125% Spike Width
70 70
% False Detections

% False Detections
60 60

50 50

40 40

30 30

20 20

10 10

0 0
0 20 40 60 80 100 0 20 40 60 80 100
% Misses % Misses

SNR = 4 SNR = 5
100 100

90 90

80 80

70 70
% False Detections

% False Detections

60 60

50 50

40 40

30 30

20 20

10 10

0 0
0 20 40 60 80 100 0 20 40 60 80 100
% Misses % Misses

Figure 4.13 Effect of Window Size on Signal Energy ROCs for Several SNRs

width is defined as the width at half-maximum amplitude of the largest phase in the

spike. This illustrates the importance of properly setting method parameters; in many

cases signal energy detection will provide improved performance, but only if the window

26
size is correct. Interestingly, the Hilbert signal showed total insensitivity to window size,

further showing that the method provides no advantage over simple thresholding.

27
4.4 Dead Time Hazard

The dead time is used to reduce the chance of multiple detections on a single spike,

but it can also create a problem if used improperly. In the case of detection on noisy data,

one might lower the threshold into the noise range in an attempt to ensure that no spikes

are missed, at the cost of increased false detections. This scenario is illustrated in Figure

4.14, in which the threshold is set too low and detects noise just prior to a spike. The

dead time prevents detection of the actual spike causing a miss or a partial extraction.

The probability of these errors occurring increases as the threshold is lowed into the noise

range, and as the dead time is increased. This effect was discovered in the ROC curve,

Figure 4.15, which bends back for long dead times as the threshold is lowered. The

results also show that the dead time hazard is quite significant, suggesting that it should

always be considered during the detection process.

Figure 4.14 Dead Time Hazard Illustration

28
Effect of Dead Time on ROC for Simple Thresholding (Averaged Over Templates, SNR = 5)
250
0% Spike Width
25%           
25% Spike Width
50% Spike Width
50%           
200 75% Spike Width
75%           
100%          
100% Spike Width
125%          
125% Spike Width

% False Detections

Fa
150
lse 
De
tec
tio
ns 100

Decreasing Threshold
50

0
0 5 10 15 20 25 30 35 40 45 50
% Misses

Figure 4.15 Effect of Dead Time on ROC for Simple Thresholding

4.5 Error Rate Estimation

Figure 4.16 illustrates an example of how error rates can be estimated in practice.

AutoClass was run on a noisy waveform with one class of spike. A mixture of two

Gaussian distributions was fitted to the histogram of peak values for a spike recording.

The first distribution corresponds to the noise and has mean peak amplitude of –118 mV.

The second distribution, due to the spikes, has a mean-peak-amplitude of –613 mV.

Therefore, the estimated SNR approximately five. This information is then used to

estimate the error rates of the detection. Using the SNR estimate with the ROC curves

for several detection methods, the estimated optimum performance rate for each method

can be calculated.

29
Histogram of Peak Amplitudes 
4
log( number of peaks )

0
­1000 ­800 ­600 ­400 ­200 0 200 400
Peak Amplitudes (mV)

Average ROCs for Several Methods at SNR = 5 SINGLE THRESHOLD  
50 SIGNAL ENERGY     
HILBERT SPACE     
45 PC ENERGY         
MATCHED FILTER    
40 TEMPLATE ERROR    
ERROR­ENERGY RATIO
35
% False Detections

30

25

20

15

10

0
0 0.5 1 1.5 2 2.5 3 3.5 4
% Misses

Figure 4.16 Estimating SNR using Histogram of Peak Amplitudes

30
5 CONCLUSIONS

The work presented here has defined two goals and taken steps towards

implementation. The first goal to is to develop practical and reliable error estimation

models for use in experimental settings. A preliminary model for detection errors has

been developed and extending error estimation models to alignment and classification

errors is the next step. The error models should be flexible, to allow the addition of new

data, and reliable. The second goal is the implementation of a knowledge-based spike

sorting system which leverages error rate information.

5.1 A Knowledge-Based Spike Sorting System

The variability and complexity of extracellular spike recordings ensures that a

general purpose, automated spike sorter will itself require a degree of complexity. One

solution is to use inherently complex, and therefore difficult to design, models for spike

waveforms. The alternative is to build a composite system which makes use of simple

methods with an intelligent control structure.

The knowledge-based system shown in Figure 5.17 proposes a structure by which

error estimation will be used to interpret sort performance and make decisions. This

composite spike sorter will use background knowledge and exchange information

between stages, allowing the user or a software agent to make educated decisions and

alter the sort to best fit the data. The system has several advantages, the first of which is

modularity. In Figure 5.17 no specific methods are listed because any technique could be

adapted to work within the system. As the system is used and tested, error estimation

models

31
User

Spike Sorter

Filtered and Sampled


Waveform

Spike Detection Knowledge System

Compute
Recovered Spike Train Waveform Parameters
Unaligned Spike Segments

Waveform
Parameters
Alignment

Estimate Errors from


Aligned Spike Segments Parameters

Error Estimates

Classification:
Identification Choose Methods
Phase and Method Parameters

Sort Method’s
Spike Classes
Parameters

Classification:
Assignment Phase

Recovered
Classified Spikes

Figure 5.17 A Knowledge-Based Spike Sorting System

32
will be updated. Modularity also makes the system more manageable because while the

system as whole will become complex, the individual system components can remain

relatively simple. Alone, many of the simple techniques discussed here are not capable of

dealing with all the complexities of general spike sorting. However, as part of the

knowledge-based system, simple techniques can be updated over time allowing for

variability in the waveform; as a result the system as a whole will be able to handle

nonstationary data.

33
REFERENCES

34
1[] M. S. Lewicki, "A review of methods for spike sorting: The detection and classification of neural
action potential," Network-Computation in Neural Systems. vol. 9, pp. 53-78, November 1998.

2[] K. Harris, D. Henze, J. Csicsvari, H. Hirase, and G. Buzsaki, "Intracellular features predicted by
extracellular recordings in the hippocampus in vivo," J. Neurophysiology. vol. 84, pp. 390-400, July
2000.

3[] M. Fee, P. Mitra, and D. Kleinfeld, "Variability of extracellular spike waveform of cortical
neurons," J. Neurophysiology, vol. 76, pp. 3823-3833, December 1996.

4[] C. Therrien, Decision Estimation and Classification: An Introduction to Pattern Recognition and
Related Topics. New York: John Wiley & Sons, 1989.

5[] D. Stashuk and Y. Qu, "Adaptive motor unit action potential clustering using shape and temporal
information," Medical & Biological Engineering & Computing, vol. 34, pp. 41-49, January 1996.

6[] C. Christodoulou and C. Pattichis, "Unsupervised pattern recognition for the classification of EMG
signals," IEEE Trans. on Biomedical Engineering, vol. 46, no. 2, pp. 169-178, February 1999.

7[] L. Fang, "Multiple unit action potential sorting: Investigation of features, algorithms, and
parameters for a fully automated system," M.S. thesis, University of Illinois at Urbana-Champaign,
Urbana, IL, USA 1994.

8[] W. M. Roberts and D. K. Hartline, "Separation of multi-unit nerve impulse trains by a multi-channel
linear filter algorithm," Brain Research, vol. 94, pp.141-149, March 1975.

9[] S. N. Gozani and J. P. Miller, "Optimal discrimination and classification of neuronal action
potential waveforms from multiunit, multichannel recordings using software-based linear filters," IEEE
Trans. on Biomedical Engineering, vol. 31, no. 4, April 1994.

10[] M. S. Lewicki, "Bayesian modeling and classification of neural signals," Neural Computation, vol.
6, pp. 1005-1030. September 1994.

11[] M. Sahani, "Latent variable models for neuronal data analysis," Ph.D. dissertation, California
Institute of Technology, Pasadena, California, USA, 1999.

12[] The Mathworks Technical Staff, Signal Processing Toolbox User's Guide Version 4, The
Mathworks, Inc., 1998.
13[] B. Wheeler, "Automatic discrimination of signal units," in Methods for Neural Ensemble
Recordings, M. Nicolelis, Ed., Boca Raton: CRC Press, pp 62-77, 1999.

14[] S. Kachigan, Multivariate Statistical Analysis: A Conceptual Introduction. Second Ed., New York:
Radius Press, 1991.

15[] B. Wheeler and W. Heetderks, "A comparison of techniques for classification of multiple neural
signals," IEEE Trans. on Biomedical Engineering, vol. BME-29, pp.752-759, December 1982.

16[] P. Cheeseman, J. Stutz, "Bayesian classification (AutoClass): Theory and results" in Advances in
Knowledge Discovery and Data Mining, U. Fayyad, G. Piatetsky-Shapiro, P. Smyth, and R.
Uthurusamy, Eds., Cambridge: AAAI Press/MIT Press, 1996.

17[] Research Institute for Advanced Computer Science, Computational Sciences Division, NASA
Ames Research Center, "AutoClass C - General information," September 2000,
http://ic.arc.nasa.gov/ic/projects/bayes-group/autoclass/autoclass-c-program.html