Electrocardiogram analyser with a mobile phone

peanutunderwearSoftware and s/w Development

Nov 7, 2013 (4 years and 6 days ago)

112 views

Electrocardiogram a
nalyser with

a m
obile

phone

André Baptista
1

and

João Sanches
2

1
Instituto Superior Técnico, Lisbon, Portugal

andrefsmbaptista
@ist.utl.pt

2

Systems and Robotics Institute, Instituto Superior Técnico, Li
s
bon Portugal

jmrs@isr.ist.utl.pt



Abstract

The Electrocardiogram (ECG) signal
measures the potential of the heart and their beats.

A
re
al

normal
ECG signal is

composed for some
important waves that traduce the different states of the
heart
at each beat, this waves

are P, Q, R, S, T and U.

By using t
h
ree electrodes located at bust, in particular
positions with a meticulous order
s
,

it is possible to
measure the
electrical activity
of the
heart
.

This paper describes a
system
that detects cardiac
anomalies in ECG trace

based on the mobile phone.
This

system analyses the different
periods and/or

the
different durations of some waves, the P, the QRS
complex, de T wave, the QT interval
, the RR period
and the rhythm cardiac.

The goal is
detect some
anomalies that could happ
en in a cardiovascular
patient and warn some entity with a message SMS
using the mobile phone.

The acquisition system
inject a modulate signal in a

bluetooth headset to communicate
and transmit
with a
mobile phone

that

is paired
the ECG signal of the
patient.


The mobile phone demodulates the PWM signal
containing the EC
G, detect
and store the different

waves and before this, the mobile phone find abnormal
intervals as periods in all of this waves.


The whole system and the corresponding hardware
and s
oftware modules are described and results are
presented for illustrative purposes

in this paper
.


Index Terms

ECG, opamp, PWM, python,

electrocar
diogram,

bluetooth.

1.


I
NTRODUCTION

The acquisition of several physiological signals,
such as the electrocardiogram (ECG), is a current
practice since several decades, mainly for
diagnosis purposes. More recently these signals
are being used for control and interface purposes.
In this
scope,

the brain computer interface (BCI)
systems have received particular attention in the
last decades.

Current
ly, some types of systems are capable to
read the electrophysiological signals and make
possible a diagnosis of some
diseases. T
o
diagnose
the ECG d
iseases the most important systems are
the

Holter, ECG at rest, ECG with exercise test
between others.

The cardiac diseases are one of the most
causes
of death in

occidental
population.
Is estimat
ed that
cardiovascular
diseases have caused the deaths of
26
.3% of Portuguese

people
[1]
.

At this article is present
ed

a modern type of
system that is capable to make diagnosis exams to
cardiovascular diseases
. This cardiac
anomalies
system detect

work
s in

mobile phone with a
particularity that
is possible to
use all day.
With
this system, it is possible detect some different
types of cardiac diseases like Branch block,
Ventricular hypertrophy, Atrial tachycardia,
Wolff
-
Parki
nson
-
White syndrome,
Atrioventricular block 1
st

block, Atrial fibrillation
,
brady
cardia
, tachycardia and arrhythmia
[2]
.

This work was developed in Nokia N81 with
S60 series, a mobile phone with big computational
power that was made to run specific applications
like games.
The decision to use this phone has
forced the SymbianOS operating system were

and
that would be the python programming
language
[3]
.

There are some equipment, both
measurements
and monitoring the signal output, but none with
the features listed in the equipment described in
this article, namely, using the audio channel of the
bluetooth headset to transmit the ECG signal

[7]
,
to analyze the ECG signal directly on the phone
and use the phone to make emergency call in case
of stroke

[8]
.


T
his paper is organized as follows. In section
2

is described the
electric cardiac system and some
of diseases verified
. In section
3

is

described the
system. In section
4

are described
the
experimental results and
the

section
5

concludes
this paper.

2.

C
ARDIAC ELECTRICAL SY
STEM AND SOME OF
THEIR ANOMALIES

The heart is a modular organ in the middle of
the chest that has both the right and the lef
t

side, a
cavity higher (atrium
) that receives the
blood

and
a lower cavity (ventricle) that takes him out. To
ensure that the blood flow in one direction, the
ventricles have a valve entrance and one exit.

