pyspike package¶
Classes¶
SpikeTrain¶

class
pyspike.SpikeTrain.
SpikeTrain
(spike_times, edges, is_sorted=True)[source]¶ Bases:
object
Class representing spike trains for the PySpike Module.

__init__
(spike_times, edges, is_sorted=True)[source]¶ Constructs the SpikeTrain.
Parameters:  spike_times – ordered array of spike times.
 edges – The edges of the spike train. Given as a pair of floats (T0, T1) or a single float T1, where then T0=0 is assumed.
 is_sorted – If False, the spike times will sorted by np.sort.

copy
()[source]¶ Returns a copy of this spike train. Use this function if you want to create a real (deep) copy of this spike train. Simple assignment t2 = t1 does not create a copy of the spike train data, but a reference as numpy.array is used for storing the data.
Returns: SpikeTrain
copy of this spike train.

PieceWiseConstFunc¶

class
pyspike.PieceWiseConstFunc.
PieceWiseConstFunc
(x, y)[source]¶ Bases:
object
A class representing a piecewise constant function.

__init__
(x, y)[source]¶ Constructs the piecewise const function.
Parameters:  x – array of length N+1 defining the edges of the intervals of the pwc function.
 y – array of length N defining the function values at the intervals.

add
(f)[source]¶ Adds another PieceWiseConst function to this function. Note: only functions defined on the same interval can be summed.
Parameters: f – PieceWiseConstFunc
function to be added.Return type: None

almost_equal
(other, decimal=14)[source]¶ Checks if the function is equal to another function up to decimal precision.
Parameters: other – another PieceWiseConstFunc
Returns: True if the two functions are equal up to decimal decimals, False otherwise Return type: bool

avrg
(interval=None)[source]¶ Computes the average of the piecewise const function: \(a = 1/T \int_0^T f(x) dx\) where T is the length of the interval.
Parameters: interval (Pair, sequence of pairs, or None.) – averaging interval given as a pair of floats, a sequence of pairs for averaging multiple intervals, or None, if None the average over the whole function is computed. Returns: the average a. Return type: float

copy
()[source]¶ Returns a copy of itself
Return type: PieceWiseConstFunc

get_plottable_data
()[source]¶ Returns two arrays containing x and ycoordinates for immeditate plotting of the piecewise function.
Returns: (x_plot, y_plot) containing plottable data Return type: pair of np.array Example:
x, y = f.get_plottable_data() plt.plot(x, y, 'o', label="Piecewise const function")

PieceWiseLinFunc¶

class
pyspike.PieceWiseLinFunc.
PieceWiseLinFunc
(x, y1, y2)[source]¶ A class representing a piecewise linear function.

__init__
(x, y1, y2)[source]¶ Constructs the piecewise linear function.
Parameters:  x – array of length N+1 defining the edges of the intervals of the pwc function.
 y1 – array of length N defining the function values at the left of the intervals.
 y2 – array of length N defining the function values at the right of the intervals.

add
(f)[source]¶ Adds another PieceWiseLin function to this function. Note: only functions defined on the same interval can be summed.
Parameters: f – PieceWiseLinFunc
function to be added.Return type: None

almost_equal
(other, decimal=14)[source]¶ Checks if the function is equal to another function up to decimal precision.
Parameters: other – another PieceWiseLinFunc
Returns: True if the two functions are equal up to decimal decimals, False otherwise Return type: bool

avrg
(interval=None)[source]¶ Computes the average of the piecewise linear function: \(a = 1/T \int_0^T f(x) dx\) where T is the interval length.
Parameters: interval (Pair, sequence of pairs, or None.) – averaging interval given as a pair of floats, a sequence of pairs for averaging multiple intervals, or None, if None the average over the whole function is computed. Returns: the average a. Return type: float

copy
()[source]¶ Returns a copy of itself
Return type: PieceWiseLinFunc

get_plottable_data
()[source]¶ Returns two arrays containing x and ycoordinates for immeditate plotting of the piecewise function.
Returns: (x_plot, y_plot) containing plottable data Return type: pair of np.array Example:
x, y = f.get_plottable_data() plt.plot(x, y, 'o', label="Piecewise const function")

