Download Ventricular Fibrillation Detection Algorithm Implemented in a Cell

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts

Cardiac contractility modulation wikipedia , lookup

Quantium Medical Cardiac Output wikipedia , lookup

Arrhythmogenic right ventricular dysplasia wikipedia , lookup

Ventricular fibrillation wikipedia , lookup

Electrocardiography wikipedia , lookup

Transcript
www.sase.com.ar
2 al 4 de marzo de 2011
UTN­FRBA, Buenos Aires, Argentina
Ventricular Fibrillation Detection Algorithm
Implemented in a Cell-Phone Platform
Michał Rospierski, Marcelo Segura, Martín Guzzo, Eduardo Zavalla, Cristian Sisterna and Eric Laciar
Laboratorio de Electrónica Digital (LED)
Universidad Nacional de San Juan (UNSJ)
San Juan, Argentina
[email protected], [email protected], [email protected], [email protected],
[email protected], [email protected]
mobile phone computer capabilities and network access, it is
possible to design a powerful system to save people in
dangerous situations.
Abstract—Due to their portability, computer capabilities and
widespread use in the society, current cell-phones can be used for
processing of other signals different than voice, like the
electrocardiogram (ECG) signals. In this work, it has been
implemented and evaluated an algorithm in a cell-phone in order
to detect a Ventricular Fibrillation (VF) in the ECG. It identifies
QRS complexes in the ECG and detects possible VF episodes by
the measurement of instantaneous cardiac rate. In case of
detecting VF, the cell phone will automatically send a Short
Message Service to pre-saved phone numbers asking for
immediate help. The developed algorithm could be used to create
an inexpensive and portable system based on a cell-phone that
can save lives. This work belongs to a global project which
includes sensors, signal acquisition, transmission to cell-phones
and alarm messages. The signal acquisition and transmission will
be implemented with low cost, low power current commercial
Systems in Package devices. These devices allow long life
operation, portability and wireless connectivity.
Figure 1 – VF in a recorded ECG
The aim of this work is to implement in a cell–phone
mathematical algorithms which can detect VF in a recorded
ECG and in case of detecting VF automatically send a Short
Message Service (SMS) to a pre-saved phone number asking
for immediate help. One of the most critical points to face and
resolve is the computing time to solve the mathematical
algorithms to detect VF with the cell-phone computing
capabilities.
Keywords: Telemedicine, Ventricular Fibrillation, ECG, cellphone, on-line processing.
I.
INTRODUCTION
Nowadays cell-phones have become one of the most
common electronic devices which are owned by almost
everyone in our world. As a consequence of their portability
and growing computer capabilities, they are used not only for
communication purposes, but also for entertainment, social
networks, positioning systems, and many other applications.
This paper explains the development of one particular
application that takes advantage of these mobile devices to
create a system that can save lives.
This paper is structured as follows. Section II describes the
selected VF detection algorithm. Section III details the
implementation and simulation of the VF detection algorithm
done in the MatLab environment. Section IV describes the
conversion from MatLab language code to Java Platform
Micro Edition (J2ME) language and checks the program
operation in an actual cell phone focusing on the processing
time of the ECG signal to detect VF. Section V details the
virtual machine environment used as a simulator. Section VI
goes through the tests in an actual cell-phone implementation.
Finally, in Section VII, results and conclusions are described.
One of the most common causes of sudden death in patients
with cardiac diseases is Ventricular Fibrillation (VF). It is a
malignant arrythmia characterized by a rapid heart rate and an
uncoordinated contraction of the cardiac muscle of the
ventricles in the heart [1]. VF is usually diagnosed on the basis
of electrocardiogram (ECG), which is the non-invasive register
of the electrical activity of the heart.
II.
VENTRICULAR FIBRILATION DETECTION ALGORITHM
One of most simple criterion of VF recognition is based on
the measurement of cardiac rate [2]. Normal resting heart rate
varies between 60 to 100 bpm. However, heart rate during VF
can reach values from about 240 up to 600 bpm and even
higher [2].
In a VF episode, the ECG has the form of an irregular
sinusoid with irregular shape and variable amplitude pulses, as
it can be seen in Fig. 1. Heart rate in such situation can go from
240 up to 600 beats per minute (bpm). In the case of a VF only
doctor help could save the life of a patient. Using the current
168
www.sase.com.ar
2 al 4 de marzo de 2011
UTN­FRBA, Buenos Aires, Argentina
The algorithm used in this work is based on a modified
version of QRS detector proposed by Pan and Tompkins [3]. It
detects the QRS complexes in ECG signals using bandwidth,
slope and pulse duration criteria. Fig. 2 is a graphical
representation of the basic steps of the algorithm.
(1)
Then, the filtered signal goes through differentiator filter
with following equation (2).
(2)
Following the Pan and Tompkins algorithm, the next step
was to square the signal and then to apply the moving window
integration filter using (3) and (4):
(3)
(4)
Finally, the developed MatLab program carries out the
normalization and finds the pulses, which have bigger value
than a threshold value. The resultant output vector contains the
same amount of samples that the input vector, but it only has
“1” and ”0” values. A “1” means that a QRS complex has
been detected, otherwise is “0”.
Figure 2 - Block diagram of Pan and Tompkins algorithm
In the first step of the algorithm the ECG signal goes
through a band-pass filter to attenuate the P and T low
frequency components of the ECG, remove baseline slow
changes or drifts and reduce 50/60 Hz line interference and
electromyographic high frequency noise. After filtering, the
signal is differentiated to amplify the QRS edges which are
much steeper than the edges of the other ECG components.
Since after differentiation the signal has positive and negative
points, it is then squared, getting a signal that has only positive
data points. Consequently, the steeper parts, which were
detected in differentiator filter, are amplified. However, the
output of the squaring function will exhibit multiple peaks
within the duration of a single QRS complex. To smooth the
resulting signal, the Pan and Tompkins algorithm uses a
moving window integration filter. After all these steps, the
signal is compared with a threshold value, set by the doctor. If
the sample value is bigger than the threshold, its value is
assigned a “1”, on the contrary if the value is smaller than the
threshold a “0” is assigned to this sample. Meanwhile the QRS
is being detected, ECG time intervals between two pulses
(named usually as RR interval) are measured and the cardiac
frequency is then calculated. If the cardiac rate is over a
specific limit, set by the doctor, it means that a possible VF
episode is detected.
III.
Fig. 3 depicts the different stages in the Pan and Tompkins
algorithm implemented in MatLab and their respective
resultant waveforms. In the plot of the bottom it can be seen
the QRS marks after processing the ECG in MatLab.
B. VF Detection Sample Buffers
Once the QRS complexes were correctly detected, the
next step was to calculate the cardiac frequency. For this
purpose the output vector of QRS was converted to a vector of
sample numbers, for which QRS has been detected, and then,
the number of samples, which are beginnings of pulses, are
found. Subsequently, the program counts the difference
between two beginnings of pulses and puts the result into a
vector named RR (time intervals between pulses).
MATLAB PROCESSING
A. Basic QRS complexes detection
A previous recorded ECG file extracted from MIT-BIH
Malignant Ventricular Arrhythmia Database [4] was taken as
an input, to detect the QRS complexes and then plot the results
of applying the Pan and Tompkins algorithm [2]. A .m file
(MatLab file) takes in the file name and the samples numbers,
which are from the file to be processed. Sampling frequency
was set at 250 Hz, and a Butterworth band–pass filter second
order with cut-off frequencies of 5 Hz and 70 Hz was
implemented by using (1).
Figure 3 – Different stages in the Pan and Tompkins algorithm implemented
in MatLab. From top to bottom: original ECG, filtered signal, differentiated
waveform, squared signal, moving integrated signal and QRS marks
169
www.sase.com.ar
2 al 4 de marzo de 2011
UTN­FRBA, Buenos Aires, Argentina
Dividing values from RR by sample frequency gives the
difference in seconds. Finally, the output vector computes the
instantaneous cardiac frequency (beats/min) accordingly to
(5).
(5)
After calculating the cardiac frequency (Fc), the decision
of VF detection is taken after than the Fc exceeding the
threshold frequency. In this work, a VF episode is considered
if at least 3 consecutive cardiac cycles have Fc values over 240
bpm [2]. However, the number of cardiac cycles and the
threshold frequency for VF detection are programmable by the
cardiologist according to the medical history of the patient.
In order to optimize the signal processing, the ECG record
is divided into 3 second windows moving in 1 second steps.
The program seeks for a VF episode in a 3 second window in
which it is looking for a bad cardiac frequency to then start
analyzing every second of the ECG. Every second a new
search starts. It can give enough time to be sure that a VF is
happening (because of the 3 seconds window) and it also can
detect it quickly enough (because of 1 second move).The other
advantage of this method, illustrated in Fig. 4, is that the first
two seconds of any next window has been already analyzed,
so it is possible to use buffers to process and analyze only the
unprocessed one second. It has to be pointed out that the
written program always analyzes last 50 samples from the
preceding second to avoid processing problems related to
starting filters.
Figure 5 - Example of a 3 second window of ECG signal with the transition of
normal heart rhythm and the beginning of a VF episode
At the bottom of Fig. 5, the plot “QRS pulses” shows the
detection of the QRS complex, red dotted line. At the end of
the plot, the detection of an increase of the cardiac frequency
can be clearly seen, successfully detecting a VF episode. Table
1 shows the instantaneous cardiac frequency results using (5).
Table 1 - Instantaneous cardiac frequency
computed by the algorithm
Fc [beats / minute]
77.7
58.6
312.5
C. Results of MatLab implementation
As it was mentioned before, a previous recorded ECG file
extracted from MIT-BIH Malignant Ventricular Arrhythmia
Database [4] was taken as an input (3000 samples, 12
seconds). This was used to be analyzed by the algorithms
implemented in MatLab. Fig. 5 details the different
waveforms obtained after passing the ECG input through the
different stages of the implemented algorithm.
394.7
500.0
300.0
333.3
IV.
J2ME INTERPRETATION
As a previous step to run the application on the cell-phone
it was necessary to use J2SE to translate the algorithms
developed in MatLab to a language closer to the cell-phone
language.
Java Platform Micro Edition is a specification that
describes a simplified version of the Java platform. Java ME
Platform is designed for devices with very limited resources,
such as mobile phones or PDAs. Due to technical limitations
of such devices, i.e., slower processors, less memory, Java ME
has its own reduced in relation to a set of Java classes called
the Standard Edition (SE) configuration. Configurations are
complemented by profiles that add to the existing classes of
their own class to ensure the execution of specific tasks for
specific devices. Profiles can therefore be enhanced with
optional packages. Such as a variety of Application
Programming Interfaces (APIs) allows designers and
Figure 4 - Representation of the signal segmentation process
170
www.sase.com.ar
2 al 4 de marzo de 2011
UTN­FRBA, Buenos Aires, Argentina
developers great flexibility in creating software for devices
with different hardware configurations [5].
B. VF Detection Application
The application that runs in the cell phone begins
reading a configuration file, previously recorded, which
contains the parameters used for the VF detection and the
telephone number to send the SMS for help. Then, an option
for starting detecting or go to administrative tasks is displayed.
The cell-phone used for this project is a Sony Ericsson
W300i. Fig. 6 shows the Java features and functionalities of
this phone.
Selecting “Detect” will start the VF detection algorithm,
displaying on the cell-phone display the average cardiac
frequency and whether a VF has been detected. In case of
detecting a VF the program automatically sends an SMS to the
phone number in the configuration file and with the message
saved in the msg.txt file adding the hour and date of detection.
After sending the SMS, the program goes back to continue
detection. Fig. 8 shows graphically what was explained above.
Selecting the option Admin, the administrative options are
shown. Among them are change the password, check
configuration, and data directories. Of course all of these
options can be changed to fit different needs.
Figure 6 - Java features on the Sony Ericsson W300i
It is equipped with internal memory up to 20 MB with
possibility of adding external memory as a Memory Stick
Micro; it also has Bluetooth wireless technology. Some of the
mentioned functionalities of this phone were not used in the
present work; however, they will be very useful for the next
development continuing the current one.
A. Declared Methods
To be able to carry out all the mathematical calculation in
J2ME, one class and several methods were written in the J2SE
platform, which are later invoked within the Java program
written in J2ME [5].
Fig. 7 is a flow diagram of the Java algorithm of the VF
detection implemented in the cell phone.
Figure 8 – VF detection application flow in the cell-phone
Start
V.
Class Object
Number of Windows
Parameters Transfer
For the virtual machine simulation the Sony Ericsson
W300 simulator was used [7]. A configuration file was created
with the values shown in Table 2.
Buffer with samples
K=0
Table 2 - Values of the different variables in the configuration file
K= K+1
K<Number of
Wndows
Finding Pulses and CF
Calculation
Recognition and Decision
Display Results
Increase Buffer Index
Si
Copy to
Window Buffer
Copy of 750
Samples
No
Variable
Stop
Cardiac frequency threshold
QRS signal level threshold
Threshold of high cardiac frequencies in
window
Threshold of windows with high cardiac
frequencies for sms
Telephone number
K=0
Copy of 350
Samples
No
Copy from
Window Buffer
K>0
VIRTUAL MACHINE SIMULATION RESULTS
Filtering
Value
250
0.55
3
3
5550001
The values used for the configuration file shown in Table
2 are the same values used in J2SE and MatLab tests. Two
virtual cell-phones were used in the virtual machine simulator,
one carries out the VF detection algorithm, and sends the SMS
Figure 7 - Flow diagram of the Java VF detection algorithm
171
www.sase.com.ar
2 al 4 de marzo de 2011
UTN­FRBA, Buenos Aires, Argentina
in case of a VF detection, and the other cell-phone is the
receiver cell-phone, which will receive the SMS. Hence, the
phone number used in this case, Table 2, is a number that
allows communicating two virtual cell-phones.
were developed to have a precise idea of the time processing
the algorithm. The results of the test for the time needed to run
the VF detection algorithm is shown in Table 3.
Table 3 - Calculation time per window in real cell-phone
Fig. 9 shows the msg.txt template file used in this test, 78
characters have been used to write the most important
information about the patient, cell-phone owner, to be sent by
SMS to the destination number.
Figure 9 - msg.txt template with the data to be sent by SMS
Fig. 10 is a screen capture of the two Sony Ericsson cellphones in the virtual machine simulation environment. The
one on the left is running the VF detection algorithm, showing
a VF detection alert message as well as sending SMS message.
The cell-phone on the right is the destination cell-phone,
doctor’s cell-phone for instance, that displays the received
SMS due to the detection of a VF in the patient’s cell-phone
(the one on the left). The testing results were the same results
obtained in the J2SE and MatLab environments.
I.
Window Number
Time for Window [ms]
1
2
3
4
5
6
7
8
9
10
183
77
77
77
79
81
SMS
86
77
83
The other factor that is very time consuming during the
calculation process is presenting the calculation results on the
cell-phone display. Adding this time, the time results shown in
Table 3 increase in approximately 50% with regards the time
obtained without displaying the results. Even though this high
percentage of increasing the time per window when displaying
the results, they are still short enough to conduct efficient VF
recognition with the proposed algorithm.
REAL CELL-PHONE IMPLEMENTATION
Having succeeded in the previous simulation, the next step
was to implement the VF detection algorithm in a real cellphone. The main challenge in this step is the time invested to
process the VF detection algorithm. Therefore, careful tests
II.
CONCLUSIONS
In this work, it has been implemented and evaluated an
algorithm to detect a Ventricular Fibrillation (VF) in a cellphone. The application in the cell-phone was able to open an
ECG digitized text file, process the samples, make the right
decision about ventricular fibrillation and in case of
emergency send SMS to a hospital or a cardiologist for help.
Moreover cell-phone was able to display current cardiac
frequency of every window. The configuration file offers an
easy way to change recognition parameters, very useful in
adjusting analysis to specified patient and ECG detection
conditions, and to change SMS contents, the SMS can contain
up to 129 characters.
Analyzing the obtained results it is possible to say that a
cell-phone, in this particular case the Sony Ericson W300i,
has enough computational power to perform efficient
ventricular fibrillation recognition with the proposed
algorithm. Average time for window calculation, without the
first window, is 79.65 ms, 127 ms with displaying results;
what is much faster than it was expected.
The flow followed with the different programming
environments was a real success. At the beginning it was
helpful to use built in signal processing MatLab libraries.
Translating code from MatLab to J2SE was simple. Finally
Figure 10 - Virtual machine simulation
172
www.sase.com.ar
2 al 4 de marzo de 2011
UTN­FRBA, Buenos Aires, Argentina
translation to J2ME brought a lot of effort to create manually
methods which are not available for this type of Java. It was
beneficial to use J2SE before J2ME.
REFERENCES
[1]
[2]
Future works are based first on using a more reliable
connection to send the request for help, like a General Packet
Radio Service (GPRS) or High-Speed Downlink Packet
Access (HSDPA) for Global System for Mobile
Communications
(GSM)
or
Universal
Mobile
Telecommunications System (UMTS) respectively; second on
using a cell phone device with Global Positioning System
(GPS) to send the localization of the patient to rescue service,
third on adding portability to the code, so it can be used by
any cell-phone. Another feature to add is to offer different
options for detecting other heart anomalies besides the VF.
[3]
[4]
[5]
[6]
[7]
173
A. J. Bayés de Luna. “Arritmias, concepto, mecanismos y clasificación,”
in Electrocardiografía Clínica. Ediciones Espaxs, Barcelona, 1999.
E. Laciar Leber and M. E. Valentinuzzi. “Chapter 4: Ventricular
fibrillation detection,” in Cardiac Fibrillation-Defibrillation. Clinical and
Engineering Aspects by Max E Valentinuzzi, World Scientific
Publishing Co, 2010.
J. Pan, W.J. Tompkins. “A real-time QRS detection algorithm”, IEEE
Trans. Biomed. Eng., 32: 230-236.
MIT-BIH Malignant Arrhythmia Database, freely available in
http://www.physionet.rg/physiobank/database/vfdb/
Sing Li and Jonathan Knudsen, Beginning J2ME: From Novice to
Professional. Third Edition, APRESS, Srpinger-Verlag New York, 2005.
B. Eckel, Thinking in JAVA. Third Edition. Prentice Hall, 2002
Sony Ericsson Developers Platform: http://developer.sonyericsson.com