The diagnosis of heart disease tends to become
es
tablished from the clinical history and physical
examination of the patient. There is a wide series
of tests and procedures to facilitate and make more
accurate the diagnosis. They include records of
electrical activity of the heart as

the ECG, Holter,

ech
ocardiography, magnetic resonance imaging,
positron emission tomography and cardiac
catheterization and the m
ost used are the ECG
and
these will be that the article will be based.

2.1.

ECG

The ECG is a fast, simple and painless, in which
amplify the electrical
impulses of the heart. To
identify the natural pacemaker that initiates each
new beating heart, the nerve pathways leading to
the stimuli, the speed (frequency) and heart
rate
.
[5]

To record an ECG arise small metal contacts
(electrodes) according to a given derivation,
obeying the triangle of Einthoven and according to
the derivation of type II.

2.2.

ECG waves

An ECG represents the electrical current flows
through the heart during a contraction and every
part of this stream is designated alphabetically.
Each heartbeat starts with a boost primary
physiological pacemaker of the heart, the sino
-
atrial node.

This im
pulse active first the upper
chambers of the heart, the atria, which represents
activation in the P wave. Next, the electric current
flowing in the direction of
inferior’s

chambers of
the heart, the ventricles, thus creating the QRS
complex,

is

representin
g the activation of these.
The T wave represents the wave of recovery,
while the electrical current spreads back over the
ventricles in the opposite
direction
.


2.3.

Anomalies

In this work, the anomalies that will be detected
are the Branch block, Ventricular h
ypertrophy,
Atrial tachycardia, Wolff
-
Parkinson
-
White
syndrome, Atrioventricular block 1
st

block, Atrial
fibrillation
,
brady
cardia
, tachycardia and
arrhythmia

[4]

[6]
.

To detect all of this anomalies
,

the system need to detect some characteristics
in
ECG signal
, this characteristics are:



Wave P duration;



QRS duration;



Interval

PR duration;



Rhythm
.

3.

S
YSTEM
D
ESCRIPTION

The developed system is composed by the
components that could see in

Fig.
1
.


Fig.
1

-

Circuit and their components.

The components of this system are:

1.

Box with acquisition circuit and
amplifier circuit and with Bluetooth
headset
;

2.

On/Off
butto
n
;

3.

USB port to power the circuit;

4.

Audio output for connection to PC;

5.

Telephone token female used to entrance
of the three contacts of ECG signal
acquisition
;

6.

Telephone token male used for entry of
the three contacts of ECG signal
acquisition
;

7.

Pin positive;

8.

Pin mass;

9.

Pin negative;

10.

Electrodes;

11.

Audio cable for PC connection.


As described above, t
he developed system has
six

main modules: the acquisition, the
modulation
and

transmission
,

the
demodulation, the
processing

and the alarm generation
.

Each of the
dev
eloped modules will be described in detail in
the following sections.

3.1.

Acquisition

system
, hardware and signal
transmission

Accord
ing to the stated objectives,

using a
bluetooth headset for the transmission of the signal
picked up by electrodes placed according to the
derivation chosen, the transmitted signal is an
audio signal. This signal is "injected" into the
microphone of
the headset and will be sent with

b
luetooth

transfer

to the phone, then this signal is
demodulated and analyzed.

The acquisition of the EC
G signal is performed
by three electrodes,
one electrode is placed below
the second vertebra towards right scapula
, the
positive electrode,

and one in th
e same direction
but on the left
, the mass pin
, the third electrode is
placed one inch
below the electrode on the left
, the
negative pin
.

The system used consists of an acquisition
circuit, a band
-
pass filter where the bandwidth was
reduced, and three
floors of amplification with a
final gain of 220. The ECG signal works in a band
ranging from 0.05 Hz up to 100Hz band passes

very close to ideal for an ECG signal
,
Fig.
2
.

To do that, an amplification chain with four
stages (based on rail
-
to
-
rail operational amplifier)
is used. The first stage is a voltage follower to
isolate the acquisition circuit from the
amplification chain. Each one of the other three
stages is a
low gain low
-
pass filter to reduce the
high frequency noise.

After the buffering stage, it is placed a band
-
pass filter so that its frequency response can
capture only the E
C
G signal characteristics,
leaving a clean signal to amplify.

The gain and offset
controls are important to
adjust the output dynamic range of the processed
signal to the input dynamic range of the
modulator
[9]
.