DiscreteFunc¶

class
pyspike.DiscreteFunc.
DiscreteFunc
(x, y, multiplicity)[source]¶ Bases:
object
A class representing values defined on a discrete set of points.

__init__
(x, y, multiplicity)[source]¶ Constructs the discrete function.
Parameters:  x – array of length N defining the points at which the values are defined.
 y – array of length N degining the values at the points x.
 multiplicity – array of length N defining the multiplicity of the values.

add
(f)[source]¶ Adds another DiscreteFunc function to this function. Note: only functions defined on the same interval can be summed.
Parameters: f – DiscreteFunc
function to be added.Return type: None

almost_equal
(other, decimal=14)[source]¶ Checks if the function is equal to another function up to decimal precision.
Parameters: other – another DiscreteFunc
Returns: True if the two functions are equal up to decimal decimals, False otherwise Return type: bool

avrg
(interval=None, normalize=True)[source]¶ Computes the average of the interval sequence: \(a = 1/N \sum f_n\) where N is the number of intervals.
Parameters: interval (Pair, sequence of pairs, or None.) – averaging interval given as a pair of floats, a sequence of pairs for averaging multiple intervals, or None, if None the average over the whole function is computed. Returns: the average a. Return type: float

copy
()[source]¶ Returns a copy of itself
Return type: DiscreteFunc

get_plottable_data
(averaging_window_size=0)[source]¶ Returns two arrays containing x and ycoordinates for plotting the interval sequence. The optional parameter averaging_window_size determines the size of an averaging window to smoothen the profile. If this value is 0, no averaging is performed.
Parameters: averaging_window_size – size of the averaging window, default=0. Returns: (x_plot, y_plot) containing plottable data Return type: pair of np.array Example:
x, y = f.get_plottable_data() plt.plot(x, y, 'o', label="Discrete function")

integral
(interval=None)[source]¶ Returns the integral over the given interval. For the discrete function, this amounts to two values: the sum over all values and the sum over all multiplicities.
Parameters: interval (Pair, sequence of pairs, or None.) – integration interval given as a pair of floats, or a sequence of pairs in case of multiple intervals, if None the integral over the whole function is computed. Returns: the summed values and the summed multiplicity Return type: pair of float


pyspike.DiscreteFunc.
average_profile
(profiles)[source]¶ Computes the average profile from the given ISI or SPIKEprofiles.
Parameters: profiles – list of PieceWiseConstFunc
orPieceWiseLinFunc
representing ISI or SPIKEprofiles to be averaged.Returns: the averages profile \(<S_{isi}>\) or \(<S_{spike}>\). Return type: PieceWiseConstFunc
orPieceWiseLinFunc
Functions¶
ISIdistance¶

pyspike.isi_distance.
isi_distance
(*args, **kwargs)[source]¶ Computes the ISIdistance \(D_I\) of the given spike trains. The isidistance is the integral over the isi distance profile \(I(t)\):
\[D_I = \int_{T_0}^{T_1} I(t) dt.\]In the multivariate case it is the integral over the multivariate ISIprofile, i.e. the average profile over all spike train pairs:
\[\begin{split}D_I = \int_0^T \frac{2}{N(N1)} \sum_{<i,j>} I^{i,j},\end{split}\]where the sum goes over all pairs <i,j>
Valid call structures:
isi_distance(st1, st2) # returns the bivariate distance isi_distance(st1, st2, st3) # multivariate distance of 3 spike trains spike_trains = [st1, st2, st3, st4] # list of spike trains isi_distance(spike_trains) # distance of the list of spike trains isi_distance(spike_trains, indices=[0, 1]) # use only the spike trains # given by the indices
Returns: The isidistance \(D_I\). Return type: double

