Bioinformatics Book
Bioinformatics Book
Prepared By
Dr. Ali Siam
2024
Chapter 1 Common Biological Signals and Patterns
Chapter 1
1.1 Fingerprint
The skin on the palms of our hands has a special pattern called friction
ridges that help us grab things effectively without slipping. These
patterns consist of ridges and valleys arranged in certain configurations
and is unique for each individual. Our finger tips also have them as you
can see from the above image.
When a finger comes in contact with a surface, the ridges make strong
contact with the surface. When we strongly grab something, the
moisture, grease, dirt, and dead skin cells on our finger can attach to
the surface of the material, leaving an impression we call a fingerprint.
1
Chapter 1 Common Biological Signals and Patterns
Human fingerprints are unique, difficult to alter, and durable over the
life of an individual, making them suitable as long-term markers of
human identity. They may be employed by police or other authorities
to identify individuals who are suspicious in crimes, or to identify
people who are incapacitated or deceased and thus unable to identify
themselves, as in the aftermath of a natural disaster.
The matching of two fingerprints is among the most widely used and
most reliable biometric techniques. Fingerprint matching considers
only the obvious features of a fingerprint, by looking at the patterns of
fingerprints. These patterns are little ridges on the end of an
individual’s fingers and thumb that are arranged in a pattern of spirals
and loops.
2
Chapter 1 Common Biological Signals and Patterns
In the early 19th century, people started to realize that no two persons
have exactly the same pattern of fingerprints to the extent that it varies
even in the case of identical twins. These patterns are formed during
the 12th week of gestation and remain permanent throughout a person’s
life. With this discovery that fingerprints are a unique method of
identifying individuals, Sir Francis Galton first introduced the
technique of comparing prints found at a crime scene with those of the
suspect. Later, Sir Edward Henry developed the system of classifying
fingerprints that was first adopted as the official system in England
which eventually spread throughout the world.
3
Chapter 1 Common Biological Signals and Patterns
• Arch: The ridges enter from one side of the finger, rise in the
center forming an arc, and then exit the other side of the finger.
• Loop: The ridges enter from one side of a finger, form a curve, and
then exit on that same side.
• Whorl: Ridges form circularly around a central point on the finger.
Scientists have found that family members often share the same
general fingerprint patterns (arch, loop, or whorl), leading to the belief
that these patterns are inherited.
4
Chapter 1 Common Biological Signals and Patterns
Even if one finger has a cut or the entire hand is in a cast, there
would still be enough fingers for making an identification.
• The fingerprint is a very certain method for identifying a person,
because all fingerprints are unique. Even identical twins have
different fingerprints.
• Compared with other methods of identification, such as a key,
access card, numerical code or a password, the fingerprint is very
secure. You cannot lose or forget it, and it cannot be stolen.
• It is also extremely practical, because you do not need to carry
anything with you. Your pockets can be empty, there is no need to
try and find anything at the bottom of your bag, and you can forget
those big bundles of keys.
• You can also save significant system management costs. In
extensive systems, such as access control in factories or offices or
visitor identification at sports clubs, there is no need for cards or
keys that need to be distributed, collected back again, or removed
from the register due to lost cards or keys. For example, when
using fingerprint identification, visitors can be granted access for
even just a single day.
5
Chapter 1 Common Biological Signals and Patterns
Fingerprint identification
6
Chapter 1 Common Biological Signals and Patterns
Two other features are sometimes used in matching: core and delta.
The core can be thought of as the center of the fingerprint pattern. The
delta is a singular point from which three patterns deviate. The core
and delta locations can be used as landmark locations by which to
orientate two fingerprints for subsequent matching - though these
features are not present on all fingerprints.
8
Chapter 1 Common Biological Signals and Patterns
Operation Principle
9
Chapter 1 Common Biological Signals and Patterns
During the matching process, the user puts the same finger on the
optical sensor, and the system will generate a template of the finger
and compare it with templates of the finger library.
For 1:1 matching, the system will compare the current finger with a
specific template stored in the Module. For 1:N matching, or
searching, the system will search the whole finger library for the
matching finger. In both circumstances, the system will return the
matching result, success or failure, based on the matching score.
Technical Parameters
10
Chapter 1 Common Biological Signals and Patterns
FAR: is the rate that the sensor falsely accepts a fake template as a
genuine template.
FRR: is the rate that the sensor falsely rejects a genuine template.
Pinouts
You can use the PC application to interface with the sensor through
your computer. The PC software can be downloaded from:
http://www.adafruit.com/datasheets/SFGDemoV2.0.rar
11
Chapter 1 Common Biological Signals and Patterns
Project description
You can control other elements (such as motors, relays, etc.) based on
the matching result of the fingerprint sensor.
Required materials
- Arduino Uno
- R307 fingerprint sensor, or other similar fingerprint sensor.
- Green and Red LEDs
- 220 Ω resistor
- Jumper wires
12
Chapter 1 Common Biological Signals and Patterns
Connection
Code
The first step in using the fingerprint sensor is to install the Adafruit
Fingerprint Library, which can be done using the Library Manager.
Open the Arduino IDE and navigate to Sketch > Include Library >
Manage Libraries.
13
Chapter 1 Common Biological Signals and Patterns
When the library manager loads search for “Fingerprint” and the first
result should be the Adafruit Fingerprint Sensor Library. Go ahead and
install it.
14
Chapter 1 Common Biological Signals and Patterns
15
Chapter 1 Common Biological Signals and Patterns
With the library installed in your computer, we can proceed to the code
of the project.
#include <Adafruit_Fingerprint.h>
Adafruit_Fingerprint finger =
Adafruit_Fingerprint(&mySerial);
void setup() {
Serial.begin(9600);
pinMode(led_Green,OUTPUT);
pinMode(led_Red,OUTPUT);
finger.begin(57600);
delay(5);
if (finger.verifyPassword()) {
16
Chapter 1 Common Biological Signals and Patterns
} else {
finger.getTemplateCount();
if (finger.templateCount == 0) {
else {
void loop() {
matchFinger();
delay(50);
void matchFinger(){
uint8_t p = finger.getImage();
if (! p==FINGERPRINT_OK)
17
Chapter 1 Common Biological Signals and Patterns
return;
Serial.println("Image taken");
p = finger.image2Tz();
if (! p==FINGERPRINT_OK)
return;
Serial.println("Image converted");
p = finger.fingerSearch();
if (p == FINGERPRINT_OK) {
Serial.print("Found ID #");
Serial.print(finger.fingerID);
digitalWrite(led_Green,HIGH);
delay(1000);
digitalWrite(led_Green,LOW);
else if (p == FINGERPRINT_NOTFOUND) {
digitalWrite(led_Red,HIGH);
delay(1000);
digitalWrite(led_Red,LOW);
18
Chapter 1 Common Biological Signals and Patterns
Upload the code to the Arduino board and test the project.
If you put a finger that have been already enrolled and stored into the
memory of the sensor, the green LED will be turned on for 1 second.
If you put a finger that cannot be identified, the red LED will be turned
on for 1 second.
19
Chapter 1 Common Biological Signals and Patterns
Project testing
1) Successful matching
2) No matching
20
Chapter 1 Common Biological Signals and Patterns
21
Chapter 1 Common Biological Signals and Patterns
Applications
or scan,
22
Chapter 1 Common Biological Signals and Patterns
1.2 Electrocardiogram
The heart
23
Chapter 1 Common Biological Signals and Patterns
The functions of the four chambers of the heart are shown in the
following table.
24
Chapter 1 Common Biological Signals and Patterns
Characteristics of ECG
Origin of ECG
The electrical signal begins in the sinoatrial node (SA) which is located
in the right atrium and travels to the right and left atria, causing them
to contract and pump blood into the ventricles. This electrical signal is
recorded as the P wave on the ECG. The PR Interval is the time, in
seconds, from the beginning of the P wave to the beginning of the QRS
complex.
The electrical signal passes from the atria to the ventricles through the
atrioventricular (AV) node. The signal slows down as it passes through
this node, allowing the ventricles to fill with blood. This slowing signal
appears as a flat line on the ECG between the end of the P wave and
the beginning of the Q wave. The PR segment represents the electrical
conduction through the atria and the delay of the electrical impulse in
the atrioventricular node.
26
Chapter 1 Common Biological Signals and Patterns
After the signal leaves the AV node it travels along a pathway called
the bundle of His and into the right and left bundle branches. The
signal travels across the heart’s ventricles causing them to contract,
pumping blood to the lungs and the body. This signal is recorded as the
QRS waves on the ECG. Because these waves occur in rapid
succession they are usually considered together as the QRS complex.
The QT interval represents the time during which the ventricles are
stimulated and recover after the stimulation. This interval shortens at a
faster heart rate and lengthens at a slower heart rate.
The initial ECGs were recorded directly on paper and, in fact, still are
in many clinical cardiac electrophysiology laboratories. The
galvanometer was directly coupled to an ink pen. This way, a voltage
27
Chapter 1 Common Biological Signals and Patterns
The electrical activity going through the heart (ECG) can be measured
by attaching external electrodes to the skin. Commonly, 10 electrodes
attached to the body are used to form 12 ECG leads, with each lead
measuring a specific electrical potential difference. This method is
used in hospitals to obtain a clean ECG signal which can be used in
diagnosis of most heart diseases.
28
Chapter 1 Common Biological Signals and Patterns
The 10 electrodes in a 12-lead ECG are: RA, LA, RL, LL, V1, V2, V3,
V4, V5, and V6.
29
Chapter 1 Common Biological Signals and Patterns
Features
• Leads-Off Detection
• Shutdown Pin
Here, we will learn how to get an ECG signal using the AD8232 sensor
and Arduino uno board.
30
Chapter 1 Common Biological Signals and Patterns
Required materials
- Arduino Uno
- AD8232 sensor with electrodes
- 3 ECG sensor pads
- Breadboard
- Jumper wires
Connection
We will connect five of the nine pins on the board to the Arduino. The
five pins you need are labeled GND, 3.3v, OUTPUT, LO-, and LO+.
The other 3 pins RA, LA, and RL are already connected to the jack.
31
Chapter 1 Common Biological Signals and Patterns
Connect the electrodes wire pin to the jack input of the sensor board, as
shown in the figure below.
Then, stick the three pads on the body at locations as shown in the
following figure. These locations are based on Einthoven's method.
32
Chapter 1 Common Biological Signals and Patterns
Note that the closer to the heart the pads are, the better the
measurement.
AD8232 sensor does not need any special library, the communication
is based on the Serial interface.
Upload the following code to the Arduino board. After that, you can
see a waveform for the ECG on the Serial Plotter window provided
that the sensors are placed correctly and not moving.
void setup() {
Serial.begin(9600);
void loop() {
Serial.println('!');
else{
Serial.println(analogRead(A0));
}
delay(5);
33
Chapter 1 Common Biological Signals and Patterns
To verify that the heart rate monitor is working as expected, open the
serial monitor at 9600 baud. You should see values printed on the
screen. Below is an example output on the serial monitor.
Now, open the serial plotter in the Arduino IDE. To open the serial
plotter, select Tools > Serial Plotter. You should see a waveform
similar to the image below when the sensors are placed correctly and
not moving.
34
Chapter 1 Common Biological Signals and Patterns
Troubleshooting
• Try to use fresh pads for each measurement. The pads loose the
ability to pass signals with multiple applications.
• Prep and clean the area you plan to stick pads. This will help
make a good connection (hair is not a good conductor).
35
Chapter 1 Common Biological Signals and Patterns
Applications
b) Import the ECG signal into MATLAB. Then, display the first 1500
points of the signal. After that, mark the P, QRS complex, and T
waves found in the graph.
Note: signals are contained in (.dat) files. Use appropriate
MATLAB functions to read signals from these files.
36
Chapter 1 Common Biological Signals and Patterns
With the heart pumping blood to the body parts, the amount of blood
reaching the body peripherals changes with every heartbeat.
Photoplethysmogram (PPG) signal describes the amount of change of
blood flow in peripherals with heartbeats. PPG is commonly measured
at fingertip or at earlobe.
The pulse oximeter has a Light Emitting Diode (LED) to shine a light
through the fingertip and a photodetector (PD) to measure the amount
of the reflected light.
When the light is emitted from the LED through the fingertip, some of
light is absorbed by the blood and the other amount is reflected to PD.
37
Chapter 1 Common Biological Signals and Patterns
38
Chapter 1 Common Biological Signals and Patterns
With two light beams with different wavelengths, Red (660 nm) and IR
(880 nm), it is reported that HbO2 and Hb absorb the two different
wavelengths with different amounts, see the following figure. Hb has a
higher absorption at 660 nm, while HbO2 has a higher absorption at
880 nm.
This characteristic denotes that the amount of absorbed light at 660 and
880 nm can be used to approximate the amount of dissolved oxygen in
39
Chapter 1 Common Biological Signals and Patterns
the blood (SpO2). The two separate PPG signals determined from the
Red and IR LEDs are used to find the ratio R which is used to calculate
the SpO2 level:
The heart rate is denoted as the frequency at which the heart pumps
blood to the arteries, and is measured as the count of contractions of
the heart per minute. The heart rate is a reflection of the physical and
mental state of the body and can vary conditionally according to the
body’s physical needs, for example when the oxygen saturation level
is low.
40
Chapter 1 Common Biological Signals and Patterns
The heart rate is typically measured in beats per minute (bpm). The
normal heart rate of healthy adult persons is between 60 and 100 bpm
while they are at rest.
41
Chapter 1 Common Biological Signals and Patterns
MAX30102 sensor
Required materials
- Arduino Uno
- MAX30102 board
- Breadboard
- Jumper wires
Connection
MAX30102 sensor has seven pins from which only four pins are used.
The four pins needed are: Vin, SCL, SDA, and GND. These pins are
connected to the Arduino board as follows:
43
Chapter 1 Common Biological Signals and Patterns
Sensor library
The sensor library can be installed using the Library Manager. Open
the Arduino IDE and navigate to Sketch > Include Library > Manage
Libraries.
44
Chapter 1 Common Biological Signals and Patterns
For flexibility when using the sensor more times, the sensor can be put
inside a clip, as shown in the following figures. This also provides
convenience for a user instead of tying a rubber band around his finger
every time he needs to use the sensor. Use a cable of four wires (for
example, you can use an old mouse cable) to connect the sensor board
to the Arduino.
45
Chapter 1 Common Biological Signals and Patterns
Code
#include <Wire.h>
#include "MAX30105.h"
MAX30105 particleSensor;
void setup()
Serial.begin(115200);
Serial.println("Initializing...");
// Initialize sensor
if (!particleSensor.begin(Wire, I2C_SPEED_FAST))
while (1);
46
Chapter 1 Common Biological Signals and Patterns
void loop()
47
Chapter 1 Common Biological Signals and Patterns
Here, we aim to measure the heart rate (BPM: beats per minute) and
the blood oxygen saturation (SpO2) using MAX30102 sensor, and print
the measurements on Arduino's serial monitor.
The previous procedure, which we used to plot the PPG signal, will be
followed except the code will changed to the following code. Also, you
should open the serial monitor instead of the serial plotter.
Code
#include <Wire.h>
#include "MAX30105.h"
#include "spo2_algorithm.h"
MAX30105 particleSensor;
48
Chapter 1 Common Biological Signals and Patterns
long IR_val;
void setup()
Serial.begin(115200);
Serial.println("Initializing...");
// Initialize sensor
if (!particleSensor.begin(Wire, I2C_SPEED_FAST))
while (1);
49
Chapter 1 Common Biological Signals and Patterns
void loop()
IR_val = particleSensor.getIR();
Serial.println(" No finger!!");
redBuffer[i] = particleSensor.getRed();
irBuffer[i] = particleSensor.getIR();
50
Chapter 1 Common Biological Signals and Patterns
maxim_heart_rate_and_oxygen_saturation(irBuffer,
bufferLength, redBuffer, &spo2, &validSPO2, &heartRate,
&validHeartRate);
Serial.print(heartRate, DEC);
Serial.println(spo2, DEC);
51
Chapter 1 Common Biological Signals and Patterns
Applications
a) Make a project to measure the heart rate and SpO2 using the
MAX30102 sensor and display the measurements on an LCD
display.
In this project, you will need:
- Arduino Uno
- MAX30102 sensor
- 16x2 LCD display
- 10 KΩ potentiometer to control the brightness of the LCD
display.
- 220 Ω resistor to control the backlight of the LCD display.
- Breadboard
- Jumper wires
b) Make a project to measure the heart rate and SpO2 using the
MAX30102 sensor and send the measurements to a mobile
application.
In this project, you will need:
- Arduino Uno
- MAX30102 sensor
- Bluetooth module
- Breadboard
- Jumper wires
You can create your own mobile application using MIT App Inventor
on : http://ai2.appinventor.mit.edu/
52
Chapter 1 Common Biological Signals and Patterns
53
Chapter 1 Common Biological Signals and Patterns
54
Chapter 1 Common Biological Signals and Patterns
55
Chapter 1 Common Biological Signals and Patterns
Applications
56
Chapter 1 Common Biological Signals and Patterns
In our daily lives, the face is perhaps the most common and familiar
biometric feature. With the invention of photography, government
departments and private entities have kept facial photographs (from
personal identity documents, passports, or membership cards). These
collections have been used in forensic investigations, as referential
databases, to match and compare a respondent’s facial images (e.g.,
criminal, witness, or victim). Besides, the broad use of digital cameras
and smartphones made facial images easy to produce every day; these
images can be easily distributed and exchanged by rapidly established
social networks such as Facebook and Twitter.
57
Chapter 1 Common Biological Signals and Patterns
58
Chapter 1 Common Biological Signals and Patterns
59
Chapter 1 Common Biological Signals and Patterns
60
Chapter 1 Common Biological Signals and Patterns
Sometimes, some steps are not separated. For example, the facial
features (eyes, mouth, and nose) used for feature extraction are
frequently used during face detection. Detection and extraction of
features can be performed simultaneously.
Facial Landmarks
After detection of the face region in the first step, which results a
bounding box that surround the face in the image, a number of feature
points (landmarks) are determined (manually or automatically) inside
the bounding box.
There are usually two types of facial landmarks: the facial key points
and interpolated landmarks. The facial key points are the dominant
landmarks on face, such as the eye corners, nose tip, mouth corners,
etc. They possess unique local appearance/shape patterns. The
interpolated landmark points either describe the facial contour or
connect the key points (as shown in the following figure). In the early
research, only sparse key landmark points are annotated and detected.
Recently, more points are annotated in the new databases. For
62
Chapter 1 Common Biological Signals and Patterns
63
Chapter 1 Common Biological Signals and Patterns
𝑁
1 𝑝 2 𝑝 2
𝑅𝑀𝑆𝐸 = ∑ √(𝑥𝑖 − 𝑥𝑖𝑡 ) + (𝑦𝑖 − 𝑦𝑖𝑡 )
𝑁
𝑖=1
𝑁 √ 𝑝 2 2
1 (𝑥𝑖 − 𝑥𝑖𝑡 ) + (𝑦𝑖𝑝 − 𝑦𝑖𝑡 )
𝑁𝑅𝑀𝑆𝐸 = ∑
𝑁 𝑑𝑛𝑜𝑟𝑚
𝑖=1
64
Chapter 1 Common Biological Signals and Patterns
– BioID: The data set contains 1521 gray scale indoor images with a
resolution of 384 × 286 from 23 subjects. Images are taken under
different illumination and backgrounds. Subjects may show moderate
expression variations. It contains landmark annotations of 20 points.
– AR: The set contains 4,000 frontal color images of 126 people with
expressions, illumination, and facial occlusions (e.g. sun glasses and
scarf). 22 landmark annotations are provided.
65
Chapter 1 Common Biological Signals and Patterns
66
Chapter 1 Common Biological Signals and Patterns
– Ibug 300-W: The ibug dataset from 300 faces in the Wild (300-W)
database 3 is the most challenging database so far with significant
variations. It only contains 114 faces of 135 images with annotations of
68 landmarks.
– Ibug 300-VW: The 300 Video in the Wild (300) database contains
114 video sequences for three different scenarios from easy to difficult.
68 facial landmark annotations are provided.
Face recognition systems have been used in recent years to secure the
devices and control access to many different services through
smartphones, such as a purchase or online payments on the store.
67
Chapter 1 Common Biological Signals and Patterns
68
Chapter 1 Common Biological Signals and Patterns
Applications
The following Matlab code detects the face in the image using the
Viola-Jones algorithm. After that, it lets the user to annotate 20
landmarks in the image, and return their locations.
I = imread('kid.jpg');
faceDetector = vision.CascadeObjectDetector();
Facebboxes = faceDetector(I);
for i=1:20
p=round(getPosition(impoint));
loc(i,1)=p(1);
loc(i,2)=p(2);
end
69
Chapter 1 Common Biological Signals and Patterns
70
Chapter 1 Common Biological Signals and Patterns
The brain is an organ that is part of the central nervous system (CNS).
The brain monitors and regulates unconscious bodily processes, such
as digestion and breathing. The brain also coordinates most voluntary
movements of your body. It is also the site of conscious thinking,
allowing you to learn and create.
Each of the hemispheres are divided into four lobes: frontal, parietal,
temporal and occipital.
71
Chapter 1 Common Biological Signals and Patterns
72
Chapter 1 Common Biological Signals and Patterns
EEG device
EEG device is used for recording the electrical activity of the brain
from the scalp. This device comprised of electrodes to be attached to
the scalp, conductive gel, amplifiers, and analog-to-digital converter.
73
Chapter 1 Common Biological Signals and Patterns
EEG waves
The EEG recording shows different types of brain waves. A wave is
any type of brain activity, which appears as a ‘wave’ shape on the EEG
recording. There are different names for the brain waves which are put
into bands according to their frequencies or number of ‘waves’ per
74
Chapter 1 Common Biological Signals and Patterns
second, and each type of wave looks different on the EEG. Some brain
waves happen at particular times or in different areas of the brain.
Delta wave (0.5 – 4 Hz): It is the highest in amplitude and the slowest
wave. The delta waves are detected in infants up to one year and
sleeping adults.
Beta wave (13 – 30 Hz): Beta waves are often associated with
problem solving and logical thinking.
75
Chapter 1 Common Biological Signals and Patterns
76
Chapter 1 Common Biological Signals and Patterns
Every cell in the human body creates some electric activity as part of
its normal functioning. This rule is also applicable to the muscle cells.
Muscle cells produce electrical signals that cause muscles to contract
and relax. EMG records these signals using either electrodes placed on
the surface of the skin or inserting needles with electrodes in the
muscle.
The raw EMG (before filtering) is often considered as the most noisy
signal among almost all biomedical signals The following figure
shows an example of an EMG signal recorded from a muscle
performing consecutive contraction and relax.
77
Chapter 1 Common Biological Signals and Patterns
EMG has also been used as a control signal for computers and other
devices. An interface device based on an EMG Switch can be used to
control moving objects, such as mobile robots or an electric
wheelchair. This may be helpful for individuals that cannot operate a
joystick-controlled wheelchair. Surface EMG recordings may also be
a suitable control signal for some interactive video games.
78
Chapter 1 Common Biological Signals and Patterns
targeted for use in noisy environments, and may be helpful for people
without vocal cords.
Required materials
- Arduino Uno
- AD8232 sensor with electrodes
- 3 ECG sensor pads
- Breadboard
- LED
- 220 Ω resistor
- Jumper wires
Connection
79
Chapter 1 Common Biological Signals and Patterns
Connect the electrodes wire pin to the jack input of the sensor board, as
shown in the figure below.
After determining which muscle group you want to target (for example
we will use the right bicep) and cleaning the skin thoroughly, place one
80
Chapter 1 Common Biological Signals and Patterns
Last, place the third electrode on a bony part of the body nearby the
muscle group. We'll call this the reference electrode. For example, for
the biceps, we are placing the reference electrode on the bony end of
my forearm close to the elbow. The electrodes are placed on the
muscle as shown in the following figure.
Upload the following code to the Arduino board. After that, you can
see a waveform for the EMG on the Serial plotter.
int ledPin = 2;
void setup() {
Serial.begin(9600);
pinMode(ledPin,OUTPUT);
81
Chapter 1 Common Biological Signals and Patterns
void loop() {
Serial.println(sensorValue);
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1);
Testing
Clench your muscle so that the value of the EMG signal exceeds the
threshold value (750 in this case, you can change this value to adjust
the threshold value). The LED will glow when the EMG signal reaches
the threshold value.
The following figures show the output of the Serial Monitor and Serial
Plotter, respectively, during the actual testing of the circuit.
82
Chapter 1 Common Biological Signals and Patterns
83
Chapter 1 Common Biological Signals and Patterns
Applications
b) You can extend the project in (a) to control a robot hand (with five
fingers, with each finger is attached to a servo motor) with your
hand, such that each EMG signal from one finger of your hand is
used to control one finger of the robot hand. In this case, you may
need five sensors, each one to acquire the EMG signal from one
finger.
84
Chapter 1 Common Biological Signals and Patterns
The cornea (front) has a positive polarity. The retina (back) has a
negative polarity. As the eye moves, the vector of the electric field
between cornea and retina (i.e., corneoretinal potential) changes with
respect to recording electrodes placed in the skin at fixed points. These
bioelectrical signals are typically very small in amplitude (µV) and an
amplifier is required to accurately record the EOG.
85
Chapter 1 Common Biological Signals and Patterns
86
Chapter 1 Common Biological Signals and Patterns
87
Chapter 1 Common Biological Signals and Patterns
88
Chapter 1 Common Biological Signals and Patterns
Applications
89
Chapter 2 Biomedical Signal Processing
Chapter 2
Recall that the time domain represents the variation of the signal
amplitude over time. Unlike the time domain, the frequency domain is
a relationship between the frequency in x-axis and the signal amplitude
in y-axis.
90
Chapter 2 Biomedical Signal Processing
The analog signals have infinitely variable values at all times, denoted
as x(t).
91
Chapter 2 Biomedical Signal Processing
𝑁−1
−𝑗2𝜋𝑘𝑛
𝑋 (𝑘 ) = ∑ 𝑥 (𝑛 ) 𝑒 𝑁
𝑛=0
92
Chapter 2 Biomedical Signal Processing
𝑁−1
1 𝑗2𝜋𝑘𝑛
𝑥 (𝑛 ) = ∑ 𝑋 (𝑘 ) 𝑒 𝑁
𝑁
𝑘=0
93
Chapter 2 Biomedical Signal Processing
The key point here is that the frequency domain only displays the
amplitude for sinusoidal waveforms. Any arbitrary waveform (non-
sinusoidal) can be decomposed into an infinite series of sinusoidal
waveforms. This infinite series is called a Fourier series. An example
of a Fourier series for a triangle waveform is shown below.
The mathematical function shows that the series starts with sin(ωt) and
continues with 1/9*sin(3ωt), 1/25*sin(5ωt) and so on. The first and
largest frequency component, sin(ωt), is called the fundamental
frequency. Subsequent sinusoidal components such as sin(3ωt) and
sin(5ωt) are called harmonics, and they will diminish in amplitude as
the series continues. Theoretically, to get a perfect representation of a
triangle wave, an infinite number of sine waves is required. However
practically if you use the fundamental and several harmonics you will
get a pretty good representation of the triangle wave. This example
shows a fundamental with four harmonics in both the time and
frequency domain. Notice in the time domain waveform, the triangle
94
Chapter 2 Biomedical Signal Processing
95
Chapter 2 Biomedical Signal Processing
Example
96
Chapter 2 Biomedical Signal Processing
The following code generates the graph shown in below figure, which
represents the magnitude of the DFT of the signal x:
y = fft(x);
y_magnitude = abs(y);
n = length(y_magnitude);
plot(y_magnitude(1:n/2-1) );
xlabel('Frequency');
ylabel('Magnitude of DFT');
97
Chapter 2 Biomedical Signal Processing
2.2 Filters
Usually, filters are used to suppress noise from signals (or images).
The corrupted signal is passed through a filter, the output will be a
clean version of the input signal.
98
Chapter 2 Biomedical Signal Processing
Then, the output of the filter will be, 𝑌(𝑓) = 𝐻 (𝑓) ∗ 𝑋(𝑓).
Filter types
99
Chapter 2 Biomedical Signal Processing
100
Chapter 2 Biomedical Signal Processing
In this filter, two cut-off frequencies are specified: the lower cut-off
frequency 𝑓𝑐 𝑙 , and the higher cut-off frequency 𝑓𝑐 ℎ . In BPF, all
frequency components below the lower cut-off frequency and above
the higher cut-off frequency will be suppressed, passing only the
frequency components between the two cut-off frequencies.
4) Band-stop filter (BSF)
It suppresses signals in a certain frequency band and allows signals
outside the band to pass. A special case of the band-stop filter is the
notch filter in which it rejects just one specific frequency. The
frequency response of an ideal band-stop filter is shown in the
following figure.
101
Chapter 2 Biomedical Signal Processing
Practical filters
102
Chapter 2 Biomedical Signal Processing
103
Chapter 2 Biomedical Signal Processing
104
Chapter 2 Biomedical Signal Processing
Example:
n=10;
Fs=1000;
fc=300;
[b,a] = butter (n,fc/(Fs/2),‘low’);
105
Chapter 2 Biomedical Signal Processing
freqz(b,a,128,1000);
Example
106
Chapter 2 Biomedical Signal Processing
a) Signal creation
Fs=1000; % sampling frequency
f1=10; % frequency of first signal
f2=50; % frequency of second signal
dt=1/Fs; % time step
duration = 1; % signal duration in seconds
t=0:dt:duration-dt; % time axis
S1=sin(2*pi*f1*t); % the first signal
S2=sin(2*pi*f2*t); % the second signal
S=S1+S2; % the compound signal (sum of the two signals)
plot(t,S)
xlabel('Time (seconds)')
title('Compound signal, S = S1+S2') % set title to the figure
From the spectrum of the signal, it is appear that the signal contains 2
components:
1- Component with 10 Hz (this is the frequency of the first signal)
2- Component with 50 Hz (this is the frequency of the second signal)
The main goal is to extract the two signals separately, and it is achieved
as follows:
108
Chapter 2 Biomedical Signal Processing
figure
freqz(b,a,128,Fs); % visualize the frequency response of
the filter
title ('Frequency response of an LPF, fc=15 Hz, order=4')
figure
plot(f, y_magnitude(1:n/2));
xlabel('Frequency (Hz)');
ylabel('Magnitude of DFT');
title('Single-Sided Amplitude Spectrum of S1(t)')
109
Chapter 2 Biomedical Signal Processing
110
Chapter 2 Biomedical Signal Processing
It is clear that, from the frequency domain of the first extracted signal,
there is a single frequency component at 10 Hz. This means that we
have successfully extracted the first signal form the compound signal.
111
Chapter 2 Biomedical Signal Processing
figure
freqz(b,a,128,Fs); % visualize the frequency response of
the filter
title ('Frequency response of an HPF, fc=40 Hz, order=4')
112
Chapter 2 Biomedical Signal Processing
113
Chapter 2 Biomedical Signal Processing
Example:
A single channel EEG sensor is used to acquire the EEG signal from a
person. The sampling frequency of the sensor is 512 Hz. Samples of the
signal are stored in an Excel file (EEG.xlsx). It is required to extract the
four waves of the brain (Alpha, Beta, Theta, and Delta) from the EEG
signal.
114
Chapter 2 Biomedical Signal Processing
Recall that, the frequency bands for the four waves are:
Alpha wave: 8 – 13 Hz
Beta wave: 13 – 30 Hz
Theta wave: 4 – 8 Hz
Delta wave: 0.5 – 4 Hz
115
Chapter 2 Biomedical Signal Processing
figure
freqz(b_beta,a_beta,128,Fs);
title('Frequency response of filter for Beta wave,
13 - 30 Hz');
figure
freqz(b_theta,a_theta,128,Fs);
title('Frequency response of filter for Theta wave,
4 - 8 Hz');
figure
freqz(b_delta,a_delta,128,Fs);
title('Frequency response of filter for Delta wave,
0.5 - 4 Hz');
116
Chapter 2 Biomedical Signal Processing
117
Chapter 2 Biomedical Signal Processing
118
Chapter 2 Biomedical Signal Processing
Example:
An ECG sensor is used acquire the ECG signal from a person. During
the acquisition process, ECG signal is exposed to some sources of noise
which affect the overall acquired signal. Usually, the noise has higher
frequencies. Normal ECG signal has lower frequency, up to 10 Hz. It is
required to design a filter to remove the noise to obtain a clean ECG
signal. The noisy ECG signal is stored in an Excel file,
noisyECG_withTrend.xlsx. The sampling frequency of the signal is
1000 sample/second.
119
Chapter 2 Biomedical Signal Processing
120
Chapter 2 Biomedical Signal Processing
Additional step may be required to remove the trend line which exists
in the filtered signal. The trend line is caused by a very low signal,
below 2 Hz, which makes the original signal to goes up and down,
continuously.
Thus, a high-pass filter may be designed to remove the trend line from
the signal.
121
Chapter 2 Biomedical Signal Processing
122
Chapter 2 Biomedical Signal Processing
For example,
1
𝑦 (𝑛 ) = [𝑥 (𝑛) + 𝑥(𝑛 − 1)]
2
Similarly,
1
𝑦(𝑛) = [𝑥(𝑛) + 𝑥(𝑛 − 1) + 𝑥(𝑛 − 2) + 𝑥(𝑛 − 3) + 𝑥(𝑛 − 4) + 𝑥(𝑛 − 5)]
6
It sets the current sample value to the average of the current and the last
5 samples.
123
Chapter 2 Biomedical Signal Processing
124
Chapter 2 Biomedical Signal Processing
125
Chapter 2 Biomedical Signal Processing
126
Chapter 2 Biomedical Signal Processing
Application
Original Signal
close all
a=xlsread('noisy.xlsx'); % Read Input Signals from Excel
time=a(:,1);
noisy_signal=a(:,2);
plot(time, noisy_signal);
127
Chapter 2 Biomedical Signal Processing
dF=Fs/L;
From the spectrum of the signal, it is appear that the signal contains 5
components:
128
Chapter 2 Biomedical Signal Processing
The main goal is to remove all noise types from the signal, and it is
achieved as follows:
sig3_modified1=ifft(P2);
figure
plot(time,sig3_modified1);
129
Chapter 2 Biomedical Signal Processing
b- Removing 50 Hz Component
d = designfilt('bandstopiir','FilterOrder',2, ...
'HalfPowerFrequency1',40,'HalfPowerFrequency2',60, ...
'DesignMethod','butter','SampleRate',Fs);
130
Chapter 2 Biomedical Signal Processing
131
Chapter 2 Biomedical Signal Processing
d = designfilt('bandstopiir','FilterOrder',2, ...
'HalfPowerFrequency1',90,'HalfPowerFrequency2',110, ...
'DesignMethod','butter','SampleRate',Fs);
132
Chapter 2 Biomedical Signal Processing
d- Removing DC Component
% Dc Component can be removed by subtracting the mean of the
signal from the signal.
sig3_modified4=sig3_modified3-mean(sig3_modified3);
figure
plot(time, sig3_modified4)
133