filters
- timeflux_dsp.utils.filters.LOGGER
- timeflux_dsp.utils.filters.design_edges(frequencies, nyq, mode)[source]
Design filter edges.
- Parameters
- Returns
freqs. Updated frequencies with transition bands. array: gains. Filter gain at frequency sampling points. list: wp. Passband edge frequencies. list: ws. Stopband edge frequencies.
- Return type
array
Filter edges design
The -6 dB point for all filters is in the middle of the transition band.
If no transition band is given, default is to use:
l_trans_bandwidth
= .. math:: min(max(l_{freq} * 0.25, 2), l_{freq})h_trans_bandwidth
= .. math:: min(max(h_{freq} * 0.25, 2.), rate / 2. - h_{freq})
Band-pass filter
The frequency response is (approximately) given by:
Where:
l_trans_bandwidth = Fp1 - Fs1 in Hz
Fh_trans_bandwidth = Fs2 - Fp2 + in Hz
freqs
= [Fp1, Fs1, Fs2, Fp2]
Band-stop filter
The frequency response is (approximately) given by:
Where:
l_trans_bandwidth = Fs1 - Fp1 in Hz
Fh_trans_bandwidth = Fp2 - Fs2 + in Hz
freqs
= [Fp1, Fs1, Fs2, Fp2]
Low-pass filter
The frequency response is (approximately) given by:
Where :
h_trans_bandwidth = Fstop - Fp in Hz
freqs
= [Fp, Fstop]
High-pass filter
The frequency response is (approximately) given by:
Where :
l_trans_bandwidth = Fp - Fstop in Hz
freqs
= [Fstop, Fp]
Notes
Adapted from mne.filters, see the documentation of:
- timeflux_dsp.utils.filters.construct_fir_filter(rate, frequencies, gains, order, phase, window, design)[source]
Construct coeffs of FIR filter.
- Parameters
rate (float) – Nominal sampling rate of the input data.
order (int) – Filter order
frequencies (list) – Transition frequencies in Hz.
design (str|'firwin2') – Design of the transfert function of the filter.
phase (str|`linear`) – Phase response (“zero”, “zero-double” or “minimum”).
window (float|`hamming`) – The window to use in FIR design, (“hamming”, “hann”, or “blackman”).
- Returns
array h. FIR coeffs.
Notes
Adapted from mne.filters, see the documentation of:
- timeflux_dsp.utils.filters.construct_iir_filter(rate, frequencies, filter_type, order=None, design='butter', pass_loss=3.0, stop_atten=50.0, output='sos')[source]
Calculate an IIR filter kernel for a given sampling rate.
- Parameters
rate (float) – Nominal sampling rate of the input data.
order (int) – Filter order
frequencies (list) – Transition frequencies in Hz.
filter_type (str) – Filter mode (lowpass, highpass, bandstop or bandpass).
design (str|'butter') – Design of the transfert function of the filter (butter, cheby1, cheby2, ellip, bessel)
pass_loss (float|`3.0`) – For Chebyshev and elliptic filters, provides the maximum ripple in the passband. (dB).
stop_atten (float|`50.0`) – For Chebyshev and elliptic filters, provides the minimum attenuation in the stop band. (dB)
- Returns
sos. IIR coeffs.
- Return type
array
Notes
Adapted from mne.filters, see the documentation of: