-
Notifications
You must be signed in to change notification settings - Fork 1
[Class] Frequency Domain Filter
This class allows you to design frequency domain filters! Conventional frequency filters can be very useful to cancel noise and artifacts that come along with the acquisition of your Biosignals.
Give the following design properties:
-
📈
fresponse
: The frequency response of the filter. Choose one from FrequencyResponse:-
FIR
- Finite Impulse Response -
BUTTER
- IIR Butterworth -
CHEBY1
- IIR Chebyshev 1 -
CHEBY2
- IIR Chebyshev 2 -
ELLIP
- IIR Elliptic -
BESSEL
- IIR Bessel
-
-
📉
band_type
: If frequency bands should be passed or rejected. Choose one from BandType:-
LOWPASS
- Low-pass -
HIGHPASS
- High-pass -
BANDPASS
- Band-pass -
BANDSTOP
- Band-stop
-
-
🔪
cutoff
: IfLOWPASS
orHIGHPASS
are chosen, give 1 frequency cutoff in Hz (in float). IfBANDPASS
orBANDSTOP
are chosen, give 2 frequency cutoffs in Hz (in a tuple of floats). -
#️⃣
order
: The filter order (in int), i.e., the number of coefficients of its H function. The more the better the result, but also the worst the computation time.
filter = FrequencyFilter(fresponse=FrequencyResponse.ELLIP, band_type=BandType.LOWPASS, cutoff=15, order=4)
filter = FrequencyFilter(fresponse=FrequencyResponse.ELLIP, band_type=BandType.BANDPASS, cutoff=(5, 30), order=4)
You can get and reset any of the four properties. You may also get the numerator and denominator coefficients of the H function computed for the last Biosignal filtered with the filter, using:
last_numerator_coeficients
last_denominator_coefficients
Raise AttributeError when no coefficients have been computed yet.
It's so easy, let's do it 👩🏽💻! To apply a Filter you have designed (e.g. f1
) to a Biosignal, just call filter
from that Biosignal and give f1
:
biosignal.filter(f1)
The filter will be applied to every channel of biosignal
and return 0 in case of success.
To draw a Bode plot of the Filter applied to a Biosignal, use plot_bode
. Example:
filter.plot_bode(show=True)
For details about plotting, see the rules of methods plot_{}.