neurodsp.spectral.compute_spectrum_wavelet

neurodsp.spectral.compute_spectrum_wavelet(sig, fs, freqs, avg_type='mean', **kwargs)[source]

Compute the power spectral density using wavelets.

Parameters
sig1d or 2d array

Time series.

fsfloat

Sampling rate, in Hz.

freqs1d array or list of float

If array, frequency values to estimate with morlet wavelets. If list, define the frequency range, as [freq_start, freq_stop, freq_step]. The freq_step is optional, and defaults to 1. Range is inclusive of freq_stop value.

avg_type{‘mean’, ‘median’}, optional

Method to average across the windows.

**kwargs

Optional inputs for using wavelets.

Returns
freqs1d array

Frequencies at which the measure was calculated.

spectrum1d or 2d array

Power spectral density.

Examples

Compute the power spectrum of a simulated time series using wavelets:

>>> from neurodsp.sim import sim_combined
>>> sig = sim_combined(n_seconds=10, fs=500,
...                    components={'sim_powerlaw': {}, 'sim_oscillation' : {'freq': 10}})
>>> freqs, spectrum = compute_spectrum_wavelet(sig, fs=500, freqs=[1, 30])