Source Code - cSPIKE


cSPIKE-Logo

cSPIKE is an easy to use spike train analysis software. It is run on Matlab command line and it uses MEX files with C++ backends for speed. cSPIKE implements functions such as ISI-distance, SPIKE-distance, SPIKe synchronization and their adaptive variants as well as basic plot functions for plotting spike trains and profiles.

Note: The complementary directional method Spike Train Order (see arXiv) has been included. See below for examples

Download:

cSPIKE.zip

Installation:


cSPIKE allows easy incorporation as a part of a Matlab program. All you need to do is to extract the files into your project folder, build the MEX files and you are set.
If you need help with compiling the MEX files there are some links at the bottom of this page. The MEX files are located in cSPIKEmex folder and in order to run cSPIKE you need to include that folder into your work path. One option to do so is to call the script initializecSPIKE at the beginning of your program. After this your cSPIKE is ready to analyze. 

Using cSPIKE:

cSPIKE is built around the main class of SpikeTrainSet. The class requires your spike time data in the form of a cell array in which each cell is a series of spike times. Each array of spike times needs to be a double precision row vector. This cell array together with the recording start and end times form a SpikeTrainSet. You can create your SpikeTrainSet object as:

STS = SpikeTrainSet(MyCellArrayOfSpikes,recordingStartTime,recordingEndTime)

Once the spike train set object has been created you can start calling the methods. Here are few examples. A complete list can be found here. The example data used here can be found in the main folder of the cSPIKE.

We have three spike trains with 15 evenly distributed random spikes from 0 to 20 in cell matrix ExampleSet. To use cSPIKE we create a SpikeTrainSet with this information and initialize cSPIKE:

>> STS = SpikeTrainSet(ExampleSet,0,20);
>> InitializecSPIKE;


We can calculate the ISI-distance for the whole data set:

>> STS.ISIdistance()

ans =

    0.5264


ISI-distance from time 13 to time 15:

>> STS.ISIdistance(13,15)

ans =

    0.5417


Adaptive ISI-Distance from time 13 to time 15 with automated threshold:

>> STS.AdaptiveISIdistance(13,15)

ans =

    0.5285


And with threshold of 0.1:

>> STS.AdaptiveISIdistance(13,15,0.1)

ans =

    0.5417


cSPIKE also includes fast MEX files for calculating pairwise distance matrices where each index is a spike train number. Because the distances are symmetric, the matrix is symmetric as well:

>> STS.SPIKEdistanceMatrix()

ans =

         0    0.2626    0.3191
    0.2626         0    0.3101
    0.3191    0.3101         0


You can also call the methods for the SpikeTrainSet by giving a method the SpikeTrainSet as first parameter. The following calls are identical:

>> STS.SPIKEdistance();
>> SPIKEdistance(STS);


>> STS.ISIdistance(13,15)
>> ISIdistance(STS,13,15)

In addition to the distance measures, the SpikeTrainSet provides the profiles for the ISI- and SPIKE-distances. Once called, the method returns a Profile-object with three main methods. You can plot the profile to current axis with the optional colour and opacity(alpha) given:

>> Profile = STS.SPIKEdistanceProfile(13,15)

Profile.Plot(colour, alpha);

>> Profile.Plot();



ISI-profile

You can also get separately the X-values of the profile and the Y-values of the profile as double arrays:

>> Profile.PlotProfileX

ans =

  Columns 1 through 4

   13.0000   13.1020   13.1020   13.5941

  Columns 5 through 8

   13.5941   13.9815   13.9815   14.1873

  Columns 9 through 10

   14.1873   15.0000


>> Profile.PlotProfileY

ans =

  Columns 1 through 4

    0.4532    0.4535    0.4061    0.4012

  Columns 5 through 8

    0.3869    0.3183    0.4433    0.3685

  Columns 9 through 10

    0.3330    0.0566


These are vectors of equal length with each index corresponding a point in the graph.

The SpikeTrainSet can also plot the spike trains to current axis with optional colour and spike width
of your choise:

STS.plotSpikeTrainSet(colour, width)

>> STS.plotSpikeTrainSet()

SpikeTrains

Spike Train Order

The newly introduced method has been implemented in cSPIKE. The function call is very simple. In order to perfoem the basic analysis, the SpikeTrainSet is built as before. Then the analysis is called as

[initialIteration,optimalIteration,synf] = STS.SpikeTrainOrderWithSurrogates(numberOfSurrogates)

The optional parameter numberOfSurrogates lets you do the test based on a number of surrogates you want. The default value is 19 for 5% confidence.

