[Simple Example]
[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 lowpass, sharp cutoff filter, which simply cuts off all frequencies above a userspecified 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 cutoff 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 highfrequency components dominate the signal. The power spectrum is expanded in the X and Y directions ( bottom left) to show more clearly the lowfrequency 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 signalprocessing application for Mac OS8 and earlier, includes a crude Fourier lowpass filter function, with adjustable harmonic cutoff.

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
cutoff rate. Has the form ry= FouFilter(y,
samplingtime, centerfrequency, frequencywidth, shape,
mode), where y is the timeseries 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 cutoff. If shape = 1, the
filter is Gaussian; as shape increases the filter shape
becomes more and more rectangular. Set mode = 0 for
bandpass filter, mode = 1 for bandreject (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 are two examples of its
application: TestFouFilter.m
demonstrates a Fourier bandpass filter applied to a noisy
100 Hz sine wave which appears in the middle third of the
signal record. TestFouFilter2.m
demonstrates the Fourier bandpass filter applied to a
noisy 100 Hz sine wave signal with the filter center
frequency swept from 50 to 150 Hz. Both requires the
FouFilter.m function in the Matlab/Octave path. iFilter 4.3, an Interactive Fourier
Filter for Matlab, allows you to select from six
filter modes ('bandpass', 'lowpass', 'highpass',
'bandreject (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 cutoff rate) while observing
the effect on the signal output dynamically. This
is a selfcontained Matlab function that does not
require any toolboxes or addon functions. 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 (ditditdit/dahdahdah/ditditdit), 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 signaltonoise 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. Watch an mp4 video of this script
in operation, with sound. Also on YouTube. The script RealTimeFourierFilter.m is a demonstration of a realtime Fourier filter which is discussed in Appendix Y. 