Functions to calculate spike-triggered average and spike-field coherence of analog signals.
elephant.sta.
spike_field_coherence
(signal, spiketrain, **kwargs)[source]¶Calculates the spike-field coherence between a analog signal(s) and a (binned) spike train.
The current implementation makes use of scipy.signal.coherence(). Additional kwargs will will be directly forwarded to scipy.signal.coherence(), except for the axis parameter and the sampling frequency, which will be extracted from the input signals.
The spike_field_coherence function receives an analog signal array and either a binned spike train or a spike train containing the original spike times. In case of original spike times the spike train is binned according to the sampling rate of the analog signal array.
The AnalogSignal object can contain one or multiple signal traces. In case of multiple signal traces, the spike field coherence is calculated individually for each signal trace and the spike train.
Parameters: | signal : neo AnalogSignal object
spiketrain : SpikeTrain or BinnedSpikeTrain
|
---|---|
Returns: | coherence : complex Quantity array
frequencies : Quantity array
|
elephant.sta.
spike_triggered_average
(signal, spiketrains, window)[source]¶Calculates the spike-triggered averages of analog signals in a time window relative to the spike times of a corresponding spiketrain for multiple signals each. The function receives n analog signals and either one or n spiketrains. In case it is one spiketrain this one is muliplied n-fold and used for each of the n analog signals.
Parameters: | signal : neo AnalogSignal object
spiketrains : one SpikeTrain or one numpy ndarray or a list of n of either of these.
window : tuple of 2 Quantity objects with dimensions of time.
|
---|---|
Returns: | result_sta : neo AnalogSignal object
|
Examples
>>> signal = neo.AnalogSignal(np.array([signal1, signal2]).T, units='mV',
... sampling_rate=10/ms)
>>> stavg = spike_triggered_average(signal, [spiketrain1, spiketrain2],
... (-5 * ms, 10 * ms))