Efficient FIR realtime filter
An efficient Finite Impulse Response (FIR) filter class written in C++ with python wrapper.
Adaptive filtering is also implemented using the Least Mean Square (LMS) or Normalised Least Mean Square (NLMS) algorithm.
If you want to install it via pip you first need to install the fir1 filter binaries:
sudo add-apt-repository ppa:berndporr/usbdux sudo apt-get update sudo apt install fir1 sudo apt install fir1-dev
Then install the python package with pip:
pip3 install fir1
You can also install from source:
git clone https://github.com/berndporr/fir1 cd fir1 cmake . make make install python3 setup.py install
There is a pre-compiled package which can be installed via pip:
pip3 install fir1
If you want to compile from source you first need to build the static fir windows library which is called fir_static.lib. Open the command line and type:
cmake -G "Visual Studio 15 2017 Win64" .
Then start Visual Studio and build fir.sln. Go back to the command line and type:
python setup.py install
The filter is a realtime filter which receives samples one by one so it can process data as it arrives from an ADC converter. This is simulated here with the for loop:
import fir1 b = signal.firwin(999,0.1) f = fir1.Fir1(b) for i in range(len(noisy_signal)): clean_signal[i] = f.filter(noisy_signal[i])
The constructor Fir1() receives the filter coefficients (= impulse response) and then filtering is performed with the method filter().
LMS adaptive filter
The file lms_50Hz_ecg_filter.py removes 50Hz from an ECG with the help of the lms filter. The filter learns its own frequency response from a reference 50Hz sine wave.
Both the demo file and an explanation how the LMS filter works can be found on the homepage of the project:
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size fir1-188.8.131.52-cp36-cp36m-win_amd64.whl (27.7 kB)||File type Wheel||Python version 3.6||Upload date||Hashes View hashes|
|Filename, size fir1-184.108.40.206-py3.6-linux-x86_64.egg (75.4 kB)||File type Egg||Python version 3.6||Upload date||Hashes View hashes|
|Filename, size fir1-220.127.116.11-py3.6-win-amd64.egg (30.7 kB)||File type Egg||Python version 3.6||Upload date||Hashes View hashes|
|Filename, size fir1-18.104.22.168.tar.gz (53.4 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for fir1-22.214.171.124-cp36-cp36m-win_amd64.whl
Hashes for fir1-126.96.36.199-py3.6-linux-x86_64.egg
Hashes for fir1-188.8.131.52-py3.6-win-amd64.egg