WindowingRemover¶
- class WindowingRemover(sfreq: float, line_freqs: int | float | ndarray | list | tuple, notch_width: int | float | ndarray | list | tuple, filter_length: int, low_bias: bool, adaptive: bool, bandwidth: float, p_value: float, verbose: bool = None)[source][source]¶
Removes windowing artifacts from data.
- Parameters:
sfreq (
float) – The sampling frequency of the data.line_freqs (
listoffloat) – The frequencies of the line noise.notch_width (
listoffloat) – The notch widths for each line frequency.filter_length (
int) – The length of the filter to use.low_bias (
bool) – Whether to use a low bias filter.adaptive (
bool) – Whether to use an adaptive filter.bandwidth (
float) – The bandwidth of the multitaper windowing function.p_value (
float) – The p-value to use in the F-test.verbose (
bool) – Whether to print information.
- __call__(x: ndarray) ndarray[source][source]¶
Remove line frequencies from data using multitaper method.
- dpss_windows(N: int, half_nbw: float, Kmax: int, *, sym: bool = True, norm: int | str = None) tuple[ndarray, ndarray][source][source]¶
Compute Discrete Prolate Spheroidal Sequences.
Will give of orders [0,Kmax-1] for a given frequency-spacing multiple NW and sequence length N.
Note
Copied from NiTime.
- Parameters:
N (
int) – Sequence length.half_nbw (
float) – Standardized half bandwidth corresponding to 2 * half_bw = BW*f0 = BW*N/dt but with dt taken as 1.Kmax (
int) – Number of DPSS windows to return is Kmax (orders 0 through Kmax-1).sym (
bool) – Whether to generate a symmetric window (True, for filter design) or a periodic window (False, for spectral analysis). Default isTrue.norm (2 |
'approximate'|'subsample'| None) – Window normalization method. If'approximate'or'subsample', windows are normalized by the maximum, and a correction scale-factor for even-length windows is applied either usingN**2/(N**2+half_nbw)(“approximate”) or a FFT-based subsample shift (“subsample”).2uses the L2 norm.None(the default) uses"approximate"whenKmax=Noneand2otherwise.
- Returns:
v, e – The v array contains DPSS windows shaped (Kmax, N). e are the eigenvalues.
- Return type:
tuple,
Notes
Tridiagonal form of DPSS calculation (Slepian, 1978)
References
David S. Slepian. Prolate spheroidal wave functions, fourier analysis, and uncertainty-V: the discrete case. Bell System Technical Journal, 57(5):1371–1430, 1978. doi:10.1002/j.1538-7305.1978.tb02104.x.
- get_thresh(n_times: int = None) tuple[ndarray, float][source][source]¶
Get the window function and threshold for given time points.
- params(n_times: int) tuple[ndarray, ndarray, bool][source][source]¶
Triage windowing and multitaper parameters.
- Parameters:
n_times (
int) – The number of time points.- Returns:
window_fun (
array,shape=(n_tapers,n_times)) – The window functions for each taper.eigenvals (
array,shape=(n_tapers,)) – The eigenvalues for each taper.adaptive (
bool) – Whether to use adaptive weights to combine the tapered spectra into PSD
- Return type: