You are on page 1of 22

sensors

Article
Wearable Real-Time Heart Attack Detection and
Warning System to Reduce Road Accidents
Muhammad E. H. Chowdhury 1, * , Khawla Alzoubi 1 , Amith Khandakar 1 , Ridab Khallifa 1 ,
Rayaan Abouhasera 1 , Sirine Koubaa 1 , Rashid Ahmed 2 andt Anwarul Hasan 2
1 Electrical Engineering Department, College of Engineering, Qatar University, Doha-2713, Qatar;
kalzoubi@qu.edu.qa (K.A.); amitk@qu.edu.qa (A.K.); rh1205366@student.qu.edu.qa (R.K.);
ra1302696@student.qu.edu.qa (R.A.); sk1300288@student.qu.edu.qa (S.K.)
2 Department of Industrial and Mechanical Engineering, College of Engineering, Qatar University, Doha 2713,
Qatar; rashid.ahmed@qu.edu.qa (R.A.); ahasan@qu.edu.qa (A.H.)
* Correspondence: mchowdhury@qu.edu.qa; Tel.: +974-4403-7382

Received: 12 April 2019; Accepted: 10 June 2019; Published: 20 June 2019 

Abstract: Heart attack is one of the leading causes of human death worldwide. Every year, about
610,000 people die of heart attack in the United States alone—that is one in every four deaths—but
there are well understood early symptoms of heart attack that could be used to greatly help in saving
many lives and minimizing damages by detecting and reporting at an early stage. On the other hand,
every year, about 2.35 million people get injured or disabled from road accidents. Unexpectedly,
many of these fatal accidents happen due to the heart attack of drivers that leads to the loss of
control of the vehicle. The current work proposes the development of a wearable system for real-time
detection and warning of heart attacks in drivers, which could be enormously helpful in reducing
road accidents. The system consists of two subsystems that communicate wirelessly using Bluetooth
technology, namely, a wearable sensor subsystem and an intelligent heart attack detection and
warning subsystem. The sensor subsystem records the electrical activity of the heart from the chest
area to produce electrocardiogram (ECG) trace and send that to the other portable decision-making
subsystem where the symptoms of heart attack are detected. We evaluated the performance of dry
electrodes and different electrode configurations and measured overall power consumption of the
system. Linear classification and several machine algorithms were trained and tested for real-time
application. It was observed that the linear classification algorithm was not able to detect heart attack
in noisy data, whereas the support vector machine (SVM) algorithm with polynomial kernel with
extended time–frequency features using extended modified B-distribution (EMBD) showed highest
accuracy and was able to detect 97.4% and 96.3% of ST-elevation myocardial infarction (STEMI) and
non-ST-elevation MI (NSTEMI), respectively. The proposed system can therefore help in reducing the
loss of lives from the growing number of road accidents all over the world.

Keywords: heart attack; real time system; portable device; machine learning algorithm; support
vector machine

1. Introduction
Fatal road accidents have become an alarming issue all over the globe. A driver with a medical
condition is much more vulnerable to being hit and much more likely to cause a crash. This could
injure the driver or anyone involved and can possibly be fatal [1]. Any disorder or condition that
inhibits the driver’s strength, coordination, agility, mental capacities, judgment, attention, knowledge,
or skill is a disorder or condition that can cause auto accidents. Some of the medical conditions that
lead to accidents are seizures, strokes, heart attacks, impaired vision, or other conditions that include

Sensors 2019, 19, 2780; doi:10.3390/s19122780 www.mdpi.com/journal/sensors


Sensors 2019, 19, 2780 2 of 22

Alzheimer’s disease, Parkinson’s disease, and dementia [2]. Anything that inhibits any ability to drive
creates a risk not only to the driver but to those sharing a road with them as well.
Although acute medical illness is responsible for a small percentage of motor vehicle crashes, with
estimates ranging from less than 0.1% to 3% in several studies [3–5], they are responsible for significant
morbidity and mortality. In a study of 298 road crashes in the Adelaide metropolitan area [6], it was
found that a medical condition was the main causal factor in 13% of the casualty crashes investigated
and accounted for 23% of all hospital admission and fatal crash outcomes. A study among Japanese
Sensors 2018, 18, x FOR PEER REVIEW 2 of 22
taxi drivers showed that a total of 98 drivers (23%) out of 844 experienced a collision or near miss
incident
inhibits duethe todriver’s
their own acute health
strength, problems [7].
coordination, agility, mental capacities, judgment, attention,
Heart attack is a sudden and
knowledge, or skill is a disorder or condition sometimes fatal occurrence
that can cause of coronary thrombosis,
auto accidents. Sometypically
of theresulting
medical
in the death of part of a heart muscle. Heart attack is among the highest
conditions that lead to accidents are seizures, strokes, heart attacks, impaired vision, or other causes of human death and
disability worldwide [8]. Even though heart attack is life threatening,
conditions that include Alzheimer’s disease, Parkinson’s disease, and dementia [2]. Anything that it has early symptoms that could
greatly
inhibitshelp
anyinability
savingtomanydrivelives andaavoiding
creates risk notconsequences
only to the driverif it is but
detected and sharing
to those reportedainroad a timely
with
manner to
them as well.the health care facilities. Therefore, to reduce road accidents that might result from the driver
beingAlthough
precipitated acute bymedical
heart attack,
illnessthere is an urgent
is responsible forneed for apercentage
a small portable wearable
of motor system
vehicle that can
crashes,
continuously
with estimates monitor
ranging forfrom
any early symptoms
less than 0.1% to of this
3% in medical
several situation,
studies which[3–5], could
they are inform the patient
responsible for
(driver) as well as medical caregivers with the vehicle location. Thus,
significant morbidity and mortality. In a study of 298 road crashes in the Adelaide metropolitan a driver could pull over the
vehicle
area [6],safely
it wasbefore
found losing
thathis/her
a medicalconsciousness
condition to wasavoid
the potentially
main causal fatal consequences,
factor in 13% of and medical
the casualty
caregivers could arrive
crashes investigated andaccounted
and provide lifesaving
for 23% of procedures
all hospital to rescue
admission the driver
and fatalin acrash
timelyoutcomes.
manner. A
study among Japanese taxi drivers showed that a total of 98 drivers (23%) out of 844 experiencedina
Myocardial infarction (MI), commonly known as heart attack, is a serious medical emergency
which theorsupply
collision near miss of blood to the
incident dueheart is suddenly
to their own acute blocked, usually by[7].
health problems a blood clot in the coronary
arteryHeart
[9,10].attack
A lack is a sudden and sometimes fatal occurrence of coronarymuscle
of blood to the heart may seriously damage the heart and can
thrombosis, be life
typically
threatening. There are three types of heart attack—ST-elevation
resulting in the death of part of a heart muscle. Heart attack is among the highest causes of human myocardial infarction (STEMI),
non-ST-elevation
death and disability myocardial infarction
worldwide [8]. (NSTEMI),
Even though and coronary
heart attackspasm is [11].
life Electrical
threatening, signals recorded
it has early
from the heart are referred to as electrocardiograms (ECG or EKG).
symptoms that could greatly help in saving many lives and avoiding consequences if it is detected A normal ECG trace (Figure 1A)
consists of components that indicate electrical events during one heartbeat.
and reported in a timely manner to the health care facilities. Therefore, to reduce road accidents that P wave is the first short
upward movement
might result from of thethe ECG being
driver tracing, which indicates
precipitated that the
by heart atriathere
attack, are contracting
is an urgent andneed
pumping
for a
blood into the ventricles. The QRS complex normally begins with
portable wearable system that can continuously monitor for any early symptoms of this medical a downward deflection, Q, a larger
upwards
situation,deflection,
which could a peak (R), the
inform andpatient
then a downwards
(driver) as well S wave. The QRS
as medical complex represents
caregivers atrial
with the vehicle
repolarization and ventricular depolarization and contraction. The
location. Thus, a driver could pull over the vehicle safely before losing his/her consciousness to PR interval indicates the transit
time
avoidfor the electrical
potentially fatalsignal to travel from
consequences, the sinuscaregivers
and medical node to the ventricles.
could arrive and T wave is normally
provide lifesaving a
modest
proceduresupwards waveform
to rescue the driverrepresenting
in a timely ventricular
manner. repolarization.

A B C
Figure 1: Comparison of the ST-segment variations in a normal subject (A) and in MI patients with STEMI (B)
Figure
Figure
and 1. 1.Comparison
NSTEMI Comparison
(C) of ST-segment
of the the ST-segment variations
variations in asubject
in a normal normal(A)subject (A)patients
and in MI and inwith
MI
patients with
ST-elevation ST-elevation
myocardial myocardial
infarction infarction
(STEMI) (B) (STEMI) (B)
and non-ST-elevation MI and non-ST-elevation
(NSTEMI) (C). MI
(NSTEMI) (C).
A STEMI (Figure 1B) occurs when a coronary artery becomes completely blocked and a large
portion of the muscle
Myocardial stops receiving
infarction blood, whereas
(MI), commonly known asNSTEMI (Figure
heart attack, is 1C) is duemedical
a serious to partialemergency
blockage
of
in the coronary
which artery of
the supply [12]. MI symptoms
blood vary
to the heart is among individuals;
suddenly around by
blocked, usually 89.7% have chest
a blood clot inpain,
the
coronary artery [9,10]. A lack of blood to the heart may seriously damage the heart muscle and can
be life threatening. There are three types of heart attack—ST-elevation myocardial infarction
(STEMI), non-ST-elevation myocardial infarction (NSTEMI), and coronary spasm [11]. Electrical
signals recorded from the heart are referred to as electrocardiograms (ECG or EKG). A normal ECG
trace (Figure 1A) consists of components that indicate electrical events during one heartbeat. P
Sensors 2019, 19, 2780 3 of 22

and 67.4% have pain in the upper part of the left arm [13]. One major symptom other than extreme
sweating is the irregularity of the ECG pattern. A STEMI will cause the ST complex to be elevated;
however, this is not the case in NSTEMI (https://myheart.net/articles/nstemi/). STEMI is detectable and
more lethal; therefore, it is the main concern [12].
The existing ambulatory ECG monitoring systems take a considerable amount of time and effort
to record ECG signals in patients through long-term hospitalization, and the ECG data have to be
sent to professionals for diagnostic analysis. However, a wearable ECG device can help in real-time
monitoring of heart attack because it can make decisions itself by observing irregular events of ECG
signals and identification of sudden heart attack and will be particularly useful for drivers in saving
their lives and avoiding accidents.
To observe the changes in ECG patterns, the ECG signal needs to be acquired, amplified, filtered,
and analyzed for MI detection through various algorithms. There are recent studies that suggest
either the development of a two-electrodes based amplifier alone [14,15] or a three-electrode wearable
portable ECG system [16,17]. In [18], two gel-less electrodes-based ECG systems were designed for
low power portable application to acquire ECG signals and heart rate while the subject was engaged in
different physical activities. In the two-electrode design, there was a reference electrode compensation
circuitry to avoid saturation and to increases common mode rejection. It also had baseline correction
and isolated ground, which helped in direct current (DC) drift and common mode noise illumination.
This system was useful for the two-electrode based signal acquisition. However, this system did not
include any machine learning algorithm to detect any abnormality of the heart. In [19], two Ag/AgCl
electrodes were used for ECG signal acquisition. The ECG signal was then transmitted at 2.4 GHz
band to a personal computer (PC). The system was capable of operating for 49 h continuously from
a rechargeable lithium-ion battery. This system was also designed to monitor ECG signal without
a smart algorithm. Yap et al. [20] presented a chest-belt type two-electrode wireless real-time ECG
recording system, which was based on an android monitoring application. This design included
motion artifacts compensation and R-peak detection for ECG arrhythmia detection. The experiment
results showed significant improvement of R-peak detection accuracy during fast movement activity
states. However, the MI detection was not implemented in this research. The algorithm implemented
in [21] detected any ST elevation and compared it to an isoelectric line. Each R peak was extracted
by comparing to a threshold of 0.6. The T peak was located between the R-peak with a margin of
400 ms and the J point (beginning of the ST-isoelectric line) with a margin of 80 ms. This approach was
implemented in this research as a reference work for linear classification to evaluate its robustness and
suitability for the driver application. Another linear classification and threshold-based algorithm was
developed in [22]. The algorithm used LabVIEW Mobile Module and Bluetooth for receiving data.
Both systems were capable of real time analysis of the ECG signal. However, they were not suitable for
MI detection. Using the Physiobank MI database, Sopic et al. [23] showed a support vector machine
(SVM) based real-time MI detection system with a classification accuracy of 90%. An enhanced and
optimized adaptive filter with optimal filter coefficients selection and a fuzzy rule-based algorithm
was shown to resolve the motion artifact issue in the two-electrode small size wearable chest belt ECG
system mounted with a three-axis accelerometer for ECG and ubiquitous activity recording in daily
life. However, the authors did not mention any abnormality classification algorithm in this work [24].
Cardiovascular disease is the leading cause of medical illness and sudden death in commercial
motor vehicle drivers (CMV) [25]. Cardiovascular disease has an increasingly powerful impact on
the health and safety of CMV drivers because of its prevalence in the population, its progressive
nature, the aging work force, and recent advances in diagnosis and therapy. Most studies have shown
that cardiovascular disease is the major cause of acute medical illness that results in motor vehicle
crashes [4,26–28]. However, a study [29] from the National Motor Vehicle Crash Causation Survey
(NMVCCS) in the USA reported that 95% of the drivers in crashes precipitated by medical emergencies
experienced seizures (35%), blackouts (29%), diabetic reactions (20%), or heart attack (11%) prior to the
crashes, where heart attack was shown to contribute to 11% of the crashes. A National Transportation
vehicle crashes [4,26–28]. However, a study [29] from the National Motor Vehicle Crash Causation
Survey (NMVCCS) in the USA reported that 95% of the drivers in crashes precipitated by medical
emergencies experienced seizures (35%), blackouts (29%), diabetic reactions (20%), or heart attack
(11%) prior to the crashes, where heart attack was shown to contribute to 11% of the crashes. A
Sensors 2019, 19, 2780 4 of 22
National Transportation Safety Board (NTSB) study [30] described fatal heavy trucks crashes where
19 out of 185 truck drivers were fatally injured. Seventeen of those 19 crashes (89%) involved a form
of cardiac
Safety Board incident
(NTSB)atstudy
the time of the accident,
[30] described e.g., trucks
fatal heavy suddencrashes
incapacitation
where 19of the
out of driver duedrivers
185 truck to an
acute fatally
were heart problem
injured. [31].
Seventeen of those 19 crashes (89%) involved a form of cardiac incident at the
time Inof this work, thee.g.,
the accident, authors
sudden proposed the development
incapacitation of the driver of due
a prototype
to an acutemodel
heart forproblem
a wearable
[31].real-
time Inheart
thisattack
work, detection
the authors and warning
proposed thesystem to be used
development of aby a vehicle
prototype driver.
model forThe authorsreal-time
a wearable worked
on anattack
heart accurate detection
detection andofwarning
symptoms of atoheart
system attack
be used by event
a vehicleusing a machine-learning
driver. The authors worked algorithm.
on an
The system
accurate is continuously
detection of symptoms monitoring the ECG
of a heart attack eventtrace
using ofathe driver, and if algorithm.
machine-learning any pre-symptom
The system of
heart attack is found,
is continuously the driver
monitoring the ECGis informed
trace of theto pull overand
driver, his/her
if anyvehicle, and an of
pre-symptom alerting call and
heart attack is
message
found, thewith theispatient
driver informedlocation
to pullisover
senthis/her
to a pre-defined
vehicle, and number to inform
an alerting call andemergency
message withmedicalthe
ambulance
patient facilities.
location is sentIntothis manner, anumber
a pre-defined driver tocan save emergency
inform himself/herself by avoiding
medical ambulancefatal road
facilities.
accidents beforea driver
In this manner, losing can
his/her
save consciousness,
himself/herself and emergency
by avoiding fatalmedical services
road accidents can approach
before losing his/herthe
driver in a timely
consciousness, manner tomedical
and emergency provideservices
required canlifesaving
approach medical
the driverprocedures
in a timely to avoidtoany
manner life-
provide
threatening consequences.
required lifesaving medicalAccordingly,
procedures the proposed
to avoid system will helpconsequences.
any life-threatening in controlling Accordingly,
the growing
number
the proposedof road accidents
system all over
will help the world.the
in controlling Furthermore,
growing number as theofproposed systemallisover
road accidents wearable and
the world.
portable,
Furthermore, any as person with previous
the proposed systemhistory (or even
is wearable without previous
and portable, any person history) of heart history
with previous attack can (or
take
even advantage of this history)
without previous system of in heart
different
attacksettings
can take (e.g., work, home,
advantage of this driving,
system inetc.). Last settings
different but not
least, work,
(e.g., this system
home, can help etc.).
driving, the vehicle
Last butdriver in claiming
not least, insurance
this system can helpfacility if the accident
the vehicle driver inisclaiming
caused
due to the facility
insurance driver’sifill
thehealth.
accident is caused due to the driver’s ill health.
The rest of the paper is divided into five sections. Section 2 discusses the research methodology
and the details of the studies done in this work. work. Section 3 shows a detailed analysis of the studies
followed by the results discussed in Section 4 and finally finally concluded
concluded in in Section
Section 5.5.

2. Experiment
2. Experiment Details
Details and
and Methods
Methods
The prototype
The prototype system
system consists
consists of
of two
two subsystems
subsystems that
that communicate
communicate wirelessly
wirelessly using
using Bluetooth
Bluetooth
low energy (BLE) technology—a wearable sensor subsystem and an intelligent
low energy (BLE) technology—a wearable sensor subsystem and an intelligent heart heart attack detection
attack
and warning
detection andsubsystem,
warning as shown in Figure
subsystem, 2. The
as shown in sensor
Figuresubsystem uses dry
2. The sensor ECG electrodes
subsystem uses dryto sense
ECG
the electrical
electrodes to activity from
sense the the chestactivity
electrical area to from
produce
the an ECGarea
chest trace.
to The raw signals
produce an ECG from the The
trace. patient’s
raw
body are sent continuously through the Bluetooth interface to the detection and
signals from the patient’s body are sent continuously through the Bluetooth interface to the warning subsystem.
The later continuously
detection and warning processes and analyzes
subsystem. the raw
The later measurements
continuously to detect
processes andanyanalyzes
symptoms related
the raw
to heart attack.
measurements to detect any symptoms related to heart attack.

Figure 2: Block diagram of the prototype system


Figure
Figure2.2.Overall
Overall system blockdiagram.
system block diagram.

Real-time ECG signal acquisition, amplification, filtering, digitization, and wireless transmission
are accomplished by the wearable sub-system. This subsystem is attached to a chest belt to be worn by
a driver. This includes three dry electrodes (reference and two electrodes for differential acquisition),
an analogue front end (AFE), and an RFduino microcontroller with an embedded BLE module. Dry
electrodes acquire the potential difference from the body, amplify and filter it through AFE, and
Real-time ECG signal acquisition, amplification, filtering, digitization, and wireless
transmission are accomplished by the wearable sub-system. This subsystem is attached to a chest
belt to be worn by a driver. This includes three dry electrodes (reference and two electrodes for
differential acquisition), an analogue front end (AFE), and an RFduino microcontroller with an
embedded BLE module. Dry electrodes acquire the potential difference from the body, amplify and
Sensors 2019, 19, 2780 5 of 22
filter it through AFE, and then digitize and transmit the raw data to the decision-making
subsystem. Reusable and smaller dimension dry electrodes (Cognionics, Inc) are embedded in a
chest belt to be
then digitize andworn by a vehicle
transmit the raw driver.
data to ThetheAFE is required to maintain
decision-making subsystem. high signal-to-noise
Reusable and smallerratio
(SNR),
dimension high drycommon
electrodes mode rejection,Inc)
(Cognionics, andarefewer baseline
embedded in adrift
chestandbeltsaturation
to be wornproblems.
by a vehicle AD8232
driver.
(analog
The AFEdevices)
is requiredAFEtoismaintain
an integrated signal conditioning
high signal-to-noise module
ratio (SNR), to extract,
high common amplify (60 dB gain),
mode rejection, and
and
fewer filter (bandwidth
baseline drift and 0.48–41 Hz) the
saturation ECG signal
problems. AD8232in the presence
(analog of noisy
devices) AFEconditions. The module
is an integrated signal
includes
conditioninglead-off
module detection,
to extract, single
amplifysupply operation,
(60 dB gain), and adjustable gain control,
filter (bandwidth 0.48–41 rail-to-rail
Hz) the ECG output,
signala
three-pole
in the presenceadjustable
of noisy low pass filter
conditions. The (LPF),
module a two-pole
includes adjustable high pass
lead-off detection, filter
single (HPF),
supply and an
operation,
integrated
adjustable gainright-leg drive
control, (RLD). A
rail-to-rail 50 Hza center
output, frequency
three-pole Wien
adjustable lowbridge notch(LPF),
pass filter filter aistwo-pole
used to
remove
adjustable thehigh
50 Hzpassline frequency
filter (HPF), and from anthe ECG signal.
integrated The drive
right-leg output of theA notch
(RLD). 50 Hz filter
centerisfrequency
digitized
usingbridge
Wien RFduino andfilter
notch transmitted
is used totoremove
the decision-making subsystem.from the ECG signal. The output of
the 50 Hz line frequency
The ARM
the notch filter isCortex
digitizedM0 using
is theRFduino
core of RFduino microcontroller
and transmitted and has a built-in
to the decision-making Bluetooth 4.0
subsystem.
low energy
The ARM Cortex M0 is the core of RFduino microcontroller and has a built-in Bluetooth as
module. RFduino uses Arduino integrated development environment (IDE) 4.0user
low
interface program,
energy module. which uses
RFduino allows testing integrated
Arduino and running of pre-written
development sketches and
environment (IDE) takes advantage
as user interfaceof
the existing
program, libraries.
which allowsRFduino
testing and has a 10-bit
running of analog-to-digital
pre-written sketches (ADC) module,
and takes which of
advantage is the
capable
existingof
acquiring the ECG signal
libraries. RFduino at a 500
has a 10-bit Hz sampling rate
analog-to-digital (ADC) withmodule,
the resolution
which is ofcapable
2.93 mV. ofMoreover,
acquiring the
dimension,
ECG signal the at alow-power
500 Hz sampling consuming rate feature,
with thethe 3.0 V operating
resolution of 2.93 mV. voltage, and the
Moreover, thebuilt-in
dimension,BLE
module make RFduino an excellent choice for this application. The
the low-power consuming feature, the 3.0 V operating voltage, and the built-in BLE module make wearable subsystem is powered
through
RFduino aanlithium
excellent(Li)-ion
choicebattery
for thisthat is connected
application. directly through
The wearable subsystem a power cell board.
is powered through The power
a lithium
management
(Li)-ion batterymodule (PMM) is directly
that is connected a boost converter (to 3.3 cell
through a power V and 5 V)The
board. andpower
micro-universal
management serial
modulebus
(USB) charger in one. The boost converter is based on the TPS61200 from
(PMM) is a boost converter (to 3.3 V and 5 V) and micro-universal serial bus (USB) charger in one. Texas Instrumentation (TI)
and boost
The has a converter
solder jumperis based selectable at 5 V and
on the TPS61200 3.3 Texas
from V outputs and an under-voltage
Instrumentation (TI) and hasprotection of 2.6
a solder jumper
V. The module can be charged by a mobile charger using an on-board micro-USB
selectable at 5 V and 3.3 V outputs and an under-voltage protection of 2.6 V. The module can be charged connector and is
capable
by a mobileof delivering
charger using 3.3 Vanoron-board
5 V. Themicro-USB
PMM is configured
connectorto provide
and 3.3 Vofoutput
is capable deliveringto the3.3RFduino,
V or 5 V.
the AFE
The PMMmodule, and the
is configured to notch
provide filter.
3.3 VThe wearable
output to themodule
RFduino, is the
a chest-belt
AFE module, with andan ECG amplifier,
the notch filter.
The wearable module is a chest-belt with an ECG amplifier, the packaging of the ECG amplifierthe
the packaging of the ECG amplifier is designed using a three-dimensional (3D) printer, and is
assembly is shown
designed using in Figure 3.
a three-dimensional (3D) printer, and the assembly is shown in Figure 3.

Figure 3: Exterior (A), interior view (B) of the 3D model of the ECG amplifier, and (C) ECG
Figure
Figure 3.3. Exterior
Exterior(A)
(A)and
andinterior
interior view
view (B)
(B) ofofthe
thethree-dimensional
three-dimensional (3D)
(3D) model
model of thethe
amplifier with the chest-belt and (D) dry electrodes.
electrocardiograms
electrocardiograms (ECG)(ECG) amplifier
amplifier and (C)and (C) amplifier
the ECG the ECGwith amplifier
the chestwith the(D)
best and chest best and
dry electrodes.
(D) dry electrodes.
The intelligent heart attack detection and warning subsystem is the brain of the whole system
and plays a major role in system operation. This module detects the event of heart attack in real-time
depending on the acquired ECG signal and the trained machine learning model using the Massachusetts
Institute of Technology-Beth Israel Hospital (MIT-BIH) ST Change Database [32]. This subsystem
is built around the single board computer, Raspberry Pi 3 (RPi3) (quad core 1.2 GHz, 1 GB RAM,
microSD, WiFi, BLE). The ECG signal is received in RPi3 over the BLE interface from RFduino. ECG
data are buffered for 10 s, and the baseline drift is corrected, segmented to ECG-beats (one ECG trace),
and smoothened using a digital filter. This subsystem incorporates SIM 908 global system for mobile
Sensors 2019, 19, 2780 6 of 22

communications (GSM)/General Packet Radio Service (GPRS) and the Global Positioning System (GPS)
module interfaced directly to RPi3 using the cooking-hack shield. The shield is popular for its low
power consumption feature during GSM communication and GPS data acquisition. The shield is
directly fitted on the Raspberry Pi 3 and powered by the RPi3 power. The standard DC connector to
supply electrical power for portable accessories used in cars is used to power the decision-making
module. The shield uses a serial communication interface for its data communication with RPi3.
However, the hardware serial port of the RPi3 is dedicated to its internal BLE module. Therefore,
the internal BLE of the RPi3 has to be disabled to establish a communication between the RPi3 and
the SIM908 module. The RPi3 runs in autonomous startup login mode and a python script is started
in startup, which is used to acquire and buffer the ECG data in the local RPi3 memory. Figures 3
and 4 show the various blocks of the prototype wearable and decision-making system. Details of the
detection
Sensors 2018,algorithm are REVIEW
18, x FOR PEER discussed in the analysis section. 6 of 22

A
B
C

GPS Antenna

BLE Dongle
GSM Antenna

Figure
Figure 4.4.Intelligent
Intelligent decision-making
decision-making subsystem
subsystem hardware
hardware (A) with(A)
thewith the 3Dmodel
3D printed printed model
(B) and the
(B) andformat
packet the packet format
used for used for communication
communication (C). (C).

2.1. Study 1: Hardware


The intelligent Performance
heart Evaluation
attack detection and warning subsystem is the brain of the whole system
and plays
All thea experimental
major role in studies
system were
operation.
carriedThis
outmodule detects
on healthy maletheand event
female of heart attackwith
volunteers in real-
the
time depending on the acquired ECG signal and the trained machine learning
ethical approval from the local ethical committee. In order to evaluate the performance of the designed model using the
Massachusetts Institute experiments
hardware, the following of Technology-Beth Israel Hospital
were conducted (MIT-BIH)
for the wearable andSTdecision-making
Change Database [32].
systems:
This subsystem is built around the single board computer, Raspberry Pi 3 (RPi3) (quad core 1.2
2.1.1. Evaluation
GHz, 1 GB RAM,ofmicroSD,
the Wearable
WiFi,System
BLE). The ECG signal is received in RPi3 over the BLE interface
from Three
RFduino. ECG data
experiments are conducted
were buffered for 10 s,
using theand the baseline
wearable system: drift is corrected,
i) dry electrodessegmented
performance, to
ECG-beats (one ECG trace), and smoothened
ii) lead configurations, and iii) ECG system performance. using a digital filter. This subsystem incorporates SIM
908 global systemoffor
The quality themobile communications
ECG signal acquired by the(GSM)/General
prototype modelPacketin Radio Service
the vehicle (GPRS) and
environment the
using
Global
both dry Positioning System Ag/AgCl
and conventional (GPS) module interfacedwhile
wet electrodes directly to RPi3
the user wasusing
drivingthethe
cooking-hack shield.
vehicle at different
The shield is popular for its low power consumption
speeds was evaluated to compare the performance of the electrodes. feature during GSM communication and GPS
data The
acquisition.
driver wasThe constantly
shield is directly fitted steering,
controlling on the Raspberry
thus hands Pi 3movement
and powered madeby the RPi3 power.
it impossible to
The standard DC connector to supply electrical power for portable accessories
extract ECG from the left arm (LA), the right arm (RA), and the right leg (RL). Electrodes used in cars is to
had used
be
to power
placed in the
suchdecision-making module. natural
a place that the driver’s The shield useswould
driving a serialnot
communication
be hampered while interface for its data
preserving the
communication with RPi3. However, the hardware serial port of the RPi 3
normal ECG signal. To select the right electrode placement area that was convenient for the driver and is dedicated to its
internal BLE module. Therefore, the internal BLE of the RPi3 has to be disabled
at the same time had high noise immunity, experiments were conducted using dry electrodes for testing to establish a
communication between the RPi3 and the SIM908 module. The RPi3 runs in
the performance of the different lead configurations in the vehicle environment at different speeds. autonomous startup
loginThere
modewere and three
a python
lead script is startedtested
configurations in startup,
using which
three ECGis used to acquire
electrodes, and buffer
as shown the ECG
in Figure 5:
data in the local RPi3 memory. Figure 3 and Figure 4 show the various blocks of the prototype
(i) Leadand
wearable I ECG Recording: ECGsystem.
decision-making sensorsDetails
were placed
of theondetection
the right algorithm
arm (RA), the are left arm (LA),
discussed in and
the
the section.
analysis right leg (RL), as shown in Figure 5A.
(ii) Chest Lead II ECG Recording: Figure 5B shows a commonly used three-electrodes chest
2.1. Study
ECG1:recording
Hardware configuration
Performance Evaluation
where the electrodes were placed on the upper left torso in a
triangular shape.
All the experimental studies were carried out on healthy male and female volunteers with the
ethical approval from the local ethical committee. In order to evaluate the performance of the
designed hardware, the following experiments were conducted for the wearable and decision-
making systems:

2.1.1. Evaluation of the Wearable System


Sensors 2019, 19, 2780 7 of 22

(iii) Chest Straight Lead: Figure 5C is a commonly used configuration in magnetic resonance imaging
Sensors 2018, 18, x FOR PEER REVIEW 7 of 22
(MRI) environments that are less susceptible to motion and vibration artifacts, which any user
might experience
electrodes for testinginside the vehicle. of the different lead configurations in the vehicle
the performance
environment at different speeds.

Negative

Positive

Neutral

(A) (B) (C)


Figure5.5.Different
Figure Different ECG
ECG leadlead configurations
configurations tested: tested:
(A) Lead(A) Lead
I; (B) I; Lead
Chest (B) Chest Lead Straight
II; (C) Chest II; (C) Chest
Lead.
Straight Lead.
ECG signals were acquired from two healthy subjects by placing electrodes simultaneously in
the chest
Therearea forthree
were the prototype and a commercial
lead configurations wireless
tested using wearable
three ECG amplifier
ECG electrodes, (BioRadio)
as shown [33]5:to
in Figure
compare the quality
i) Lead of the ECG ECG
I ECG Recording: traces.
sensors were placed on the right arm (RA), the left arm (LA),
and the right leg (RL), as shown in Figure 5A.
2.1.2.ii)
Decision-Making
Chest Lead II ECG and Alerting System
Recording: Figure 5B shows a commonly used three-electrodes chest
ECGThe recording configuration where the
SIM 908 modules functionality of short electrodes
messagewere placed
service (SMS),oncall
the upper left
origination andtorso in a
reception,
triangular
and GPS datashape.
acquisition were tested initially in the command-line interface of the RPi3 using attention
(AT) iii) Chest Straight
commands. Lead: Figure
Multi-threaded 5C iscode
Python a commonly usedfor
was written configuration
RPi3 using thein magnetic resonance
arduPi library [34]
imaging (MRI) environments that are less susceptible to motion and vibration artifacts,
developed by a cooking hack to automatically initiate an SMS text if the abnormality in ECG trace was which any
user mightExperiments
detected. experience inside the vehicle.
were carried out to evaluate the performance of the alerting system, which
ECGan
included signals
audiblewere acquired
(buzzer) localfrom
alert two healthy
for the driversubjects
and theby placing electrodes
GSM/GPRS based callsimultaneously
and SMS alerts to in
chest area for
the pre-defined the prototype and a commercial wireless wearable ECG amplifier (BioRadio) [33]
number.
to compare the quality of the ECG traces.
2.1.3. Reliability of the BLE Transmission between Two Sub-Systems
2.1.2.Experiments
Decision-Makingwere and Alerting
conducted toSystem
check the performance of the wireless transmission system in
transmitting
The SIMthe 908ECG data over
modules the wirelessofinterface
functionality and to evaluate
short message service the fidelity
(SMS), call of the signal and
origination at a
500 Hz sampling
reception, and GPSfrequency. RFduinowere
data acquisition uses BLE protocol
tested initiallytoin
transmit data throughinterface
the command-line a GenericofAttribute
the RPi3
Profile (GATT) to
using attention RPi3.
(AT) GATT is the
commands. standard BLEPython
Multi-threaded devicescode
communication
was writtenservices
for RPi3and characteristics
using the arduPi
protocol.
library [34]Before any BLE
developed by connection is established,
a cooking hack the device
to automatically should
initiate advertise
an SMS text if itself. Advertising
the abnormality in
and connection processes are controlled by the Generic Access Profile (GAP). Once
ECG trace was detected. Experiments were carried out to evaluate the performance of the alerting a connection is
initiated, the peripheral
system, which includeddevice (wearable
an audible subsystem’s
(buzzer) local alertRFduino) can only
for the driver andbetheconnected
GSM/GPRS to one central
based call
device
and SMS (RPi3). In the
alerts to ourpre-defined
system, RFduino
number. was the GATT master, which held the GATT service and
characteristic. On the other hand, the GATT client (RPi3) was responsible for sending requests and
2.1.3. Reliability
receiving of the
responses. ToBLE Transmission
ensure reliable databetween Two Sub-Systems
transmission to the RPi3 without missing any data packet,
notification of incoming data packet reception in the BLE buffer was used. Moreover, to increase the
Experiments were conducted to check the performance of the wireless transmission system in
sampling frequency of the RFduino to 500 Hz in data acquisition, ECG data were buffered before
transmitting the ECG data over the wireless interface and to evaluate the fidelity of the signal at a
transmission, and after every 20 ms, a buffered frame was sent to RPi3. This was to ensure low
500 Hz sampling frequency. RFduino uses BLE protocol to transmit data through a Generic
power consumption of the wearable system while keeping high frequency sampling for reliable ECG
Attribute Profile (GATT) to RPi3. GATT is the standard BLE devices communication services and
acquisition. The RFduino timer interrupt was used to ensure 2 ms interrupt-driven data acquisition to
characteristics protocol. Before any BLE connection is established, the device should advertise itself.
guarantee the 500 Hz sampling frequency.
Advertising and connection processes are controlled by the Generic Access Profile (GAP). Once a
connection is initiated, the peripheral device (wearable subsystem’s RFduino) can only be
connected to one central device (RPi3). In our system, RFduino was the GATT master, which held
the GATT service and characteristic. On the other hand, the GATT client (RPi3) was responsible for
sending requests and receiving responses. To ensure reliable data transmission to the RPi3 without
missing any data packet, notification of incoming data packet reception in the BLE buffer was used.
Moreover, to increase the sampling frequency of the RFduino to 500 Hz in data acquisition, ECG
data were buffered before transmission, and after every 20 ms, a buffered frame was sent to RPi3.
This was to ensure low power consumption of the wearable system while keeping high frequency
sampling
Sensors 2019, for reliable ECG acquisition. The RFduino timer interrupt was used to ensure 28 ofms
19, 2780 22
interrupt-driven data acquisition to guarantee the 500 Hz sampling frequency.

2.1.4. Power
2.1.4. Power Consumption
Consumption of
of the
the Two
Two Subsystems
Subsystems
A detailed
A detailedstudy
studywas accomplished
was accomplished on the
on power consumption
the power of the two
consumption subsystems
of the to compare
two subsystems to
the efficiency of the system in terms of the power consumption. Overall
compare the efficiency of the system in terms of the power consumption. Overall power power consumption of
the wearable system
consumption was testedsystem
of the wearable in fourwastesttested
scenarios: low-power
in four consumption
test scenarios: modeconsumption
low-power of RFduino,
ECG signal acquisition with no BLE transmission, ECG acquisition and burst BLE
mode of RFduino, ECG signal acquisition with no BLE transmission, ECG acquisition and burst transmission, and
continuous ECG acquisition and BLE transmission with a 500 Hz sampling of
BLE transmission, and continuous ECG acquisition and BLE transmission with a 500 Hz samplingECG data while the
frames
of ECG of buffered
data ECG
while the data were
frames transmitted
of buffered every
ECG data 20 ms.
were Figure 6A
transmitted shows
every the Figure
20 ms. complete
6A power
shows
consumption testing arrangement for the power management section of the wearable
the complete power consumption testing arrangement for the power management section of the subsystem.

(A)

Voltage and current measurement

(B)
Figure
Figure 6.6. Set-up
Set-upofofpower
powerconsumption
consumption study
study for for wearable
wearable subsystem
subsystem (A)decision-making
(A) and and decision-
making
subsystem subsystem
(B). (B).

The decision-making
The decision-making subsystem
subsystem was was designed
designedwith
withmultiple
multiplecomponents—RPi3,
components—RPi3,GPS, GPS,a
a GPRS/GSM shield, a cooling fan, and a BLE dongle. To characterize the current
GPRS/GSM shield, a cooling fan, and a BLE dongle. To characterize the current consumption of the consumption
of the complete
complete subsystem,
subsystem, individual
individual systemsystem component
component consumption
consumption was evaluated
was evaluated by the bytestthe test
set-up
set-up shown
shown in Figure
in Figure 6B. The6B. The power
power meter
meter was was drawing
drawing 3.2 mA3.2 mA without
without connecting
connecting it to theitRPi3,
to thewhich
RPi3,
which represented the power consumption of the mobile charger and the power meter
represented the power consumption of the mobile charger and the power meter itself. This mobile itself. This
mobile charger was connected to RPi3 using RPi’s micro-USB port. Different
charger was connected to RPi3 using RPi’s micro-USB port. Different scenarios of current scenarios of current
consumption were
consumption were tested
tested to
to find
find out
out the
the current
current consumption
consumption byby the
the decision-making
decision-making modulemodule in in
these
these cases. We tested how much current it consumed
We tested how much current it consumed during during the initialization
initialization process, the BLE
data transmission
data transmission and
and processing,
processing, idle
idle mode,
mode, fan
fan off
off mode,
mode, GSM
GSM initialization mode, and
initialization mode, and active
active
transmission mode of GSM and GPS.

2.2. Study
2.2. Study 2:
2: Performance
PerformanceEvaluation
Evaluation of
of MI
MI Detection
Detection Algorithms
Algorithms
In order
In order to
to evaluate the performance
evaluate the performance ofof the
the MI
MI detection
detection algorithms,
algorithms, the
the authors
authors experimented
experimented
with a linear classification algorithm in the preliminary study and then 22 different
with a linear classification algorithm in the preliminary study and then 22 different machine machine
learning
(ML) algorithms [three decision tree, two discriminant analysis, six SVMs, six k-nearest
learning (ML) algorithms [three decision tree, two discriminant analysis, six SVMs, six k-nearest neighbor
(KNN), and five ensembles classifiers] were trained for real-time ECG classification. Experiments
were done in two phases. In the first phase, we used a public labeled database “MIT-BIH ST Change
Database” for identifying suitable classification algorithms for detecting heart attack. In this database,
normal healthy subject data and abnormal MI patient data are available. The MIT-BIH ST change
database has 28 ECG recording datasets in total, where 14 subjects’ ECG recordings were normal ECG
Sensors 2019, 19, 2780 9 of 22

traces, seven patients had T-inversion, and the other patients experienced long-term recordings that
showed ST elevation and depression. The databases are developed and managed by the Physiobank
organization. Physiobank is a database of “well-characterized digital recordings of physiologic signals
and related data for the use by the biomedical research community”. Therefore, training and testing of
the machine learning algorithm were accomplished by real healthy patient and MI patient datasets.
In the second phase of real-time implementation in the RPi3, the wearable system was tested on normal
subjects and an ECG simulator to simulate abnormal ST-elevated MI situations to test the functionality
of the complete system in real-time.
The linear classification algorithm was implemented in the PC (Intel core i7, 8 GB RAM, Windows
7 x64) environment using Matlab 2015b. We used sliding windows of size 10 seconds to include
several consecutive interbeat intervals. The sliding window continuously moved to the next interbeat
interval, overlapping half of the interval. Therefore, the features for abnormality could be extracted
from the sliding window. Twenty-two machine learning algorithms were implemented initially in
the PC environment using Matlab 2015b to classify MI. The two best performing algorithms were
identified, and then the best performing algorithm was implemented in RPi3 using Python 2.7. Signal
pre-processing was accomplished using signal processing, wavelet transformation, and statistics
and machine learning toolboxes in the Matlab on the PC using Numpy (v1.13.3), Matplotlib (v3.0.2),
PyWavelets (v0.5.0), and LIBSVM Python libraries in Python on RPi3.

2.2.1. Linear Classification of MI


The linear classification detected three major deflections in the ECG signals: P and T waves
along with a QRS complex. The ECG signal underwent several signal processing steps—filtering,
baseline wonder removal, and wavelet transformation—before the deflections were detected, which is
explained in analysis (Section 3). The blocks for the linear classification MI detection algorithm are
shown in Figure 7A. Finding the R wave and detecting its peak was the most important part in this
method in order to diagnose heart rhythm abnormalities. All other ECG parameters were estimated
based on this value. The R-peak, where the heartbeat had the maximum amplitude, was extracted by
setting the threshold level approximated by 0.6. The basic idea of this algorithm was taken from the
Tompkins method [35]. Taking into consideration that the QRS complex duration was almost 60 ms
and knowing the exact time where the R peak occurred, the S and the Q points could be easily detected.
These points should have been within the interval of approximately 32 ms after and before the R-peak,
respectively, where the first minimum points took place. Following the same method and the same
timing interval, the J point was estimated to be the first point reaching zero, taking the negative S point
as a reference. The T peak was allocated by using information to indicate precisely the right interval in
which the T peak should have occurred. Hence, the T peak was the maximum point between 400 ms
from the R peak and 80 ms after the J point. It was detected by comparing neighboring points and
searching for the maximum value in this restricted interval. Consequently, the K point was estimated
to be in a duration of 35 ms from T peak. The ECG signal could be treated symmetrically, which eased
the detection of the work by dealing with the ECG trace in a similar manner after and before the R
peak, which was executed to get the Q, the K, and the P peak as well as the H point. This helped to
identify the changes occurring in the ST segment, and any change that occurred in the ST segment
was essential in identifying the heart attack, as it was continuously compared to the isoelectric line
(as shown in Figure 8) to spot any abnormality in the case of ST elevation, depression, or T-inversion,
which represented myocardial infarction.
Sensors 2019, 19,2018,
Sensors 278018, x FOR PEER REVIEW 10 of 22 10 of 22

Sensors 2018, 18, x FOR PEER REVIEW 10 of 22

(A)
(A)

(B)
Figure 7. Blocks of the linear classification (B)
(A) and machine learning (ML) (B) based MI
detection algorithm.
Figure 7. Blocks of the linear classification (A) and machine learning (ML) (B) based MI
Figure 7. Blocks of the linear classification (A) and machine learning (ML) (B) based MI detection algorithm.
detection algorithm.

Figure Figure 8. Normal


8. Normal ECG waveform
ECG waveform with
with the the waves
waves and intervals.
and intervals. Note:Note: user-defined
user-defined HI HI
lineline
represents
represents
the isoelectric
Figure (ISO)the isoelectric
line and
8. Normal ECGJK (ISO) line and
line represents
waveform JK line
with thethe represents
ST segments.
waves the ST segments.
and intervals. Note: user-defined HI line
represents the isoelectric (ISO) line and JK line represents the ST segments.
2.2.2. ML Algorithm-Based
2.2.2. Classification
ML Algorithm-Based Classificationof
ofMI
MI
2.2.2. ML Algorithm-Based Classification of MI
The blocks for ML
the ML algorithmbased based MIMI detection
The blocks for the algorithm detectionalgorithm
algorithm are shown
are shownin Figure 7B. Some
in Figure 7B. Some
of theThe
pre-processing
blocks for steps
the ML of linear classification
algorithm based MI were common
detection for ML
algorithm are based
shown classification.
in Figure 7B.ItSome
was
of the pre-processing steps of linear classification were common for ML based classification. It was
used
of theinpre-processing
segmenting the ECGofsignal
steps linearinto ECG-beats.
classification R peaks
were commonwereforused
MLasbased
the most visible features
classification. It was
used inofsegmenting
theincomplete the ECG
ECGthe signal
trace, into ECG-beats. R peaks were used as the most visible features
used segmenting ECGwhile
signalT into
peaks and P peaks
ECG-beats. demonstrated
R peaks were usedthe as boundaries of each
the most visible ECG
features
of the complete
trace. The ECG
length trace,
of while
each trace T peaks
differed and
from P peaks
patient todemonstrated
patient with
of the complete ECG trace, while T peaks and P peaks demonstrated the boundaries of each ECG thethe boundaries
presence of the of each ECG
inter-
trace. The length
subjective of
and each trace differed
intra-subjective from
variability patient
between to patient
the with
patients. the
Five presence
hundred
trace. The length of each trace differed from patient to patient with the presence of the inter- of
traces thefrominter-subjective
each
patient from
and intra-subjective
subjective andthevariability
MIT-BIH database
intra-subjective between withthe
variabilityeither normal
patients.
between theor abnormal
Five hundred
patients. hearthundred
Five rhythms
traces fromwereeach
traces generated.
frompatient
each from
Several
patient time the
from (t)-domain,
MIT-BIH frequency
database (f)-domain,
with either and time–frequency
normal or abnormal (t,f)rhythms
heart domainwere features were
generated.
the MIT-BIH database with either normal or abnormal heart rhythms were generated. Several
extracted
Several time from(t)-domain,
the segmented ECG data,
frequency which are
(f)-domain, anddetailed in the analysis
time–frequency (t,f) section.
domain Three
features popular
were
time (t)-domain, frequency (f)-domain, and time–frequency (t,f) domain features were extracted
quadratic
extracted fromtime–frequency
the segmented distributions
ECG data,(QTFDs)—Wigner–Ville
which are detailed in the distribution (WVD),Three
analysis section. Spectrogram
popular
from the segmented ECG data, which are detailed in the analysis section. Three popular quadratic
quadratic time–frequency distributions (QTFDs)—Wigner–Ville distribution (WVD), Spectrogram
time–frequency distributions (QTFDs)—Wigner–Ville distribution (WVD), Spectrogram (SPEC), and
extended modified B-distribution (EMBD)—were compared in this work. The (t,f) features could be
obtained by extending t-domain and f-domain features to the joint (t,f) domain. The performance of
each feature in detecting ST elevation or T-wave inversion in ECG was evaluated by performing an
area under the curve (AUC) analysis on the values of the features extracted from the ECG segments
belonging to different abnormal cases (e.g., ST elevation and T-inversion). Five-fold cross validation
Sensors 2019, 19, 2780 11 of 22

was used for training and validation of the 22 different machine learning models. The best performing
model was used to classify the two-class MI detection problem.

Sensors 2018, 18, x FOR PEER REVIEW


3. Analysis 11 of 22

Discussed below
(SPEC), and are the
extended severalB-distribution
modified pre-processing steps thatcompared
(EMBD)—were were commonin this to bothThe
work. classification
(t,f)
features
algorithms couldasbesome
as well obtained
thatby extending
were t-domain
specific and algorithm.
to the ML f-domain features to the joint (t,f) domain.
The performance of each feature in detecting ST elevation or T-wave inversion in ECG was
evaluated bySteps
3.1. Pre-Processing performing an area under the curve (AUC) analysis on the values of the features
extracted from the ECG segments belonging to different abnormal cases (e.g., ST elevation and T-
The pre-processing
inversion). stepsvalidation
Five-fold cross of the ECG was usedsignal used inandboth
for training classification
validation of the 22 algorithms
different are
machine
discussed below: learning models. The best performing model was used to classify the two-class MI
detection
Digital problem.
Filtering: It was essential to filter the signal and eliminate the inherent noises, which is
commonly called
3. Analysis
baseline wander and can be initiated by respiration, body movements, or even
perspiration, as well as by power line interference of 50 Hz. The ECG signal was prone to muscle
Discussed below are the several pre-processing steps that were common to both classification
noise (EMG), bowel movements (EGG), and noise generated from electroencephalography (EEG) [36].
algorithms as well as some that were specific to the ML algorithm.
In addition, ECG was often contaminated by artifacts constituted through electrodes or the interference
of the signal processingSteps
3.1. Pre-Processing hardware [37]. Thus, it was essential to use a filtering technique along with
baseline wander
The pre-processing for
correction further
steps analysis
of the ECG signalof theinsignal
used for better feature
both classification algorithmsextraction of the ECG
are discussed
signal. Finite
below: impulse response filter (FIR) was selected using the window method to smooth the noisy
signal by slicing
Digitalthe array It
Filtering: ofwas
dataessential
into selected
to filterlength windows,
the signal computing
and eliminate averages
the inherent of the
noises, whichdata
is within
commonly
that range, called baseline
and maintaining thewander
process and can be initiated
throughout by respiration,
the data set using body movements, or even
the moving-average filter [38].
perspiration, as well as by power line interference of 50 Hz. The ECG signal was prone to muscle
Baseline Wander Correction: It was noticed that the baseline of the signals was not exactly at zero
noise (EMG), bowel movements (EGG), and noise generated from electroencephalography (EEG)
level. This made the isoelectric line not well defined for extraction and computation, which resulted in
[36]. In addition, ECG was often contaminated by artifacts constituted through electrodes or the
inaccurate MI detection.
interference of the signalThus, processing
baseline wander
hardwarecorrection
[37]. Thus,was required.
it was The
essential to signal was fed into a
use a filtering
200 ms technique
width medianalong withfilterbaseline
to eliminate
wander QRS complexes
correction and
for further P-waves.
analysis of theThe obtained
signal signal
for better featurefrom the
extraction
filter was processed of the ECGa signal.
with median Finite
filterimpulse
of 600 response filter (FIR)
ms to eliminate was
the selected using
T-waves. the window
The attained signal was
method tofrom
then subtracted smooththethe noisy signal
resultant signal byofslicing
the FIRthe filter.
array The
of data intoshown
plots selected
in length
Figurewindows,
9 represent the
computing averages of the data within that range, and maintaining the process throughout the data
signal before and after baseline correction.
set using the moving-average filter [38].

Figure
Figure 9. 9. Overall
Overall representation
representation of the signal
of the signal beforebefore andbaseline
and after after baseline
wander wander correction:
correction: (A) Original
(A) Original signal; (B) baseline corrected ECG signal.
signal; (B) baseline corrected ECG signal.

Biorthogonal Wavelet Transformation: Continuous wavelet transformation was used for synthesizing
the ECG signal, and this allowed us to inspect how the frequency component varied within certain
Sensors 2018, 18, x FOR PEER REVIEW 12 of 22

Baseline Wander Correction: It was noticed that the baseline of the signals was not exactly at zero
Sensors 2019,
level.19, 2780
This made the isoelectric line not well defined for extraction and computation, which resulted 12 of 22
in inaccurate MI detection. Thus, baseline wander correction was required. The signal was fed into
a 200 ms width median filter to eliminate QRS complexes and P-waves. The obtained signal from
rangesthe
of filter
time,wasi.e.,processed
how thewith
ECG wavelets
a median filterwere
of 600generated.
ms to eliminateThethefrequency
T-waves. Theof attained
the QRS complex was
signal
mainlywas
present in the 23 from
then subtracted and the 24 scales.
theresultant signal of the
Since theFIR 24The
filter.
scale plots shown
showed in Figure
less noise to 23 , in this
9 represent
compared
the signal before and after baseline correction.
work, scale 24 was used for R-peak detection.
Biorthogonal Wavelet Transformation: Continuous wavelet transformation was used for
synthesizing the ECG signal, and this allowed us to inspect how the frequency component varied
3.2. Linear Classification
within certain ranges of time, i.e., how the ECG wavelets were generated. The frequency of the QRS
complex
All the ECG was points
mainly present
and timein the 23 and the
intervals were24 scales. Since the
calculated, andscale 24 showed
heart rate (HR)less and
noise isoelectric
compared to 2 , in this work, scale 2 was used for R-peak detection.
3 4
(ISO) potential and ST segment potential were calculated and compared with each other to spot any
abnormality in Classification
3.2. Linear the case of ST elevation, depression, or T-inversion, as mentioned in the preliminary
study section. Classification accuracy was calculated for normal and noisy data.
All the ECG points and time intervals were calculated, and heart rate (HR) and isoelectric (ISO)
potential and ST segment potential were calculated and compared with each other to spot any
3.3. MLabnormality
Based Classification
in the case of ST elevation, depression, or T-inversion, as mentioned in the preliminary
study section.
In the subsequent Classification
section, weaccuracy wasthe
discuss calculated for normal
remaining signaland noisy data.
pre-processing steps, features extraction,
training and
3.3. MLvalidation of the SVM model, classification, and the steps to implement the SVM to detect
Based Classification
MI in a real-time manner.
In the subsequent section, we discuss the remaining signal pre-processing steps, features
Segmentation: To compensate the variability of the ECG trace length, zeroes were padded at the
extraction, training and validation of the SVM model, classification, and the steps to implement the
beginning
SVMand at the
to detect MIend of any trace
in a real-time manner.that had less than the trace-length defined in the segmentation
process. Segmenting
Segmentation:theTo ECG signalstheinto
compensate traces of
variability allowed
the ECGfor data
trace manipulation
length, zeroes wereand permitted
padded at the primary
beginning
observation andunique
of the at the features
end of any trace that
of each type.had less than
Figure the trace-length
10 shows defined
the difference in in
thetheECG signal
segmentation process. Segmenting the ECG signals into traces allowed for data manipulation and
in both time and frequency domains for normal and abnormal conditions in which the abnormality
permitted primary observation of the unique features of each type. Figure 10 shows the difference
was considered
in the ECGto be divided
signal in two
in both time andtypes, T-inversion
frequency domains forand ST elevation.
normal In order
and abnormal to have
conditions in accurate
and general presentation
which the abnormality of waseach category
considered to be(normal,
divided inST-elevated, and T-inverted),
two types, T-inversion 3500InECG traces
and ST elevation.
over 28order
different
to havesubjects
accuratewere considered.
and general Therefore,
presentation of each the total (normal,
category numberST-elevated,
of ECG traces and T-considered
in this inverted),
study was 350010,500.
ECG tracesWe over 28 different
averaged subjects
the ECG were considered.
traces Therefore,case
for each different the total
wherenumber
each one was
of ECG traces considered in this study was 10,500. We averaged the ECG traces for each different
a combination of different subjects to overcome the inter-patient variability problem due to typical
case where each one was a combination of different subjects to overcome the inter-patient
varyingvariability
parameters across
problem due the patients
to typical [32].
varying parameters across the patients [32].

A B C
Amplitude (V)
Amplitude (V)

Amplitude (V)

Time (s) Time (s) Time (s)


Power Spectral Density
Power Spectral Density

Power Spectral Density

D E F
(V 2/Hz)
(V 2/Hz)

(V 2/Hz)

Frequency (Hz) Frequency (Hz) Frequency (Hz)

FigureFigure
10. ECG10. ECG
tracetrace averaged
averaged overover traces
traces andand
itsits powerspectral
power spectral density
density for
for (A and normal,
(A,D) D) (B,E)
normal,and
ST-elevation, (B and E) ST-elevation,
(C,F) and (Crespectively.
T-wave inversion, and F) T-wave inversion, respectively.

Features
Features Extraction:
Extraction: TheThe power
power spectral
spectral ofofthe
thesignal
signalininFigure
Figure 10D,E,F
10D,E,F shows
showsthat
thatthe
thepower
power spectral
spectral density peaks appeared at different frequencies for normal and abnormal ECG signals.
density peaks appeared at different frequencies for normal and abnormal ECG signals. Moreover,
Moreover, the power spectral density rapidly vanished and crossed zero for both affected cases.
the power spectral
This was not thedensity
case for rapidly vanished
non-affected ECG, as and crossed
frequencies zero for
appeared up both affected
to 30 Hz. cases. that
This reflected This was not
the case for non-affected ECG, as frequencies appeared up to 30 Hz. This reflected that the simple
frequency domain feature could help in classifying the ECG signals. However, t-domain, f-domain,
and (t,f)-domain provided insight into the signal while compensating for the noise or motion artifacts.
Mean, variance, skewness, kurtosis, and coefficient of variation were used as t-domain features
to spot abnormalities in the ECG-beats. The mean described the average value for the readings,
the variance showed how much the recorded signal deviated from the mean, skewness showed
the T wave symmetry in shape, and kurtosis showed the degree of peakness of the T wave shape.
The coefficient of variation described the relationship between data points based on the dispersion
around the mean value. This permitted the comparison of data points for the data series that had
different mean values. Table 1 summarizes the t-domain features with discrete ECG beat and x[n] as
an N-point signal.
Sensors 2019, 19, 2780 13 of 22

Table 1. Time-domain features with their mathematical expression.

Features Mathematical Expression


m(t) = N1 n x[n]
P
Mean
Variance σ (t) = N n (x[n] − m(t))2
2 1 P

γ(t) = Nσ13 (t) n (x[n] − m(t))3


P
Skewness
k(t) = Nσ14 (t) n (x[n] − m(t))4
P
Kurtosis
σ(t)
Coefficient of Variation C(t) = m(t)

Frequency-domain features such as the spectral flux, the spectral entropy, and the spectral flatness
were employed for the detection of abnormalities in ECG signals. The spectral flux measured the
rate of change of the spectral content of the ECG signal with time, whereas the spectral flatness (SF)
measured the level of uniformity of the energy distribution in the frequency domain and was defined
as the geometric mean of the magnitude spectrum of the ECG signal normalized by its arithmetic mean.
However, spectral entropy (SE) measured the randomness in the distribution of the signal energy in
the frequency domain.
Time- and frequency-domain features extended to produce joint (t,f)-features. Wigner–Ville
distribution (WVD), Spectrogram (SPEC), and extended modified B-distribution (EMBD) were used
to extend the (t,f)-features. Table 2 shows the t-domain, the f-domain, and the (t,f)-domain features
extracted [39] from the ECG traces. These were used for training the ML models and testing the ECG
data using the trained best performing model.

Table 2. Features extracted from the ECG traces.

Time-Domain Features Frequency-Domain Features Time-Frequency Features

 Combines all the


pre-mentioned features
 Use Quadratic time-frequency
 Mean distribution (QTFD) to find joint (t,f)
 Variance  Spectral flux representation:
 Skewness  Spectral entropy
 Kurtosis  Spectral flatness i. Winger-Ville Distribution
 Coefficient of variance (WVD)
ii. Spectrogram (SPEC)
iii. Extended Modified
B-Distribution (EMBD)

Performance Evaluation: The Receiver operating characteristic (ROC) analysis was used to evaluate
the performance of the ML algorithm for classification. It explained the capability of the trained model
in classifying different classes. The higher the value of area under the curve (AUC) was, the better the
model was in distinguishing the normal beat from the abnormal. The performance of each feature in
detecting ST elevation and T-wave inversion in ECG was evaluated by performing an ROC analysis on
the values of the feature extracted from ECG segments belonging to different abnormal cases (e.g., ST
elevation and T-wave inversion).
Apart from the AUC value, confusion matrix and several standard statistical evaluation parameters
were used to evaluate the performance of the algorithms:
True Positive Rate (TPR)/Recall/Sensitivity:

TP
Recall = (1)
TP + FN

Specificity:
TN
Speci f icity = (2)
TN + FP
Sensors 2019, 19, 2780 14 of 22

False Positive Rate (FPR):

FP
FPR = 1 − Speci f icity = (3)
TN + FP

Precision:
TP
Precision = (4)
TP + FP
F-measure or score:
2 ∗ Recall ∗ Precision
F score = (5)
Recall + Precision
Accuracy:
TP + TN
Accuracy (ACC) = (6)
Total positives and negatives
where TP is true positive, TN is true negative, FP is false positive, and FN is false negative.
The above-mentioned parameters were estimated using five-fold cross validation such that the
entire database was divided into five equal sets. Out of five sets, four sets were used for training, while
one set was used for testing. This process was repeated five times such that each set was tested once.
The final results were obtained by averaging the results of all the iterations. The averages of recall,
specificity, precision, f-score, and accuracy were calculated for the four iterations along with their
standard deviation. Performance evaluations of three different time-frequency distributions (TFDs)
were calculated to identify which TFD produced higher accuracy.

3.4. Real-Time Implementation


Two models were trained and validated using the labeled (training and testing) data; one was
for the STEMI (MI for ST segment elevation), and the other model was for the NSTEMI (MI for
T-wave inversion). A Python-based machine learning algorithm was implemented using the open
source LIBSVM library [40], and multi-threaded application was used for real-time pre-processing
and classification of ECG data. The decision of the real-time classifier was updated every 10 seconds,
and the alerting tone was generated locally to the driver. The in-house built C++ program was used
to initiate an emergency call and text short message using the GSM/GPRS module to a pre-defined
emergency number.

4. Results and Discussion


This section summarizes the results from the hardware experiments and algorithm performance
evaluation studies.

4.1. Hardware Performance Evaluation


The ECG signal acquired from dry electrodes was found comparable to the wet electrodes.
Moreover, dry electrodes are reusable and non-disposable, which reduces the running cost of the
system. In addition, the conductivity of the dry electrode increases over time, which guarantees signal
quality in a real-time system. However, in wet electrodes, after a couple of hours, the gel starts to
dry, impedance increases, and signal quality becomes poor. Figure 11A shows the ECG traces for
different driving scenarios for both type of electrodes. It was observed that the ECG signals were
continually getting better in the case of dry electrodes, which was not the case in wet electrodes. It is
worth mentioning that the wearable system was robust enough to acquire the ECG signal from the
driver during the different driving speed scenarios.
system. In addition, the conductivity of the dry electrode increases over time, which guarantees
signal quality in a real-time system. However, in wet electrodes, after a couple of hours, the gel
starts to dry, impedance increases, and signal quality becomes poor. Figure 11A shows the ECG
traces for different driving scenarios for both type of electrodes. It was observed that the ECG
signals were continually getting better in the case of dry electrodes, which was not the case in wet
Sensors 2019, 19, 2780 15 of 22
electrodes. It is worth mentioning that the wearable system was robust enough to acquire the ECG
signal from the driver during the different driving speed scenarios.

(A)

(B)
Figure11.11.Performance
Figure Performance of electrodes
of dry dry electrodes in comparison
in comparison to wet (A)
to wet electrodes electrodes (A) lead
and different and
different lead configurations (B) at different
configurations (B) at different vehicle speeds. vehicle speeds.

Figure
Figure 12 12shows
showsthe ECG
the ECG traces recorded
traces fromfrom
recorded two different subjects
two different chosenchosen
subjects randomly. The quality
randomly. The
of the ECG
quality of signal
the ECGacquired
signalwirelessly
acquiredshows the evidence
wirelessly shows of theevidence
the performance of the
of the prototype system
performance of the
and the
Sensors
prototype reliability
2018, 18, of
x FOR and
system the
PEER wireless
REVIEW
the communication
reliability unit
of the wireless used in the prototype.
communication unit used in the prototype.16 of 22
Amplitude (V)

Amplitude (V)

A B

Time (s) Time (s)


Figure
Figure Figure
5: ECG 5:
traceECG trace recorded in RPi3 for (A) normal subject and (B) MI patient.
12.
Figure 12.recorded
ECG datadata
ECG in collected
RPi3 from
collected (A) normal
wirelessly
wirelessly fromsubject
from (A) and (B)
subject
(A) subject from
1 1and
and afrom
(B)(B) subject
from with2.previous
subject
subject 2. MI
record.
Initial trials
Initial trials revealed
revealedthatthat the
the Lead
Lead II configuration
configuration (RA,(RA, LA,LA, and
and RL)
RL) waswas not
not practical
practical for
for the
the
driver and was significantly affected by noise due to hand movements
driver and was significantly affected by noise due to hand movements during controlling the during controlling the steering;
the comparison
steering; betweenbetween
the comparison the configurations (ii) and(ii)
the configurations (iii)
andis (iii)
shown in Figure
is shown 11B. Generally,
in Figure both
11B. Generally,
configurations
both produced
configurations similarsimilar
produced qualityquality
ECG signals
ECG and wereand
signals comparable to clinical grade
were comparable ECG grade
to clinical traces,
even at higher vehicle speeds. However, the selection of the configuration then
ECG traces, even at higher vehicle speeds. However, the selection of the configuration then needed needed to be based on
how comfortable it would be for the driver. From the results, it was evident that
to be based on how comfortable it would be for the driver. From the results, it was evident that the the straight alignment
configuration
straight of theconfiguration
alignment electrode wasof thethe
best option for
electrode wasECGtheacquisition
best option in for
the ECG
driving environment.
acquisition in the
driving environment.
The ECG signal sent from the wearable system to the RPi3 was logged and compared for the
transmission reliability. It was compared frame by frame to identify any discrepancy of the received
data (e.g., packet loss) during the transmission. It was observed that acknowledged and frame-
based data transmission ensured the communication reliability, and no packet loss was observed in
Sensors 2019, 19, 2780 16 of 22

The ECG signal sent from the wearable system to the RPi3 was logged and compared for
the transmission reliability. It was compared frame by frame to identify any discrepancy of the
received data (e.g., packet loss) during the transmission. It was observed that acknowledged and
frame-based data transmission ensured the communication reliability, and no packet loss was observed
in the transmission.
The SIM 908 GSM module was used for calling and sending SMS to the medical emergency service
with the car location information acquired using the GPS module embedded in the SIM 908. During
normal ECG acquisition, pre-processing, and classification, GPS data were not acquired to keep the
power requirement of the RPi3 minimum. GPS data were only acquired when any abnormality was
detected; then, time stamp, latitude, and longitude of the car location with the MI detection information
were sent. The ECG simulator was connected to the wearable system to generate normal and abnormal
ECG signals. It was evaluated whether the system could detect real-time ECG abnormality.
It was observed that the wearable subsystem drew the largest amount of current when the
ECG data were acquired continuously, as shown in Figure 13A. In the case of burst transmission,
approximately a 6 mA current was drawn. This subsystem continuously drained 2 mA, even if there
was no BLE transmission. However, this system was designed to continuously transmit data every
20 ms and acquire data at every 2 ms interval. In continuous transmission mode, this subsystem drew
9.3 mA of current. Since the wearable subsystem would be running on battery, it was important to
calculate the lifetime of the battery if it drew 9.3 mA of continuous current. The battery capacity could
be calculated from the input current rating of the battery (1000 mAh in the prototype system) and the
maximum load current (9.3 mA) of the circuit.

Battery Capacity(mAh)
Battery Li f e = ∗ 0.70 (7)
Load Current in mill amps

Equation (7) leads to 1000 mAh/9.3 mA × 0.7, i.e., approximately 75 h. Here, the factor of 0.7
(https://www.digikey.com/en/resources/conversion-calculators/conversion-calculator-battery-life) was
used for external factors that could affect battery life. Therefore, it could be summarized that the
wearable subsystem could be powered continuously for around three days from a 1000 mAh battery.
However, the system would only be used by the driver during driving, therefore it would be expected
that the daily driving time should not be more than 2–3 h for normal users unless the driver was
driving a taxi. Battery should last up to a week for normal users if they do not use the system more
than couple of hours in any day. Therefore, for the battery to last at least 24 h, the battery should be
approximately 320 mAh in size.
The decision-making subsystem was designed with multiple components—RPi3, GPS,
a GPRS/GSM shield, a cooling fan, and a BLE dongle. The initialization current consumption
by RPi3 alone, RPi3 in idle mode and processing mode, fan consumption, and consumption of GSM
and GPS modules and the complete system were recorded. Figure 13B shows the variation of current
consumption by the decision-making subsystem at different scenarios. It is evident from Figure 13B that
the RPi3 consumed around 1 A of current in its normal operational mode; however, part of this current
was due to the cooling fan, as it was drawing approximately 0.3 A current. However, this subsystem
took a maximum of 1.3 A when it was in the processing mode with continuous BLE transmission and
GSM service and GPS data acquisition mode. The decision-making subsystem was powered using the
vehicle’s cigarette lighter port, which was capable of supplying a constant 5 V supply with a maximum
2 A continuous current, which was much less than the current drawn by this subsystem.
Sensors 2019, 19, 2780 17 of 22
Sensors 2018, 18, x FOR PEER REVIEW 17 of 22

Continuous BLE
Transmission
BLE BLE BLE BLE
Current consumption

Initialization Transmission Transmission Transmission


Idle Idle
Idle Idle Idle
(mA)

Time (s)
(A)
GPS Data
Current consumption (A)

RPi3
Continuous BLE
Initialization GSM+GPS & Processing
Initialization
Idle
Fan
Off

Time (s)
(B)
Figure13.13.
Figure Current
Current consumption
consumption in different
in different operationaloperational scenarios
scenarios for the wearablefor the wearable
subsystem (A) and
subsystem (A) and the
the RPI3 subsystem (B). RPI3 subsystem (B).

4.2. Performance Evaluation ofsubsystem


The decision-making MI Detection Algorithms
was designed with multiple components—RPi3, GPS, a
GPRS/GSM shield, a cooling fan, and a BLE dongle.
In the following section, the performance of linear The initialization
and current consumption
ML based algorithms by RPi3
are summarized.
alone, RPi3 in idle mode and processing mode, fan consumption, and consumption of
Linear classification algorithm for MI detection: The characteristic points of the ECG signal beside the GSM and
R
GPS modules
peak and the
were extracted complete
to fulfill system were
the detection recorded.infarction
of myocardial Figure 13B shows
by the the variation
comparison of the of current
isoelectric
consumption
line with the ST bysegment,
the decision-making subsystem
as shown in Figure 14A. at different
Figure scenarios. It isthat
14A demonstrates evident from Figure
the classical 13B
detection
that the RPi3 consumed around 1 A of current in its normal operational mode; however,
method worked reliably for noise free data. However, the linear classification and thresholding-based part of this
current was
algorithm was due
nottorobust
the cooling
enough fan,in as
theitpresence
was drawing approximately
of movement artifacts0.3 A current.
induced However,
in the ECG signalsthis
subsystem took a maximum of 1.3 A when it was in the processing mode
along with impulsive noises, and the algorithm failed in the noisy data (as shown in Figure 14B). with continuous BLE
transmission
Therefore, theand GSMlearning
machine service based
and GPS data acquisition
algorithm should be usedmode. forThe decision-making
classifying ECG signals.subsystem
was powered using the vehicle’s cigarette lighter port, which was capable of supplying a constant 5
V supply with a maximum 2 A continuous current, which was much less than the current drawn by
this subsystem.

4.2. Performance Evaluation of MI Detection Algorithms


In the following section, the performance of linear and ML based algorithms are summarized.
Linear classification algorithm for MI detection: The characteristic points of the ECG signal beside
the R peak were extracted to fulfill the detection of myocardial infarction by the comparison of the
isoelectric line with the ST segment, as shown in Figure 14A. Figure 14A demonstrates that the
classical detection method worked reliably for noise free data. However, the linear classification
and thresholding-based algorithm was not robust enough in the presence of movement artifacts
induced in the ECG signals along with impulsive noises, and the algorithm failed in the noisy data
(as shown in Figure 14B). Therefore, the machine learning based algorithm should be used for
classifying ECG signals.
Sensors 2019, 19, 2780 18 of 22
Sensors 2018, 18, x FOR PEER REVIEW 18 of 22

(A)

(B)
Figure14.
Figure 14.ECG
ECG parameters
parameters detection
detection for normal
for normal subject
subject (A) (A) and
and effect of theeffect
motionofartifact
the motion
in the
artifact
linear in the linear
classification classification
algorithm (B). algorithm (B).

Machine Learning (ML) based MI detection algorithm: All All the


the features listed earlier were extracted,
ROC analysis
ROC analysiswaswasperformed
performed forfor each
each feature,
feature, andand
AUCAUC was was calculated.
calculated. TableTable
3 shows3 shows
the AUC thevalues
AUC
values
for for the feature
the feature extractedextracted for ST-elevation
for ST-elevation and T-waveand T-wave
inversioninversion
from thefrom the different
different original original
t-domain,t-
domain, f-domain,
f-domain, and joint and joint (t,f)-domain
(t,f)-domain features forfeatures for threeTFDs.
three different different TFDs. All
All features features
that scoredthat scored a
a minimum
minimum
of of 0.5 were
0.5 and above and above weretoconsidered
considered be useful totoapply
be useful to apply Ittowas
to classifiers. classifiers. It was
noticed that all noticed that
the selected
all the selected
features fulfilledfeatures fulfilled the
the requirement forrequirement for any
any of the three of the threeTherefore,
distributions. distributions. Therefore,
all the featuresall the
were
features were used for training and validation of 22 different
used for training and validation of 22 different machine learning models. machine learning models.
Computation of the ML algorithms validation accuracy was done using k-fold cross validation,
where k was equal to five. There were five iterations, and the total accuracy was computed by
obtaining the averages of the five accuracies and their standard deviations. Table 4 shows the
accuracies resulting from classifying ST-elevation, and Table 5 shows the accuracies resulting from
T-wave inversion for the three different (t,f)-distributions for the two best performing algorithms,
the SVM and the k-nearest neighbors (KNN), where SVM outperformed KNN. The SVM training
was selected to be a three-degree polynomial kernel function. The average accuracies of SVM for
Sensors 2019, 19, 2780 19 of 22

Table 3. Results of the ROC analysis of t-domain, f-domain, and (t,f)-domain features for the
ST-elevation detection.

WVD SPEC EMBD


Features
Original Joint(t,f) Original Joint(t,f) Original Joint(t,f)
Mean 0.53 0.67 0.53 0.75 0.53 0.75
Variance 0.51 0.71 0.51 0.66 0.51 0.58
Skewness 0.68 0.57 0.68 0.67 0.68 0.57
Kurtosis 0.75 0.57 0.75 0.69 0.75 0.56
Coefficient of Variation 0.50 0.74 0.50 0.65 0.50 0.58
Spectral Flux 0.76 0.82 0.76 0.83 0.76 0.55
Spectral Flatness 0.54 0.71 0.54 0.79 0.54 0.68
Spectral Entropy 0.81 0.71 0.81 0.65 0.81 0.59

Computation of the ML algorithms validation accuracy was done using k-fold cross validation,
where k was equal to five. There were five iterations, and the total accuracy was computed by obtaining
the averages of the five accuracies and their standard deviations. Table 4 shows the accuracies resulting
from classifying ST-elevation, and Table 5 shows the accuracies resulting from T-wave inversion
for the three different (t,f)-distributions for the two best performing algorithms, the SVM and the
k-nearest neighbors (KNN), where SVM outperformed KNN. The SVM training was selected to be a
three-degree polynomial kernel function. The average accuracies of SVM for ST-elevation classification
were 87.1 ± 7.77%, 85.3 ± 9.9%, and 97.4 ± 2.1% for WVD, SPEC, and EMBD distributions, respectively.
The average accuracies for T-wave inversion classification were 78.0 ± 17.2%, 72.1 ± 3.09%, and
96.3 ± 0.66% for WVD, SPEC, and EMBD distributions, respectively.

Table 4. Evaluation parameters in classifying ST-elevation.

Parameters/ML WVD SPEC EMBD


Algorithms
SVM KNN SVM KNN SVM KNN
Recall (TPR) 92% 89% 89% 90% 99.1% 96.7%
FPR 11% 12% 14% 13% 1.7% 3.8%
Precision 89% 88% 86% 87% 98.3% 96.2%
F-score 90.5% 88.9% 87.5% 86% 98.7% 97%
Accuracy 87.1% 86.4% 85.3% 84.2% 97.4% 95.9%

Table 5. Evaluation parameters in classifying T-wave inversion.

Parameters/ML WVD SPEC EMBD


Algorithms
SVM KNN SVM KNN SVM KNN
Recall (TPR) 86% 84% 83% 84% 98.5% 96.9%
FPR 19% 20% 22% 21% 1.3% 4.3%
Precision 81% 80% 78% 79% 97.8% 95.7%
F-score 83.4% 82.7% 75.9% 76.2 98.2% 96.6%
Accuracy 78% 76.3% 72.1% 74% 96.3% 95.1%
* WVD: Wigner-Ville distribution; SPEC: Spectrogram; EMBD: extended modified B-distribution; TPR: true positive
rate; FPR: false positive rate.

It was quite evident that the EMBD outperformed the others in classifying ST-elevation and
T-wave inversion in both the abnormal ECG wave classifications. Moreover, the standard deviation
showed that the variation for different iterations was at minimum for the EMBD distribution; therefore,
this distribution was more immune to noisy data. In the Python-based implementation, the t-domain,
the f-domain, and the (t,f)-domain EMBD distributions were implemented for real-time classification.
This was also revealed from the recall and the precision parameters. Both the recall and the precision
were reasonable for reliable detection, and this was true for both positive and negative classifications,
which was also reflected from the F-score.
Sensors 2019, 19, 2780 20 of 22

5. Conclusions
In this study, we proposed and implemented a portable wearable ECG system for real-time heart
attack detection. The hardware complexity was reduced by using off-the-shelf AD8232 AFE and a
miniaturized microcontroller with built-in BLE. By using this device, the driver could keep track of
his/her heart condition on a daily basis at low cost. Moreover, the immediate response on heart attack
detection and alerting could help the driver to avoid road accidents and most likely save valuable lives.
The linear classification algorithm is very fast in execution; however, it is unable to work with noisy
ECG signals. However, the SVM algorithm with extended time-frequency features with the EMBD
distribution showed highest accuracies of 97.4% and 96.3% for detecting ST-elevation and T-wave
inversion, respectively. In addition, the proposed wearable device has lower power consumption,
and therefore it is expected that the device can run for 24 h continuously with a 320 mAh battery.
In summary, the device could contribute to excellent health monitoring and improve alerting services
to the driver as well as to medical care-givers. In this manner, a driver could save himself/herself by
avoiding fatal road accidents before losing his/her consciousness, and emergency medical services
could approach the driver in a timely manner to provide required lifesaving medical procedures to
avoid any life-threatening consequences. In the future, we would like to make the wearable device a
wearable patch or a wearable smart watch to make it more feasible to the user. There will be some
challenges in using a smart watch because of the hand movements; however, an adaptive motion
artifact removal algorithm might enable a new way to modify this life-saving gadget.

Author Contributions: Experiments were designed by M.E.H.C. and K.A. Experiments were performed and
experimental data were acquired by M.E.H.C., R.K., R.A. (Rayaan Abouhasera), S.K. and A.K. Data were analyzed
by M.E.H.C., S.K., R.A. (Rashid Ahmed) and A.H. All authors were involved in interpretation of data and
paper writing.
Acknowledgments: The publication of this article was funded by the Qatar National Library. This work
was supported in part by the Undergraduate Research Experience Program (UREP) under Grant number
UREP19-069-2-031, in part by the Qatar University Student Grant under Grant number QUST-CENG-SPR\2017-23.
Conflicts of Interest: The authors certify that they have NO affiliations with or involvement in any organization
or entity with any financial interest or non-financial interest in the subject matter or materials discussed in
this manuscript.

References
1. Peden, M.; Scurfield, R.; Sleet, D.; Mohan, D.; Hyder, A.A.; Jarawan, E.; Mathers, C. (Eds.) World Report on
Road Traffic Injury Prevention; World Health Organization: Geneva, Switzerland, 2004.
2. Lowman. What Medical Conditions Can Lead To Auto Accidents? Available online: https://www.
lowmanlawfirm.com/blog/bid/101531/What-Medical-Conditions-Can-Lead-To-Auto-Accidents (accessed
on 8 June 2019).
3. Halinen, M.O.; Jaussi, A. Fatal road accidents caused by sudden death of the driver in Finland and Vaud,
Switzerland. Eur. Heart J. 1994, 15, 888–894. [CrossRef] [PubMed]
4. Ostrom, M.; Eriksson, A. Natural death while driving. J. Forensic Sci. 1987, 32, 988–998. [CrossRef] [PubMed]
5. McFarland, R.A.; Moore, R.C. Accidents and accident prevention. In Annual Review of Medicine Vol. 13;
Rystand, D.A., Creger, W.P., Eds.; Annual Reviews, Inc.: Palo Alto, CA, USA, 1962.
6. Lindsay, V.; Baldock, M. Medical conditions as a contributing factor in crash causation. In Proceedings
of the 2008 Australasian Road Safety Research, Policing and Education Conference, Adelaide, Australia,
9–12 November 2008; pp. 610–628.
7. Hitosugi, M.; Hasegawa, M.; Yamauchi, S.; Morita, S.; Furukawa, S. Main factors causing health-related
vehicle collisions and incidents in Japanese taxi drivers. Rom. J. Leg. Med. 2015, 23, 83–86. [CrossRef]
8. Murray, C.J.; Lopez, A.D. Global mortality, disability, and the contribution of risk factors: Global Burden of
Disease Study. Lancet 1997, 349, 1436–1442. [CrossRef]
9. Gibson, A.L.; Wagner, D.; Heyward, V. Advanced Fitness Assessment and Exercise Prescription, 8E; Human
Kinetics: Champaign, IL, USA, 2018.
Sensors 2019, 19, 2780 21 of 22

10. Bhopal, R.S. Epidemic of Cardiovascular Disease and Diabetes: Explaining the Phenomenon in South Asians
Worldwide; Oxford University Press: Oxford, UK, 2019.
11. Mechanic, O.J.; Shamai, A.G. Acute Myocardial Infarction; StatPearls [Internet]; StatPearls Publishing: Tampa/St.
Petersburg, FL, USA, 2019.
12. Patel, S.; Chauhan, Y. Heart attack detection and medical attention using motion sensing device-kinect. Int. J.
Sci. Res. Publ. 2014, 4, 1–4.
13. Mittleman, M.A.; Malcolm, M.; Geoffrey, H.T.; Jane, B.S.; Robert, J.G.; James, E.M. Triggering of acute
myocardial infarction by heavy physical exertion–protection against triggering by regular exertion. N. Engl.
J. Med. 1993, 329, 1677–1683. [CrossRef] [PubMed]
14. Inan, O.T.; Kovacs, G.T. An two-electrode transimpedance biosignal amplifier with active current feedback
stabilization. IEEE Trans. Biomed. Circuits Syst. 2010, 4, 93–100. [CrossRef]
15. Dobrev, D. Two-electrode non-differential biopotential amplifier. Med. Biol. Eng. Comput. 2002, 40, 546–549.
[CrossRef]
16. Nemati, E.; Deen, M.J.; Mondal, T. A wireless wearable ECG sensor for long-term applications. IEEE Commun. Mag.
2012, 50, 36–43. [CrossRef]
17. Singh, R.K.; Sarkar, A.; Anoop, C. A health monitoring system using multiple non-contact ECG sensors
for automotive drivers. In Proceedings of the 2016 IEEE International Instrumentation and Measurement
Technology Conference Proceedings (I2MTC), Taipei, Taiwan, 23–26 May 2016; pp. 1–6.
18. Richard, E.; Chan, A.D. Design of a gel-less two-electrode ECG monitor. In Proceedings of the 2016 IEEE
International Workshop on Medical Measurements and Applications (MeMeA), Ottawa, ON, Canada,
30 April–1 May 2010; pp. 92–96.
19. Valchinov, E.; Pallikarakis, N. A wearable wireless ECG sensor: A design with a minimal number of parts.
In Proceedings of the XII Mediterranean Conference on Medical and Biological Engineering and Computing
2010, Chalkidiki, Greece, 27–30 May 2010; Bamidis, P.D., Pallikarakis, N., Eds.; Springer: Berlin/Heidelberg,
Germany, 2010; Volume 29, pp. 288–291.
20. Yap, J.; Noh, Y.H.; Jeong, D.U. The deployment of novel techniques for mobile ECG monitoring. Int. J. Smart Home
2012, 6, 1–14.
21. Noh, Y.H.; Jeong, D.U. Implementation of fuzzy-rule based activity classification and optimized adaptive
filter-set for wearable ECG recording. Int. J. Multimed. Ubiquitous Eng. 2012, 7, 59–72.
22. Reichlin, T.; Hochholzer, W.; Bassetti, S.; Steuer, S.; Stelzig, C.; Hartwiger, S. Early diagnosis of myocardial
infarction with sensitive cardiac troponin assays. N. Engl. J. Med. 2009, 361, 858–867. [CrossRef] [PubMed]
23. Sopic, D.; Aminifar, A.; Aminifar, A.; Atienza, D. Real-time classification technique for early detection and
prevention of myocardial infarction on wearable devices. In Proceedings of the 2017 IEEE Biomedical Circuits
and Systems Conference (BioCAS), Turin, Italy, 19–21 October 2017; pp. 1–4.
24. Rad, M.Z.; Ghuchani, S.R.; Bahaadinbeigy, K.; Khalilzadeh, M.M. Real time recognition of heart attack in a
smart phone. Acta Inform. Med. 2015, 23, 151. [CrossRef] [PubMed]
25. Blumenthal, R.; Braunstein, J.; Connolly, H.; Epstein, A.; Gersh, B.J.; Wittels, E.H. Cardiovascular Advisory Panel
Guidelines for the Medical Examination of Commercial Motor Vehicle Drivers; US Department of Transportation
Federal Motor Carrier Safety Administration: Washington, DC, USA, 2002.
26. Antecol, D.H.; Roberts, W.C. Sudden death behind the wheel from natural disease in drivers of four-wheeled
motorized vehicles. Am. J. Card. 1990, 66, 1329–1335. [CrossRef]
27. West, I.; Nielsen, G.L.; Gilmore, A.E. Natural death at the wheel. JAMA 1968, 205, 68–73. [CrossRef]
28. Myerburg, R.J.; Davis, J.H. The medical ecology of public safety. 1. Sudden death due to coronary heart
disease. Am. Heart J. 1964, 68, 586–595. [CrossRef]
29. Hanna, R. The contribution of medical conditions to passenger vehicle crashes. Annu. Emerg. Med. 2010, 55,
563–564.
30. National Transportation Safety Board (NTSB). Safety Study: Fatigue, Alcohol, Other Drugs, and Medical Factors
in Fatal-to-the-Driver Heavy Truck Crashes; NTSB Report No. NTSB/SS-90/01; US Department of Transportation:
Washington, DC, USA, 1990.
31. Krueger, G.P.; Belzer, M.; Alvarez, A.; Knipling, R.; Husting, E.; Brewster, R.; Siebert, J. Health and wellness
of commercial drivers. Domain Truck. Bus Saf. Res. 2007, 117, 58–91.
Sensors 2019, 19, 2780 22 of 22

32. Goldberger, A.L.; Amaral, L.A.N.; Glass, L.; Hausdorff, J.M.; Ivanov, P.C.; Mark, R.G.; Mietus, J.E.; Moody, G.B.;
Peng, C.K.; Stanley, H.E. PhysioBank, PhysioToolkit, and PhysioNet: Components of a New Research Resource
for Complex Physiologic Signals. Circulation 2015, 101, e215–e220. [CrossRef]
33. BioRadio. Available online: https://glneurotech.com/bioradio/ (accessed on 27 February 2017).
34. ArduPi Library. Available online: https://raspberry-projects.com/pi/arduino/using-arduino-shields/ardupi
(accessed on 27 February 2017).
35. Pan, J.; Tompkins, W.J. A real-time QRS detection algorithm. IEEE Trans. Biomed. Eng. 1985, 32, 230–236.
[CrossRef]
36. Cichocki, A.; Amari, S.I. Adaptive Blind Signal and Image Processing: Learning Algorithms and Applications; John
Wiley & Sons: Hoboken, NJ, USA, 2002; Volume 1.
37. Clifford, G.D.; Azuaje, F.; Mcsharry, P. ECG statistics, noise, artifacts, and missing data. Adv. Methods Tools
ECG Data Anal. 2006, 6, 18.
38. 1-D Digital Filter—MATLAB Filter. Available online: https://www.mathworks.com/help/matlab/ref/filter.html
(accessed on 22 December 2016).
39. Staszewski, W.J.; Robertson, A.N. Time–frequency and time–scale analyses for structural health monitoring.
Philos. Trans. R. Soc. A Math. Phys. Eng. Sci. 2006, 365, 449–477. [CrossRef] [PubMed]
40. Chang, C.C.; Lin, C.J. LIBSVM: A library for support vector machines. ACM Trans. Intell. Syst. Technol. 2011,
2, 27. [CrossRef]

© 2019 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access
article distributed under the terms and conditions of the Creative Commons Attribution
(CC BY) license (http://creativecommons.org/licenses/by/4.0/).

You might also like