Spikedetekt

View the Project on GitHub klusta-team/spikedetekt

SpikeDetekt

This is a program for spike detection, that is optimized for high-channel count silicon probes.

This software was developed at the Cortical Processing Laboratory at UCL.

Please send feedback to Kenneth Harris (firstname at cortexlab.net), Shabnam Kadir (firstname at cortexlab.net)

Subscribe to our googlegroups by sending an email to: klustaviewas+subscribe 'at' googlegroups.com

Here is a quick Start Guide (will become more comprehensive with time):

0) Installation:

SpikeDetekt is written in Python and should work on any OS. To install it, make sure you first have Python on your computer.

We recommend you use Python 2.6 or 2.7 (don't use python 3.X!). A free academic distribution can be obtained from Enthought Python.

SpikeDetekt requires the following Python packages to be installed:

Once you have set up Python on your system, download and unzip/tar either the .zip file or the tarball, go to the `spikedetekt' folder and type (on the command line):

python setup.py install

In the above, 'python' is the necessary command on your system for calling python. The file 'setup.py' is to be found in the unzipped folder spikedetekt.

This will install SpikeDetekt.

1) Usage:

To perform spike detection, you need:

The .dat file is a flat file of two byte signed integers, in the order [Time1Channel1, Time1Channel2, .. Time1ChannelN, Time2Channel1, ...]

The above may have any combination of names. The name of your .params file will be the name of the folder where all the output will be stored. The simplest case is when you have the same name for all three files:

myexperiment.dat
myexperiment.probe
myexperiment.params

This will result in output files contained in a folder with the local name: myexperiment.

2) Probefiles:

The probe file is a text file that contains information about the spatial arrangement of electrodes on the recording probe. SpikeDetekt needs this information because it detects spikes on high-count probes as spatiotemporally continuous threshold crossings.

The probe file must contain an "adjancy graph", the specifies all pairs of channels that are nearest neighbors. (Sometimes you will want to also include second-nearest neighbors in the graph too).

This information is presented in the following form:

probes = {
    1: [
        (0, 1), (0, 2),
        (1, 2), (1, 3),
        ...
        ],
    2: [
       (13,15),(13,14),...
        ],

    shank number: [neighbouring channel pairs
        ],
    ...
    }

The probe file is actually formatted as a python command defining dictionary variable probes, with one key for each shank number, and values a list of neighboring channel pairs on that shank. If you don't know Python, don't worry, just think of it as a text file with the above format.

As a more concrete example, for the following 32 channel zig-zag probe the adjacency graph is defined by the black lines:

If there are odd channels on one edge, even channels on the other, the .probe file corresponding to the above probe would like something this:

probes = {
    # Probe 1
    1:[
        (0, 1), (0, 2),
        (1, 2), (1, 3),
        (2, 3), (2, 4),
        (3, 4), (3, 5),
        (4, 5), (4, 6),
        (5, 6), (5, 7),
        (6, 7), (6, 8),
        (7, 8), (7, 9),
        (8, 9), (8, 10),
        (9, 10), (9, 11),
        (10, 11), (10, 12),
        (11, 12), (11, 13),
        (12, 13), (12, 14),
        (13, 14), (13, 15),
        (14, 15), (14, 16),
        (15, 16), (15, 17),
        (16, 17), (16, 18),
        (17, 18), (17, 19),
        (18, 19), (18, 20),
        (19, 20), (19, 21),
        (20, 21), (20, 22),
        (21, 22), (21, 23),
        (22, 23), (22, 24),
        (23, 24), (23, 25),
        (24, 25), (24, 26),
        (25, 26), (25, 27),
        (26, 27), (26, 28),
        (27, 28), (27, 29),
        (28, 29), (28, 30),
        (29, 30), (29, 31),
        (30, 31),
        ]
    }

Further examples of probe files can be found in the distribution:

3) Parameters to adjust

The parameter file (with a name something like myexperiment.params) contains further information about how to detect spikes. The following parameters, specifying the probe file name, the raw data files, number of recording channels and sample rate, are compulsory:

RAW_DATA_FILES = ['file1.dat', 'file2.dat','file3.dat']
SAMPLERATE = 20000 # in Hertz
NCHANNELS = 32
PROBE_FILE = 'probe_filename.probe'

Note that you can specify an ordered list of .dat files, which will be concatenated before spikes are detected.

There are also a lot of optional parameters. You should specify these in your parameter file if you want to override the default parameters, whose value appears in the file spikedetekt/spikedetekt/defaultparameters.py. Note that the parameter files are also python scripts, but again you don't need to worry about this, just think of them as text files. These parameters, and an explanation of what they do, can be found in the file defaultparameters.py.

4) Running

To run the program type the following into the command line:

python spikedetekt/scripts/detektspikes.py myexperiment.params

See below on how to configure your parameter file, myexperiment.params according to the specifics of your experimental setup.

5) Output

SpikeDetekt will output the following files for each shank, where n is the shank number:

In addition, the following file will also be output:

6) How to cite

If you have used KlustaKwik and/or SpikeDetekt for a scientific publication, please cite our preprint on the arxiv, 'High-dimensional cluster analysis with the Masked EM Algorithm' by Shabnam N. Kadir, Dan F.M. Goodman and Kenneth D. Harris:

http://arxiv.org/abs/1309.2848