Functions to generate spike trains from analog signals, or to generate random spike trains.
Some functions are based on the NeuroTools stgen module, which was mostly written by Eilif Muller, or from the NeuroTools signals.analogs module.
elephant.spike_train_generation.
compound_poisson_process
(rate, A, t_stop, shift=None, t_start=array(0.) * ms)[source]¶Generate a Compound Poisson Process (CPP; see [1]) with a given amplitude distribution A and stationary marginal rates r.
The CPP process is a model for parallel, correlated processes with Poisson spiking statistics at pre-defined firing rates. It is composed of len(A)-1 spike trains with a correlation structure determined by the amplitude distribution A: A[j] is the probability that a spike occurs synchronously in any j spike trains.
The CPP is generated by creating a hidden mother Poisson process, and then copying spikes of the mother process to j of the output spike trains with probability A[j].
Note that this function decorrelates the firing rate of each SpikeTrain from the probability for that SpikeTrain to participate in a synchronous event (which is uniform across SpikeTrains).
Parameters: | rate : quantities.Quantity
A : array
t_stop : quantities.Quantity
shift : None or quantities.Quantity, optional
t_start : quantities.Quantity, optional
|
---|---|
Returns: | List of neo.SpikeTrains
|
References
[1] Staude, Rotter, Gruen (2010) J Comput Neurosci 29:327-350.
elephant.spike_train_generation.
cpp
(rate, A, t_stop, shift=None, t_start=array(0.) * ms)¶Generate a Compound Poisson Process (CPP; see [1]) with a given amplitude distribution A and stationary marginal rates r.
The CPP process is a model for parallel, correlated processes with Poisson spiking statistics at pre-defined firing rates. It is composed of len(A)-1 spike trains with a correlation structure determined by the amplitude distribution A: A[j] is the probability that a spike occurs synchronously in any j spike trains.
The CPP is generated by creating a hidden mother Poisson process, and then copying spikes of the mother process to j of the output spike trains with probability A[j].
Note that this function decorrelates the firing rate of each SpikeTrain from the probability for that SpikeTrain to participate in a synchronous event (which is uniform across SpikeTrains).
Parameters: | rate : quantities.Quantity
A : array
t_stop : quantities.Quantity
shift : None or quantities.Quantity, optional
t_start : quantities.Quantity, optional
|
---|---|
Returns: | List of neo.SpikeTrains
|
References
[1] Staude, Rotter, Gruen (2010) J Comput Neurosci 29:327-350.
elephant.spike_train_generation.
homogeneous_gamma_process
(a, b, t_start=array(0.) * ms, t_stop=array(1000.) * ms, as_array=False)[source]¶Returns a spike train whose spikes are a realization of a gamma process with the given parameters, starting at time t_start and stopping time t_stop (average rate will be b/a).
All numerical values should be given as Quantities, e.g. 100*Hz.
Parameters: | a : int or float
b : Quantity scalar with dimension 1/time
t_start : Quantity scalar with dimension time
t_stop : Quantity scalar with dimension time
as_array : bool
|
---|---|
Raises: | ValueError : If t_start and t_stop are not of type pq.Quantity. |
Examples
>>> from quantities import Hz, ms
>>> spikes = homogeneous_gamma_process(2.0, 50*Hz, 0*ms, 1000*ms)
>>> spikes = homogeneous_gamma_process(
5.0, 20*Hz, 5000*ms, 10000*ms, as_array=True)
elephant.spike_train_generation.
homogeneous_poisson_process
(rate, t_start=array(0.) * ms, t_stop=array(1000.) * ms, as_array=False)[source]¶Returns a spike train whose spikes are a realization of a Poisson process with the given rate, starting at time t_start and stopping time t_stop.
All numerical values should be given as Quantities, e.g. 100*Hz.
Parameters: | rate : Quantity scalar with dimension 1/time
t_start : Quantity scalar with dimension time
t_stop : Quantity scalar with dimension time
as_array : bool
|
---|---|
Raises: | ValueError : If t_start and t_stop are not of type pq.Quantity. |
Examples
>>> from quantities import Hz, ms
>>> spikes = homogeneous_poisson_process(50*Hz, 0*ms, 1000*ms)
>>> spikes = homogeneous_poisson_process(
20*Hz, 5000*ms, 10000*ms, as_array=True)
elephant.spike_train_generation.
inhomogeneous_poisson_process
(rate, as_array=False)[source]¶Returns a spike train whose spikes are a realization of an inhomogeneous Poisson process with the given rate profile.
Parameters: | rate : neo.AnalogSignal
as_array : bool
Raises —— ValueError : If rate contains any negative value. |
---|
elephant.spike_train_generation.
peak_detection
(signal, threshold=array(0.) * mV, sign='above', format=None)[source]¶Return the peak times for all events that cross threshold. Usually used for extracting spike times from a membrane potential. Similar to spike_train_generation.threshold_detection.
Parameters: | signal : neo AnalogSignal object
threshold : A quantity, e.g. in mV
sign : ‘above’ or ‘below’
format : None or ‘raw’
|
---|---|
Returns: | result_st : neo SpikeTrain object
|
elephant.spike_train_generation.
single_interaction_process
(rate, rate_c, t_stop, n=2, jitter=array(0.) * ms, coincidences='deterministic', t_start=array(0.) * ms, min_delay=array(0.) * ms, return_coinc=False)[source]¶Generates a multidimensional Poisson SIP (single interaction process) plus independent Poisson processes
A Poisson SIP consists of Poisson time series which are independent except for simultaneous events in all of them. This routine generates a SIP plus additional parallel independent Poisson processes.
See [1].
Parameters: | t_stop: quantities.Quantity
rate: quantities.Quantity
rate_c: quantities.Quantity
n: int, optional
jitter: quantities.Quantity, optional
coincidences: string, optional
t_start: quantities.Quantity, optional
min_delay: quantities.Quantity, optional
return_coinc: bool, optional
|
---|---|
Returns: | output: list
|
References
[1] Kuhn, Aertsen, Rotter (2003) Neural Comput 15(1):67-101
EXAMPLE:
>>> import quantities as qt
>>> import jelephant.core.stocmod as sm
>>> sip, coinc = sm.sip_poisson(n=10, n=0, t_stop=1*qt.sec, rate=20*qt.Hz, rate_c=4, return_coinc = True)
elephant.spike_train_generation.
spike_extraction
(signal, threshold=array(0.) * mV, sign='above', time_stamps=None, extr_interval=(array(-2.) * ms, array(4.) * ms))[source]¶Return the peak times for all events that cross threshold and the waveforms. Usually used for extracting spikes from a membrane potential to calculate waveform properties. Similar to spike_train_generation.peak_detection.
Parameters: | signal : neo AnalogSignal object
threshold : A quantity, e.g. in mV
sign : ‘above’ or ‘below’
time_stamps: None, quantity array or Object with .times interface
extr_interval: unpackable time quantities, len == 2
|
---|---|
Returns: | result_st : neo SpikeTrain object
|
elephant.spike_train_generation.
threshold_detection
(signal, threshold=array(0.) * mV, sign='above')[source]¶Returns the times when the analog signal crosses a threshold. Usually used for extracting spike times from a membrane potential. Adapted from version in NeuroTools.
Parameters: | signal : neo AnalogSignal object
threshold : A quantity, e.g. in mV
sign : ‘above’ or ‘below’
format : None or ‘raw’
|
---|---|
Returns: | result_st : neo SpikeTrain object
|