Acquisition
circuit
Signal conditioning
Band
-
pass filter
[
0
.
218
,
113
.
532
]
Hz
First stage
K
1
=
10
Second stage
K
2
<
10
Third stage
K
3
=
2
.
2

Fig.
2
. Acquisition module block
diagram
.


The filtered and amplified E
C
G signal
is used to
modulate in pulse

(
PWM
) a



square wave
carrier to be transmitted by the audio channel.

The modulated signal is injected
into the audio
input of the bluetooth headset

and this signal is
transmitted to the mobile phone, which will be
analysed
.

The PWM modulator is described in next
section.


3.2.

PWM modulation

The PWM was created from the integrated
circuit NE555. The circuit was

designed which is
in datash
eet the same integrated circuit, that circuit
could be seen in the
Fig.
3
.


Fig.
3

-

Modulation PWM

circuit.

In developing this circuit, referred to the
Protel2004 program to create the design of printed
circuit board PWM modulator with the distinction
of being designed in order to use the space
previously occupied by the integrated circuit
LM331,
packaging dip
-
8
,
developed to the FM
modulator which was used on this circuit board
,
see
Fig.
4
.


Fig.
4



Design top and bott
om of the circuit board
PWM modulator
.

After the design to be used in printed circuit
board, went to the creation of its circuit, and the
board is on the

Fig.
5


Fig.
5

-

Circuit board PWM.


It was desired output frequency of less than





, and scaled to the values of resistors and the
capacitor to archive this objective
. It was used the










and




,
this
values are

shown in equation

(1)
.























(1)

After completion of the circuit and the scaling
of output frequency, changed manually the circuit
thus introducing a
resistive divider in order to
lower the output voltage while ensuring no
overrun bluetooth headset microphone.


The signal was obtained to meet the objectives
set for an output frequency below





and with
an output voltage around



.


3.3.

Demodulation


Th
e PWM signal is a signal modulated by pulse
width.
To demodulate this signal it used one low
-
pass filter second order
Butterworth
, as it was
intended demodulation with a minimum
number
of calculations possible
.

The pass
-
band of the signal ECG it’s between





and



and because this, it was used a
cut frequency of the



. With this cut
frequency and a







, we obtain the
next equation
s
.





















(2)
























(3)

















(4)

With a sampling frequency of

the




, the
discrete system is:






































(5)


















































(6)

Using the Z transform, the equation low
-
pass
filter is given for equation



























































(7)

The results of the demodulation are in line with
expectations and in accordance with the desired
one. This demodulation made the phone work
quickly enough, and the system is only dependent
on the absence of current hypothesis of direct
access to stream aud
io bluetooth headset

3.4.

Processing

The application has been developed in
P
ython
programming language. Python is being used more
often by programmers, because it is a

programming language platform and operating
system independent.

Python also uses several modu
les, developed by
users from all around the world with all kind of
different purposes. Here, it is used mainly the

PyAudio

module
, for audio stream input
acquisition.

The application takes



of the ECG signal
modulated PWM and demodulates it renders the
detection algorithm of the various intervals,
checks for abnormalities and collects more



signal.

After receive and demodulate the ECG signal in
PWM, the mobile phone need to search some
periods and the different waves in the real signal
ECG. When all t
he wave intervals are discovered,
will find some combinations of the signal ECG
characteristics and will find if this signal has some
anomaly. If the system finds some anomaly,

it

will
send a SMS to a

competent

entity.




The relevant intervals discovered

are the duration
of the P wave, the T wave, the QRS complex, the
PR interval and the QT interval. The system
discovered yet the RR, PP intervals a
nd the
rhythm. In the
Fig.
6

is

represented the
algorithm
used.

The algorithm begins by finding represented a
positive peak in the signal. When this peak is
found, the peak voltage, determines whether it is a
peak P, T, R, for each of these peaks is at differe
nt

levels

of tension
.

In the case of P and T waves, the program
through two cycles, one advancing and one
retreating into the signal, determines the limits of
the waves, looking for the point where it gives the
reversal of the slope on each side.

In the
case of the QRS complex, the program
searches the limits of the R wave and hence the
peak Q and S using the algorithm described above,
but in this case, the algorithm searches for the
beginning of the Q wave and the end of the S
wave and thereby obtaining
the QRS PR and QT.

