neurodsp.timefrequency.convolve_wavelet

neurodsp.timefrequency.convolve_wavelet(sig, fs, freq, n_cycles=7, scaling=0.5, wavelet_len=None, norm='sss')[source]

Convolve a signal with a complex wavelet.

Parameters
sig1d array

Time series to filter.

fsfloat

Sampling rate, in Hz.

freqfloat

Center frequency of bandpass filter.

n_cyclesfloat, optional, default: 7

Length of the filter, as the number of cycles of the oscillation with specified frequency.

scalingfloat, optional, default: 0.5

Scaling factor for the morlet wavelet.

wavelet_lenint, optional

Length of the wavelet. If defined, this overrides the freq and n_cycles inputs.

norm{‘sss’, ‘amp’}, optional

Normalization method:

  • ‘sss’ - divide by the square root of the sum of squares

  • ‘amp’ - divide by the sum of amplitudes

Returns
array

Complex time series.

Notes

  • The real part of the returned array is the filtered signal.

  • Taking np.abs() of output gives the analytic amplitude.

  • Taking np.angle() of output gives the analytic phase.

Examples

Convolve a complex wavelet with a simulated signal:

>>> from neurodsp.sim import sim_combined
>>> sig = sim_combined(n_seconds=10, fs=500,
...                    components={'sim_powerlaw': {}, 'sim_oscillation' : {'freq': 10}})
>>> cts = convolve_wavelet(sig, fs=500, freq=10)