Source Code - cSPIKE

Matlab command line library

Description of the codes

cSPIKE v 1.5 30.6.2023: Eero Satuvuori, Thomas Kreuz

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 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 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 the script "MEX_compile.m". This may take a few minutes.

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

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

Matlab workspace. The "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!


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


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.RateIndependentSPIKEdistanceMatrix(obj, time1, time2)               ###

Profile = STS.RateIndependentSPIKEdistanceProfile(obj, time1, time2) ###

STS.AdaptiveRateIndependentSPIKEdistance(time1, time2, threshold)

STS.AdaptiveRateIndependentSPIKEdistanceMatrix(obj, time1, time2, threshold) ###

STS.AdaptiveRateIndependentSPIKEdistanceProfile(obj, time1, time2, threshold) ###



SPIKESM: Spike synchronization matrix

SPIKEOM: Spike order matrix

SPIKETOM: Spike train order matrix ####

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

[SPIKESM, SPIKEOM, SPIKETOM] = 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.TriggeredAdaptiveISImatrix(threshold, varargin)


STS.TriggeredAdaptiveSPIKEmatrix(threshold, varargin)

STS.TriggeredRateIndependentSPIKEmatrix(varargin) ####

STS.TriggeredAdaptiveRateIndependentSPIKEmatrix(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



STS.AveragedAdaptiveISIdistanceMatrix(threshold, varargin)


STS.AveragedAdaptiveSPIKEdistanceMatrix(threshold, varargin)

STS.AveragedRateIndependentSPIKEdistanceMatrix(varargin) ####

STS.AveragedAdaptiveRateIndependentSPIKEdistanceMatrix(threshold, varargin) ####

Auxiliary functions:

STS.SetData(spiketrains, beginning, ending )

   Replaces the data in the object with new data


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

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


   Returns the threshold value obtained from the set

[time1,time2] = STS.giveTIMES()

   Gives the beginning and the end of the recording


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

   given. Default colour is black.

SpikeTrainSet contents

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.


   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