Template matching in manual spike sorting

When sorting spikes, it is pretty common to find a bunch of nice example waveforms for a unit, but it is often tricky to find good features that cleanly separate these waveforms from the rest. For this reason, many clustering packages can compute some distance metric between an example and the other waveforms. This is usually known as ‘template matching’.

Got some examples, but no good features to separate the cluster.

Got some examples, but no good features to separate the cluster. (PCA doesn’t work well either in this example)

Template matching is a clear application for some simple supervised learning: train some classifier on the waveforms throw the predictions into a new feature, done.

With a reasonably low spike threshold I get candidate events in at around 100-500Hz. In a few hours of recording time, that makes  1-4 million candidate spikes, with 64 to 128 samples each, so we’re dealing with ~500Mb. Not too bad, but when computing a new feature in the middle of manual sorting, we don’t want to wait more than a few seconds, so most of the usual methods are out of the game.

Luckily, a simple linear regression works pretty well for this, especially when the user can throw out obvious spikes from other clusters etc. before running a regression only on the remaining ambiguous data.

Simple regression feature - separation is not great, but could be usable.

Simple regression feature – separation is not great, but could be usable.

This feature is available in simpleclust, just turn off visibility on all clusters that should be ignored in the regression, put as many examples as possible in a new cluster, click the ‘+’ icon on the cluster and select ‘regression feature’.  Happy sorting!

If you want to play with this feature, or add some fast classifier code, grab simpleclust on github, and check line ~150 in sc_parse_clickonwaveforms.m for an example.

This entry was posted in Data analysis, Matlab, Technical things. Bookmark the permalink.

Comments are closed.