neurodsp.spectral.compute_spectrum_medfilt

neurodsp.spectral.compute_spectrum_medfilt(sig, fs, filt_len=1.0, f_range=None)[source]

Compute the power spectral density as a smoothed FFT.

Parameters
sig1d or 2d array

Time series.

fsfloat

Sampling rate, in Hz.

filt_lenfloat, optional, default: 1

Length of the median filter, in Hz.

f_rangelist of [float, float], optional

Frequency range to sub-select from the power spectrum.

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 as a smoothed FFT:

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