elephant.spectral.multitaper_psd¶
- elephant.spectral.multitaper_psd(signal, fs=1, nw=4, num_tapers=None, peak_resolution=None, attach_units=True)[source]¶
Estimates power spectrum density (PSD) of a given ‘neo.AnalogSignal’ using the Multitaper method.
The PSD is obtained through the following steps:
Calculate ‘num_tapers’ approximately independent estimates of the spectrum by multiplying the signal with the discrete prolate spheroidal functions (also known as Slepian function) and calculate the PSD of each tapered signal.
Average the approximately independent estimates of each signal to decrease overall variance of the estimates
- Parameters:
- signalneo.AnalogSignal or pq.Quantity or np.ndarray
Time series data of which PSD is estimated. When signal is np.ndarray sampling frequency should be given through keyword argument fs. Signal should be passed as (n_channels, n_samples)
- 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.
- attach_units: bool, optional
If True and signals is an instance of pq.Quantity, units are attached to the estimated cross spectrum. Default: True
- Returns:
- freqsnp.ndarray
Frequencies associated with power estimate in psd
- psdnp.ndarray
PSD estimate of the time series in signal
- Raises:
- ValueError
If peak_resolution is not a positive number.
If peak_resolution is None and num_tapers is not a positive number.
- TypeError
If peak_resolution is None and num_tapers is not an int.
Notes
There is a parameter hierarchy regarding nw, num_tapers and peak_resolution. If peak_resolution is provided, it determines both nw and the num_tapers. Specifying num_tapers has an effect only if peak_resolution is not provided.