Skip to content

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.

@example
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
julia
SpikeTrain

A 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).

source

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
julia
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 the Timeseries constructor.

Returns

  • A SpikeTrain (binary time series) with true values at the sorted spike times.

See also: spiketimes

Examples

julia
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]
source
TimeseriesBase.Utils.spiketimes Function
julia
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

Returns

See also: spiketrain, times

Examples

julia
julia> spike_times = [1.0, 2.5, 4.0];
julia> st = spiketrain(spike_times);
julia> spiketimes(st)  # Returns [1.0, 2.5, 4.0]
source
TimeseriesTools.stoic Function
julia
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 is npi, the integral of two gaussians with equal variance at a given distance from each other.

  • σ: Width parameter of the kernel. For npi, this is the width of the unit-mass Gaussian kernels. Default is 0.025.

  • Δt: Time window for considering spikes as close. Default is σ * 10.

source
TimeseriesTools.pointprocess! Function
julia
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 to Random.default_rng().

  • t0: (optional) The initial time. Defaults to 0.0.

source