### Source Code - cSPIKE - Documentation

# cSPIKE v 1.0 29.9.2016: Eero Satuvuori

This is the main part of cSPIKE. The object offers the basic functionality of graphical user interface SPIKY as a command line version. The main functions are implemented with MEX files and C++ backends. Methods are based on the ISI-distance, the SPIKE-distance and the SPIKE-synchronization by Thomas Kreuz et al. The class contains data and methods for storing spike trains as a single set as well as calculating the different distance measures.

*** Important ***

Before you use the cSPIKE for the very first time on a computer you

need to compile the MEX and C++ backends. To do so go to folder

cSPIKEmex and run script MEX_compile.m. This may take few minutes.

Every time you call for MEX files(most functions of the SpikeTrainSet

use them) the folder in which they are located need to be in your

Matlab workspace. InitializecSPIKE-script will add it to your path. It

needs to be called once every time after starting Matlab and any

additional calls are not needed. This is not called by the SpikeTrainSet!

*****************

The SpikeTrainSet implements the following functions

To create a spike train set object call the constructor:

spiketrains: A cell array with SpikeTrains{1} containing an

array of spike times [spike1 spike2 ...spikeN] for the

first spike train and respectively for the other spike

trains. The object accepts only spike data aligned as row

vectors

beginning: The start time of the recording

endgin: The end time of the recording

STS = SpikeTrainSet(spiketrains, beginning, ending )

Then you can call methods for the spike train set:

time1: Start time of the analysis interval.

time2: End time of the analysis interval. If not given or if

time1 = time2 instantaneous dissimilarity value is given instead.

threshold: Threshold for the adaptive method. If not given the

threshold extracted from the data is used instead.

Profile: Profile object

STS.ISIdistance(time1, time2)

STS.ISIdistanceMatrix(time1, time2)

Profile = STS.ISIdistanceProfile(time1, time2)

STS.AdaptiveISIdistance(time1, time2, threshold)

STS.AdaptiveISIdistanceMatrix(time1, time2,threshold)

Profile = STS.AdaptiveISIdistanceProfile(time1, time2,threshold)

STS.SPIKEdistance(time1, time2)

STS.SPIKEdistanceMatrix(obj, time1, time2)

Profile = STS.SPIKEdistanceProfile(obj, time1, time2)

STS.AdaptiveSPIKEdistance(time1, time2, threshold)

STS.AdaptiveSPIKEdistanceMatrix(obj, time1, time2,threshold)

Profile = STS.AdaptiveSPIKEdistanceProfile(obj, time1, time2,threshold)

STS.RateIndependentSPIKEdistance(time1, time2)

STS.AdaptiveRateIndependentSPIKEdistance(time1, time2, threshold)

STS.SPIKEsynchro(time1,time2)

STS.AdaptiveSPIKEsynchro(time1,time2,threshold)

SPIKESM: Spike synchronization matrix

SPIKEOM: Spike order matrix

normSPIKEOM: normalized spike order matrix

[SPIKESM,SPIKEOM,normSPIKEOM]= STS.SPIKESynchroMatrix(time1, time2)

[SPIKESM,SPIKEOM,normSPIKEOM] = STS.AdaptiveSPIKESynchroMatrix(time1, time2, threshold)

synchro: a cell array identical to spike train set but instead of spike

times it contains SPIKE-synchronization values of each spike

Sorder: a cell array identical to spike train set but instead of spike

times it contains SPIKE-order values of each spike

STOrder: a cell array identical to spike train set but instead of spike

times it contains spike-train-order values of each spike

[synchro,Sorder,STOrder] = STS.SPIKEsynchroProfile(time1, time2)

[synchro,Sorder,STOrder] = STS.AdaptiveSPIKEsynchroProfile(time1, time2,threshold)

varargin: Each time moment is given as a separate parameter. Returns

the dissimilarity averaged over all time points.

STS.TriggeredISImatrix(varargin)

