Filters¶
eitprocessing.filters.butterworth_filters.LowPassFilter
dataclass
¶
LowPassFilter(
*,
filter_type: Literal["lowpass"] = "lowpass",
cutoff_frequency: float | tuple[float],
order: int,
sample_frequency: float,
ignore_max_order: InitVar[bool] = False
)
Low-pass Butterworth filter for filtering in the time domain.
LowPassFilter
is a convenience class similar to ButterworthFilter
, where the
filter_type
is set to "lowpass".
apply_filter
¶
Apply the filter to the input data.
PARAMETER | DESCRIPTION |
---|---|
input_data
|
Data to be filtered. If the input data has more than one axis, the filter is applied to the last axis.
TYPE:
|
axis
|
Data axis the filter should be applied to. This defaults to the last axis, assuming this to be the time axis of the input data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
The filtered output with the same shape as the input data. |
eitprocessing.filters.butterworth_filters.HighPassFilter
dataclass
¶
HighPassFilter(
*,
filter_type: Literal["highpass"] = "highpass",
cutoff_frequency: float | tuple[float],
order: int,
sample_frequency: float,
ignore_max_order: InitVar[bool] = False
)
High-pass Butterworth filter for filtering in the time domain.
HighPassFilter
is a convenience class similar to ButterworthFilter
, where the
filter_type
is set to "highpass".
apply_filter
¶
Apply the filter to the input data.
PARAMETER | DESCRIPTION |
---|---|
input_data
|
Data to be filtered. If the input data has more than one axis, the filter is applied to the last axis.
TYPE:
|
axis
|
Data axis the filter should be applied to. This defaults to the last axis, assuming this to be the time axis of the input data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
The filtered output with the same shape as the input data. |
eitprocessing.filters.butterworth_filters.BandStopFilter
dataclass
¶
BandStopFilter(
*,
filter_type: Literal["bandstop"] = "bandstop",
cutoff_frequency: float | tuple[float],
order: int,
sample_frequency: float,
ignore_max_order: InitVar[bool] = False
)
Band-stop Butterworth filter for filtering in the time domain.
BandStopFilter
is a convenience class similar to ButterworthFilter
, where the
filter_type
is set to "bandstop".
apply_filter
¶
Apply the filter to the input data.
PARAMETER | DESCRIPTION |
---|---|
input_data
|
Data to be filtered. If the input data has more than one axis, the filter is applied to the last axis.
TYPE:
|
axis
|
Data axis the filter should be applied to. This defaults to the last axis, assuming this to be the time axis of the input data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
The filtered output with the same shape as the input data. |
eitprocessing.filters.butterworth_filters.BandPassFilter
dataclass
¶
BandPassFilter(
*,
filter_type: Literal["bandpass"] = "bandpass",
cutoff_frequency: float | tuple[float],
order: int,
sample_frequency: float,
ignore_max_order: InitVar[bool] = False
)
Band-pass Butterworth filter for filtering in the time domain.
BandPassFilter
is a convenience class similar to ButterworthFilter
, where the
filter_type
is set to "bandpass".
apply_filter
¶
Apply the filter to the input data.
PARAMETER | DESCRIPTION |
---|---|
input_data
|
Data to be filtered. If the input data has more than one axis, the filter is applied to the last axis.
TYPE:
|
axis
|
Data axis the filter should be applied to. This defaults to the last axis, assuming this to be the time axis of the input data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
The filtered output with the same shape as the input data. |
eitprocessing.filters.butterworth_filters.ButterworthFilter
dataclass
¶
ButterworthFilter(
*,
filter_type: Literal["lowpass", "highpass", "bandpass", "bandstop"],
cutoff_frequency: float | tuple[float],
order: int,
sample_frequency: float,
ignore_max_order: InitVar[bool] = False
)
Butterworth filter for filtering in the time domain.
Generates a low-pass, high-pass, band-pass or band-stop digital Butterworth filter of order
order
. Filters are created using cascaded second-order sections representation, providing
better stability compared to the traditionally used transfer function (numerator/denominator or
b/a representation).
The apply_filter()
method applies the filter to the provided data using forward-backward
filtering. This minimizes the phase shift, and effectively doubles the order of the filter.
ButterworthFilter
is a wrapper of the scipy.butter()
and scipy.filtfilt()
functions:
- https://docs.scipy.org/doc/scipy-1.10.1/reference/generated/scipy.signal.butter.html
- https://docs.scipy.org/doc/scipy-1.10.1/reference/generated/scipy.signal.filtfilt.html
PARAMETER | DESCRIPTION |
---|---|
filter_type
|
The type of filter to create: a low pass, high pass, band pass or band stop filter.
TYPE:
|
cutoff_frequency
|
Cutoff frequency or frequencies (in Hz). For low pass or high pass
filters, |
order
|
Order of the filter. The effective order size is twice the given order, due to forward-backward filtering. Higher orders improve the effectiveness of a filter, but can result in unstable or incorrect filtering.
TYPE:
|
sample_frequency
|
The sample frequency of the data to be filtered (in Hz).
TYPE:
|
ignore_max_order
|
Whether to raise an exception if the order is larger than the maximum of 10. Defaults to False.
TYPE:
|
Examples:
>>> t = np.arange(0, 100, 0.1)
>>> signal = np.sin(t) + 0.1 * np.sin(10 * t)
>>> lowpass_filter = ButterworthFilter(
... filter_type='lowpass',
... cutoff_frequenct=45,
... order=4,
... sample_frequency=250
... )
>>> filtered_signal = lowpass_filter.apply_filter(signal)
apply_filter
¶
Apply the filter to the input data.
PARAMETER | DESCRIPTION |
---|---|
input_data
|
Data to be filtered. If the input data has more than one axis, the filter is applied to the last axis.
TYPE:
|
axis
|
Data axis the filter should be applied to. This defaults to the last axis, assuming this to be the time axis of the input data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
The filtered output with the same shape as the input data. |