The return values are two stuctures, where the output is stored and an array containing the F values of the surrogates. Please see the paper "Leaders and Followers: Quantifying consistency in spatio-temporal propagation patterns" for more details. Also the cSPIKE package contains an example for how to create an analysis using the structure in file SpikeTrainOrderExample.m. that produces the following figure.

Spike Train Order example

cSPIKE has more functionality that is not decribed here. Please refer to the documentation and papers for more information. Also you can see a short description of all the methods by:

>> help SpikeTrainSet



Compiling MEX files:

In order to build the MEX files and the C++ backends you need a C++ compiler in your Matlab. Here are few links that could help:

What you need to build MEX files
About compilers for Matlab R2016a

 Once you have your C++ compiler go to the folder cSPIKEmex and run the script MEX_compile. This will compile your MEX files and C++ backends in the folder. The process may take few minutes.

As a summary you need to:

1) Extract the cSPIKE to folder of your choise
2) Install a C++ compiler for your Matlab
3) Compile your MEX files and C++ backends
4) Add the folder cSPIKEmex to your work path
5) Get to cSPIKE main folder and create your first SpikeTrainSet


See also:

Measuring spike train synchrony I:   SPIKY (graphical user interface)

Graphical user interface (Matlab) which can be used to calculate and visualize both the SPIKE- and the ISI-distance between two (or more) spike trains. This is an extension and update of the code in II (there you also find the links to the relevant articles).

Measuring spike train synchrony III:   SPIKE- and ISI-Distance

Matlab codes to calculate both the SPIKE- and the ISI-distance between two (or more) spike trains

For a detailed description of the methods please refer to:

Kreuz T, Chicharro D, Houghton C, Andrzejak RG, Mormann F:
Monitoring spike train synchrony.
J Neurophysiol 109, 1457 (2013) [PDF].

Also submitted to the arXiv [PDF].

Kreuz T:
SPIKE-distance.
Scholarpedia
7(12), 30652 (2012).

Measuring spike train synchrony IV:   Event Synchronization

Matlab-Code to measure the event synchronization and the event delay between two given spike trains

For a detailed description of the method please refer to:

Quian Quiroga R, Kreuz T, and Grassberger P:
Event Synchronization: A simple and fast method to measure synchronicity and time delay patterns.
Phys.Rev. E 66, 041904 (2002) [PDF].

Measuring spike train synchrony V:   Directionality

Matlab code to calculate the directionality measure L between two given spike trains (or between two continuous datasets or between a spike train and a continuous dataset)

For a detailed description of the method please refer to:

Andrzejak RG, Kreuz T:
Characterizing unidirectional couplings between point processes and flows.
European Physics Letters 96, 50012 (2011) [PDF].

Measuring spike train synchrony VI:   van Rossum distance and multi-neuron extension

Matlab codes to calculate the spike train metric by van Rossum and the multi-neuron extension by Houghton and Sen.

For a detailed description of the method please refer to:

Houghton C, Kreuz T:
On the efficient calculation of van Rossum distances.
Network: Computation in Neural Systems 23, 48 (2012) [PDF].

Measuring spike train synchrony VII:  Victor-Purpura distance and multi-neuron extension

Matlab codes to calculate the spike train metric by Victor-Purpura and the multi-neuron extension by Victor-Purpura-Aronov.

(Homepage of Prof. Jonathan D. Victor, Cornell, NY, USA)

See also:

Matlab code for the Victor-Purpura distance which in addition calculates the percentage of spikes that have been matched by a time shift as well as the average time shift

For a detailed description of the algorithm please refer to:

Chicharro D, Kreuz T, Andrzejak RG:
What can spike train distances tell us about the neural code?
J Neurosci Methods 199, 146 (2011) [PDF].

 


For questions and comments please contact me at "eero.satuvuori (at) unifi.it".

 


These are some keywords to help people to find this page.

spike train analysis, measuring spike train synchrony, monitoring spike train synchrony, ISI-distance, SPIKE-distance, SPIKE-synchronization, Adaptive ISI-distance,Adaptive SPIKE-distance, Adaptive SPIKE-synchronization, open Matlab source codes, free download


Notices

FOR SCIENTIFIC USE ONLY

These codes are free of charge for research and education purposes only. Any commercial or military use of this software is prohibited.

The software on this site is provided "as-is," without any expressed or implied warranty. In no event am I or my host institution liable for any damages arising from the use of the software. Since it is distributed for free, I do also not take responsibility for any eventual error in it.

BSD license:

Copyright (c) 2016, Eero Satuvuori
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 


activate the plugin aktuelle Homepage