STS.TriggeredAdaptiveISImatrix(threshold, varargin)

STS.TriggeredSPIKEmatrix(varargin)

STS.TriggeredAdaptiveSPIKEmatrix(threshold, varargin)

varargin: Each pair of inputs defines a new interval over which the

distance is defined. A unique union of the intervals is

used when defining the intervals over which the average is

taken.

STS.AveragedISIdistanceMatrix(varargin)

STS.AveragedAdaptiveISIdistanceMatrix(threshold, varargin)

STS.AveragedSPIKEdistanceMatrix(varargin)

STS.AveragedAdaptiveSPIKEdistanceMatrix(threshold, varargin)

Auxiliary functions:

STS.SetData(spiketrains, beginning, ending )

Replaces the data in the object with new data

STS.giveDATA()

Gives the a copy of the data array of the object. Data{1} contains

the edge corrected data and Data{2} the original spikes.

STS.giveTHR()

Returns the threshold value obtained from the set

[time1,time2] = STS.giveTIMES()

Gives the beginning and the end of the recording

STS.plotSpikeTrainSet(colour,widith)

Plots the spike trains to current axis with colour and spike widith

given. Default colour is black.

## SpikeTrainSet contents

- Class for enclosing spiketrains into one class and handling the set.
- PRIVATE METHODS **************************************************
- Checking data availability
- Unique Union
- Checking that the DATA given is valid
- Cutting function
- Check input times
- Correct the DATA Edges
- Form pooled spiketrain of all spiketrains
- Time shift functions.
- PUBLIC METHODS ***************************************************
- Constructor
- Setting data
- ISI METHODS ----------------------------------------------------
- ISI-distance for interval/point
- Adaptive ISI-distance for interval/point
- ISI-distance/dissimilarity matrix
- Adaptive ISI-distance/dissimilarity matrix
- Triggered ISI-dissimilarity matrix
- Triggered Adaptive ISI-dissimilarity matrix
- Averaged ISI-distance matrix
- Averaged Adaptive ISI-distance matrix
- ISI-distance profile
- Adaptive ISI-distance profile
- SPIKE METHODS --------------------------------------------------
- SPIKE-distance for interval/point
- Adaptive SPIKE-distance for interval/point
- Rate independent SPIKE distance for interval/point
- Adaptive Rate independent SPIKE distance for interval/point
- SPIKE distance/dissimilarity matrix
- Adaptive SPIKE distance/dissimilarity matrix
- Triggered SPIKE-dissimilarity matrix
- Triggered Adaptive SPIKE-dissimilarity matrix
- Averaged SPIKE-distance matrix
- Averaged Adaptive SPIKE-distance matrix
- SPIKE-distance profile
- Adaptive SPIKE-distance profile
- SPIKE-Synchronization METHODS ----------------------------------
- SPIKE-Synchronization
- Adaptive SPIKE-synchronization
- SPIKE-synchronization profile
- Adaptive SPIKE-synchronization profile
- Surrogate test for Spike Train Order
- SPIKE-synchronization matrix
- Adaptive SPIKE-synchronization matrix
- Auxiliary functions --------------------------------------------
- Get function
- Threshold value extracted from the data
- Start and end of the data set
- Plotting function

# Profile v 1.0 29.9.2016: Eero Satuvuori

Object for storing the data and plotting ISI-profile and SPIKE-profile

The Profile object is created by the object SpikeTrainSet upon calling

for the ISI- and the SPIKE-distance based profiles.

Xvalues = PlotProfileX()

Returns the X-ticks of the profile as a vector

Yvalues = PlotProfileY()

Returns the Y-values of the profile that are matched to their

corresponding index values in the Xvalues.

Plot(obj,colour,alpha)

Plots the profile to the current axis with colour defined. Alpha is

the opacity of the profile. For 1 the profile is solid and for 0.1

almost transparent.

Published with MATLAB® R2015b

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].

**: 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

**: 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
VI: 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.