elephant.spectral.multitaper_coherence¶
- elephant.spectral.multitaper_coherence(signal_i, signal_j, n_segments=1, len_segment=None, frequency_resolution=None, overlap=0.5, fs=1, nw=4, num_tapers=None, peak_resolution=None)[source]¶
Estimates the magnitude-squared coherence and phase-lag of two given neo.AnalogSignal using the Multitaper method. The function calls segmented_multitaper_cross_spectrum internally and thus both functions share parts of the respective signatures.
\[C(\omega)=\frac{|S_{xy}(\omega)|^2}{S_{xx}(\omega)S_{yy}(\omega)}\]- Parameters:
- signal_ineo.AnalogSignal or pq.Quantity or np.ndarray
First time series data of the pair between which coherence is computed.
- signal_jneo.AnalogSignal or pq.Quantity or np.ndarray
Second time series data of the pair between which coherence is computed. The shapes and the sampling frequencies of signal_i and signal_j must be identical. When signal_i and signal_j are not neo.AnalogSignal, sampling frequency should be specified through the keyword argument fs. Otherwise, the default value is used (fs = 1.0).
- fsfloat, optional
Specifies the sampling frequency of the input time series Default: 1.0
- nwfloat, optional
Time bandwidth product Default: 4.0
- num_tapersint, optional
Number of tapers used in 1. to obtain estimate of PSD. By default, [2*nw] - 1 is chosen. Default: None
- peak_resolutionpq.Quantity float, optional
Quantity in Hz determining the number of tapers used for analysis. Fine peak resolution –> low numerical value –> low number of tapers High peak resolution –> high numerical value –> high number of tapers When given as a float, it is taken as frequency in Hz. Default: None.
- n_segmentsint, optional
Number of segments. The length of segments is adjusted so that overlapping segments cover the entire stretch of the given data. This parameter is ignored if len_segment or frequency_resolution is given. Default: 1
- len_segmentint, optional
Length of segments. This parameter is ignored if frequency_resolution is given. If None, it will be determined from other parameters. Default: None
- frequency_resolutionpq.Quantity or float, optional
Desired frequency resolution of the obtained coherence estimate in terms of the interval between adjacent frequency bins. When given as a float, it is taken as frequency in Hz. If None, it will be determined from other parameters. Default: None
- overlapfloat, optional
Overlap between segments represented as a float number between 0 (no overlap) and 1 (complete overlap). Default: 0.5 (half-overlapped)
- Returns:
- freqsnp.ndarray
Frequencies associated with the magnitude-squared coherence estimate
- coherencenp.ndarray
Magnitude-squared coherence estimate
- phase_lagnp.ndarray
Phase lags associated with the magnitude-square coherence estimate