$30
Computing the Fourier Transform of a biological signal: The Fourier Transform is perhaps the
most popular technique for analyzing biological signals. It allows the signals to be visualized in
the frequency domain via spectra. From Lecture, the Fourier Transform is given as follows:
π(π) = ∫−∞∞ π₯(π‘)π−πππ‘ππ‘.
(1)
In general, the biological signal π₯(π‘) is too complicated to determine its Fourier Transform π(π)
analytically (i.e., by pencil and paper). A computer must therefore be used. However, the Fourier
Transform is a continuous function and an infinite integral. As a result, it cannot be determined
with a computer! Three modifications are necessary for computer-based solution. First, the
integral is approximated using rectangular pulses of width ππ to convert it to a sum as follows:
π(π) ≈ ∑∞π=−∞ π₯(π ππ )π−ππππ πππ .
(2)
Then, the signal is assumed to be non-zero within the finite time interval [0, (π − 1)ππ + ππ ] so
that the infinite sum becomes a finite sum as follows:
π(π) = ∑ππ=−01 π₯(π ππ )π−ππππ πππ .
(3)
Finally, the continuous variable πππ is sampled at intervals of 2ππ over the range of [0,2π] to
transform the continuous function to a discrete function as follows:
π[π] = π(π)|πππ =2πππ = ∑ππ=−01 π₯(π ππ )π−π2ππ ππππ ,
π = 0,1, … , π − 1.
(4)
For convenience, ππ is set to unity to arrive at the “Discrete Fourier Transform (DFT)” as follows:
π[π] = ∑ππ=−01 π₯[π]π−π2ππ ππ ,
π = 0,1, … , π − 1.
(5)
The DFT is a discrete function and a finite sum. As a result, it is amenable to computer-based
solution for a given “sampled signal” π₯[π].
The Fast Fourier Transform (FFT) is a family of algorithms for efficient computation of the DFT.
These algorithms, in particular, are widely used in biological signal processing.2
The purpose of this problem is to learn how to use the all-important, built-in fft function.
1. Figure 1 shows a continuous-time signal π₯(π‘). The Fourier Transform of this signal can be
determined analytically and is π(π) = 12 ( π ππ(6π)
6π )2 π−ππ12 . Plot the magnitude and phase
spectra over an π range of [0, π] using a fine sampling interval.
This exact result will be
needed to compare the FFT results to be computed below.
Figure 1
2. Take samples of π₯(π‘) at ππ = 1 to define π₯[π] as a vector of 25 samples in length using the
triang function. Use the fft function to compute the DFT of this signal for π = 256. Plot the
DFT magnitude and phase spectra. Note that the x-axis should range over an πππ of [0,2π].
How does this result compare to the analytical result? What is the highest frequency shown
by the FFT?
3. Now plot the DFT spectra of the signal for π = 16, 32, 128. Compare all FFT plots with the
analytical result. For what values of π are the DFT samples (mostly) valid? Which values of
π are, for the most part, indicative of the true spectral content of the signal and why? How
can π be chosen in practice without knowledge of the analytical result?
4. Use pair 17 in Table 7.1 (Fourier Transform pairs) and properties in Table 7.2 (Fourier
Transform properties) to derive π(π) in question 1. (Hint: see Practice Exam 1!)
5. Compute the DFT for the clean action potentialsignal from Project 1. Plot the DFT magnitude
and phase spectra. Note that π
π =
1
in the previous questions. This simplification turned out
to make frequencies for π₯(π‘) and
π₯
[π
] the same values! However, in general, ππ is not unity.
For example, ππ = 0.0796 ms for the action potentialsignal. So,such simplification no longer
holds. From the red font, it can be inferred that the highest frequency shown by the FFT in
units of Hz is half the “sampling frequency” (i.e., 1/(2*0.0796)=6.2814 kHz in this case). So,
make sure to plot the spectra from 0 kHz to 6.2814 kHz! Do the spectra meet your
expectations for the action potential signal?Designing a filter to remove noise from a biological signal: In Project 1, a filter impulse response
was given, which removed the noise in the noisy action potential signal without compromising
the information in the clean action potentialsignal. In practice, filters are not given! The purpose
of this problem is to learn how to design a filter.
6. Plot the DFT magnitude and phase spectra for the noisy action potential signal from Project
1. Compare to the corresponding plots of the clean action potential signal. This comparison
may be facilitated using units of decibels. What are the main differences in the frequency
domain? Noting these differences should help in filter design.
7. Now design a filter using window-based filter design to selectively remove the noise. Use the
built-in function fir1. Apply the filter to each signal while experimenting with different cutoff
frequencies. Plot the selected filter impulse response and each of the filtered signals. What
kind of filter was selected and what were the cutoff frequencies?