Signal filtering is a fundamental technique in signal processing used to enhance, clean or isolate specific components of a signal by removing unwanted noise or frequencies. It plays an important role in domains like audio processing, biomedical engineering, communications and data analysis. With Python's SciPy library, particularly scipy.signal module provides a robust set of tools to design and apply various digital filters.
Signal Filtering Techniques
1. Butterworth Low pass Filter
Butterworth Low pass Filter removes high frequency noise by allowing frequencies below the cutoff (100 Hz) to pass smoothing the signal.
A noisy signal is created by combining sinusoids and random noise and a Butterworth low pass filter removes frequencies above 100 Hz using zero phase filtering then the original and filtered signals are plotted for comparison.
Butterworth High pass Filter removes low frequency components below the cutoff (100 Hz) highlighting higher frequency details.
A Butterworth high pass filter is applied to remove frequencies below 100 Hz from the signal. The filtfilt function ensures zero phase distortion during filtering. The filtered signal is plotted alongside the original to show the high frequency components retained.
Butterworth Band pass Filter passes frequencies within a specified range filtering out frequencies outside this band.
A Butterworth band pass filter passes frequencies between 40 Hz and 130 Hz removing components outside this range. The filtfilt function ensures zero phase distortion. The plot shows the original and band pass filtered signals for comparison.
Butterworth Band stop Filter removes frequencies within a narrow band often used to eliminate specific noise like powerline interference.
A Butterworth band stop (notch) filter removes frequencies between 55 Hz and 65 Hz from the signal. The filtfilt function applies the filter with zero phase distortion. The plot compares the original and notch filtered signals.
Median Filter reduces impulsive noise by replacing each point with the median of neighbouring values, preserving edges better than linear filters.
A median filter with a kernel size of 5 is applied to the signal to reduce noise especially impulsive noise. It replaces each point with the median of neighbouring values preserving edges better than linear filters. The plot shows the original and median filtered signals for comparison.
Savitzky Golay Filter smooths the signal by fitting polynomials within a moving window, preserving signal features like peaks while reducing noise.
The Savitzky Golay filter smooths the signal using a polynomial fit within a moving window of length 11 and polynomial order 3. This preserves features like peaks while reducing noise. The plot compares the original and smoothed signals.
Noise Reduction: All signals are contaminated by unwanted noise and this noise can come from environmental interference, electronic components or transmission errors. Filtering helps clean the signal preserving the important information and discarding the irrelevant fluctuations.
Improved Analysis and Feature Detection: Noisy data can make it difficult to detect features such as peaks, troughs or edges. Filtering helps make these features more apparent and accurate which is critical for Peak detection, Edge detection etc.
Data Pre processing: Before feeding signals into algorithms itβs essential to pre process the data to remove distortions. Filters ensure the input is clean and relevant which improves model performance and stability.
Eliminating Sensor Errors and Artifacts: Sensor readings often suffer from sudden spikes, dropouts or drifts due to environmental factors, hardware limitations or calibration issues. Filters can smooth out these anomalies and make the data more reliable for decision making.