[Command line function] [Interactive Fourier Filter] [Application of a narrow bandpass filter]
The Fourier filter is a type of filtering function that is based on manipulation of specific frequency components of a signal. It works by taking the Fourier transform of the signal, then attenuating or amplifying specific frequencies, and finally inverse transforming the result. Care must be taken to use both the sine and cosine (or equivalently frequency and phase, or real and imaginary) components of the Fourier transform. The example below is a crude low-pass, sharp cut-off filter, which simply cuts off all frequencies above a user-specified limit. The assumption is made here that the frequency components of the signal fall predominantly at low frequencies and those of the noise fall predominantly at high frequencies. The user tries to find a cut-off frequency that will allow most of the noise to be eliminated while not distorting the signal significantly.
The signal at the top left seems to be only random noise, but its power spectrum (top right) shows that high-frequency components dominate the signal. The power spectrum is expanded in the X and Y directions ( bottom left) to show more clearly the low-frequency region. Working on the hypothesis that the components above the 20th harmonic are noise, the Fourier filter function can be used to delete the higher harmonics and to reconstruct the signal from the first 20 harmonics. The result (bottom right) shows the signal contains two bands at about x=200 and x=300 that are totally obscured by noise in the original signal.
SPECTRUM, the freeware signal-processing application for Mac OS8 and earlier, includes a crude Fourier low-pass filter function, with adjustable harmonic cut-off.
The custom Matlab/Octave function FouFilter.m is a more flexible Fourier filter that can serve as a lowpass, highpass, bandpass, or bandreject (notch) filter with variable cut-off rate. Has the form ry= FouFilter(y, samplingtime, centerfrequency, frequencywidth, shape, mode), where y is the time-series signal vector, 'samplingtime' is the total duration of sampled signal in sec, millisec, or microsec; 'centerfrequency' and 'frequencywidth' are the center frequency and width of the filter in Hz, KHz, or MHz, respectively; 'Shape' determines the sharpness of the cut-off. If shape = 1, the filter is Gaussian; as shape increases the filter shape becomes more and more rectangular. Set mode = 0 for band-pass filter, mode = 1 for band-reject (notch) filter. FouFilter returns the filtered signal in ry. It can handle signals of virtually any length, limited only by the memory in your computer. Here's an examplexx=[0:.001:2*pi]';
y=[noise;signal+noise]; % sine wave is added halfway through.
title('Sine wave is added halfway through.')
title('Signal filtered with FouFilter.m')
iFilter 4.3, an Interactive Fourier
Filter for Matlab, allows you to select from six
filter modes ('band-pass', 'low-pass', 'high-pass',
'band-reject (notch), 'comb pass', and 'comb notch'). (In
the comb modes, the filter has multiple bands
located at frequencies 1, 2, 3, 4... times the center
frequency, each with the same controllable width and
shape). In each of these filter modes, you can
interactively adjust the filter parameters (center
frequency, filter width, and cut-off rate) while observing
the effect on the signal output dynamically. Does
not work in Octave.
Click here to view or download.
MorseCode.m uses iFilter to demonstrate the abilities and limitations of Fourier filtering. It creates a pulsed fixed frequency (0.05) sine wave that spells out “SOS” in Morse code (dit-dit-dit/dah-dah-dah/dit-dit-dit), adds random white noise so that the SNR is very poor (about 0.1 in this example). The white noise has a frequency spectrum that is spread out over the entire range of frequencies; the signal itself is concentrated mostly at a fixed frequency (0.05) but the presence of the Morse Code pulses spreads out its spectrum over a narrow frequency range of about 0.0004. This suggests that a Fourier bandpass filter tuned to the signal frequency might be able to isolate the signal from the noise. As the bandwidth is reduced, the signal-to-noise ratio improves and the signal begins to emerges from the noise until it becomes clear, but if the bandwidth is too narrow, the step response time is too slow to give distinct “dits” and “dahs”. The step response time is inversely proportional to the bandwidth. (Use the ? and " keys to adjust the bandwidth. Press 'P' or the Spacebar to hear the sound). You can actually hear that sine wave component better than you can see it in the waveform plot (upper panel), because the ear works like a spectrum analyzer, with separate nerve endings assigned to to specific frequencies, whereas the eye analyzes the graph spatially, looking at the overall amplitude and not at individual frequencies.