pyspike.isi_distance.
isi_distance_bi
(spike_train1, spike_train2, interval=None)[source]¶ Specific function to compute the bivariate ISIdistance. This is a deprecated function and should not be called directly. Use
isi_distance()
to compute ISIdistances.Parameters:  spike_train1 (
SpikeTrain
) – First spike train.  spike_train2 (
SpikeTrain
) – Second spike train.  interval (Pair of floats or None.) – averaging interval given as a pair of floats (T0, T1), if None the average over the whole function is computed.
Returns: The isidistance \(D_I\).
Return type: double
 spike_train1 (

pyspike.isi_distance.
isi_distance_matrix
(spike_trains, indices=None, interval=None)[source]¶ Computes the time averaged isidistance of all pairs of spiketrains.
Parameters:  spike_trains – list of
SpikeTrain
 indices (list or None) – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
 interval (Pair of floats or None.) – averaging interval given as a pair of floats, if None the average over the whole function is computed.
Returns: 2D array with the pair wise time average isi distances \(D_{I}^{ij}\)
Return type: np.array
 spike_trains – list of

pyspike.isi_distance.
isi_distance_multi
(spike_trains, indices=None, interval=None)[source]¶ Specific function to compute the multivariate ISIdistance. This is a deprecfated function and should not be called directly. Use
isi_distance()
to compute ISIdistances.Parameters:  spike_trains – list of
SpikeTrain
 indices – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
 interval (Pair of floats or None.) – averaging interval given as a pair of floats, if None the average over the whole function is computed.
Returns: The timeaveraged multivariate ISI distance \(D_I\)
Return type: double
 spike_trains – list of

pyspike.isi_distance.
isi_profile
(*args, **kwargs)[source]¶ Computes the isidistance profile \(I(t)\) of the given spike trains. Returns the profile as a PieceWiseConstFunc object. The ISIvalues are defined positive \(I(t)>=0\).
Valid call structures:
isi_profile(st1, st2) # returns the bivariate profile isi_profile(st1, st2, st3) # multivariate profile of 3 spike trains spike_trains = [st1, st2, st3, st4] # list of spike trains isi_profile(spike_trains) # profile of the list of spike trains isi_profile(spike_trains, indices=[0, 1]) # use only the spike trains # given by the indices
The multivariate ISI distance profile for a set of spike trains is defined as the average ISIprofile of all pairs of spiketrains:
\[\begin{split}<I(t)> = \frac{2}{N(N1)} \sum_{<i,j>} I^{i,j},\end{split}\]where the sum goes over all pairs <i,j>
Returns: The isidistance profile \(I(t)\) Return type: PieceWiseConstFunc

pyspike.isi_distance.
isi_profile_bi
(spike_train1, spike_train2)[source]¶ Specific function to compute a bivariate ISIprofile. This is a deprecated function and should not be called directly. Use
isi_profile()
to compute ISIprofiles.Parameters:  spike_train1 (
SpikeTrain
) – First spike train.  spike_train2 (
SpikeTrain
) – Second spike train.
Returns: The isidistance profile \(I(t)\)
Return type:  spike_train1 (

pyspike.isi_distance.
isi_profile_multi
(spike_trains, indices=None)[source]¶ Specific function to compute the multivariate ISIprofile for a set of spike trains. This is a deprecated function and should not be called directly. Use
isi_profile()
to compute ISIprofiles.Parameters:  spike_trains – list of
SpikeTrain
 indices – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
Returns: The averaged isi profile \(<I(t)>\)
Return type:  spike_trains – list of
SPIKEdistance¶

pyspike.spike_distance.
spike_distance
(*args, **kwargs)[source]¶ Computes the SPIKEdistance \(D_S\) of the given spike trains. The spikedistance is the integral over the spike distance profile \(D(t)\):
\[D_S = \int_{T_0}^{T_1} S(t) dt.\]Valid call structures:
spike_distance(st1, st2) # returns the bivariate distance spike_distance(st1, st2, st3) # multivariate distance of 3 spike trains spike_trains = [st1, st2, st3, st4] # list of spike trains spike_distance(spike_trains) # distance of the list of spike trains spike_distance(spike_trains, indices=[0, 1]) # use only the spike trains # given by the indices
In the multivariate case, the spike distance is given as the integral over the multivariate profile, that is the average profile of all spike train pairs:
\[\begin{split}D_S = \int_0^T \frac{2}{N(N1)} \sum_{<i,j>} S^{i, j} dt\end{split}\]Returns: The spikedistance \(D_S\). Return type: double

pyspike.spike_distance.
spike_distance_bi
(spike_train1, spike_train2, interval=None)[source]¶ Specific function to compute a bivariate SPIKEdistance. This is a deprecated function and should not be called directly. Use
spike_distance()
to compute SPIKEdistances.Parameters:  spike_train1 (
SpikeTrain
) – First spike train.  spike_train2 (
SpikeTrain
) – Second spike train.  interval (Pair of floats or None.) – averaging interval given as a pair of floats (T0, T1), if None the average over the whole function is computed.
Returns: The spikedistance.
Return type: double
 spike_train1 (

pyspike.spike_distance.
spike_distance_matrix
(spike_trains, indices=None, interval=None)[source]¶ Computes the time averaged spikedistance of all pairs of spiketrains.
Parameters:  spike_trains – list of
SpikeTrain
 indices (list or None) – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
 interval (Pair of floats or None.) – averaging interval given as a pair of floats, if None the average over the whole function is computed.
Returns: 2D array with the pair wise time average spike distances \(D_S^{ij}\)
Return type: np.array
 spike_trains – list of

pyspike.spike_distance.
spike_distance_multi
(spike_trains, indices=None, interval=None)[source]¶ Specific function to compute a multivariate SPIKEdistance. This is a deprecated function and should not be called directly. Use
spike_distance()
to compute SPIKEdistances.Parameters:  spike_trains – list of
SpikeTrain
 indices (list or None) – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
 interval (Pair of floats or None.) – averaging interval given as a pair of floats, if None the average over the whole function is computed.
Returns: The averaged multivariate spike distance \(D_S\).
Return type: double
 spike_trains – list of

pyspike.spike_distance.
spike_profile
(*args, **kwargs)[source]¶ Computes the spikedistance profile \(S(t)\) of the given spike trains. Returns the profile as a PieceWiseConstLin object. The SPIKEvalues are defined positive \(S(t)>=0\).
Valid call structures:
spike_profile(st1, st2) # returns the bivariate profile spike_profile(st1, st2, st3) # multivariate profile of 3 spike trains spike_trains = [st1, st2, st3, st4] # list of spike trains spike_profile(spike_trains) # profile of the list of spike trains spike_profile(spike_trains, indices=[0, 1]) # use only the spike trains # given by the indices
The multivariate spikedistance profile is defined as the average of all pairs of spiketrains:
\[\begin{split}<S(t)> = \frac{2}{N(N1)} \sum_{<i,j>} S^{i, j}`,\end{split}\]where the sum goes over all pairs <i,j>
Returns: The spikedistance profile \(S(t)\) Return type: PieceWiseConstLin

pyspike.spike_distance.
spike_profile_bi
(spike_train1, spike_train2)[source]¶ Specific function to compute a bivariate SPIKEprofile. This is a deprecated function and should not be called directly. Use
spike_profile()
to compute SPIKEprofiles.Parameters:  spike_train1 (
SpikeTrain
) – First spike train.  spike_train2 (
SpikeTrain
) – Second spike train.
Returns: The spikedistance profile \(S(t)\).
Return type:  spike_train1 (

pyspike.spike_distance.
spike_profile_multi
(spike_trains, indices=None)[source]¶ Specific function to compute a multivariate SPIKEprofile. This is a deprecated function and should not be called directly. Use
spike_profile()
to compute SPIKEprofiles.Parameters:  spike_trains – list of
SpikeTrain
 indices (list or None) – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
Returns: The averaged spike profile \(<S>(t)\)
Return type:  spike_trains – list of
SPIKEsynchronization¶

pyspike.spike_sync.
filter_by_spike_sync
(spike_trains, threshold, indices=None, max_tau=None, return_removed_spikes=False)[source]¶ Removes the spikes with a multivariate spike_sync value below threshold.

pyspike.spike_sync.
spike_sync
(*args, **kwargs)[source]¶ Computes the spike synchronization value SYNC of the given spike trains. The spike synchronization value is the computed as the total number of coincidences divided by the total number of spikes:
\[SYNC = \sum_n C_n / N.\]Valid call structures:
spike_sync(st1, st2) # returns the bivariate spike synchronization spike_sync(st1, st2, st3) # multivariate result for 3 spike trains spike_trains = [st1, st2, st3, st4] # list of spike trains spike_sync(spike_trains) # spikesync of the list of spike trains spike_sync(spike_trains, indices=[0, 1]) # use only the spike trains # given by the indices
The multivariate SPIKESync is again defined as the overall ratio of all coincidence values divided by the total number of spikes.
Returns: The spike synchronization value. Return type: double

pyspike.spike_sync.
spike_sync_bi
(spike_train1, spike_train2, interval=None, max_tau=None)[source]¶ Specific function to compute a bivariate SPIKESync value. This is a deprecated function and should not be called directly. Use
spike_sync()
to compute SPIKESync values.Parameters:  spike_train1 (
pyspike.SpikeTrain
) – First spike train.  spike_train2 (
pyspike.SpikeTrain
) – Second spike train.  interval (Pair of floats or None.) – averaging interval given as a pair of floats (T0, T1), if None the average over the whole function is computed.
 max_tau – Maximum coincidence window size. If 0 or None, the coincidence window has no upper bound.
Returns: The spike synchronization value.
Return type: double
 spike_train1 (

pyspike.spike_sync.
spike_sync_matrix
(spike_trains, indices=None, interval=None, max_tau=None)[source]¶ Computes the overall spikesynchronization value of all pairs of spiketrains.
Parameters:  spike_trains – list of
pyspike.SpikeTrain
 indices (list or None) – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
 interval (Pair of floats or None.) – averaging interval given as a pair of floats, if None the average over the whole function is computed.
 max_tau – Maximum coincidence window size. If 0 or None, the coincidence window has no upper bound.
Returns: 2D array with the pair wise time spike synchronization values \(SYNC_{ij}\)
Return type: np.array
 spike_trains – list of

pyspike.spike_sync.
spike_sync_multi
(spike_trains, indices=None, interval=None, max_tau=None)[source]¶ Specific function to compute a multivariate SPIKESync value. This is a deprecated function and should not be called directly. Use
spike_sync()
to compute SPIKESync values.Parameters:  spike_trains – list of
pyspike.SpikeTrain
 indices (list or None) – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
 interval (Pair of floats or None.) – averaging interval given as a pair of floats, if None the average over the whole function is computed.
 max_tau – Maximum coincidence window size. If 0 or None, the coincidence window has no upper bound.
Returns: The multivariate spike synchronization value SYNC.
Return type: double
 spike_trains – list of

pyspike.spike_sync.
spike_sync_profile
(*args, **kwargs)[source]¶ Computes the spikesynchronization profile S_sync(t) of the given spike trains. Returns the profile as a DiscreteFunction object. In the bivariate case, he S_sync values are either 1 or 0, indicating the presence or absence of a coincidence. For multivariate cases, each spike in the set of spike trains, the profile is defined as the number of coincidences divided by the number of spike trains pairs involving the spike train of containing this spike, which is the number of spike trains minus one (N1).
Valid call structures:
spike_sync_profile(st1, st2) # returns the bivariate profile spike_sync_profile(st1, st2, st3) # multivariate profile of 3 sts sts = [st1, st2, st3, st4] # list of spike trains spike_sync_profile(sts) # profile of the list of spike trains spike_sync_profile(sts, indices=[0, 1]) # use only the spike trains # given by the indices
In the multivariate case, the profile is defined as the number of coincidences for each spike in the set of spike trains divided by the number of spike trains pairs involving the spike train of containing this spike, which is the number of spike trains minus one (N1).
Returns: The spikesync profile \(S_{sync}(t)\). Return type: pyspike.function.DiscreteFunction

pyspike.spike_sync.
spike_sync_profile_bi
(spike_train1, spike_train2, max_tau=None)[source]¶ Specific function to compute a bivariate SPIKESyncprofile. This is a deprecated function and should not be called directly. Use
spike_sync_profile()
to compute SPIKESyncprofiles.Parameters:  spike_train1 (
pyspike.SpikeTrain
) – First spike train.  spike_train2 (
pyspike.SpikeTrain
) – Second spike train.  max_tau – Maximum coincidence window size. If 0 or None, the coincidence window has no upper bound.
Returns: The spikesync profile \(S_{sync}(t)\).
Return type: pyspike.function.DiscreteFunction
 spike_train1 (

pyspike.spike_sync.
spike_sync_profile_multi
(spike_trains, indices=None, max_tau=None)[source]¶ Specific function to compute a multivariate SPIKESyncprofile. This is a deprecated function and should not be called directly. Use
spike_sync_profile()
to compute SPIKESyncprofiles.Parameters:  spike_trains – list of
pyspike.SpikeTrain
 indices (list or None) – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
 max_tau – Maximum coincidence window size. If 0 or None, the coincidence window has no upper bound.
Returns: The multivariate spike sync profile \(<S_{sync}>(t)\)
Return type: pyspike.function.DiscreteFunction
 spike_trains – list of
PSTH¶

pyspike.psth.
psth
(spike_trains, bin_size)[source]¶ Computes the peristimulus time histogram of a set of
SpikeTrain
. The PSTH is simply the histogram of merged spike events. Thebin_size
defines the width of the histogram bins.Parameters:  spike_trains – list of
SpikeTrain
 bin_size – width of the histogram bins.
Returns: The PSTH as a
PieceWiseConstFunc
 spike_trains – list of
Directionality¶

pyspike.spike_directionality.
optimal_spike_train_sorting
(spike_trains, indices=None, interval=None, max_tau=None, full_output=False)[source]¶ Finds the best sorting of the given spike trains by computing the spike directionality matrix and optimize the order using simulated annealing. For a detailed description of the algorithm see: http://iopscience.iop.org/article/10.1088/13672630/aa68c3/meta
Parameters:  spike_trains – list of
SpikeTrain
 indices (list or None) – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
 interval (Pair of floats or None.) – time interval filter given as a pair of floats, if None the full spike trains are used (default=None).
 max_tau – Maximum coincidence window size. If 0 or None, the coincidence window has no upper bound (default=None).
 full_output – If true, then function will additionally return the number of performed iterations (default=False)
Returns: (p, F)  tuple with the optimal permutation and synfire indicator. if full_output=True , (p, F, iter) is returned.
 spike_trains – list of

pyspike.spike_directionality.
permutate_matrix
(D, p)[source]¶ Helper function that applies the permutation p to the columns and rows of matrix D. Return the permutated matrix \(D'[n,m] = D[p[n], p[m]]\).
Parameters:  D – The matrix.
 d – The permutation.
Returns: The permuated matrix D’, ie \(D'[n,m] = D[p[n], p[m]]\)

pyspike.spike_directionality.
spike_directionality
(spike_train1, spike_train2, normalize=True, interval=None, max_tau=None)[source]¶ Computes the overall spike directionality of the first spike train with respect to the second spike train.
Parameters:  spike_train1 (
pyspike.SpikeTrain
) – First spike train.  spike_train2 (
pyspike.SpikeTrain
) – Second spike train.  normalize – Normalize by the number of spikes (multiplicity).
 max_tau – Maximum coincidence window size. If 0 or None, the coincidence window has no upper bound.
Returns: The spike train order profile \(E(t)\).
 spike_train1 (

pyspike.spike_directionality.
spike_directionality_matrix
(spike_trains, normalize=True, indices=None, interval=None, max_tau=None)[source]¶ Computes the spike directionality matrix for the given spike trains.
Parameters:  spike_trains (List of
pyspike.SpikeTrain
) – List of spike trains.  normalize – Normalize by the number of spikes (multiplicity).
 indices (list or None) – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
 max_tau – Maximum coincidence window size. If 0 or None, the coincidence window has no upper bound.
Returns: The spikedirectionality values.
 spike_trains (List of

pyspike.spike_directionality.
spike_directionality_values
(*args, **kwargs)[source]¶ Computes the spike directionality value for each spike in each spike train. Returns a list containing an array of spike directionality values for every given spike train.
Valid call structures:
spike_directionality_values(st1, st2) # returns the bivariate profile spike_directionality_values(st1, st2, st3) # multivariate profile of 3 # spike trains spike_trains = [st1, st2, st3, st4] # list of spike trains spike_directionality_values(spike_trains) # profile of the list of spike trains spike_directionality_values(spike_trains, indices=[0, 1]) # use only the spike trains # given by the indices
Additonal arguments: :param max_tau: Upper bound for coincidence window (default=None). :param indices: list of indices defining which spike trains to use,
if None all given spike trains are used (default=None)Returns: The spike directionality values \(D^n_i\) as a list of arrays.

pyspike.spike_directionality.
spike_train_order
(*args, **kwargs)[source]¶ Computes the spike train order (Synfire Indicator) of the given spike trains.
Valid call structures:
spike_train_order(st1, st2, normalize=True) # normalized bivariate # spike train order spike_train_order(st1, st2, st3) # multivariate result of 3 spike trains spike_trains = [st1, st2, st3, st4] # list of spike trains spike_train_order(spike_trains) # result for the list of spike trains spike_train_order(spike_trains, indices=[0, 1]) # use only the spike trains # given by the indices
 Additonal arguments:
 max_tau Upper bound for coincidence window, default=None.
 normalize Flag indicating if the reslut should be normalized by the number of spikes , default=`False`
Returns: The spike train order value (Synfire Indicator)

pyspike.spike_directionality.
spike_train_order_bi
(spike_train1, spike_train2, normalize=True, interval=None, max_tau=None)[source]¶ Computes the overall spike train order value (Synfire Indicator) for two spike trains.
Parameters:  spike_train1 (
pyspike.SpikeTrain
) – First spike train.  spike_train2 (
pyspike.SpikeTrain
) – Second spike train.  normalize – Normalize by the number of spikes (multiplicity).
 max_tau – Maximum coincidence window size. If 0 or None, the coincidence window has no upper bound.
Returns: The spike train order value (Synfire Indicator)
 spike_train1 (

pyspike.spike_directionality.
spike_train_order_multi
(spike_trains, indices=None, normalize=True, interval=None, max_tau=None)[source]¶ Computes the overall spike train order value (Synfire Indicator) for many spike trains.
Parameters:  spike_trains – list of
SpikeTrain
 indices – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
 normalize – Normalize by the number of spike (multiplicity).
 interval (Pair of floats or None.) – averaging interval given as a pair of floats, if None the average over the whole function is computed.
 max_tau – Maximum coincidence window size. If 0 or None, the coincidence window has no upper bound.
Returns: Spike train order values (Synfire Indicator) F for the given spike trains.
Return type: double
 spike_trains – list of

pyspike.spike_directionality.
spike_train_order_profile
(*args, **kwargs)[source]¶ Computes the spike train order profile \(E(t)\) of the given spike trains. Returns the profile as a DiscreteFunction object.
Valid call structures:
spike_train_order_profile(st1, st2) # returns the bivariate profile spike_train_order_profile(st1, st2, st3) # multivariate profile of 3 # spike trains spike_trains = [st1, st2, st3, st4] # list of spike trains spike_train_order_profile(spike_trains) # profile of the list of spike trains spike_train_order_profile(spike_trains, indices=[0, 1]) # use only the spike trains # given by the indices
Additonal arguments: :param max_tau: Upper bound for coincidence window, default=None. :param indices: list of indices defining which spike trains to use,
if None all given spike trains are used (default=None)Returns: The spike train order profile \(E(t)\) Return type: DiscreteFunction

pyspike.spike_directionality.
spike_train_order_profile_bi
(spike_train1, spike_train2, max_tau=None)[source]¶ Computes the spike train order profile P(t) of the two given spike trains. Returns the profile as a DiscreteFunction object.
Parameters:  spike_train1 (
pyspike.SpikeTrain
) – First spike train.  spike_train2 (
pyspike.SpikeTrain
) – Second spike train.  max_tau – Maximum coincidence window size. If 0 or None, the coincidence window has no upper bound.
Returns: The spike train order profile \(E(t)\).
Return type: pyspike.function.DiscreteFunction
 spike_train1 (

pyspike.spike_directionality.
spike_train_order_profile_multi
(spike_trains, indices=None, max_tau=None)[source]¶ Computes the multivariate spike train order profile for a set of spike trains. For each spike in the set of spike trains, the multivariate profile is defined as the sum of asymmetry values divided by the number of spike trains pairs involving the spike train of containing this spike, which is the number of spike trains minus one (N1).
Parameters:  spike_trains – list of
pyspike.SpikeTrain
 indices (list or None) – list of indices defining which spike trains to use, if None all given spike trains are used (default=None)
 max_tau – Maximum coincidence window size. If 0 or None, the coincidence window has no upper bound.
Returns: The multivariate spike sync profile \(<S_{sync}>(t)\)
Return type: pyspike.function.DiscreteFunction
 spike_trains – list of
Helper functions¶

pyspike.spikes.
generate_poisson_spikes
(rate, interval)[source]¶ Generates a Poisson spike train with the given rate in the given time interval
Parameters:  rate – The rate of the spike trains
 interval (pair of doubles or double) – A pair (T_start, T_end) of values representing the start and end time of the spike train measurement or a single value representing the end time, the T_start is then assuemd as 0. Auxiliary spikes will be added to the spike train at the beginning and end of this interval, if they are not yet present.
Returns: Poisson spike train as a
SpikeTrain

pyspike.spikes.
import_spike_trains_from_time_series
(file_name, start_time, time_bin, separator=None, comment='#')[source]¶ Imports spike trains from time series consisting of 0 and 1 denoting the absence or presence of a spike. Each line in the data file represents one spike train.
Parameters:  file_name – The name of the data file containing the time series.
 edges – A pair (T_start, T_end) of values representing the start and end time of the spike train measurement or a single value representing the end time, the T_start is then assuemd as 0.
 separator – The character used to seprate the values in the text file
 comment – Lines starting with this character are ignored.

pyspike.spikes.
load_spike_trains_from_txt
(file_name, edges, separator=' ', comment='#', is_sorted=False, ignore_empty_lines=True)[source]¶ Loads a number of spike trains from a text file. Each line of the text file should contain one spike train as a sequence of spike times separated by separator. Empty lines as well as lines starting with comment are neglected. The edges represents the start and the end of the spike trains.
Parameters:  file_name – The name of the text file.
 edges – A pair (T_start, T_end) of values representing the start and end time of the spike train measurement or a single value representing the end time, the T_start is then assuemd as 0.
 separator – The character used to seprate the values in the text file
 comment – Lines starting with this character are ignored.
 sort – If true, the spike times are order via np.sort, default=True
Returns: list of
SpikeTrain

pyspike.spikes.
merge_spike_trains
(spike_trains)[source]¶ Merges a number of spike trains into a single spike train.
Parameters: spike_trains – list of SpikeTrain
Returns: spike train with the merged spike times

pyspike.spikes.
save_spike_trains_to_txt
(spike_trains, file_name, separator=' ', precision=8)[source]¶ Saves the given spike trains into a file with the given file name. Each spike train will be stored in one line in the text file with the times separated by separator.
Parameters:  spike_trains – List of
SpikeTrain
objects  file_name – The name of the text file.
 spike_trains – List of

pyspike.spikes.
spike_train_from_string
(s, edges, sep=' ', is_sorted=False)[source]¶ Converts a string of times into a
SpikeTrain
.Parameters:  s – the string with (ordered) spike times.
 edges – interval defining the edges of the spike train. Given as a pair of floats (T0, T1) or a single float T1, where T0=0 is assumed.
 sep – The separator between the time numbers, default=’ ‘.
 is_sorted – if True, the spike times are not sorted after loading, if False, spike times are sorted with np.sort
Returns: