Bases: object
Class representing spike trains for the PySpike Module.
Constructs the SpikeTrain.
Parameters: |
|
---|
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. |
---|
Bases: object
A class representing a piece-wise constant function.
Constructs the piece-wise const function.
Parameters: |
|
---|
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 |
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 |
Computes the average of the piece-wise 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 |
Returns a copy of itself
Return type: | PieceWiseConstFunc |
---|
Returns two arrays containing x- and y-coordinates for immeditate plotting of the piece-wise 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="Piece-wise const function")
A class representing a piece-wise linear function.
Constructs the piece-wise linear function.
Parameters: |
|
---|
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 |
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 |
Computes the average of the piece-wise 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 |
Returns a copy of itself
Return type: | PieceWiseLinFunc |
---|
Returns two arrays containing x- and y-coordinates for immeditate plotting of the piece-wise 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="Piece-wise const function")
Bases: object
A class representing values defined on a discrete set of points.
Constructs the discrete function.
Parameters: |
|
---|
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 |
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 |
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 |
Returns a copy of itself
Return type: | DiscreteFunc |
---|
Returns two arrays containing x- and y-coordinates 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")
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 |
Computes the average profile from the given ISI- or SPIKE-profiles.
Parameters: | profiles – list of PieceWiseConstFunc or PieceWiseLinFunc representing ISI- or SPIKE-profiles to be averaged. |
---|---|
Returns: | the averages profile \(<S_{isi}>\) or \(<S_{spike}>\). |
Return type: | PieceWiseConstFunc or PieceWiseLinFunc |
Computes the ISI-distance \(D_I\) of the given spike trains. The isi-distance is the integral over the isi distance profile \(I(t)\):
In the multivariate case it is the integral over the multivariate ISI-profile, i.e. the average profile over all spike train pairs:
where the sum goes over all pairs <i,j>
Valid call structures:
isi_distance(st1, st2) # returns the bi-variate distance
isi_distance(st1, st2, st3) # multi-variate 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 isi-distance \(D_I\). |
---|---|
Return type: | double |
Specific function to compute the bivariate ISI-distance. This is a deprecated function and should not be called directly. Use isi_distance() to compute ISI-distances.
Parameters: |
|
---|---|
Returns: | The isi-distance \(D_I\). |
Return type: | double |
Computes the time averaged isi-distance of all pairs of spike-trains.
Parameters: |
|
---|---|
Returns: | 2D array with the pair wise time average isi distances \(D_{I}^{ij}\) |
Return type: | np.array |
Specific function to compute the multivariate ISI-distance. This is a deprecfated function and should not be called directly. Use isi_distance() to compute ISI-distances.
Parameters: |
|
---|---|
Returns: | The time-averaged multivariate ISI distance \(D_I\) |
Return type: | double |
Computes the isi-distance profile \(I(t)\) of the given spike trains. Returns the profile as a PieceWiseConstFunc object. The ISI-values are defined positive \(I(t)>=0\).
Valid call structures:
isi_profile(st1, st2) # returns the bi-variate profile
isi_profile(st1, st2, st3) # multi-variate 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 ISI-profile of all pairs of spike-trains:
where the sum goes over all pairs <i,j>
Returns: | The isi-distance profile \(I(t)\) |
---|---|
Return type: | PieceWiseConstFunc |
Specific function to compute a bivariate ISI-profile. This is a deprecated function and should not be called directly. Use isi_profile() to compute ISI-profiles.
Parameters: |
|
---|---|
Returns: | The isi-distance profile \(I(t)\) |
Return type: |
Specific function to compute the multivariate ISI-profile for a set of spike trains. This is a deprecated function and should not be called directly. Use isi_profile() to compute ISI-profiles.
Parameters: |
|
---|---|
Returns: | The averaged isi profile \(<I(t)>\) |
Return type: |
Computes the SPIKE-distance \(D_S\) of the given spike trains. The spike-distance is the integral over the spike distance profile \(D(t)\):
Valid call structures:
spike_distance(st1, st2) # returns the bi-variate distance
spike_distance(st1, st2, st3) # multi-variate 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:
Returns: | The spike-distance \(D_S\). |
---|---|
Return type: | double |
Specific function to compute a bivariate SPIKE-distance. This is a deprecated function and should not be called directly. Use spike_distance() to compute SPIKE-distances.
Parameters: |
|
---|---|
Returns: | The spike-distance. |
Return type: | double |
Computes the time averaged spike-distance of all pairs of spike-trains.
Parameters: |
|
---|---|
Returns: | 2D array with the pair wise time average spike distances \(D_S^{ij}\) |
Return type: | np.array |
Specific function to compute a multivariate SPIKE-distance. This is a deprecated function and should not be called directly. Use spike_distance() to compute SPIKE-distances.
Parameters: |
|
---|---|
Returns: | The averaged multi-variate spike distance \(D_S\). |
Return type: | double |
Computes the spike-distance profile \(S(t)\) of the given spike trains. Returns the profile as a PieceWiseConstLin object. The SPIKE-values are defined positive \(S(t)>=0\).
Valid call structures:
spike_profile(st1, st2) # returns the bi-variate profile
spike_profile(st1, st2, st3) # multi-variate 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 spike-distance profile is defined as the average of all pairs of spike-trains:
where the sum goes over all pairs <i,j>
Returns: | The spike-distance profile \(S(t)\) |
---|---|
Return type: | PieceWiseConstLin |
Specific function to compute a bivariate SPIKE-profile. This is a deprecated function and should not be called directly. Use spike_profile() to compute SPIKE-profiles.
Parameters: |
|
---|---|
Returns: | The spike-distance profile \(S(t)\). |
Return type: |
Specific function to compute a multivariate SPIKE-profile. This is a deprecated function and should not be called directly. Use spike_profile() to compute SPIKE-profiles.
Parameters: |
|
---|---|
Returns: | The averaged spike profile \(<S>(t)\) |
Return type: |
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:
Valid call structures:
spike_sync(st1, st2) # returns the bi-variate spike synchronization
spike_sync(st1, st2, st3) # multi-variate result for 3 spike trains
spike_trains = [st1, st2, st3, st4] # list of spike trains
spike_sync(spike_trains) # spike-sync of the list of spike trains
spike_sync(spike_trains, indices=[0, 1]) # use only the spike trains
# given by the indices
The multivariate SPIKE-Sync 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 |
Specific function to compute a bivariate SPIKE-Sync value. This is a deprecated function and should not be called directly. Use spike_sync() to compute SPIKE-Sync values.
Parameters: |
|
---|---|
Returns: | The spike synchronization value. |
Return type: | double |
Computes the overall spike-synchronization value of all pairs of spike-trains.
Parameters: |
|
---|---|
Returns: | 2D array with the pair wise time spike synchronization values \(SYNC_{ij}\) |
Return type: | np.array |
Specific function to compute a multivariate SPIKE-Sync value. This is a deprecated function and should not be called directly. Use spike_sync() to compute SPIKE-Sync values.
Parameters: |
|
---|---|
Returns: | The multi-variate spike synchronization value SYNC. |
Return type: | double |
Computes the spike-synchronization 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 multi-variate 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 (N-1).
Valid call structures:
spike_sync_profile(st1, st2) # returns the bi-variate profile
spike_sync_profile(st1, st2, st3) # multi-variate 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 (N-1).
Returns: | The spike-sync profile \(S_{sync}(t)\). |
---|---|
Return type: | pyspike.function.DiscreteFunction |
Specific function to compute a bivariate SPIKE-Sync-profile. This is a deprecated function and should not be called directly. Use spike_sync_profile() to compute SPIKE-Sync-profiles.
Parameters: |
|
---|---|
Returns: | The spike-sync profile \(S_{sync}(t)\). |
Return type: | pyspike.function.DiscreteFunction |
Specific function to compute a multivariate SPIKE-Sync-profile. This is a deprecated function and should not be called directly. Use spike_sync_profile() to compute SPIKE-Sync-profiles.
Parameters: |
|
---|---|
Returns: | The multi-variate spike sync profile \(<S_{sync}>(t)\) |
Return type: | pyspike.function.DiscreteFunction |
Computes the peri-stimulus time histogram of a set of SpikeTrain. The PSTH is simply the histogram of merged spike events. The bin_size defines the width of the histogram bins.
Parameters: |
|
---|---|
Returns: | The PSTH as a PieceWiseConstFunc |
Generates a Poisson spike train with the given rate in the given time interval
Parameters: |
|
---|---|
Returns: | Poisson spike train as a SpikeTrain |
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: |
|
---|---|
Returns: | list of SpikeTrain |
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 |
Converts a string of times into a SpikeTrain.
Parameters: |
|
---|---|
Returns: |