Spike trains
A SpikeTrain is a point-process series whose lookup is the vector of spike times and whose values are absent (Bool or trivially true). Multivariate spike trains store a vector of trains, one per channel/unit.
using TimeseriesTools, Distributions, Random
Random.seed!(0)
spikes = sort(cumsum(rand(Exponential(0.05), 200))) # ISI ~ 50 ms
st = spiketrain(spikes)Spike spectra
A power spectrum of a spike train can be computed via the autocovariance function (using Autocorrelations), giving a frequency-domain summary of rate fluctuations.
Pairwise similarity
stoic computes the spike-time tiling coefficient (Cutts & Eglen, 2014) and related spike-time covariance measures, pairwise across channels.
Surrogates
Spike-train surrogate methods (RandomJitter, GammaRenewal, …) live in the separate TimeseriesToolsSurrogates.jl package; see Surrogates.
Reference
TimeseriesBase.TimeSeries.SpikeTrain Type
SpikeTrainA type alias for a spike-train time series, which contains spike times in the time dimension and true for all values corresponding to a spike. The spike times can be retrieved with times(x).
Missing docstring.
Missing docstring for UnivariateSpikeTrain. Check Documenter's build log for details.
Missing docstring.
Missing docstring for MultivariateSpikeTrain. Check Documenter's build log for details.
TimeseriesBase.Utils.spiketrain Function
spiketrain(x; kwargs...)Construct a SpikeTrain from a vector of spike times x.
The input vector x is sorted and converted into a binary time series where each time point corresponds to a spike (value of true).
Arguments
x: A vector of spike times (will be sorted).kwargs...: Additional keyword arguments passed to theTimeseriesconstructor.
Returns
- A
SpikeTrain(binary time series) withtruevalues at the sorted spike times.
See also: spiketimes
Examples
julia> spike_times = [1.5, 3.2, 0.8, 5.1];
julia> st = spiketrain(spike_times);
julia> times(st) # Returns sorted spike times: [0.8, 1.5, 3.2, 5.1]TimeseriesBase.Utils.spiketimes Function
spiketimes(x::UnivariateSpikeTrain)
spiketimes(x::SpikeTrain)
spiketimes(x::AbstractArray)Extract spike times from a SpikeTrain or pass through an array unchanged.
For a univariate spike train, returns the time indices where spikes occur (where the value is true). For a multivariate spike train, returns an array where each element contains the spike times for one channel/dimension. For a plain array, returns the array unchanged (identity function).
Arguments
x: ASpikeTrainorAbstractArray.
Returns
For
UnivariateSpikeTrain: A vector of spike times.For multivariate
SpikeTrain: An array of spike time vectors, one per channel.For
AbstractArray: The input array unchanged.
See also: spiketrain, times
Examples
julia> spike_times = [1.0, 2.5, 4.0];
julia> st = spiketrain(spike_times);
julia> spiketimes(st) # Returns [1.0, 2.5, 4.0]TimeseriesTools.stoic Function
stoic(a, b; kpi = npi, σ = 0.025, Δt = σ * 10)Compute the spike-train overlap-integral coefficient between two spike trains, after normalizing both convolutions to unit energy
See the unnamed metric from "Schreiber S, Fellous JM, Whitmer JH, Tiesinga PHE, Sejnowski TJ (2003). A new correlation based measure of spike timing reliability. Neurocomputing 52:925-931."
Arguments
a: Spike train a.b: Spike train b.kpi: Kernel product integral, a function of the distance between two spikes. Default isnpi, the integral of two gaussians with equal variance at a given distance from each other.σ: Width parameter of the kernel. Fornpi, this is the width of the unit-mass Gaussian kernels. Default is0.025.Δt: Time window for considering spikes as close. Default isσ * 10.
TimeseriesTools.pointprocess! Function
pointprocess!(spikes, D; rng = Random.default_rng(), t0 = 0.0)Simulate a point process by sampling inter-spike intervals from a given distribution D (a Distributions.Distribution) into spikes, starting from t0.
Requires Distributions to be loaded (provided by DistributionsExt).
Arguments
spikes: An array to store the generated spike times.D: The distribution from which to sample inter-spike intervals.rng: (optional) The random number generator to use. Defaults toRandom.default_rng().t0: (optional) The initial time. Defaults to0.0.