For each signal cycle, all intervals are collected
for delivery and all conditions of all the anomalies
selected are checked. If the algorithm finds any
abnormalities in the ECG tracing, the program
collects information from the time and

type of
fault to a log file. Next, the program sends the
same information to an authority by SMS in
accordance with the number set in your phone.

4.

E
XPERIMENTAL
R
ESULTS

At this chapter it will be described the different
experimental signals, all of them are very
satisfactory like we will see.
The acquisition
system
is able to easily acquire the EC
G si
gnal,
fi
lter it and amplify it. At the first step, when the
system acquire the
real signal we obtain a signal
like a signal in
Fig.
7

where

we can be seen all
the
important waves like P and T waves and the QRS
complex
.

Fig.
6

-

Flowchart that represents the algorithm to
detect the waves.


Fig.
7

-

ECG si
g
n
al acquired

original
.

When we obtain the original signal, this signal
will pass in the t
h
ree amplifier
steps in the
amplifier circuit. This circuit will
clean some
noise at the signal and we will see the signal
amplified at the

Fig.
8
.


Fig.
8

-

Signal ECG amplified and filtered.

After the amplification step the signal are
modulated with PWM circuit described in the
chapter before.

This signal is transferred and
received in the mobile phone. W
e could see the
signal in the

Fig.
9
.


Fig.
9

-

Signal ECG modulated in PWM.

When the signal is

received in the

mobile phone,
the program use th
e algorithm described in the
chapter
3.3

and
obtain the
Fig.
10

signal.


Fig.
10

-

Signal ECG demodulated.

This signal is

used to detect the important waves
to a correct detection of the
cardiac

anomalies. So,
to detect the

waves
, are

used the
different
levels of
the signal like we could see in the next figure and
like is explained in

the chapter before, see the
Fig.
11
.


Fig.
11

-

Figure illustrates the tensions of the
levels chosen.

5.

C
ONCLUSIONS

AND
F
UTURE WORK

With this system it is possible to prove that
mobile phones are an important factor for the
continuous monitoring of cardiovascular patients
by giving them a better and more guarded quality
of life.

This system is still possible to create
algorithms
for the detection of other cardiac anomalies.

W
e could tell that the mobile phones have a lot
of computational power at this time and this is
very important with biological and monitoring
systems.

This paper conclude
s that the use of
convention
al b
luetooth headset is possible, and
even a cost effective and robust, as evidenced in
the developed system.

For the portability of the system in future will
have to seek a solution that will pass through,
place the electrodes in order to be closer, maki
ng
the system more comfortable for the patient.

I predict that in future, with increased
computing power, this system can have better
results and it is also possible in the near future
direct access to streaming audio headset.

For the circuit of the acquis
ition, future work to
develop, is to create an even more dedicated
circuit, operating in a frequency band ideal for a
range of [0.05 Hz
-
100 Hz] and with a lower
sampling frequency in order to reduce volume of
calculations.

A
CKNOWLEDGMENT

The authors of thi
s paper would like to thank the
coach of the Laboratories of electronics Campus
Taguspark
of the
Ins
tituto Superior Técnico, Mr.
Joã
o Pina dos Santos.
His
knowledge

provided
vital support for the conclusion of this system.

R
EFERENCES

[1]

Clayman P. D., O
coração, Circulo dos
Leitores, 1992.

[2]

Mariana Avelar, S. S., Alarme de acidente
cardiovascular, 2005.

[3]

M. Lutz, Leaning Python, 3
rd

Edition,
O’Reilly, 2007.

[4]

Davidson, C., Compreender as doenças de
coração, Porto Editora, 2006

[5]

Edward K. Chung, M. ,

Pocket Guide to ECG
Diagnosis. Blackwell Science, 1996.

[6]

Merck Sharp & Dohme, Enciclopédia Médica


Volume 1: Doençãs cardiovasculares,
Editoral Oceano, S. L.

[7]

Medgadget, internet journal of emerging
medical thecnologies:
http://medgadget.com/archives/2008/01/micro
_ecg_for_mobile_monitoring.html,2008
.

[8]

Forum nokia,
http://blogs.forum.nokia.com/index.php?op=
ViewArticle&blogld=38462&articled=648,20
07.

[9]

João Raminhos,
Aquisição de Sinais
Fisiológicos


Aplicação ao control de uma
plataforma móvel a partir do EOG, 2009.
.