elephant.phase_analysis.spike_triggered_phase¶

elephant.phase_analysis.
spike_triggered_phase
(hilbert_transform, spiketrains, interpolate)[source]¶ Calculate the set of spiketriggered phases of a neo.AnalogSignal.
Parameters:  hilbert_transformneo.AnalogSignal or list of neo.AnalogSignal
neo.AnalogSignal of the complex analytic signal (e.g., returned by the elephant.signal_processing.hilbert function). If hilbert_transform is only one signal, all spike trains are compared to this signal. Otherwise, length of hilbert_transform must match the length of spiketrains.
 spiketrainsneo.SpikeTrain or list of neo.SpikeTrain
Spike trains on which to trigger hilbert_transform extraction.
 interpolatebool
If True, the phases and amplitudes of hilbert_transform for spikes falling between two samples of signal is interpolated. If False, the closest sample of hilbert_transform is used.
Returns:  phaseslist of np.ndarray
Spiketriggered phases. Entries in the list correspond to the neo.SpikeTrain`s in `spiketrains. Each entry contains an array with the spiketriggered angles (in rad) of the signal.
 amplist of pq.Quantity
Corresponding spiketriggered amplitudes.
 timeslist of pq.Quantity
A list of times corresponding to the signal. They correspond to the times of the neo.SpikeTrain referred by the list item.
Raises:  ValueError
If the number of spike trains and number of phase signals don’t match, and neither of the two are a single signal.
Examples
Create a 20 Hz oscillatory signal sampled at 1 kHz and a random Poisson spike train, then calculate spiketriggered phases and amplitudes of the oscillation:
>>> import neo >>> import elephant >>> import quantities as pq >>> import numpy as np ... >>> f_osc = 20. * pq.Hz >>> f_sampling = 1 * pq.ms >>> tlen = 100 * pq.s ... >>> time_axis = np.arange( ... 0, tlen.magnitude, ... f_sampling.rescale(pq.s).magnitude) * pq.s >>> analogsignal = neo.AnalogSignal( ... np.sin(2 * np.pi * (f_osc * time_axis).simplified.magnitude), ... units=pq.mV, t_start=0*pq.ms, sampling_period=f_sampling) >>> spiketrain = (elephant.spike_train_generation. ... homogeneous_poisson_process( ... 50 * pq.Hz, t_start=0.0*pq.ms, t_stop=tlen.rescale(pq.ms))) ... >>> phases, amps, times = elephant.phase_analysis.spike_triggered_phase( ... elephant.signal_processing.hilbert(analogsignal), ... spiketrain, ... interpolate=True) >>> phases [array([0.57890515, 1.03105904, 0.82241075, ..., 0.90023903, 2.23702263, 2.93744259])] >>> amps [array([0.86117412, 1.08918248, 0.98256318, ..., 1.05760518, 1.08407016, 1.01927305]) * dimensionless] >>> times [array([6.41327152e+00, 2.02715221e+01, 1.05827312e+02, ..., 9.99692942e+04, 9.99808429e+04, 9.99870120e+04]) * ms]