15
Research Article Embedded System Based on an ARM Microcontroller to Analyze Heart Rate Variability in Real Time Using Wavelets Victor H. Rodriguez , 1 Carlos Medrano , 1,2 and Inmaculada Plaza 1,2 1 EduQTech, E.U. Politecnica, Universidad de Zaragoza, c/Atarazana 2, 44003 Teruel, Spain 2 IIS Arag´ on, Universidad de Zaragoza, Zaragoza, Spain Correspondence should be addressed to Victor H. Rodriguez; victor rod [email protected] Received 15 June 2018; Revised 18 September 2018; Accepted 26 September 2018; Published 16 October 2018 Guest Editor: Guangjie Han Copyright © 2018 Victor H. Rodriguez et al. is is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. e analyses of electrocardiogram (ECG) and heart rate variability (HRV) are of primordial interest for cardiovascular diseases. e algorithm used for the detection of the QRS complex is the basis for HRV analysis and HRV quality will depend strongly on it. e aim of this paper is to implement HRV analysis in real time on an ARM microcontroller (MCU). us, there is no need to send raw data to a cloud server for real time HRV monitoring and, consequently, the communication requirements and the power consumption of the local sensor node would be far lower. e system would facilitate the integration into edge computing, for instance, in small local networks, such as hospitals. A QRS detector based on wavelets is proposed, which is able to autonomously select the coefficients the QRS complex will be detected with. To validate it, the MITBIH and NSRDB databases were used. is detector was implemented in real time using an MCU. Subsequently HRV analysis was implemented in the time, frequency, and nonlinear domains. When evaluating the QRS detector with the MITBIH database, 99.61% positive prediction (PP), 99.3% sensitivity (SE), and a prediction error rate (DER) of 1.12% were obtained. For the NSRDB database the results were a PP of 99.95%, an SE of 99.98%, and a DER of 0.0006%. e execution of the QRS detector in the MCU took 52 milliseconds. On the other hand, the time required to calculate the HRV depends on the data size, but it took only a few seconds to analyze several thousands of interbeat intervals. e results obtained for the detector were superior to 99%, so it is expected that the HRV is reliable. It has also been shown that the detection of QRS complex can be done in real time using advanced processing techniques such as wavelets. 1. Introduction e ECG signal is a defined waveform representation that shows the phases through which the heart passes. e signal represents the polarization and depolarization of the atrium and the ventricle (see Figure 1) [1]. With the ECG, doctors can detect heart disease across the heart rate variability (HRV). Bearing in mind that cardiovascular diseases generate 30% of global deaths, the analysis of the ECG is considered a topic of great interest for researchers [2]. e heart waveform is also oſten referred to as the QRS complex and is the basis for most of the algorithms used for ECG analysis. Basically, the detection of the QRS complex consists in detecting the R peaks of the ECG signal that is the peak between the Q and S waves (see Figure 1). e variability of time between R peaks is the basis for HRV analysis. In the literature, the interval between R peaks is usually referred to as interbeat interval () [3], normal to normal () [4], or RR interval () [5]. From now on, any of them will be used interchangeably. e analysis of the HRV is a noninvasive method that allows analyzing the activity of the autonomic nervous system (ANS). Likewise, it has been found that HRV alterations are linked to cardiovascular diseases [6– 8] or that meditation can alter HRV patterns [9]. ere are several methods to measure the HRV, but the most common belong to three categories: time domain, frequency domain, and nonlinear. In the time domain, statistical and geometric measures are included [5, 6, 10]. e main problem of analyzing the ECG signal is the noise present due to its susceptibility to interferences such as power line, RF interferences, and muscle artifacts, com- plicating the detection of the QRS complex (see Figure 1). is is why in recent years different types of algorithms have been developed for the elimination of noise and the detection Hindawi Wireless Communications and Mobile Computing Volume 2018, Article ID 9138578, 14 pages https://doi.org/10.1155/2018/9138578

Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

  • Upload
    others

  • View
    29

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

Research ArticleEmbedded System Based on an ARM Microcontroller toAnalyze Heart Rate Variability in Real Time Using Wavelets

Victor H Rodriguez 1 Carlos Medrano 12 and Inmaculada Plaza 12

1EduQTech EU Politecnica Universidad de Zaragoza cAtarazana 2 44003 Teruel Spain2IIS Aragon Universidad de Zaragoza Zaragoza Spain

Correspondence should be addressed to Victor H Rodriguez victor rod onthotmailcom

Received 15 June 2018 Revised 18 September 2018 Accepted 26 September 2018 Published 16 October 2018

Guest Editor Guangjie Han

Copyright copy 2018 Victor H Rodriguez et al This is an open access article distributed under the Creative Commons AttributionLicense which permits unrestricted use distribution and reproduction in any medium provided the original work is properlycited

The analyses of electrocardiogram (ECG) and heart rate variability (HRV) are of primordial interest for cardiovascular diseasesThe algorithm used for the detection of the QRS complex is the basis for HRV analysis and HRV quality will depend strongly onit The aim of this paper is to implement HRV analysis in real time on an ARM microcontroller (MCU) Thus there is no need tosend raw data to a cloud server for real time HRV monitoring and consequently the communication requirements and the powerconsumption of the local sensor node would be far lower The system would facilitate the integration into edge computing forinstance in small local networks such as hospitals A QRS detector based on wavelets is proposed which is able to autonomouslyselect the coefficients the QRS complex will be detected with To validate it the MITBIH and NSRDB databases were used Thisdetector was implemented in real time using an MCU Subsequently HRV analysis was implemented in the time frequencyand nonlinear domains When evaluating the QRS detector with the MITBIH database 9961 positive prediction (PP) 993sensitivity (SE) and a prediction error rate (DER) of 112 were obtained For the NSRDB database the results were a PP of 9995an SE of 9998 and a DER of 00006The execution of the QRS detector in the MCU took 52 milliseconds On the other handthe time required to calculate the HRV depends on the data size but it took only a few seconds to analyze several thousands ofinterbeat intervalsThe results obtained for the detector were superior to 99 so it is expected that the HRV is reliable It has alsobeen shown that the detection of QRS complex can be done in real time using advanced processing techniques such as wavelets

1 Introduction

The ECG signal is a defined waveform representation thatshows the phases through which the heart passes The signalrepresents the polarization and depolarization of the atriumand the ventricle (see Figure 1) [1]With the ECG doctors candetect heart disease across the heart rate variability (HRV)Bearing in mind that cardiovascular diseases generate 30 ofglobal deaths the analysis of the ECG is considered a topic ofgreat interest for researchers [2] The heart waveform is alsooften referred to as the QRS complex and is the basis for mostof the algorithms used for ECG analysis

Basically the detection of the QRS complex consists indetecting the R peaks of the ECG signal that is the peakbetween the Q and S waves (see Figure 1) The variability oftime between R peaks is the basis for HRV analysis In theliterature the interval between R peaks is usually referred to

as interbeat interval (119868119861119868) [3] normal to normal (119873119873) [4] orRR interval (119877119877) [5] From now on any of them will be usedinterchangeably The analysis of the HRV is a noninvasivemethod that allows analyzing the activity of the autonomicnervous system (ANS) Likewise it has been found thatHRV alterations are linked to cardiovascular diseases [6ndash8] or that meditation can alter HRV patterns [9] There areseveral methods to measure the HRV but the most commonbelong to three categories time domain frequency domainand nonlinear In the time domain statistical and geometricmeasures are included [5 6 10]

The main problem of analyzing the ECG signal is thenoise present due to its susceptibility to interferences suchas power line RF interferences and muscle artifacts com-plicating the detection of the QRS complex (see Figure 1)This is why in recent years different types of algorithms havebeen developed for the elimination of noise and the detection

HindawiWireless Communications and Mobile ComputingVolume 2018 Article ID 9138578 14 pageshttpsdoiorg10115520189138578

2 Wireless Communications and Mobile Computing

Rwae

wae

wae wae

Rwae

S

S wae

wae

QQ

Twae

Twae

wae

P

PPRsegment

PRsegment

STsegment

STsegment

QRScomplex

QRScomplex

QTinteral

QTinteral

PRInteral

PR Interal

Figure 1 ECG waves intervals and segments Left theoretical wave right real wave

of QRS complex Pan and Tompkin were pioneer in thistopic Their algorithm consisted in using a digital band passfilter and a dynamic threshold [11] Subsequently algorithmswith more advanced techniques for the detection of the QRScomplex emerged such as the use of wavelets [5 12] adaptivefilters [13] Differential Threshold [14] Level-Crossing Sam-pling [15] HiddenMarkovModels [16] S-transform [17] andmany more The use of wavelets has allowed the detectionof R peaks even in different scenarios like varying QRSmorphologies and high grade of noise It has obtained the bestresults The adaptive filters use methodologies based on theleaky-LMS (LLMS) algorithm of LMS family The differentialthreshold algorithms outstand for their low computationalrequirements The level-crossing sampling was tested witha hardware implementation leading to an ECG-monitoringsystemwith a low energy consumption noise cancelation andlow-drawn input current leads The application of HMM andS-transform are in a more experimental phase

Recent studies have shown that HRV analysis in thefrequency domain reveals the activity of the sympatheticnervous system (SNS) and the parasympathetic nervoussystem (PNS) where the high frequencies band (HF 015-040 Hz) corresponds mainly to the activity of the PNS andthe low frequency band (LF 004-015 Hz) corresponds tothe activity of the SNS [5] It has also been found that thereduction of HRV and the increase in the LFHF ratio areassociated with several cardiovascular diseases [5 6]

In recent years the eHealth and mHealth services havegrown and they are expected to continue growing in orderto offer more efficient services to patients [18] thanks to thegrowth of the Internet of Things (119868119900119879) and the improvementof portable devices in the area of health On the other hand

as smart devices are increasingly involved in peoplersquos lives (forexample fall detection systems monitors of physical activityvital signs or sleep quality) they require wide bandwidthsand lower latencies The use of cloud computing is notrecommended in applications that require very low latenciesbetween the data sources and the processing unit [19] Somespecific examples try to define strategies to overcome theassociated problems For instance Gonzalez-Landero et al[20] made an intelligent tracking system of the heart ratewhich predicts the hours in which it is high Then theheart rate is measured with high frequency (every minute)at certain moments and low frequency (every 10 minutes)at other moments This saves energy in communicationHowever this cannot be generalized to any kind of mea-surements since the requirements for sampling are higher orchanging the rate of the communications is not an optionFor HRV the sampling frequency must be very high (500 Hzrecommended) and the possible reduction of communicationimplies a computation in a local node which is the proposedapproach of this paper

To solve the problems of cloud computing a new process-ing technique has emerged edge computing In contrast tocloud computing in edge computing the data generated bythe device is processed in the network edge instead of beingtransmitted to a centralized cloud for processing resultingin very low latencies and lower bandwidth requirements[19 21] The characteristics of edge computing make thistechnique the most suitable for many eHealth and mHealthapplications in which sending raw data would not be fea-sible Health applications are one of the typical areas ofedge computing [22] In [23] real-time signal processingalgorithms are proposed to be implemented in a local node

Wireless Communications and Mobile Computing 3

Preprocessing stage

QRS Detector

Adaptive threshold

DWT Reconstructed signal

Energy levels

ECG signal

Squared and filtered

InitialFindFind The peak is in

correct interval time

Save

false find the next peak

false

true

true

Time_idx

Currentinterval time gt

15s

wae

Pk_ampwae

Pk_ampwae

Pk_ampwae

Thsignal

Thsignal

Thsignal_Temp signal

Rwae

Sr signal Fd signal

= ThThsignal signal = 090 lowast Th

Thsignal = 015 lowast

Figure 2 Flow chart of the complete QRS detector

closer to the sensing environment They are responsible forall the real-time processing of health-related collected data toenable a set of personalized services The proposed scenarioincludes applications for gas leak detection fall detection andpulse and oxygen abnormal level detection Sometimes thecomputation in local nodes requires the search for algorithmseffective yet simple enough to be run in low end processorsIn [24] a wireless acoustic sensor for ambient assisted living isproposed in keeping with the philosophy of edge computingThe proposed sensor is able to record audio samples at leastto 10 kHz sampling frequency It is capable of doing audiosignal processing without compromising the sample rate andthe energy consumption

The aimof this paper is to propose a portable system capa-ble of doing a real-time analysis of the HRV using an ARMmicrocontroller The solution adopted is efficient in termsof energy by avoiding communication of raw data Withinthis aim we have developed and improved a QRS complexdetector using wavelets This detector has the capability ofselecting autonomously the coefficients to detect the R peaksThe implementation on the MCU required the optimizationand improvement of the functions for HRV analysis Theproposed device is designed to be used in a portable way insmall local networks such as hospitals where the advantagesoffered by edge computing can show up especially in topicsrelated to privacy in addition to a real-time analysis ofpatients In this way the quality of the mHealth services could

be increasedThe system could also be used in applications forremote HRVmonitoring like in [25] or [26]

The QRS detector proposed in this work is an exten-sion of the paper sent to the International Conference OnBiomedical Engineering and Applications (ICBEA) [27] Thedifferences with respect to [27] are the following (i) in thecurrent paper the detector is analyzed in more detail (blockdiagram of the detector usemore variable symbols so that thetext can be followed easily use more images and the full set ofconditions to find an R peak) (ii) In addition the HRV is alsomeasured in the current work (iii) the optimization of thealgorithms for a lower RAMconsumption is described givingthe possibility of creating applications in embedded systemswith limited resources and achieving real-time capability

2 Materials and Methods

21 Complex QRS Detector Algorithm The proposed algo-rithm consisted of three stages The first (preprocessing) wasresponsible for filtering and adjusting the signal for the detec-tor In the second stage the detector itself was implementedwhich decided whether the found peak was an R peak or notAnd finally in the third stage an adaptive threshold was builtupdating its level with the last peak found Figure 2 shows ablock diagram of the complex QRS detector algorithm

(a) Preprocessing StageThefirst step in this stage was to applythe DiscreteWavelet Transform (DWT)This tool is based on

4 Wireless Communications and Mobile Computing

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000

2000

4000Raw Signal

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200

0

200Signal level 7 CD7 Energy0011866

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus400minus200

0200400

Signal level 6 CD6 Energy0014883

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus600minus400minus200

0200400

Signal level 5 CD5 Energy0018902

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus400minus200

0200400

Signal level 4 CD4 Energy0017893

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200minus100

0100

Signal level 3 CD3 Energy00078712

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200

0

200Signal level 2 CD2 Energy000064865

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200

0200

Signal level 1 CD Energy66053e-05

Figure 3 Decomposition of the signal into wavelets and their energy levels in percentage

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000

1000

2000

3000

Raw Signal

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000Samples

Signal ReconstructedSamples

AD

C Va

lues

(RAW

)

minus1000

minus500

0

500

1000

AD

C Va

lues

(RAW

)

Figure 4 Signal reconstructed with 4 levels of detail coefficients (54 6 and 7)

the decomposition of a signal in subbands by means of theuse of a pair of digital filters (low pass and high pass filters)The outputs of the low pass filter are named approximationcoefficients (119862119860119899) while the outputs of the high pass filterare named detail coefficients (119862119863119899) where 119899 represents thelevel of the subband This process of decomposition throughfiltering is repeated 119899 times In each iteration the signalis subsampled by a factor of 2 In practice the DWT isimplemented with the Mallat pyramid algorithm [28] Somestudies have shown that the use of a four order Daubechieswavelet is one of the most effective when processing ECGsignals [29] Afterwards the energy percentage of each levelwas calculated (see (1)-(3) and Figure 3) then the four oneswith more energy were selected to reconstruct the signal(Figure 4) In this way it was assured that the levels withmore information of the ECG signal were selected becausenoise or some interferences such as those of the electricalnetwork or the artifacts are usually found at low energylevels (high frequencies generally between 1198621198631 and 1198621198632)(see Figure 3) Therefore using energy levels to discriminate

the noise of QRS complex was a good option Finally weproceeded to remove the offset of the signal by leaving outthe approximation coefficients (1198621198607) In the present studya db4 mother wavelet with 7 levels of decomposition wasselected The number of levels was selected because the datawere processed in buffers of 1024 and thus the number ofiterations allowed was 7

119864119879119862119863 = 119873sum119895

( 119897sum119894

10038161003816100381610038161003816119862119863119894119895100381610038161003816100381610038162 + 119897sum119894

10038161003816100381610038161003816119862119860119894119895100381610038161003816100381610038162) (1)

119864119862119863119895 = 119897sum119894=1

10038161003816100381610038161003816119862119863119894119895100381610038161003816100381610038162 119895 = 1 2 119873 (2)

119875119862119863119895 = 119864119862119863119895119864119879119862119863 lowast 100 119895 = 1 2 119873 (3)

where 119864119879119862119863 is total energy of all 119862119863 119864119862119863119895 is energyon each 119862119863 119875119862119863119895 is percent of energy on each 119862119863119895 is number of decomposition levels 119894 is number ofcoefficient on each 119862119863 119897 is length of 119862119863 and 119873 ismaximum number of decomposition levels

The next step was to reconstruct the signal (119878119903) using onlythe coefficients of the 4 details with the highest energy (seeFigure 4)Then the first difference was applied (4) and later itwas squared to emphasize theR peaks (5) Finally bymeans ofan average filter the signal was smoothed using a window of02 s (119908119894119899119889119900119908119904119878119894119911119890 samples) (see (6))The size of the averagefilter is an important factor If the 119908119894119899119889119900119908119904119878119894119911119890 is too widethe filter will merge the QRS and T complexes If it is toonarrow the QRS complex will produce several peaks andit can cause difficulties in its detection Generally the sizeshould be approximately as wide as the QRS complex [11]

119878119889 [119899] = 119878119903 [119899] minus 119878119903 [119899 minus 1] (4)

119878119902 [119899] = (119878119889 [119899])2 (5)

119865119889 [119899] = 1119908119894119899119889119900119908119904119878119894119911119890 lowast (119878119902 [119899] + 119878119902 [119899 minus 1] + sdot sdot sdot+ 119878119902 [119899 minus (119908119894119899119889119900119908119904119878119894119911119890 minus 1)])

(6)

Wireless Communications and Mobile Computing 5

Sr signalFd signal

minus100

0

100

200

300

400

500

mill

ivol

ts m

V

times104204 206 208 21 212 214 216202

samples

Figure 5 Input signals to QRS detector (signal 100 from MITBIHdatabase)

(b) QRSDetector StageThe stage of the detector required twoinputs for its operation which are the reconstructed signal119878119903 (containing the ECG signal) and the 119865119889 signal that servesas a basis to find the possible location of the QRS complex(see Figure 5) The signal 119865119889 had to start from the half of119908119894119899119889119900119908119904119878119894119911119890 plus one (see (7)) so that both signals (119878119903 and119865119889) coincided in the location of the peaksThis is because theaverage filter introduced a delay in the signal

119865119889 = 119865119889 [( 1199081198941198991198891199001199081199041198781198941199111198902 ) + 1 119905119900 119890119899119889] (7)

The steps followed by the detector are as follows

(i) To calculate the initial threshold using the 119865119889 signalThe threshold (119879ℎ119904119894119892119899119886119897) was set to 15 of the maxi-mum peak that was located in the first 02 s of the 119865119889signal

(ii) To find a peak (119875119896 119886119898119901119908119886V119890) that exceeded 119879ℎ119904119894119892119899119886119897 inthe119865119889 signal When this occurred the index (119875119870119894119899119889119890119909)of the 119865119889 signal was stored

(iii) The next step was to find an 119877119908119886V119890 in the signal 119878119903using 119875119870119894119899119889119890119909 Then a window of 04 s was selectedaround119875119870119894119899119889119890119909Thewindow size was set 04 s becausethis detector is limited to a range of 40 to 150 BPMwhere 04 s equals 150 BPMThus themaximumpeakwas searched using (8)The peak obtained in this waywas a candidate for an 119877119908119886V119890 To determine if the peakfound was a true 119877119908119886V119890 two criteria were followed(a) For the first 10 peaks the time interval between

the current peak and the previous peak had tobe between 04 s and 15 s

(b) For the rest of peaks (more than 10) an averageof the intervals of all previous peaks was taken

(119898119875119896119905119894119898119890) and if the current interval was greaterthan 60of119898119875119896119905119894119898119890 without being greater than15 s the current peak was considered an 119877119908119886V119890With this we avoided confusing the 119877119908119886V119890 withthe 119875119908119886V119890 or the 119879119908119886V119890 sometimes they tend tohave similar amplitudes

119877119908119886V119890= max peak (119878119903 (119875119896119894119899119889119890119909 minus 02119904 119905119900 119875119896119894119899119889119890119909 + 02119904)) (8)

(iv) Finally the index (119877 119894119889119909119908119886V119890) in which the 119877119908119886V119890 wasfound was multiplied by the sampling period In thisway the time in which it had occurred was obtained(119879119894119898119890 119894119889119909119908119886V119890) and later storedThe amplitude of thepeak of the signal 119865119889 (119875119896 119886119898119901119908119886V119890) will be used in thenext stage (adaptive threshold)

(c) Adaptive Threshold In this stage the 119879ℎ119904119894119892119899119886119897 changed itsvalue according to the following two conditions

(i) If an 119877119908119886V119890 peak was confirmed the amplitude119875119896 119886119898119901119908119886V119890 was used to update the 119879ℎ119904119894119892119899119886119897 using (9)(ii) If after a time greater than 15 s (corresponding to

40 BPM) starting from the last 119877 119894119889119909119908119886V119890 no 119877119908119886V119890was found the 119879ℎ119904119894119892119899119886119897 was stored as 119879ℎ119904119894119892119899119886119897 119879119890119898119901 andthen it was reduced by 10 Then the search fromthe last 119877 119894119889119909119908119886V119890 was restarted This modification of119879ℎ119904119894119892119899119886119897 could be repeated up to 3 times If no 119877119908119886V119890was found afterwards the 119879ℎ119904119894119892119899119886119897 retrieved its valuefrom 119879ℎ119904119894119892119899119886119897 119879119890119898119901 and the algorithm continued withthe search for more peaks without returning to theprevious index With this process we could detect119877119908119886V119890 waves that had a smaller amplitude whichmight not exceed the 119879ℎ119904119894119892119899119886119897 because the previousone had a very large amplitude see Figure 6

119879ℎ119904119894119892119899119886119897 = 015 lowast 119875119896 119886119898119901119908119886V119890 (9)

22 HRV Analysis Table 1 shows the parameters obtainedin the different categories of HRV analysis methods Thefollowing subsections explain each category but we insist onthe nontrivial ones or the details required to reproduce ourresults

221 Preprocessing for HRV Analysis This section is devotedto the set of operations required to eliminate ectopic beatsThey are known to give erroneous measures in the HRVanalysis if they are not eliminated This preprocessing isperformed before the calculation of any of the parametersshown in Table 1 We used the method proposed by [30]following these steps

Step 1 The linear trend of the 119868119861119868 vector was removed using(10) For that purpose the line that best fits 119868119861119868was calculatedby least squares

119868119861119868119897119894119899119890119886119897 119889119890119905119903119890119899119889 = 119868119861119868 minus (119883 lowast 1198621 + 1198622) (10)

where 119883 = 119894119904 119886 119904119897119900119901119890 and 1198621 and 1198622 are the coefficients afterresolving the system by Least-Squares

6 Wireless Communications and Mobile Computing

Table 1 Parameters of the analysis HRV

Domain Description Symbol Unitslowast Biological meanTime Mean between IBI interval 119868119861119868119898119890119886119899 ms

Mean heart rate 119867119877119898119890119886119899 BPMStandard deviation of NN intervals SDNN ms Estimate of overall HRV

Measure the mean of standard deviation ofintervals RR in windows of 5 minutes iSDNN ms

Measure the standard deviation of the meanof the intervals RR in windows of 5 minutes SDANN ms

Root mean squared of successive differences RMSSD ms Short term componentPercentage of intervals that differs more than

50 ms pNN50

Standard deviation of the heart rate 119867119877119904119905119889 BPMMaximum time between IBI interval 119872119886119909 msMinimum time between IBI interval 119872119894119899 ms

Frequency Low frequency power LF 1198981199042 Sympathetic nervousSystem activity

High frequency power HF 1198981199042 parasympathetic nervousSystem activity

Ratio between low and high frequency LFHF Sympathovagal balanceLow frequency normalized LFn nuHigh frequency normalized HFn nu

Non linear Poincare SD1 SD2119878119863119903119886119905119894119900 ms Term variability

Geometric (time domain) Triangular index RRTrin Estimate of overall HRVTriangular Interpolation index TINN

lowast BPM(beats per minute) ms (milliseconds)1198981199042(milliseconds squared) nu (normalized units) (percent)

Sr signalFd signal

Small peak after a big peak

minus200

minus100

0

100

200

300

mill

ivol

ts m

V

204 206 208 21 212 214202samples times104

Figure 6 Portion of the signal 104 of theMITBIH database showinglarge differences in amplitude

Step 2 The standard deviation (119878119879119863119868119861119868) and the mean(119872119899119889119868119861119868) of 119868119861119868119897119894119899119890119886119897 119889119890119905119903119890119899119889 were calculated

Step 3 A threshold (119905119903119904ℎ119904119889) was set in order to find theectopic beats In this case it was equal to three times the119878119879119863119868119861119868

119905119903119904ℎ119904119889 = 3 lowast 119878119879119863119868119861119868 (11)

Step 4 Finally to find an ectopic beat the mean 119872119899119889119868119861119868 wassubtracted from the absolute value of the 119868119861119868[119909]119897119894119899119890119886119897 119889119890119905119903119890119899119889Ectopic beats were those beats in which the result was higherthan 119905119903119904ℎ119904119889 in those cases the sample 119868119861119868[119909] was substitutedby the mean of the five preceding samples and the fivefollowing samples of it

222 Analysis of HRV in the Time Domain After the ectopicbeats were removed the vector 119868119861119868 was transformed fromseconds to milliseconds (119898119868119861119868) and the statistical param-eters shown in Table 1 were calculated which correspondto widely known statistical measurements (means standarddeviations)

223 Analysis of HRV in the Frequency Domain Theanalysisin the frequency domain had three stages (a) preprocessingin this stage the signal went through a series of filters toeliminate its offset (b) interpolation the signal without offsetwas interpolated at 4 Hz (c) spectral analysis the spectraldensity (PSD) was calculated using the Welch method

Wireless Communications and Mobile Computing 7

Preprocessing

Step 1 It began by smoothing the 119868119861119868 vector Some authorshave shown that the smoothness prior filter is usually veryeffective in bioelectric signals like the ECG [37 38] It iseven used in commercial software such as Kubios for HRVanalysis [39] However its algorithm requires many resourcesin RAM memory to be implemented in an MCU Thereforein this paper we opted to do the filtering using waveletsThe filtering with the wavelets was done by eliminatingthe coefficients of the details In this case a wavelet 1198891198875with four decomposition levels was used in which afterhaving eliminated all the 119862119863 coefficients the signal wasreconstructed (119868119861119868119908119886V119890) Finally using (12) the signal wassmoothedThepurpose of this filtering processwas to removeany disturbance in low frequency that affects RR intervals

119868119861119868119904119898119900119900119905ℎ [119909] = (119868119861119868 [119909] minus 119868119861119868119908119886V119890 [119909]) (12)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(119868119861119868)Step 2 Calculate the temporary vector (119905) which will be usedto perform the interpolation The temporary vector is thecumulative sum of the 119868119861119868 vectorminus the first value of itself(13)

119905 = cumulativesum (119868119861I) minus 119868119861119868 [0] (13)

Interpolation The vector 119868119861119868119904119898119900119900119905ℎ was passed to ms(119898119868119861119868119904119898119900119900119905ℎ) Then the interpolation was carried out usingthe cubic spline algorithm at 4 Hz (14) Once 119898119868119861119868119904119898119900119900119905ℎ wasinterpolated the average was subtracted (15)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 = 119904119901119897119894119899119890 (119905 119898119868119861119868119904119898119900119900119905ℎ) (14)

119898119868119861119868119905119900119875119878119863 = 119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890minus 119898119890119886119899 (119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890) (15)

Calculation of the Spectral Density To calculate the PSDwith the Welch method the algorithm implemented usedthe fast Fourier transform (FFT) with a window of 256points (119863119886119905119886119908119894119899119889119900119908) and overlapping of 128 points Beforeapplying the FFT to each window the data were smoothed bymultiplying them by a Hamming function (119867119886119898119898119894119899119892119908119894119899119889119900119908)of the same width as 119863119886119905119886119908119894119899119889119900119908 In this way we avoidedabrupt discontinuities at the beginning and end of eachwindow

Obtaining the Parameters in the Frequency Domain Aftercomputing the PSD (119875119878119863119904119894119892119899119886119897) of the 119898119868119861119868119905119900119875119878119863 signalthe area under the curve was calculated for each band offrequencies associated with the HRV the 119881119871119865 band (0 to 004Hz) the 119871119865 band (004 to 015 Hz) and the 119867119865 band (015 to04 Hz) Once the areas for each band were calculated the119871119865119867119865 ratio was calculated by dividing the total area of 119871119865

650 700 750 800 850 900 950650

700

750

800

850

900

950

RRN (ms)

RRN+1(m

s) EpArea

SD1

SD2

Figure 7 Representation of the Poincare analysis

by the total area of 119867119865 (16)The normalized 119871119865 and 119867119865 werecalculated with (17) and (18)

119871119865119867119865 = 119871119865119867119865 (16)

119871119865119899119900119903119898119886119897119894119911119890119889 = 119871119865119871119865 + 119867119865 (17)

119867119865119899119900119903119898119886119897119894119911119890119889 = 119867119865119871119865 + 119867119865 (18)

224 Poincare Analysis The Poincare analysis is a graphicalmethod that evaluates the dynamics of the HRV from thecurrent (119877119877119873) and the next (119877119877119873+1) RR intervals

119877119877119873 = (119898119868119861119868 [0] 119898119868119861119868 [1] 119898119868119861119868 [119873 minus 1]) (19)

119877119877119873+1 = (119898119868119861119868 [1] 119898119868119861119868 [2] 119898119868119861119868 [119873]) (20)

where 119873 = 119897119890119899119892119905ℎ(119898119868119861119868)To perform a quantitative analysis and evaluate the HRV

an ellipse was fit to the data (see Figure 7) The width of theellipse is known as the standard deviation 1 (1198781198631) and thelength as the standard deviation 2 (1198781198632) From 1198781198631 and 1198781198632the area of the ellipse was calculated (119864119901119860119903119890119886) [6] It is saidthat 1198781198631 represents the HRV in short times (short term) andis correlated with the SNA while 1198781198632 represent long periods(long term) and is correlated with SNS [40] Due to thecorrelation between the standard deviation of the RR intervaldifference (119889119868119861119868) (see (21)) and 1198781198631 1198781198631 was calculated using(22)-(24) From the 119878119863119873119873 parameter and SD119889119868119861119868 (see (23))1198781198632 was calculated with (25) the area 119864119901119860119903119890119886 with (26) andfinally the ratio 119878119863119903119886119905119894119900 with (27) [41]

The Poincare plot represents the healthy case by a largeellipse area and small for critical diseases To perform theanalysis of Poincare periods between 5 to 20 minutes arerecommended [6] On the other hand [42 43] observed thata lowest 119878119863119903119886119905119894119900 value is present in healthy subjects In thesame way a small value in 1198781198631 for diseased subjects indicatesweakening of parasympathetic regulation by health disorder

8 Wireless Communications and Mobile Computing

As 1198781198632 decreases the SNS activity increases Figure 7 showsan arrhythmia case from the signal 215 (MITBIH) in which itcan observed that the most of the samples are focused in thecenter of the plot and represent a small ellipse area

119889119868119861119868 [119909] = 119898119868119861119868 [119909 + 1] minus 119898119868119861119868 [119909] (21)

119889119868119861119868119898119890119886119899 = sum119873119909=0 (119889119868119861119868 [119909])119873 (22)

SD119889119868119861119868 = radic sum119873119909=0 1003816100381610038161003816119889119868119861119868 [119909] minus 11988911986811986111986811989811989011988611989910038161003816100381610038162119873 (23)

1198781198631 = radic05 lowast SD1198891198681198611198682 (24)

1198781198632 = radic(2 lowast 1198781198631198731198732) minus (05 lowast SD1198891198681198611198682) (25)

119864119901119860119903119890119886 = 120587 lowast 1198781198631 lowast 1198781198632 (26)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(d119868119861119868)119878119863119903119886119905119894119900 = 11987811986311198781198632 (27)

225 Triangular Geometric Analysis Triangular geometricanalysis is usually considered as part of the analysis in thetime domain However it deserves further explanation sinceit is more complex than the rest This analysis is doneby calculating the histogram of the vector 119898119868119861119868 throughwhich two parameters can be calculated the triangular index(119877119877119879119903119894119899) and the index of triangular interpolation of the baseof the histogram (119879119868119873119873) The 119877119877119879119903119894119899 is equal to the totalnumber of RR intervals divided by the maximum value of thehistogram (119881119886119897119898119886119909) (28) This index gives an overall estimateof the HRV The width of the bins used in this analysiswas set to 78125 ms The 119879119868119873119873 index gives a value on thedistribution of the density of all the RR intervals as the baseof a triangle and it is usually calculated by means of a leastsquares estimateThus119860119903119890119886119905119894119899119899 (see (29)) was minimized andthe limiting points N and M were found Then 119879119868119873119873 wascalculated with (30) see Figure 8 [44]

119877119877119879119903119894119899 = 119873119881119886119897119898119886119909 (28)

119860119903119890119886119905119894119899119899 = intinfin0

(119863 (119905) minus 119902 (119905))2 119889119905 (29)

where 119863 is histogram output 119902 defines the base of triangle thatfits histogram and its cero for 119905 le 119873 119905 ge 119872 and 119902(119883) = 119884

119879119868119873119873 = 119872 minus 119873 (30)

where 119872 and 119873 are the limits of 11986011990311989011988611990511989411989911989923 Parameters and Databases Used to Evaluate the Perfor-mance of QRSDetector In order to compare the performanceof the QRS detector with those found in the literature weused the sensitivity parameter (119878119864) (see (31)) the positive

600 650 700 750 800 850 900 950 1000Time in ms

0

50

100

150

200

250

600 650 700 750 800 850 900 950 1000Time in (ms)

0

50

100

150

200

250

Y

N X M

Figure 8 Points of the histogram used to calculate the indexes ofthe triangular geometric analysis

predictive value (119875119875) (see (32)) and the percentage of theprediction error rate (119863119864119877) (see (33)) 119863119864119877 was also used toevaluate the accuracy of the algorithm

119878119864 = 119879119875119879119875 + 119865119873 lowast 100 (31)

119875119875 = 119879119875119879119875 + 119865119875 lowast 100 (32)

119863119864119877 = 119865119875 + 119865119873119879119875 lowast 100 (33)

where119879119875 are the true positives in detecting the 119877119908119886V119890 119865119873 arethe 119877119908119886V119890 peaks that have not been detected and 119865119875 are thepeaks that have been mistakenly detected as 119877119908119886V119890

In order to validate and compare our proposed algo-rithm for QRS complex detection the MIT-BIT arrhythmiadatabase (MITBIH) and the normal sinus rhythm database(NSRDB) both available online were used [45] Then theresults obtained were compared with other algorithms tosee their effectiveness The MITBIH database consists of 48recordings Each recording has two signals extracted fromhalf hour of a 24-hour recording which have been sampledat 360 Hz and belong to 47 patients in total The NSRDBdatabase contains 18 signals with a duration of 130 minutessampled at 128 Hz and belong to healthy adults aged 20 to 50years

24 Implementation on an MCU The MCU used for theimplementation of the QRS detector and the HRV analysiswas an STM32F407ZET6 MCU Two features can be high-lighted for the present study it has a set of instructions fordigital signal processing (DSP) and a floating point process-ing unit (FPU) whichmake it anMCUcapable of performingadvanced digital processing calculations Likewise it has aflash program memory of 512 Kbyte 192 Kbyte of SRAMmemory and a working frequency of 168 MHz

TheDSP libraries provided by CMSIS (Cortex Microcon-troller Software Interface Standard) were used for the signal

Wireless Communications and Mobile Computing 9

Figure 9 Analysis of the HRV in real time

Figure 10 Analysis of the HRV in frequency domain

processing and the open source wavelib library [46] was usedfor the wavelet implementation The wavelib library had tobe modified and optimized in terms of RAM resources to beused in an MCU

The MCU accessed the MITBIH and NSRDB databasesthrough a microSD card memory in which each recordingwas stored in a separate text data file They were processed inreal time in blocks of 1024 data The block size was chosen fortwo reasons the first one because this number of samples isenough to apply theDWTwith 7 levels of decomposition andthe second because the amount of RAM required is constant(25 kB) and did not compromise the rest of calculationsIt is worth explaining that for an application in real lifethe MCU could acquire data in real time from two externalsources selecting only one at a time The first one wouldinvolve a serial port through the HC-05 Bluetooth moduleat a baud rate of 230400 The second one could use theAD8232 module using the digital analog converter (ADC)with a sampling frequency of 500Hz In both cases interruptscould be used being activated whenever there is a new dataavailable Thus even while the signal is being processed theMCU can continue to fill new buffers for further processingTo display the data locally two LCD screens SSD1306 of128x64 pixels were incorporated using the I2C protocol Anexample of the information displayed on LCD are show inthe Figures 9 and 10 Figure 9 shows the data displayed inreal time while Figure 10 shows the analysis in the frequencydomain for the signal 215 (MITBIH database)

To reduceRAMconsumptionwhenprocessing the signalthe following programming techniques were applied

(i) Avoiding the creations of arrays or matrices withinfunctions it is better to use loops and perform thecorresponding calculations in each iteration

typedef union unsigned uint8 t AllFlags

struct unsigned flag 01

unsigned flag 11

unsigned flag 21

unsigned flag 31

unsigned flag 41

unsigned flag 51

unsigned flag 61

unsigned flag 71 DeviceStatusFlags

DeviceStatusFlags Flags

Used Bytes in RAM 1

uint8 t flag 0

uint8 t flag 1

uint8 t flag 2

uint8 t flag 3

uint8 t flag 4

uint8 t flag 5

uint8 t flag 6

uint8 t flag 7

Used Bytes in RAM 8

Code 1 Efficient use of RAMmemory using structures and unions

(ii) If possible using the input variables as output vari-ables in functions so that new variables are notneeded

(iii) Making use of structures and unions to pack data andtake control of system flags in this way the amount ofRAM required is fully utilized For example in Code 1you can see that less RAM is required using structuresand unions for the same number of flags

For example in Code 2 it is assumed that the inputvariable 119910 has a size of 2000 data In Matlab 64047 bytesis required to perform the same calculation (remove lineartrend) since it does so bymeans of arrays while the algorithmof Code 2 occupied only 48 bytes in the MCU (12 119891119897119900119886119905variables and an 119894119899119905 variable that require 4 bytes each one)since the result was stored in the same input variable

The algorithms optimized following the ideas shown inCode 2 were the average filter the peak detection and thethreshold updating in the QRS detector the calculation of119894119878119863119873119873 and 119878119863119860119873119873 the application of DWT (see (10)) thelinear trend removal (see (12)) and the calculation of the PSD(see (15))

3 Results

The results of Table 2 correspond to the performance of theQRS detector when evaluated with the MITBIH database119863119861 is the number of detected beats and 119879119861 is the totalnumber of beats in each ECG signal It can be observed that109086 pulses of a total of 109494 have been detected 108713

10 Wireless Communications and Mobile Computing

void arm lineal detrend f32 (float 32 t lowast y int size) float 32 t abcdefx1x2C1C2determinant

int i

a=0b=0c=0d=0e=0f=0

x2=1

determinant=0

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size create a slope

a=a+(x1 lowast x1)

b=b+x1

c=c+x1

d=d+x2

e=e+(x1 lowast y [ i ] )f=f+(x2 lowast y [ i ] )

determinant = a lowast d - b lowast c

if ( isnan (determinant) | | isinf(determinant)) return else

C1 = (e lowast d - b lowast f)determinant resolve the System

C2 = (a lowast f - e lowast c)determinant to find the coefficients C1 and C2

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size

y [ i ] =y [ i ] -(x1 lowast C1+C2) remove lineal trendCode 2 C-code to eliminate the linear trend

Table 2 Parameters used to evaluate the QRS detector

Record No TB DB TP FP FN SE PP DERTotal 109494 109086 108713 373 781 9930 9961 112

were true positives 781 were false negative and 373 werefalse positives In addition the QRS detector showed a 119878119864 of9930with a positive prediction of 9961 and an error ratein the detection of pulses of 112

Table 3 shows the results obtained between the differentalgorithms found in the literature and ours using the MIT-BIH database The results we have obtained are a little worseHowever the difference between the algorithm with better 119878119864[34] and ours is only 057 In119875119875 the difference with respectto [35] is 030 and in119863119864119877 the differencewith respect to [36]is only 084

Table 4 shows the comparison between the resultsobtained by our algorithm and those obtained by [32] usingthe 119873119878119877119863119861 database In this comparison [32] has betterresults than us in 119878119864 and 119875119875 by 001 while 119863119864119877 is only00002 better

The time required by the MCU for the HRV analysis willvary according to the size of the IBI vector Table 5 shows theexecution times that were required to analyze the signal 215 oftheMITBIH databaseThis particular file was chosen becauseit contains more QRS complex than the rest of the signals(3358 found by our algorithm)

On the other hand the execution times for the QRSdetector will always be the same (47ms for detection and 5msfor saving in a microSD the temporary location of the 119877119908119886V119890found) because the length of the input vector has a constantsize (1024 samples)

The time required to fill the 1024 data buffer is 1024 lowast(1119891119904) where 119891119904 is the sampling frequency In the case ofthe MITBIH 119891119904 is 360 Hz so it would take 284 s to fill itIn the case of the NSRDB 119891119904 is 128 Hz so that it would take8 s In both cases the detection of the QRS complex can bedone in real time since it only takes 52 ms The detector mayoperate in real time up to a maximum sampling frequencyof 195 kHz However some studies show that 500 Hz is avery reliable frequency forHRV analysis [47] Our system caneasily achieve real time for this recommended frequency

Although the times required for the analysis of the HRVvary depending on the size of 119868119861119868 inTable 5 it can be seen thatthe smoothing of the signal using wavelets and the analysis inthe frequency domain required more time for its executionOn the other side the Poincare analysis was the fastest Thetime required for the complete HRV analysis of signal 215(MITBIH database) was 4401 s

Wireless Communications and Mobile Computing 11

Table 3 Comparison of the results obtained using different algorithm in the MITBIH database

DB TP FP FN SE PP DERJP Martınez et al [31] 109428 109208 153 220 9980 9986 034J Pan amp Tompkins [11] 109809 109532 507 277 9975 9954 071Gutierrez-Rivas et al [32] - 109447 289 502 9954 9973 -Chouakri et al [33] 109488 108043 3068 1446 9868 9724 412Santanu et al [34] 109666 109351 315 144 9987 9969 042Moody amp Mark [35] 109428 107567 94 1861 9830 9991 179Merah et al[36] 109494 109316 126 178 9984 9988 028Proposed algorithm 109086 108713 373 781 9930 9961 112

Table 4 Comparison of the results using the NSRDB database

Algorithm TB TP FP FN SE PP DERGutierrez-Rivas et al [32] 192389 192325 64 17 9996 9999 00004Proposed algorithm 192389 192297 92 25 9995 9998 00006

Refreshing the LCD screens took 50 ms and it was donewhile the buffer was filling so that the update times of thescreens had no influence on the calculations of the HRV

The execution time on a regular PC with the processingperformed inMatlab is also shown in Table 5 for comparisonIt is lower than in the MCU implementation because of thepowerful processor The idea is not to be competitive witha PC server in this aspect but to avoid transmitting data toa server in the cloud which would be a great burden forthe network In addition this would imply a higher powerconsumption for the sensor node For instance the proposedsystem has these power consumption contributions 42 mAfor the MCU in sleep mode 49 mA while processing asignal from a micro SD card 75 mA while processing signalsfrom AD8232 or 169 mA while processing signals fromBluetooth (HC-05 module) Thus it is clear that avoidingcommunication is of great interest

4 Conclusions and Future Work

The results obtained with the QRS detector that we haveproposed based on wavelets and with automatic selection ofthe coefficients of the details have been higher than 99 in119878119864 and 119875119875 using the MITBIH database They are worse thanprevious studies but the difference does not exceed 09 inany of the parameters used in that comparison (119878119864 119875119875 119863119864119877)On the other hand using the NSRDB database the resultshave been better (119878119864 = 9995 119875119875 = 9998 and 119863119864119877 =00006) In comparison with [32] SE and PP have been only001 lower

The QRS detection algorithm was followed by an HRVanalysis In both stages several algorithms had to be opti-mized for the implementation on an MCU Thanks to theefficient use of RAM it has beenpossible to develop thewholeHRV analysis as a standalone application embedded on anMCU ARM

With the execution times shown in Table 5 it has beenshown that theQRSdetector is capable of running in real timefor the most common frequencies used in ECGs Likewise

given that some parameters such as 119868119861119868119898119890119886119899 119878119863119873119873119877119872119878119878119863and 119867119877119898119890119886119899 require very little time for their execution andthat they are in the time domain they could be displayed bysending them via Bluetooth or Wifi to a mobile applicationIn this way an HRV analysis would be done in real time Inaddition the energy consumption is low so it can facilitate itsintegration on portable devices

The time required for the complete analysis of the HRVwill be variable (depending on the amount of data) but it willbe in the order of seconds for practical purposes making it aviable application

Our system could also help in applications like the oneshown in [25] in which HRV and location are measured toevaluate wellness and recommend a place to live accordinglyAll the RR intervals are sent to the userrsquos mobile phone andfrom it to a server in which a time domain parameter of HRVis calculated The system could be improved if the wearabledevice measured itself HRV avoiding the battery consum-ing process of the communication with the mobile phoneBesides our system can calculate all the HRV parametersand could improve the determination of the userrsquos wellnessAnother application of our system could be the integrationinto the system to monitor asthma disease presented in [26]in which the heart rate is also a key component

This system developed on an ARM MCU could be com-plemented by developing a mobile application that displaysthe results of the HRV analysis in a more adequate wayto the user showing comparisons or statistics with respectto previous analyses In this way the user would get bettercontrol over hisher HRV

As future work several lines are devised In the first onethe QRS detector will be improved to obtain better resultsthan those seen in Tables 3 and 4 The second line will bedevoted to the optimization of the proposed system code tointegrate it in the most optimal way into an 119868119900119879 networkIt can be tested using Wifi ZigBee or Bluetooth networksfor short ranges For instance it could receive informationfrom a network edge and then send back to a server onlythe HRV results to be displayed This will help to improve

12 Wireless Communications and Mobile Computing

Table 5 Time required for HRV analysis of the signal 215 (MITBIH database)

Main function Sub functions (ms) Execution time (ms) inMCU

Execution time (ms) inIntel i7 (MatLab)

Detector QRS 47 39DWT perform (37)First difference (lt1)Squared signal (lt3)Filter average (lt3)

Find peaks and update threshold (lt3)Save data to SD 5 -Preprocessing Remove Artifacts 3 1Time DomainHRV 30 9

119868119861119868119898119890119886119899 (lt1)119867119877119898119890119886119899 (1)119878119863119873119873 (lt1)119894119878119863119873119873 (12)119878119863119860119873119873 (11)119877119872119878119878119863 (lt1)

11990111987311987350 11987311987350 (1)119867119877119904119905119889 (1)119872119886119909 (lt1)119872119894119899 (lt1)

Geometrictriangular HRV 89 2

119877119877119879119903119894119899 (17)119879119868119873119873 (62)

Poincare HRV 1 11198781198631 1198781198632 119886119899119889 119864119901119860119903119890119886 (1)

Refresh LCD 50 -FrequencyDomain HRV 4176 163

119868119861119868119904119898119900119900119905ℎ (2084)119905 (lt1)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 (1331)119875119878119863119904119894119892119899119886119897 (302)

119881119871119865 119871119865 119867119865 119871119865119867119865 119871119865119899119900119903119898119886119897119894119911119890119889 and119867119865119899119900119903119898119886119897119894119911119890119889 (458)

mHealth and eHealth services using systems embedded inmicrocontrollers On the other hand we will work to makethe proposed device as small as possible similar to smartband In this way it will be able to track heart rate variabilityduring the daily activity

Data Availability

The data supporting this study are from previously reportedstudies and datasets which have been cited or are includedwithin the article

Conflicts of Interest

The authors declare that they have no conflicts of interest

Acknowledgments

The authors would like to thank the ldquoFondo Social Europeordquothe ldquoDiputacion General de Aragonrdquo (reference groupEduQTech T49 17R) Victor H Rodriguez acknowledges agrant from ldquoCONACYT-Gobierno del Estado de DurangoMexico 330795386043rdquo

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 2: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

2 Wireless Communications and Mobile Computing

Rwae

wae

wae wae

Rwae

S

S wae

wae

QQ

Twae

Twae

wae

P

PPRsegment

PRsegment

STsegment

STsegment

QRScomplex

QRScomplex

QTinteral

QTinteral

PRInteral

PR Interal

Figure 1 ECG waves intervals and segments Left theoretical wave right real wave

of QRS complex Pan and Tompkin were pioneer in thistopic Their algorithm consisted in using a digital band passfilter and a dynamic threshold [11] Subsequently algorithmswith more advanced techniques for the detection of the QRScomplex emerged such as the use of wavelets [5 12] adaptivefilters [13] Differential Threshold [14] Level-Crossing Sam-pling [15] HiddenMarkovModels [16] S-transform [17] andmany more The use of wavelets has allowed the detectionof R peaks even in different scenarios like varying QRSmorphologies and high grade of noise It has obtained the bestresults The adaptive filters use methodologies based on theleaky-LMS (LLMS) algorithm of LMS family The differentialthreshold algorithms outstand for their low computationalrequirements The level-crossing sampling was tested witha hardware implementation leading to an ECG-monitoringsystemwith a low energy consumption noise cancelation andlow-drawn input current leads The application of HMM andS-transform are in a more experimental phase

Recent studies have shown that HRV analysis in thefrequency domain reveals the activity of the sympatheticnervous system (SNS) and the parasympathetic nervoussystem (PNS) where the high frequencies band (HF 015-040 Hz) corresponds mainly to the activity of the PNS andthe low frequency band (LF 004-015 Hz) corresponds tothe activity of the SNS [5] It has also been found that thereduction of HRV and the increase in the LFHF ratio areassociated with several cardiovascular diseases [5 6]

In recent years the eHealth and mHealth services havegrown and they are expected to continue growing in orderto offer more efficient services to patients [18] thanks to thegrowth of the Internet of Things (119868119900119879) and the improvementof portable devices in the area of health On the other hand

as smart devices are increasingly involved in peoplersquos lives (forexample fall detection systems monitors of physical activityvital signs or sleep quality) they require wide bandwidthsand lower latencies The use of cloud computing is notrecommended in applications that require very low latenciesbetween the data sources and the processing unit [19] Somespecific examples try to define strategies to overcome theassociated problems For instance Gonzalez-Landero et al[20] made an intelligent tracking system of the heart ratewhich predicts the hours in which it is high Then theheart rate is measured with high frequency (every minute)at certain moments and low frequency (every 10 minutes)at other moments This saves energy in communicationHowever this cannot be generalized to any kind of mea-surements since the requirements for sampling are higher orchanging the rate of the communications is not an optionFor HRV the sampling frequency must be very high (500 Hzrecommended) and the possible reduction of communicationimplies a computation in a local node which is the proposedapproach of this paper

To solve the problems of cloud computing a new process-ing technique has emerged edge computing In contrast tocloud computing in edge computing the data generated bythe device is processed in the network edge instead of beingtransmitted to a centralized cloud for processing resultingin very low latencies and lower bandwidth requirements[19 21] The characteristics of edge computing make thistechnique the most suitable for many eHealth and mHealthapplications in which sending raw data would not be fea-sible Health applications are one of the typical areas ofedge computing [22] In [23] real-time signal processingalgorithms are proposed to be implemented in a local node

Wireless Communications and Mobile Computing 3

Preprocessing stage

QRS Detector

Adaptive threshold

DWT Reconstructed signal

Energy levels

ECG signal

Squared and filtered

InitialFindFind The peak is in

correct interval time

Save

false find the next peak

false

true

true

Time_idx

Currentinterval time gt

15s

wae

Pk_ampwae

Pk_ampwae

Pk_ampwae

Thsignal

Thsignal

Thsignal_Temp signal

Rwae

Sr signal Fd signal

= ThThsignal signal = 090 lowast Th

Thsignal = 015 lowast

Figure 2 Flow chart of the complete QRS detector

closer to the sensing environment They are responsible forall the real-time processing of health-related collected data toenable a set of personalized services The proposed scenarioincludes applications for gas leak detection fall detection andpulse and oxygen abnormal level detection Sometimes thecomputation in local nodes requires the search for algorithmseffective yet simple enough to be run in low end processorsIn [24] a wireless acoustic sensor for ambient assisted living isproposed in keeping with the philosophy of edge computingThe proposed sensor is able to record audio samples at leastto 10 kHz sampling frequency It is capable of doing audiosignal processing without compromising the sample rate andthe energy consumption

The aimof this paper is to propose a portable system capa-ble of doing a real-time analysis of the HRV using an ARMmicrocontroller The solution adopted is efficient in termsof energy by avoiding communication of raw data Withinthis aim we have developed and improved a QRS complexdetector using wavelets This detector has the capability ofselecting autonomously the coefficients to detect the R peaksThe implementation on the MCU required the optimizationand improvement of the functions for HRV analysis Theproposed device is designed to be used in a portable way insmall local networks such as hospitals where the advantagesoffered by edge computing can show up especially in topicsrelated to privacy in addition to a real-time analysis ofpatients In this way the quality of the mHealth services could

be increasedThe system could also be used in applications forremote HRVmonitoring like in [25] or [26]

The QRS detector proposed in this work is an exten-sion of the paper sent to the International Conference OnBiomedical Engineering and Applications (ICBEA) [27] Thedifferences with respect to [27] are the following (i) in thecurrent paper the detector is analyzed in more detail (blockdiagram of the detector usemore variable symbols so that thetext can be followed easily use more images and the full set ofconditions to find an R peak) (ii) In addition the HRV is alsomeasured in the current work (iii) the optimization of thealgorithms for a lower RAMconsumption is described givingthe possibility of creating applications in embedded systemswith limited resources and achieving real-time capability

2 Materials and Methods

21 Complex QRS Detector Algorithm The proposed algo-rithm consisted of three stages The first (preprocessing) wasresponsible for filtering and adjusting the signal for the detec-tor In the second stage the detector itself was implementedwhich decided whether the found peak was an R peak or notAnd finally in the third stage an adaptive threshold was builtupdating its level with the last peak found Figure 2 shows ablock diagram of the complex QRS detector algorithm

(a) Preprocessing StageThefirst step in this stage was to applythe DiscreteWavelet Transform (DWT)This tool is based on

4 Wireless Communications and Mobile Computing

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000

2000

4000Raw Signal

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200

0

200Signal level 7 CD7 Energy0011866

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus400minus200

0200400

Signal level 6 CD6 Energy0014883

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus600minus400minus200

0200400

Signal level 5 CD5 Energy0018902

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus400minus200

0200400

Signal level 4 CD4 Energy0017893

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200minus100

0100

Signal level 3 CD3 Energy00078712

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200

0

200Signal level 2 CD2 Energy000064865

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200

0200

Signal level 1 CD Energy66053e-05

Figure 3 Decomposition of the signal into wavelets and their energy levels in percentage

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000

1000

2000

3000

Raw Signal

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000Samples

Signal ReconstructedSamples

AD

C Va

lues

(RAW

)

minus1000

minus500

0

500

1000

AD

C Va

lues

(RAW

)

Figure 4 Signal reconstructed with 4 levels of detail coefficients (54 6 and 7)

the decomposition of a signal in subbands by means of theuse of a pair of digital filters (low pass and high pass filters)The outputs of the low pass filter are named approximationcoefficients (119862119860119899) while the outputs of the high pass filterare named detail coefficients (119862119863119899) where 119899 represents thelevel of the subband This process of decomposition throughfiltering is repeated 119899 times In each iteration the signalis subsampled by a factor of 2 In practice the DWT isimplemented with the Mallat pyramid algorithm [28] Somestudies have shown that the use of a four order Daubechieswavelet is one of the most effective when processing ECGsignals [29] Afterwards the energy percentage of each levelwas calculated (see (1)-(3) and Figure 3) then the four oneswith more energy were selected to reconstruct the signal(Figure 4) In this way it was assured that the levels withmore information of the ECG signal were selected becausenoise or some interferences such as those of the electricalnetwork or the artifacts are usually found at low energylevels (high frequencies generally between 1198621198631 and 1198621198632)(see Figure 3) Therefore using energy levels to discriminate

the noise of QRS complex was a good option Finally weproceeded to remove the offset of the signal by leaving outthe approximation coefficients (1198621198607) In the present studya db4 mother wavelet with 7 levels of decomposition wasselected The number of levels was selected because the datawere processed in buffers of 1024 and thus the number ofiterations allowed was 7

119864119879119862119863 = 119873sum119895

( 119897sum119894

10038161003816100381610038161003816119862119863119894119895100381610038161003816100381610038162 + 119897sum119894

10038161003816100381610038161003816119862119860119894119895100381610038161003816100381610038162) (1)

119864119862119863119895 = 119897sum119894=1

10038161003816100381610038161003816119862119863119894119895100381610038161003816100381610038162 119895 = 1 2 119873 (2)

119875119862119863119895 = 119864119862119863119895119864119879119862119863 lowast 100 119895 = 1 2 119873 (3)

where 119864119879119862119863 is total energy of all 119862119863 119864119862119863119895 is energyon each 119862119863 119875119862119863119895 is percent of energy on each 119862119863119895 is number of decomposition levels 119894 is number ofcoefficient on each 119862119863 119897 is length of 119862119863 and 119873 ismaximum number of decomposition levels

The next step was to reconstruct the signal (119878119903) using onlythe coefficients of the 4 details with the highest energy (seeFigure 4)Then the first difference was applied (4) and later itwas squared to emphasize theR peaks (5) Finally bymeans ofan average filter the signal was smoothed using a window of02 s (119908119894119899119889119900119908119904119878119894119911119890 samples) (see (6))The size of the averagefilter is an important factor If the 119908119894119899119889119900119908119904119878119894119911119890 is too widethe filter will merge the QRS and T complexes If it is toonarrow the QRS complex will produce several peaks andit can cause difficulties in its detection Generally the sizeshould be approximately as wide as the QRS complex [11]

119878119889 [119899] = 119878119903 [119899] minus 119878119903 [119899 minus 1] (4)

119878119902 [119899] = (119878119889 [119899])2 (5)

119865119889 [119899] = 1119908119894119899119889119900119908119904119878119894119911119890 lowast (119878119902 [119899] + 119878119902 [119899 minus 1] + sdot sdot sdot+ 119878119902 [119899 minus (119908119894119899119889119900119908119904119878119894119911119890 minus 1)])

(6)

Wireless Communications and Mobile Computing 5

Sr signalFd signal

minus100

0

100

200

300

400

500

mill

ivol

ts m

V

times104204 206 208 21 212 214 216202

samples

Figure 5 Input signals to QRS detector (signal 100 from MITBIHdatabase)

(b) QRSDetector StageThe stage of the detector required twoinputs for its operation which are the reconstructed signal119878119903 (containing the ECG signal) and the 119865119889 signal that servesas a basis to find the possible location of the QRS complex(see Figure 5) The signal 119865119889 had to start from the half of119908119894119899119889119900119908119904119878119894119911119890 plus one (see (7)) so that both signals (119878119903 and119865119889) coincided in the location of the peaksThis is because theaverage filter introduced a delay in the signal

119865119889 = 119865119889 [( 1199081198941198991198891199001199081199041198781198941199111198902 ) + 1 119905119900 119890119899119889] (7)

The steps followed by the detector are as follows

(i) To calculate the initial threshold using the 119865119889 signalThe threshold (119879ℎ119904119894119892119899119886119897) was set to 15 of the maxi-mum peak that was located in the first 02 s of the 119865119889signal

(ii) To find a peak (119875119896 119886119898119901119908119886V119890) that exceeded 119879ℎ119904119894119892119899119886119897 inthe119865119889 signal When this occurred the index (119875119870119894119899119889119890119909)of the 119865119889 signal was stored

(iii) The next step was to find an 119877119908119886V119890 in the signal 119878119903using 119875119870119894119899119889119890119909 Then a window of 04 s was selectedaround119875119870119894119899119889119890119909Thewindow size was set 04 s becausethis detector is limited to a range of 40 to 150 BPMwhere 04 s equals 150 BPMThus themaximumpeakwas searched using (8)The peak obtained in this waywas a candidate for an 119877119908119886V119890 To determine if the peakfound was a true 119877119908119886V119890 two criteria were followed(a) For the first 10 peaks the time interval between

the current peak and the previous peak had tobe between 04 s and 15 s

(b) For the rest of peaks (more than 10) an averageof the intervals of all previous peaks was taken

(119898119875119896119905119894119898119890) and if the current interval was greaterthan 60of119898119875119896119905119894119898119890 without being greater than15 s the current peak was considered an 119877119908119886V119890With this we avoided confusing the 119877119908119886V119890 withthe 119875119908119886V119890 or the 119879119908119886V119890 sometimes they tend tohave similar amplitudes

119877119908119886V119890= max peak (119878119903 (119875119896119894119899119889119890119909 minus 02119904 119905119900 119875119896119894119899119889119890119909 + 02119904)) (8)

(iv) Finally the index (119877 119894119889119909119908119886V119890) in which the 119877119908119886V119890 wasfound was multiplied by the sampling period In thisway the time in which it had occurred was obtained(119879119894119898119890 119894119889119909119908119886V119890) and later storedThe amplitude of thepeak of the signal 119865119889 (119875119896 119886119898119901119908119886V119890) will be used in thenext stage (adaptive threshold)

(c) Adaptive Threshold In this stage the 119879ℎ119904119894119892119899119886119897 changed itsvalue according to the following two conditions

(i) If an 119877119908119886V119890 peak was confirmed the amplitude119875119896 119886119898119901119908119886V119890 was used to update the 119879ℎ119904119894119892119899119886119897 using (9)(ii) If after a time greater than 15 s (corresponding to

40 BPM) starting from the last 119877 119894119889119909119908119886V119890 no 119877119908119886V119890was found the 119879ℎ119904119894119892119899119886119897 was stored as 119879ℎ119904119894119892119899119886119897 119879119890119898119901 andthen it was reduced by 10 Then the search fromthe last 119877 119894119889119909119908119886V119890 was restarted This modification of119879ℎ119904119894119892119899119886119897 could be repeated up to 3 times If no 119877119908119886V119890was found afterwards the 119879ℎ119904119894119892119899119886119897 retrieved its valuefrom 119879ℎ119904119894119892119899119886119897 119879119890119898119901 and the algorithm continued withthe search for more peaks without returning to theprevious index With this process we could detect119877119908119886V119890 waves that had a smaller amplitude whichmight not exceed the 119879ℎ119904119894119892119899119886119897 because the previousone had a very large amplitude see Figure 6

119879ℎ119904119894119892119899119886119897 = 015 lowast 119875119896 119886119898119901119908119886V119890 (9)

22 HRV Analysis Table 1 shows the parameters obtainedin the different categories of HRV analysis methods Thefollowing subsections explain each category but we insist onthe nontrivial ones or the details required to reproduce ourresults

221 Preprocessing for HRV Analysis This section is devotedto the set of operations required to eliminate ectopic beatsThey are known to give erroneous measures in the HRVanalysis if they are not eliminated This preprocessing isperformed before the calculation of any of the parametersshown in Table 1 We used the method proposed by [30]following these steps

Step 1 The linear trend of the 119868119861119868 vector was removed using(10) For that purpose the line that best fits 119868119861119868was calculatedby least squares

119868119861119868119897119894119899119890119886119897 119889119890119905119903119890119899119889 = 119868119861119868 minus (119883 lowast 1198621 + 1198622) (10)

where 119883 = 119894119904 119886 119904119897119900119901119890 and 1198621 and 1198622 are the coefficients afterresolving the system by Least-Squares

6 Wireless Communications and Mobile Computing

Table 1 Parameters of the analysis HRV

Domain Description Symbol Unitslowast Biological meanTime Mean between IBI interval 119868119861119868119898119890119886119899 ms

Mean heart rate 119867119877119898119890119886119899 BPMStandard deviation of NN intervals SDNN ms Estimate of overall HRV

Measure the mean of standard deviation ofintervals RR in windows of 5 minutes iSDNN ms

Measure the standard deviation of the meanof the intervals RR in windows of 5 minutes SDANN ms

Root mean squared of successive differences RMSSD ms Short term componentPercentage of intervals that differs more than

50 ms pNN50

Standard deviation of the heart rate 119867119877119904119905119889 BPMMaximum time between IBI interval 119872119886119909 msMinimum time between IBI interval 119872119894119899 ms

Frequency Low frequency power LF 1198981199042 Sympathetic nervousSystem activity

High frequency power HF 1198981199042 parasympathetic nervousSystem activity

Ratio between low and high frequency LFHF Sympathovagal balanceLow frequency normalized LFn nuHigh frequency normalized HFn nu

Non linear Poincare SD1 SD2119878119863119903119886119905119894119900 ms Term variability

Geometric (time domain) Triangular index RRTrin Estimate of overall HRVTriangular Interpolation index TINN

lowast BPM(beats per minute) ms (milliseconds)1198981199042(milliseconds squared) nu (normalized units) (percent)

Sr signalFd signal

Small peak after a big peak

minus200

minus100

0

100

200

300

mill

ivol

ts m

V

204 206 208 21 212 214202samples times104

Figure 6 Portion of the signal 104 of theMITBIH database showinglarge differences in amplitude

Step 2 The standard deviation (119878119879119863119868119861119868) and the mean(119872119899119889119868119861119868) of 119868119861119868119897119894119899119890119886119897 119889119890119905119903119890119899119889 were calculated

Step 3 A threshold (119905119903119904ℎ119904119889) was set in order to find theectopic beats In this case it was equal to three times the119878119879119863119868119861119868

119905119903119904ℎ119904119889 = 3 lowast 119878119879119863119868119861119868 (11)

Step 4 Finally to find an ectopic beat the mean 119872119899119889119868119861119868 wassubtracted from the absolute value of the 119868119861119868[119909]119897119894119899119890119886119897 119889119890119905119903119890119899119889Ectopic beats were those beats in which the result was higherthan 119905119903119904ℎ119904119889 in those cases the sample 119868119861119868[119909] was substitutedby the mean of the five preceding samples and the fivefollowing samples of it

222 Analysis of HRV in the Time Domain After the ectopicbeats were removed the vector 119868119861119868 was transformed fromseconds to milliseconds (119898119868119861119868) and the statistical param-eters shown in Table 1 were calculated which correspondto widely known statistical measurements (means standarddeviations)

223 Analysis of HRV in the Frequency Domain Theanalysisin the frequency domain had three stages (a) preprocessingin this stage the signal went through a series of filters toeliminate its offset (b) interpolation the signal without offsetwas interpolated at 4 Hz (c) spectral analysis the spectraldensity (PSD) was calculated using the Welch method

Wireless Communications and Mobile Computing 7

Preprocessing

Step 1 It began by smoothing the 119868119861119868 vector Some authorshave shown that the smoothness prior filter is usually veryeffective in bioelectric signals like the ECG [37 38] It iseven used in commercial software such as Kubios for HRVanalysis [39] However its algorithm requires many resourcesin RAM memory to be implemented in an MCU Thereforein this paper we opted to do the filtering using waveletsThe filtering with the wavelets was done by eliminatingthe coefficients of the details In this case a wavelet 1198891198875with four decomposition levels was used in which afterhaving eliminated all the 119862119863 coefficients the signal wasreconstructed (119868119861119868119908119886V119890) Finally using (12) the signal wassmoothedThepurpose of this filtering processwas to removeany disturbance in low frequency that affects RR intervals

119868119861119868119904119898119900119900119905ℎ [119909] = (119868119861119868 [119909] minus 119868119861119868119908119886V119890 [119909]) (12)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(119868119861119868)Step 2 Calculate the temporary vector (119905) which will be usedto perform the interpolation The temporary vector is thecumulative sum of the 119868119861119868 vectorminus the first value of itself(13)

119905 = cumulativesum (119868119861I) minus 119868119861119868 [0] (13)

Interpolation The vector 119868119861119868119904119898119900119900119905ℎ was passed to ms(119898119868119861119868119904119898119900119900119905ℎ) Then the interpolation was carried out usingthe cubic spline algorithm at 4 Hz (14) Once 119898119868119861119868119904119898119900119900119905ℎ wasinterpolated the average was subtracted (15)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 = 119904119901119897119894119899119890 (119905 119898119868119861119868119904119898119900119900119905ℎ) (14)

119898119868119861119868119905119900119875119878119863 = 119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890minus 119898119890119886119899 (119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890) (15)

Calculation of the Spectral Density To calculate the PSDwith the Welch method the algorithm implemented usedthe fast Fourier transform (FFT) with a window of 256points (119863119886119905119886119908119894119899119889119900119908) and overlapping of 128 points Beforeapplying the FFT to each window the data were smoothed bymultiplying them by a Hamming function (119867119886119898119898119894119899119892119908119894119899119889119900119908)of the same width as 119863119886119905119886119908119894119899119889119900119908 In this way we avoidedabrupt discontinuities at the beginning and end of eachwindow

Obtaining the Parameters in the Frequency Domain Aftercomputing the PSD (119875119878119863119904119894119892119899119886119897) of the 119898119868119861119868119905119900119875119878119863 signalthe area under the curve was calculated for each band offrequencies associated with the HRV the 119881119871119865 band (0 to 004Hz) the 119871119865 band (004 to 015 Hz) and the 119867119865 band (015 to04 Hz) Once the areas for each band were calculated the119871119865119867119865 ratio was calculated by dividing the total area of 119871119865

650 700 750 800 850 900 950650

700

750

800

850

900

950

RRN (ms)

RRN+1(m

s) EpArea

SD1

SD2

Figure 7 Representation of the Poincare analysis

by the total area of 119867119865 (16)The normalized 119871119865 and 119867119865 werecalculated with (17) and (18)

119871119865119867119865 = 119871119865119867119865 (16)

119871119865119899119900119903119898119886119897119894119911119890119889 = 119871119865119871119865 + 119867119865 (17)

119867119865119899119900119903119898119886119897119894119911119890119889 = 119867119865119871119865 + 119867119865 (18)

224 Poincare Analysis The Poincare analysis is a graphicalmethod that evaluates the dynamics of the HRV from thecurrent (119877119877119873) and the next (119877119877119873+1) RR intervals

119877119877119873 = (119898119868119861119868 [0] 119898119868119861119868 [1] 119898119868119861119868 [119873 minus 1]) (19)

119877119877119873+1 = (119898119868119861119868 [1] 119898119868119861119868 [2] 119898119868119861119868 [119873]) (20)

where 119873 = 119897119890119899119892119905ℎ(119898119868119861119868)To perform a quantitative analysis and evaluate the HRV

an ellipse was fit to the data (see Figure 7) The width of theellipse is known as the standard deviation 1 (1198781198631) and thelength as the standard deviation 2 (1198781198632) From 1198781198631 and 1198781198632the area of the ellipse was calculated (119864119901119860119903119890119886) [6] It is saidthat 1198781198631 represents the HRV in short times (short term) andis correlated with the SNA while 1198781198632 represent long periods(long term) and is correlated with SNS [40] Due to thecorrelation between the standard deviation of the RR intervaldifference (119889119868119861119868) (see (21)) and 1198781198631 1198781198631 was calculated using(22)-(24) From the 119878119863119873119873 parameter and SD119889119868119861119868 (see (23))1198781198632 was calculated with (25) the area 119864119901119860119903119890119886 with (26) andfinally the ratio 119878119863119903119886119905119894119900 with (27) [41]

The Poincare plot represents the healthy case by a largeellipse area and small for critical diseases To perform theanalysis of Poincare periods between 5 to 20 minutes arerecommended [6] On the other hand [42 43] observed thata lowest 119878119863119903119886119905119894119900 value is present in healthy subjects In thesame way a small value in 1198781198631 for diseased subjects indicatesweakening of parasympathetic regulation by health disorder

8 Wireless Communications and Mobile Computing

As 1198781198632 decreases the SNS activity increases Figure 7 showsan arrhythmia case from the signal 215 (MITBIH) in which itcan observed that the most of the samples are focused in thecenter of the plot and represent a small ellipse area

119889119868119861119868 [119909] = 119898119868119861119868 [119909 + 1] minus 119898119868119861119868 [119909] (21)

119889119868119861119868119898119890119886119899 = sum119873119909=0 (119889119868119861119868 [119909])119873 (22)

SD119889119868119861119868 = radic sum119873119909=0 1003816100381610038161003816119889119868119861119868 [119909] minus 11988911986811986111986811989811989011988611989910038161003816100381610038162119873 (23)

1198781198631 = radic05 lowast SD1198891198681198611198682 (24)

1198781198632 = radic(2 lowast 1198781198631198731198732) minus (05 lowast SD1198891198681198611198682) (25)

119864119901119860119903119890119886 = 120587 lowast 1198781198631 lowast 1198781198632 (26)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(d119868119861119868)119878119863119903119886119905119894119900 = 11987811986311198781198632 (27)

225 Triangular Geometric Analysis Triangular geometricanalysis is usually considered as part of the analysis in thetime domain However it deserves further explanation sinceit is more complex than the rest This analysis is doneby calculating the histogram of the vector 119898119868119861119868 throughwhich two parameters can be calculated the triangular index(119877119877119879119903119894119899) and the index of triangular interpolation of the baseof the histogram (119879119868119873119873) The 119877119877119879119903119894119899 is equal to the totalnumber of RR intervals divided by the maximum value of thehistogram (119881119886119897119898119886119909) (28) This index gives an overall estimateof the HRV The width of the bins used in this analysiswas set to 78125 ms The 119879119868119873119873 index gives a value on thedistribution of the density of all the RR intervals as the baseof a triangle and it is usually calculated by means of a leastsquares estimateThus119860119903119890119886119905119894119899119899 (see (29)) was minimized andthe limiting points N and M were found Then 119879119868119873119873 wascalculated with (30) see Figure 8 [44]

119877119877119879119903119894119899 = 119873119881119886119897119898119886119909 (28)

119860119903119890119886119905119894119899119899 = intinfin0

(119863 (119905) minus 119902 (119905))2 119889119905 (29)

where 119863 is histogram output 119902 defines the base of triangle thatfits histogram and its cero for 119905 le 119873 119905 ge 119872 and 119902(119883) = 119884

119879119868119873119873 = 119872 minus 119873 (30)

where 119872 and 119873 are the limits of 11986011990311989011988611990511989411989911989923 Parameters and Databases Used to Evaluate the Perfor-mance of QRSDetector In order to compare the performanceof the QRS detector with those found in the literature weused the sensitivity parameter (119878119864) (see (31)) the positive

600 650 700 750 800 850 900 950 1000Time in ms

0

50

100

150

200

250

600 650 700 750 800 850 900 950 1000Time in (ms)

0

50

100

150

200

250

Y

N X M

Figure 8 Points of the histogram used to calculate the indexes ofthe triangular geometric analysis

predictive value (119875119875) (see (32)) and the percentage of theprediction error rate (119863119864119877) (see (33)) 119863119864119877 was also used toevaluate the accuracy of the algorithm

119878119864 = 119879119875119879119875 + 119865119873 lowast 100 (31)

119875119875 = 119879119875119879119875 + 119865119875 lowast 100 (32)

119863119864119877 = 119865119875 + 119865119873119879119875 lowast 100 (33)

where119879119875 are the true positives in detecting the 119877119908119886V119890 119865119873 arethe 119877119908119886V119890 peaks that have not been detected and 119865119875 are thepeaks that have been mistakenly detected as 119877119908119886V119890

In order to validate and compare our proposed algo-rithm for QRS complex detection the MIT-BIT arrhythmiadatabase (MITBIH) and the normal sinus rhythm database(NSRDB) both available online were used [45] Then theresults obtained were compared with other algorithms tosee their effectiveness The MITBIH database consists of 48recordings Each recording has two signals extracted fromhalf hour of a 24-hour recording which have been sampledat 360 Hz and belong to 47 patients in total The NSRDBdatabase contains 18 signals with a duration of 130 minutessampled at 128 Hz and belong to healthy adults aged 20 to 50years

24 Implementation on an MCU The MCU used for theimplementation of the QRS detector and the HRV analysiswas an STM32F407ZET6 MCU Two features can be high-lighted for the present study it has a set of instructions fordigital signal processing (DSP) and a floating point process-ing unit (FPU) whichmake it anMCUcapable of performingadvanced digital processing calculations Likewise it has aflash program memory of 512 Kbyte 192 Kbyte of SRAMmemory and a working frequency of 168 MHz

TheDSP libraries provided by CMSIS (Cortex Microcon-troller Software Interface Standard) were used for the signal

Wireless Communications and Mobile Computing 9

Figure 9 Analysis of the HRV in real time

Figure 10 Analysis of the HRV in frequency domain

processing and the open source wavelib library [46] was usedfor the wavelet implementation The wavelib library had tobe modified and optimized in terms of RAM resources to beused in an MCU

The MCU accessed the MITBIH and NSRDB databasesthrough a microSD card memory in which each recordingwas stored in a separate text data file They were processed inreal time in blocks of 1024 data The block size was chosen fortwo reasons the first one because this number of samples isenough to apply theDWTwith 7 levels of decomposition andthe second because the amount of RAM required is constant(25 kB) and did not compromise the rest of calculationsIt is worth explaining that for an application in real lifethe MCU could acquire data in real time from two externalsources selecting only one at a time The first one wouldinvolve a serial port through the HC-05 Bluetooth moduleat a baud rate of 230400 The second one could use theAD8232 module using the digital analog converter (ADC)with a sampling frequency of 500Hz In both cases interruptscould be used being activated whenever there is a new dataavailable Thus even while the signal is being processed theMCU can continue to fill new buffers for further processingTo display the data locally two LCD screens SSD1306 of128x64 pixels were incorporated using the I2C protocol Anexample of the information displayed on LCD are show inthe Figures 9 and 10 Figure 9 shows the data displayed inreal time while Figure 10 shows the analysis in the frequencydomain for the signal 215 (MITBIH database)

To reduceRAMconsumptionwhenprocessing the signalthe following programming techniques were applied

(i) Avoiding the creations of arrays or matrices withinfunctions it is better to use loops and perform thecorresponding calculations in each iteration

typedef union unsigned uint8 t AllFlags

struct unsigned flag 01

unsigned flag 11

unsigned flag 21

unsigned flag 31

unsigned flag 41

unsigned flag 51

unsigned flag 61

unsigned flag 71 DeviceStatusFlags

DeviceStatusFlags Flags

Used Bytes in RAM 1

uint8 t flag 0

uint8 t flag 1

uint8 t flag 2

uint8 t flag 3

uint8 t flag 4

uint8 t flag 5

uint8 t flag 6

uint8 t flag 7

Used Bytes in RAM 8

Code 1 Efficient use of RAMmemory using structures and unions

(ii) If possible using the input variables as output vari-ables in functions so that new variables are notneeded

(iii) Making use of structures and unions to pack data andtake control of system flags in this way the amount ofRAM required is fully utilized For example in Code 1you can see that less RAM is required using structuresand unions for the same number of flags

For example in Code 2 it is assumed that the inputvariable 119910 has a size of 2000 data In Matlab 64047 bytesis required to perform the same calculation (remove lineartrend) since it does so bymeans of arrays while the algorithmof Code 2 occupied only 48 bytes in the MCU (12 119891119897119900119886119905variables and an 119894119899119905 variable that require 4 bytes each one)since the result was stored in the same input variable

The algorithms optimized following the ideas shown inCode 2 were the average filter the peak detection and thethreshold updating in the QRS detector the calculation of119894119878119863119873119873 and 119878119863119860119873119873 the application of DWT (see (10)) thelinear trend removal (see (12)) and the calculation of the PSD(see (15))

3 Results

The results of Table 2 correspond to the performance of theQRS detector when evaluated with the MITBIH database119863119861 is the number of detected beats and 119879119861 is the totalnumber of beats in each ECG signal It can be observed that109086 pulses of a total of 109494 have been detected 108713

10 Wireless Communications and Mobile Computing

void arm lineal detrend f32 (float 32 t lowast y int size) float 32 t abcdefx1x2C1C2determinant

int i

a=0b=0c=0d=0e=0f=0

x2=1

determinant=0

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size create a slope

a=a+(x1 lowast x1)

b=b+x1

c=c+x1

d=d+x2

e=e+(x1 lowast y [ i ] )f=f+(x2 lowast y [ i ] )

determinant = a lowast d - b lowast c

if ( isnan (determinant) | | isinf(determinant)) return else

C1 = (e lowast d - b lowast f)determinant resolve the System

C2 = (a lowast f - e lowast c)determinant to find the coefficients C1 and C2

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size

y [ i ] =y [ i ] -(x1 lowast C1+C2) remove lineal trendCode 2 C-code to eliminate the linear trend

Table 2 Parameters used to evaluate the QRS detector

Record No TB DB TP FP FN SE PP DERTotal 109494 109086 108713 373 781 9930 9961 112

were true positives 781 were false negative and 373 werefalse positives In addition the QRS detector showed a 119878119864 of9930with a positive prediction of 9961 and an error ratein the detection of pulses of 112

Table 3 shows the results obtained between the differentalgorithms found in the literature and ours using the MIT-BIH database The results we have obtained are a little worseHowever the difference between the algorithm with better 119878119864[34] and ours is only 057 In119875119875 the difference with respectto [35] is 030 and in119863119864119877 the differencewith respect to [36]is only 084

Table 4 shows the comparison between the resultsobtained by our algorithm and those obtained by [32] usingthe 119873119878119877119863119861 database In this comparison [32] has betterresults than us in 119878119864 and 119875119875 by 001 while 119863119864119877 is only00002 better

The time required by the MCU for the HRV analysis willvary according to the size of the IBI vector Table 5 shows theexecution times that were required to analyze the signal 215 oftheMITBIH databaseThis particular file was chosen becauseit contains more QRS complex than the rest of the signals(3358 found by our algorithm)

On the other hand the execution times for the QRSdetector will always be the same (47ms for detection and 5msfor saving in a microSD the temporary location of the 119877119908119886V119890found) because the length of the input vector has a constantsize (1024 samples)

The time required to fill the 1024 data buffer is 1024 lowast(1119891119904) where 119891119904 is the sampling frequency In the case ofthe MITBIH 119891119904 is 360 Hz so it would take 284 s to fill itIn the case of the NSRDB 119891119904 is 128 Hz so that it would take8 s In both cases the detection of the QRS complex can bedone in real time since it only takes 52 ms The detector mayoperate in real time up to a maximum sampling frequencyof 195 kHz However some studies show that 500 Hz is avery reliable frequency forHRV analysis [47] Our system caneasily achieve real time for this recommended frequency

Although the times required for the analysis of the HRVvary depending on the size of 119868119861119868 inTable 5 it can be seen thatthe smoothing of the signal using wavelets and the analysis inthe frequency domain required more time for its executionOn the other side the Poincare analysis was the fastest Thetime required for the complete HRV analysis of signal 215(MITBIH database) was 4401 s

Wireless Communications and Mobile Computing 11

Table 3 Comparison of the results obtained using different algorithm in the MITBIH database

DB TP FP FN SE PP DERJP Martınez et al [31] 109428 109208 153 220 9980 9986 034J Pan amp Tompkins [11] 109809 109532 507 277 9975 9954 071Gutierrez-Rivas et al [32] - 109447 289 502 9954 9973 -Chouakri et al [33] 109488 108043 3068 1446 9868 9724 412Santanu et al [34] 109666 109351 315 144 9987 9969 042Moody amp Mark [35] 109428 107567 94 1861 9830 9991 179Merah et al[36] 109494 109316 126 178 9984 9988 028Proposed algorithm 109086 108713 373 781 9930 9961 112

Table 4 Comparison of the results using the NSRDB database

Algorithm TB TP FP FN SE PP DERGutierrez-Rivas et al [32] 192389 192325 64 17 9996 9999 00004Proposed algorithm 192389 192297 92 25 9995 9998 00006

Refreshing the LCD screens took 50 ms and it was donewhile the buffer was filling so that the update times of thescreens had no influence on the calculations of the HRV

The execution time on a regular PC with the processingperformed inMatlab is also shown in Table 5 for comparisonIt is lower than in the MCU implementation because of thepowerful processor The idea is not to be competitive witha PC server in this aspect but to avoid transmitting data toa server in the cloud which would be a great burden forthe network In addition this would imply a higher powerconsumption for the sensor node For instance the proposedsystem has these power consumption contributions 42 mAfor the MCU in sleep mode 49 mA while processing asignal from a micro SD card 75 mA while processing signalsfrom AD8232 or 169 mA while processing signals fromBluetooth (HC-05 module) Thus it is clear that avoidingcommunication is of great interest

4 Conclusions and Future Work

The results obtained with the QRS detector that we haveproposed based on wavelets and with automatic selection ofthe coefficients of the details have been higher than 99 in119878119864 and 119875119875 using the MITBIH database They are worse thanprevious studies but the difference does not exceed 09 inany of the parameters used in that comparison (119878119864 119875119875 119863119864119877)On the other hand using the NSRDB database the resultshave been better (119878119864 = 9995 119875119875 = 9998 and 119863119864119877 =00006) In comparison with [32] SE and PP have been only001 lower

The QRS detection algorithm was followed by an HRVanalysis In both stages several algorithms had to be opti-mized for the implementation on an MCU Thanks to theefficient use of RAM it has beenpossible to develop thewholeHRV analysis as a standalone application embedded on anMCU ARM

With the execution times shown in Table 5 it has beenshown that theQRSdetector is capable of running in real timefor the most common frequencies used in ECGs Likewise

given that some parameters such as 119868119861119868119898119890119886119899 119878119863119873119873119877119872119878119878119863and 119867119877119898119890119886119899 require very little time for their execution andthat they are in the time domain they could be displayed bysending them via Bluetooth or Wifi to a mobile applicationIn this way an HRV analysis would be done in real time Inaddition the energy consumption is low so it can facilitate itsintegration on portable devices

The time required for the complete analysis of the HRVwill be variable (depending on the amount of data) but it willbe in the order of seconds for practical purposes making it aviable application

Our system could also help in applications like the oneshown in [25] in which HRV and location are measured toevaluate wellness and recommend a place to live accordinglyAll the RR intervals are sent to the userrsquos mobile phone andfrom it to a server in which a time domain parameter of HRVis calculated The system could be improved if the wearabledevice measured itself HRV avoiding the battery consum-ing process of the communication with the mobile phoneBesides our system can calculate all the HRV parametersand could improve the determination of the userrsquos wellnessAnother application of our system could be the integrationinto the system to monitor asthma disease presented in [26]in which the heart rate is also a key component

This system developed on an ARM MCU could be com-plemented by developing a mobile application that displaysthe results of the HRV analysis in a more adequate wayto the user showing comparisons or statistics with respectto previous analyses In this way the user would get bettercontrol over hisher HRV

As future work several lines are devised In the first onethe QRS detector will be improved to obtain better resultsthan those seen in Tables 3 and 4 The second line will bedevoted to the optimization of the proposed system code tointegrate it in the most optimal way into an 119868119900119879 networkIt can be tested using Wifi ZigBee or Bluetooth networksfor short ranges For instance it could receive informationfrom a network edge and then send back to a server onlythe HRV results to be displayed This will help to improve

12 Wireless Communications and Mobile Computing

Table 5 Time required for HRV analysis of the signal 215 (MITBIH database)

Main function Sub functions (ms) Execution time (ms) inMCU

Execution time (ms) inIntel i7 (MatLab)

Detector QRS 47 39DWT perform (37)First difference (lt1)Squared signal (lt3)Filter average (lt3)

Find peaks and update threshold (lt3)Save data to SD 5 -Preprocessing Remove Artifacts 3 1Time DomainHRV 30 9

119868119861119868119898119890119886119899 (lt1)119867119877119898119890119886119899 (1)119878119863119873119873 (lt1)119894119878119863119873119873 (12)119878119863119860119873119873 (11)119877119872119878119878119863 (lt1)

11990111987311987350 11987311987350 (1)119867119877119904119905119889 (1)119872119886119909 (lt1)119872119894119899 (lt1)

Geometrictriangular HRV 89 2

119877119877119879119903119894119899 (17)119879119868119873119873 (62)

Poincare HRV 1 11198781198631 1198781198632 119886119899119889 119864119901119860119903119890119886 (1)

Refresh LCD 50 -FrequencyDomain HRV 4176 163

119868119861119868119904119898119900119900119905ℎ (2084)119905 (lt1)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 (1331)119875119878119863119904119894119892119899119886119897 (302)

119881119871119865 119871119865 119867119865 119871119865119867119865 119871119865119899119900119903119898119886119897119894119911119890119889 and119867119865119899119900119903119898119886119897119894119911119890119889 (458)

mHealth and eHealth services using systems embedded inmicrocontrollers On the other hand we will work to makethe proposed device as small as possible similar to smartband In this way it will be able to track heart rate variabilityduring the daily activity

Data Availability

The data supporting this study are from previously reportedstudies and datasets which have been cited or are includedwithin the article

Conflicts of Interest

The authors declare that they have no conflicts of interest

Acknowledgments

The authors would like to thank the ldquoFondo Social Europeordquothe ldquoDiputacion General de Aragonrdquo (reference groupEduQTech T49 17R) Victor H Rodriguez acknowledges agrant from ldquoCONACYT-Gobierno del Estado de DurangoMexico 330795386043rdquo

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 3: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

Wireless Communications and Mobile Computing 3

Preprocessing stage

QRS Detector

Adaptive threshold

DWT Reconstructed signal

Energy levels

ECG signal

Squared and filtered

InitialFindFind The peak is in

correct interval time

Save

false find the next peak

false

true

true

Time_idx

Currentinterval time gt

15s

wae

Pk_ampwae

Pk_ampwae

Pk_ampwae

Thsignal

Thsignal

Thsignal_Temp signal

Rwae

Sr signal Fd signal

= ThThsignal signal = 090 lowast Th

Thsignal = 015 lowast

Figure 2 Flow chart of the complete QRS detector

closer to the sensing environment They are responsible forall the real-time processing of health-related collected data toenable a set of personalized services The proposed scenarioincludes applications for gas leak detection fall detection andpulse and oxygen abnormal level detection Sometimes thecomputation in local nodes requires the search for algorithmseffective yet simple enough to be run in low end processorsIn [24] a wireless acoustic sensor for ambient assisted living isproposed in keeping with the philosophy of edge computingThe proposed sensor is able to record audio samples at leastto 10 kHz sampling frequency It is capable of doing audiosignal processing without compromising the sample rate andthe energy consumption

The aimof this paper is to propose a portable system capa-ble of doing a real-time analysis of the HRV using an ARMmicrocontroller The solution adopted is efficient in termsof energy by avoiding communication of raw data Withinthis aim we have developed and improved a QRS complexdetector using wavelets This detector has the capability ofselecting autonomously the coefficients to detect the R peaksThe implementation on the MCU required the optimizationand improvement of the functions for HRV analysis Theproposed device is designed to be used in a portable way insmall local networks such as hospitals where the advantagesoffered by edge computing can show up especially in topicsrelated to privacy in addition to a real-time analysis ofpatients In this way the quality of the mHealth services could

be increasedThe system could also be used in applications forremote HRVmonitoring like in [25] or [26]

The QRS detector proposed in this work is an exten-sion of the paper sent to the International Conference OnBiomedical Engineering and Applications (ICBEA) [27] Thedifferences with respect to [27] are the following (i) in thecurrent paper the detector is analyzed in more detail (blockdiagram of the detector usemore variable symbols so that thetext can be followed easily use more images and the full set ofconditions to find an R peak) (ii) In addition the HRV is alsomeasured in the current work (iii) the optimization of thealgorithms for a lower RAMconsumption is described givingthe possibility of creating applications in embedded systemswith limited resources and achieving real-time capability

2 Materials and Methods

21 Complex QRS Detector Algorithm The proposed algo-rithm consisted of three stages The first (preprocessing) wasresponsible for filtering and adjusting the signal for the detec-tor In the second stage the detector itself was implementedwhich decided whether the found peak was an R peak or notAnd finally in the third stage an adaptive threshold was builtupdating its level with the last peak found Figure 2 shows ablock diagram of the complex QRS detector algorithm

(a) Preprocessing StageThefirst step in this stage was to applythe DiscreteWavelet Transform (DWT)This tool is based on

4 Wireless Communications and Mobile Computing

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000

2000

4000Raw Signal

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200

0

200Signal level 7 CD7 Energy0011866

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus400minus200

0200400

Signal level 6 CD6 Energy0014883

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus600minus400minus200

0200400

Signal level 5 CD5 Energy0018902

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus400minus200

0200400

Signal level 4 CD4 Energy0017893

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200minus100

0100

Signal level 3 CD3 Energy00078712

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200

0

200Signal level 2 CD2 Energy000064865

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200

0200

Signal level 1 CD Energy66053e-05

Figure 3 Decomposition of the signal into wavelets and their energy levels in percentage

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000

1000

2000

3000

Raw Signal

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000Samples

Signal ReconstructedSamples

AD

C Va

lues

(RAW

)

minus1000

minus500

0

500

1000

AD

C Va

lues

(RAW

)

Figure 4 Signal reconstructed with 4 levels of detail coefficients (54 6 and 7)

the decomposition of a signal in subbands by means of theuse of a pair of digital filters (low pass and high pass filters)The outputs of the low pass filter are named approximationcoefficients (119862119860119899) while the outputs of the high pass filterare named detail coefficients (119862119863119899) where 119899 represents thelevel of the subband This process of decomposition throughfiltering is repeated 119899 times In each iteration the signalis subsampled by a factor of 2 In practice the DWT isimplemented with the Mallat pyramid algorithm [28] Somestudies have shown that the use of a four order Daubechieswavelet is one of the most effective when processing ECGsignals [29] Afterwards the energy percentage of each levelwas calculated (see (1)-(3) and Figure 3) then the four oneswith more energy were selected to reconstruct the signal(Figure 4) In this way it was assured that the levels withmore information of the ECG signal were selected becausenoise or some interferences such as those of the electricalnetwork or the artifacts are usually found at low energylevels (high frequencies generally between 1198621198631 and 1198621198632)(see Figure 3) Therefore using energy levels to discriminate

the noise of QRS complex was a good option Finally weproceeded to remove the offset of the signal by leaving outthe approximation coefficients (1198621198607) In the present studya db4 mother wavelet with 7 levels of decomposition wasselected The number of levels was selected because the datawere processed in buffers of 1024 and thus the number ofiterations allowed was 7

119864119879119862119863 = 119873sum119895

( 119897sum119894

10038161003816100381610038161003816119862119863119894119895100381610038161003816100381610038162 + 119897sum119894

10038161003816100381610038161003816119862119860119894119895100381610038161003816100381610038162) (1)

119864119862119863119895 = 119897sum119894=1

10038161003816100381610038161003816119862119863119894119895100381610038161003816100381610038162 119895 = 1 2 119873 (2)

119875119862119863119895 = 119864119862119863119895119864119879119862119863 lowast 100 119895 = 1 2 119873 (3)

where 119864119879119862119863 is total energy of all 119862119863 119864119862119863119895 is energyon each 119862119863 119875119862119863119895 is percent of energy on each 119862119863119895 is number of decomposition levels 119894 is number ofcoefficient on each 119862119863 119897 is length of 119862119863 and 119873 ismaximum number of decomposition levels

The next step was to reconstruct the signal (119878119903) using onlythe coefficients of the 4 details with the highest energy (seeFigure 4)Then the first difference was applied (4) and later itwas squared to emphasize theR peaks (5) Finally bymeans ofan average filter the signal was smoothed using a window of02 s (119908119894119899119889119900119908119904119878119894119911119890 samples) (see (6))The size of the averagefilter is an important factor If the 119908119894119899119889119900119908119904119878119894119911119890 is too widethe filter will merge the QRS and T complexes If it is toonarrow the QRS complex will produce several peaks andit can cause difficulties in its detection Generally the sizeshould be approximately as wide as the QRS complex [11]

119878119889 [119899] = 119878119903 [119899] minus 119878119903 [119899 minus 1] (4)

119878119902 [119899] = (119878119889 [119899])2 (5)

119865119889 [119899] = 1119908119894119899119889119900119908119904119878119894119911119890 lowast (119878119902 [119899] + 119878119902 [119899 minus 1] + sdot sdot sdot+ 119878119902 [119899 minus (119908119894119899119889119900119908119904119878119894119911119890 minus 1)])

(6)

Wireless Communications and Mobile Computing 5

Sr signalFd signal

minus100

0

100

200

300

400

500

mill

ivol

ts m

V

times104204 206 208 21 212 214 216202

samples

Figure 5 Input signals to QRS detector (signal 100 from MITBIHdatabase)

(b) QRSDetector StageThe stage of the detector required twoinputs for its operation which are the reconstructed signal119878119903 (containing the ECG signal) and the 119865119889 signal that servesas a basis to find the possible location of the QRS complex(see Figure 5) The signal 119865119889 had to start from the half of119908119894119899119889119900119908119904119878119894119911119890 plus one (see (7)) so that both signals (119878119903 and119865119889) coincided in the location of the peaksThis is because theaverage filter introduced a delay in the signal

119865119889 = 119865119889 [( 1199081198941198991198891199001199081199041198781198941199111198902 ) + 1 119905119900 119890119899119889] (7)

The steps followed by the detector are as follows

(i) To calculate the initial threshold using the 119865119889 signalThe threshold (119879ℎ119904119894119892119899119886119897) was set to 15 of the maxi-mum peak that was located in the first 02 s of the 119865119889signal

(ii) To find a peak (119875119896 119886119898119901119908119886V119890) that exceeded 119879ℎ119904119894119892119899119886119897 inthe119865119889 signal When this occurred the index (119875119870119894119899119889119890119909)of the 119865119889 signal was stored

(iii) The next step was to find an 119877119908119886V119890 in the signal 119878119903using 119875119870119894119899119889119890119909 Then a window of 04 s was selectedaround119875119870119894119899119889119890119909Thewindow size was set 04 s becausethis detector is limited to a range of 40 to 150 BPMwhere 04 s equals 150 BPMThus themaximumpeakwas searched using (8)The peak obtained in this waywas a candidate for an 119877119908119886V119890 To determine if the peakfound was a true 119877119908119886V119890 two criteria were followed(a) For the first 10 peaks the time interval between

the current peak and the previous peak had tobe between 04 s and 15 s

(b) For the rest of peaks (more than 10) an averageof the intervals of all previous peaks was taken

(119898119875119896119905119894119898119890) and if the current interval was greaterthan 60of119898119875119896119905119894119898119890 without being greater than15 s the current peak was considered an 119877119908119886V119890With this we avoided confusing the 119877119908119886V119890 withthe 119875119908119886V119890 or the 119879119908119886V119890 sometimes they tend tohave similar amplitudes

119877119908119886V119890= max peak (119878119903 (119875119896119894119899119889119890119909 minus 02119904 119905119900 119875119896119894119899119889119890119909 + 02119904)) (8)

(iv) Finally the index (119877 119894119889119909119908119886V119890) in which the 119877119908119886V119890 wasfound was multiplied by the sampling period In thisway the time in which it had occurred was obtained(119879119894119898119890 119894119889119909119908119886V119890) and later storedThe amplitude of thepeak of the signal 119865119889 (119875119896 119886119898119901119908119886V119890) will be used in thenext stage (adaptive threshold)

(c) Adaptive Threshold In this stage the 119879ℎ119904119894119892119899119886119897 changed itsvalue according to the following two conditions

(i) If an 119877119908119886V119890 peak was confirmed the amplitude119875119896 119886119898119901119908119886V119890 was used to update the 119879ℎ119904119894119892119899119886119897 using (9)(ii) If after a time greater than 15 s (corresponding to

40 BPM) starting from the last 119877 119894119889119909119908119886V119890 no 119877119908119886V119890was found the 119879ℎ119904119894119892119899119886119897 was stored as 119879ℎ119904119894119892119899119886119897 119879119890119898119901 andthen it was reduced by 10 Then the search fromthe last 119877 119894119889119909119908119886V119890 was restarted This modification of119879ℎ119904119894119892119899119886119897 could be repeated up to 3 times If no 119877119908119886V119890was found afterwards the 119879ℎ119904119894119892119899119886119897 retrieved its valuefrom 119879ℎ119904119894119892119899119886119897 119879119890119898119901 and the algorithm continued withthe search for more peaks without returning to theprevious index With this process we could detect119877119908119886V119890 waves that had a smaller amplitude whichmight not exceed the 119879ℎ119904119894119892119899119886119897 because the previousone had a very large amplitude see Figure 6

119879ℎ119904119894119892119899119886119897 = 015 lowast 119875119896 119886119898119901119908119886V119890 (9)

22 HRV Analysis Table 1 shows the parameters obtainedin the different categories of HRV analysis methods Thefollowing subsections explain each category but we insist onthe nontrivial ones or the details required to reproduce ourresults

221 Preprocessing for HRV Analysis This section is devotedto the set of operations required to eliminate ectopic beatsThey are known to give erroneous measures in the HRVanalysis if they are not eliminated This preprocessing isperformed before the calculation of any of the parametersshown in Table 1 We used the method proposed by [30]following these steps

Step 1 The linear trend of the 119868119861119868 vector was removed using(10) For that purpose the line that best fits 119868119861119868was calculatedby least squares

119868119861119868119897119894119899119890119886119897 119889119890119905119903119890119899119889 = 119868119861119868 minus (119883 lowast 1198621 + 1198622) (10)

where 119883 = 119894119904 119886 119904119897119900119901119890 and 1198621 and 1198622 are the coefficients afterresolving the system by Least-Squares

6 Wireless Communications and Mobile Computing

Table 1 Parameters of the analysis HRV

Domain Description Symbol Unitslowast Biological meanTime Mean between IBI interval 119868119861119868119898119890119886119899 ms

Mean heart rate 119867119877119898119890119886119899 BPMStandard deviation of NN intervals SDNN ms Estimate of overall HRV

Measure the mean of standard deviation ofintervals RR in windows of 5 minutes iSDNN ms

Measure the standard deviation of the meanof the intervals RR in windows of 5 minutes SDANN ms

Root mean squared of successive differences RMSSD ms Short term componentPercentage of intervals that differs more than

50 ms pNN50

Standard deviation of the heart rate 119867119877119904119905119889 BPMMaximum time between IBI interval 119872119886119909 msMinimum time between IBI interval 119872119894119899 ms

Frequency Low frequency power LF 1198981199042 Sympathetic nervousSystem activity

High frequency power HF 1198981199042 parasympathetic nervousSystem activity

Ratio between low and high frequency LFHF Sympathovagal balanceLow frequency normalized LFn nuHigh frequency normalized HFn nu

Non linear Poincare SD1 SD2119878119863119903119886119905119894119900 ms Term variability

Geometric (time domain) Triangular index RRTrin Estimate of overall HRVTriangular Interpolation index TINN

lowast BPM(beats per minute) ms (milliseconds)1198981199042(milliseconds squared) nu (normalized units) (percent)

Sr signalFd signal

Small peak after a big peak

minus200

minus100

0

100

200

300

mill

ivol

ts m

V

204 206 208 21 212 214202samples times104

Figure 6 Portion of the signal 104 of theMITBIH database showinglarge differences in amplitude

Step 2 The standard deviation (119878119879119863119868119861119868) and the mean(119872119899119889119868119861119868) of 119868119861119868119897119894119899119890119886119897 119889119890119905119903119890119899119889 were calculated

Step 3 A threshold (119905119903119904ℎ119904119889) was set in order to find theectopic beats In this case it was equal to three times the119878119879119863119868119861119868

119905119903119904ℎ119904119889 = 3 lowast 119878119879119863119868119861119868 (11)

Step 4 Finally to find an ectopic beat the mean 119872119899119889119868119861119868 wassubtracted from the absolute value of the 119868119861119868[119909]119897119894119899119890119886119897 119889119890119905119903119890119899119889Ectopic beats were those beats in which the result was higherthan 119905119903119904ℎ119904119889 in those cases the sample 119868119861119868[119909] was substitutedby the mean of the five preceding samples and the fivefollowing samples of it

222 Analysis of HRV in the Time Domain After the ectopicbeats were removed the vector 119868119861119868 was transformed fromseconds to milliseconds (119898119868119861119868) and the statistical param-eters shown in Table 1 were calculated which correspondto widely known statistical measurements (means standarddeviations)

223 Analysis of HRV in the Frequency Domain Theanalysisin the frequency domain had three stages (a) preprocessingin this stage the signal went through a series of filters toeliminate its offset (b) interpolation the signal without offsetwas interpolated at 4 Hz (c) spectral analysis the spectraldensity (PSD) was calculated using the Welch method

Wireless Communications and Mobile Computing 7

Preprocessing

Step 1 It began by smoothing the 119868119861119868 vector Some authorshave shown that the smoothness prior filter is usually veryeffective in bioelectric signals like the ECG [37 38] It iseven used in commercial software such as Kubios for HRVanalysis [39] However its algorithm requires many resourcesin RAM memory to be implemented in an MCU Thereforein this paper we opted to do the filtering using waveletsThe filtering with the wavelets was done by eliminatingthe coefficients of the details In this case a wavelet 1198891198875with four decomposition levels was used in which afterhaving eliminated all the 119862119863 coefficients the signal wasreconstructed (119868119861119868119908119886V119890) Finally using (12) the signal wassmoothedThepurpose of this filtering processwas to removeany disturbance in low frequency that affects RR intervals

119868119861119868119904119898119900119900119905ℎ [119909] = (119868119861119868 [119909] minus 119868119861119868119908119886V119890 [119909]) (12)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(119868119861119868)Step 2 Calculate the temporary vector (119905) which will be usedto perform the interpolation The temporary vector is thecumulative sum of the 119868119861119868 vectorminus the first value of itself(13)

119905 = cumulativesum (119868119861I) minus 119868119861119868 [0] (13)

Interpolation The vector 119868119861119868119904119898119900119900119905ℎ was passed to ms(119898119868119861119868119904119898119900119900119905ℎ) Then the interpolation was carried out usingthe cubic spline algorithm at 4 Hz (14) Once 119898119868119861119868119904119898119900119900119905ℎ wasinterpolated the average was subtracted (15)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 = 119904119901119897119894119899119890 (119905 119898119868119861119868119904119898119900119900119905ℎ) (14)

119898119868119861119868119905119900119875119878119863 = 119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890minus 119898119890119886119899 (119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890) (15)

Calculation of the Spectral Density To calculate the PSDwith the Welch method the algorithm implemented usedthe fast Fourier transform (FFT) with a window of 256points (119863119886119905119886119908119894119899119889119900119908) and overlapping of 128 points Beforeapplying the FFT to each window the data were smoothed bymultiplying them by a Hamming function (119867119886119898119898119894119899119892119908119894119899119889119900119908)of the same width as 119863119886119905119886119908119894119899119889119900119908 In this way we avoidedabrupt discontinuities at the beginning and end of eachwindow

Obtaining the Parameters in the Frequency Domain Aftercomputing the PSD (119875119878119863119904119894119892119899119886119897) of the 119898119868119861119868119905119900119875119878119863 signalthe area under the curve was calculated for each band offrequencies associated with the HRV the 119881119871119865 band (0 to 004Hz) the 119871119865 band (004 to 015 Hz) and the 119867119865 band (015 to04 Hz) Once the areas for each band were calculated the119871119865119867119865 ratio was calculated by dividing the total area of 119871119865

650 700 750 800 850 900 950650

700

750

800

850

900

950

RRN (ms)

RRN+1(m

s) EpArea

SD1

SD2

Figure 7 Representation of the Poincare analysis

by the total area of 119867119865 (16)The normalized 119871119865 and 119867119865 werecalculated with (17) and (18)

119871119865119867119865 = 119871119865119867119865 (16)

119871119865119899119900119903119898119886119897119894119911119890119889 = 119871119865119871119865 + 119867119865 (17)

119867119865119899119900119903119898119886119897119894119911119890119889 = 119867119865119871119865 + 119867119865 (18)

224 Poincare Analysis The Poincare analysis is a graphicalmethod that evaluates the dynamics of the HRV from thecurrent (119877119877119873) and the next (119877119877119873+1) RR intervals

119877119877119873 = (119898119868119861119868 [0] 119898119868119861119868 [1] 119898119868119861119868 [119873 minus 1]) (19)

119877119877119873+1 = (119898119868119861119868 [1] 119898119868119861119868 [2] 119898119868119861119868 [119873]) (20)

where 119873 = 119897119890119899119892119905ℎ(119898119868119861119868)To perform a quantitative analysis and evaluate the HRV

an ellipse was fit to the data (see Figure 7) The width of theellipse is known as the standard deviation 1 (1198781198631) and thelength as the standard deviation 2 (1198781198632) From 1198781198631 and 1198781198632the area of the ellipse was calculated (119864119901119860119903119890119886) [6] It is saidthat 1198781198631 represents the HRV in short times (short term) andis correlated with the SNA while 1198781198632 represent long periods(long term) and is correlated with SNS [40] Due to thecorrelation between the standard deviation of the RR intervaldifference (119889119868119861119868) (see (21)) and 1198781198631 1198781198631 was calculated using(22)-(24) From the 119878119863119873119873 parameter and SD119889119868119861119868 (see (23))1198781198632 was calculated with (25) the area 119864119901119860119903119890119886 with (26) andfinally the ratio 119878119863119903119886119905119894119900 with (27) [41]

The Poincare plot represents the healthy case by a largeellipse area and small for critical diseases To perform theanalysis of Poincare periods between 5 to 20 minutes arerecommended [6] On the other hand [42 43] observed thata lowest 119878119863119903119886119905119894119900 value is present in healthy subjects In thesame way a small value in 1198781198631 for diseased subjects indicatesweakening of parasympathetic regulation by health disorder

8 Wireless Communications and Mobile Computing

As 1198781198632 decreases the SNS activity increases Figure 7 showsan arrhythmia case from the signal 215 (MITBIH) in which itcan observed that the most of the samples are focused in thecenter of the plot and represent a small ellipse area

119889119868119861119868 [119909] = 119898119868119861119868 [119909 + 1] minus 119898119868119861119868 [119909] (21)

119889119868119861119868119898119890119886119899 = sum119873119909=0 (119889119868119861119868 [119909])119873 (22)

SD119889119868119861119868 = radic sum119873119909=0 1003816100381610038161003816119889119868119861119868 [119909] minus 11988911986811986111986811989811989011988611989910038161003816100381610038162119873 (23)

1198781198631 = radic05 lowast SD1198891198681198611198682 (24)

1198781198632 = radic(2 lowast 1198781198631198731198732) minus (05 lowast SD1198891198681198611198682) (25)

119864119901119860119903119890119886 = 120587 lowast 1198781198631 lowast 1198781198632 (26)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(d119868119861119868)119878119863119903119886119905119894119900 = 11987811986311198781198632 (27)

225 Triangular Geometric Analysis Triangular geometricanalysis is usually considered as part of the analysis in thetime domain However it deserves further explanation sinceit is more complex than the rest This analysis is doneby calculating the histogram of the vector 119898119868119861119868 throughwhich two parameters can be calculated the triangular index(119877119877119879119903119894119899) and the index of triangular interpolation of the baseof the histogram (119879119868119873119873) The 119877119877119879119903119894119899 is equal to the totalnumber of RR intervals divided by the maximum value of thehistogram (119881119886119897119898119886119909) (28) This index gives an overall estimateof the HRV The width of the bins used in this analysiswas set to 78125 ms The 119879119868119873119873 index gives a value on thedistribution of the density of all the RR intervals as the baseof a triangle and it is usually calculated by means of a leastsquares estimateThus119860119903119890119886119905119894119899119899 (see (29)) was minimized andthe limiting points N and M were found Then 119879119868119873119873 wascalculated with (30) see Figure 8 [44]

119877119877119879119903119894119899 = 119873119881119886119897119898119886119909 (28)

119860119903119890119886119905119894119899119899 = intinfin0

(119863 (119905) minus 119902 (119905))2 119889119905 (29)

where 119863 is histogram output 119902 defines the base of triangle thatfits histogram and its cero for 119905 le 119873 119905 ge 119872 and 119902(119883) = 119884

119879119868119873119873 = 119872 minus 119873 (30)

where 119872 and 119873 are the limits of 11986011990311989011988611990511989411989911989923 Parameters and Databases Used to Evaluate the Perfor-mance of QRSDetector In order to compare the performanceof the QRS detector with those found in the literature weused the sensitivity parameter (119878119864) (see (31)) the positive

600 650 700 750 800 850 900 950 1000Time in ms

0

50

100

150

200

250

600 650 700 750 800 850 900 950 1000Time in (ms)

0

50

100

150

200

250

Y

N X M

Figure 8 Points of the histogram used to calculate the indexes ofthe triangular geometric analysis

predictive value (119875119875) (see (32)) and the percentage of theprediction error rate (119863119864119877) (see (33)) 119863119864119877 was also used toevaluate the accuracy of the algorithm

119878119864 = 119879119875119879119875 + 119865119873 lowast 100 (31)

119875119875 = 119879119875119879119875 + 119865119875 lowast 100 (32)

119863119864119877 = 119865119875 + 119865119873119879119875 lowast 100 (33)

where119879119875 are the true positives in detecting the 119877119908119886V119890 119865119873 arethe 119877119908119886V119890 peaks that have not been detected and 119865119875 are thepeaks that have been mistakenly detected as 119877119908119886V119890

In order to validate and compare our proposed algo-rithm for QRS complex detection the MIT-BIT arrhythmiadatabase (MITBIH) and the normal sinus rhythm database(NSRDB) both available online were used [45] Then theresults obtained were compared with other algorithms tosee their effectiveness The MITBIH database consists of 48recordings Each recording has two signals extracted fromhalf hour of a 24-hour recording which have been sampledat 360 Hz and belong to 47 patients in total The NSRDBdatabase contains 18 signals with a duration of 130 minutessampled at 128 Hz and belong to healthy adults aged 20 to 50years

24 Implementation on an MCU The MCU used for theimplementation of the QRS detector and the HRV analysiswas an STM32F407ZET6 MCU Two features can be high-lighted for the present study it has a set of instructions fordigital signal processing (DSP) and a floating point process-ing unit (FPU) whichmake it anMCUcapable of performingadvanced digital processing calculations Likewise it has aflash program memory of 512 Kbyte 192 Kbyte of SRAMmemory and a working frequency of 168 MHz

TheDSP libraries provided by CMSIS (Cortex Microcon-troller Software Interface Standard) were used for the signal

Wireless Communications and Mobile Computing 9

Figure 9 Analysis of the HRV in real time

Figure 10 Analysis of the HRV in frequency domain

processing and the open source wavelib library [46] was usedfor the wavelet implementation The wavelib library had tobe modified and optimized in terms of RAM resources to beused in an MCU

The MCU accessed the MITBIH and NSRDB databasesthrough a microSD card memory in which each recordingwas stored in a separate text data file They were processed inreal time in blocks of 1024 data The block size was chosen fortwo reasons the first one because this number of samples isenough to apply theDWTwith 7 levels of decomposition andthe second because the amount of RAM required is constant(25 kB) and did not compromise the rest of calculationsIt is worth explaining that for an application in real lifethe MCU could acquire data in real time from two externalsources selecting only one at a time The first one wouldinvolve a serial port through the HC-05 Bluetooth moduleat a baud rate of 230400 The second one could use theAD8232 module using the digital analog converter (ADC)with a sampling frequency of 500Hz In both cases interruptscould be used being activated whenever there is a new dataavailable Thus even while the signal is being processed theMCU can continue to fill new buffers for further processingTo display the data locally two LCD screens SSD1306 of128x64 pixels were incorporated using the I2C protocol Anexample of the information displayed on LCD are show inthe Figures 9 and 10 Figure 9 shows the data displayed inreal time while Figure 10 shows the analysis in the frequencydomain for the signal 215 (MITBIH database)

To reduceRAMconsumptionwhenprocessing the signalthe following programming techniques were applied

(i) Avoiding the creations of arrays or matrices withinfunctions it is better to use loops and perform thecorresponding calculations in each iteration

typedef union unsigned uint8 t AllFlags

struct unsigned flag 01

unsigned flag 11

unsigned flag 21

unsigned flag 31

unsigned flag 41

unsigned flag 51

unsigned flag 61

unsigned flag 71 DeviceStatusFlags

DeviceStatusFlags Flags

Used Bytes in RAM 1

uint8 t flag 0

uint8 t flag 1

uint8 t flag 2

uint8 t flag 3

uint8 t flag 4

uint8 t flag 5

uint8 t flag 6

uint8 t flag 7

Used Bytes in RAM 8

Code 1 Efficient use of RAMmemory using structures and unions

(ii) If possible using the input variables as output vari-ables in functions so that new variables are notneeded

(iii) Making use of structures and unions to pack data andtake control of system flags in this way the amount ofRAM required is fully utilized For example in Code 1you can see that less RAM is required using structuresand unions for the same number of flags

For example in Code 2 it is assumed that the inputvariable 119910 has a size of 2000 data In Matlab 64047 bytesis required to perform the same calculation (remove lineartrend) since it does so bymeans of arrays while the algorithmof Code 2 occupied only 48 bytes in the MCU (12 119891119897119900119886119905variables and an 119894119899119905 variable that require 4 bytes each one)since the result was stored in the same input variable

The algorithms optimized following the ideas shown inCode 2 were the average filter the peak detection and thethreshold updating in the QRS detector the calculation of119894119878119863119873119873 and 119878119863119860119873119873 the application of DWT (see (10)) thelinear trend removal (see (12)) and the calculation of the PSD(see (15))

3 Results

The results of Table 2 correspond to the performance of theQRS detector when evaluated with the MITBIH database119863119861 is the number of detected beats and 119879119861 is the totalnumber of beats in each ECG signal It can be observed that109086 pulses of a total of 109494 have been detected 108713

10 Wireless Communications and Mobile Computing

void arm lineal detrend f32 (float 32 t lowast y int size) float 32 t abcdefx1x2C1C2determinant

int i

a=0b=0c=0d=0e=0f=0

x2=1

determinant=0

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size create a slope

a=a+(x1 lowast x1)

b=b+x1

c=c+x1

d=d+x2

e=e+(x1 lowast y [ i ] )f=f+(x2 lowast y [ i ] )

determinant = a lowast d - b lowast c

if ( isnan (determinant) | | isinf(determinant)) return else

C1 = (e lowast d - b lowast f)determinant resolve the System

C2 = (a lowast f - e lowast c)determinant to find the coefficients C1 and C2

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size

y [ i ] =y [ i ] -(x1 lowast C1+C2) remove lineal trendCode 2 C-code to eliminate the linear trend

Table 2 Parameters used to evaluate the QRS detector

Record No TB DB TP FP FN SE PP DERTotal 109494 109086 108713 373 781 9930 9961 112

were true positives 781 were false negative and 373 werefalse positives In addition the QRS detector showed a 119878119864 of9930with a positive prediction of 9961 and an error ratein the detection of pulses of 112

Table 3 shows the results obtained between the differentalgorithms found in the literature and ours using the MIT-BIH database The results we have obtained are a little worseHowever the difference between the algorithm with better 119878119864[34] and ours is only 057 In119875119875 the difference with respectto [35] is 030 and in119863119864119877 the differencewith respect to [36]is only 084

Table 4 shows the comparison between the resultsobtained by our algorithm and those obtained by [32] usingthe 119873119878119877119863119861 database In this comparison [32] has betterresults than us in 119878119864 and 119875119875 by 001 while 119863119864119877 is only00002 better

The time required by the MCU for the HRV analysis willvary according to the size of the IBI vector Table 5 shows theexecution times that were required to analyze the signal 215 oftheMITBIH databaseThis particular file was chosen becauseit contains more QRS complex than the rest of the signals(3358 found by our algorithm)

On the other hand the execution times for the QRSdetector will always be the same (47ms for detection and 5msfor saving in a microSD the temporary location of the 119877119908119886V119890found) because the length of the input vector has a constantsize (1024 samples)

The time required to fill the 1024 data buffer is 1024 lowast(1119891119904) where 119891119904 is the sampling frequency In the case ofthe MITBIH 119891119904 is 360 Hz so it would take 284 s to fill itIn the case of the NSRDB 119891119904 is 128 Hz so that it would take8 s In both cases the detection of the QRS complex can bedone in real time since it only takes 52 ms The detector mayoperate in real time up to a maximum sampling frequencyof 195 kHz However some studies show that 500 Hz is avery reliable frequency forHRV analysis [47] Our system caneasily achieve real time for this recommended frequency

Although the times required for the analysis of the HRVvary depending on the size of 119868119861119868 inTable 5 it can be seen thatthe smoothing of the signal using wavelets and the analysis inthe frequency domain required more time for its executionOn the other side the Poincare analysis was the fastest Thetime required for the complete HRV analysis of signal 215(MITBIH database) was 4401 s

Wireless Communications and Mobile Computing 11

Table 3 Comparison of the results obtained using different algorithm in the MITBIH database

DB TP FP FN SE PP DERJP Martınez et al [31] 109428 109208 153 220 9980 9986 034J Pan amp Tompkins [11] 109809 109532 507 277 9975 9954 071Gutierrez-Rivas et al [32] - 109447 289 502 9954 9973 -Chouakri et al [33] 109488 108043 3068 1446 9868 9724 412Santanu et al [34] 109666 109351 315 144 9987 9969 042Moody amp Mark [35] 109428 107567 94 1861 9830 9991 179Merah et al[36] 109494 109316 126 178 9984 9988 028Proposed algorithm 109086 108713 373 781 9930 9961 112

Table 4 Comparison of the results using the NSRDB database

Algorithm TB TP FP FN SE PP DERGutierrez-Rivas et al [32] 192389 192325 64 17 9996 9999 00004Proposed algorithm 192389 192297 92 25 9995 9998 00006

Refreshing the LCD screens took 50 ms and it was donewhile the buffer was filling so that the update times of thescreens had no influence on the calculations of the HRV

The execution time on a regular PC with the processingperformed inMatlab is also shown in Table 5 for comparisonIt is lower than in the MCU implementation because of thepowerful processor The idea is not to be competitive witha PC server in this aspect but to avoid transmitting data toa server in the cloud which would be a great burden forthe network In addition this would imply a higher powerconsumption for the sensor node For instance the proposedsystem has these power consumption contributions 42 mAfor the MCU in sleep mode 49 mA while processing asignal from a micro SD card 75 mA while processing signalsfrom AD8232 or 169 mA while processing signals fromBluetooth (HC-05 module) Thus it is clear that avoidingcommunication is of great interest

4 Conclusions and Future Work

The results obtained with the QRS detector that we haveproposed based on wavelets and with automatic selection ofthe coefficients of the details have been higher than 99 in119878119864 and 119875119875 using the MITBIH database They are worse thanprevious studies but the difference does not exceed 09 inany of the parameters used in that comparison (119878119864 119875119875 119863119864119877)On the other hand using the NSRDB database the resultshave been better (119878119864 = 9995 119875119875 = 9998 and 119863119864119877 =00006) In comparison with [32] SE and PP have been only001 lower

The QRS detection algorithm was followed by an HRVanalysis In both stages several algorithms had to be opti-mized for the implementation on an MCU Thanks to theefficient use of RAM it has beenpossible to develop thewholeHRV analysis as a standalone application embedded on anMCU ARM

With the execution times shown in Table 5 it has beenshown that theQRSdetector is capable of running in real timefor the most common frequencies used in ECGs Likewise

given that some parameters such as 119868119861119868119898119890119886119899 119878119863119873119873119877119872119878119878119863and 119867119877119898119890119886119899 require very little time for their execution andthat they are in the time domain they could be displayed bysending them via Bluetooth or Wifi to a mobile applicationIn this way an HRV analysis would be done in real time Inaddition the energy consumption is low so it can facilitate itsintegration on portable devices

The time required for the complete analysis of the HRVwill be variable (depending on the amount of data) but it willbe in the order of seconds for practical purposes making it aviable application

Our system could also help in applications like the oneshown in [25] in which HRV and location are measured toevaluate wellness and recommend a place to live accordinglyAll the RR intervals are sent to the userrsquos mobile phone andfrom it to a server in which a time domain parameter of HRVis calculated The system could be improved if the wearabledevice measured itself HRV avoiding the battery consum-ing process of the communication with the mobile phoneBesides our system can calculate all the HRV parametersand could improve the determination of the userrsquos wellnessAnother application of our system could be the integrationinto the system to monitor asthma disease presented in [26]in which the heart rate is also a key component

This system developed on an ARM MCU could be com-plemented by developing a mobile application that displaysthe results of the HRV analysis in a more adequate wayto the user showing comparisons or statistics with respectto previous analyses In this way the user would get bettercontrol over hisher HRV

As future work several lines are devised In the first onethe QRS detector will be improved to obtain better resultsthan those seen in Tables 3 and 4 The second line will bedevoted to the optimization of the proposed system code tointegrate it in the most optimal way into an 119868119900119879 networkIt can be tested using Wifi ZigBee or Bluetooth networksfor short ranges For instance it could receive informationfrom a network edge and then send back to a server onlythe HRV results to be displayed This will help to improve

12 Wireless Communications and Mobile Computing

Table 5 Time required for HRV analysis of the signal 215 (MITBIH database)

Main function Sub functions (ms) Execution time (ms) inMCU

Execution time (ms) inIntel i7 (MatLab)

Detector QRS 47 39DWT perform (37)First difference (lt1)Squared signal (lt3)Filter average (lt3)

Find peaks and update threshold (lt3)Save data to SD 5 -Preprocessing Remove Artifacts 3 1Time DomainHRV 30 9

119868119861119868119898119890119886119899 (lt1)119867119877119898119890119886119899 (1)119878119863119873119873 (lt1)119894119878119863119873119873 (12)119878119863119860119873119873 (11)119877119872119878119878119863 (lt1)

11990111987311987350 11987311987350 (1)119867119877119904119905119889 (1)119872119886119909 (lt1)119872119894119899 (lt1)

Geometrictriangular HRV 89 2

119877119877119879119903119894119899 (17)119879119868119873119873 (62)

Poincare HRV 1 11198781198631 1198781198632 119886119899119889 119864119901119860119903119890119886 (1)

Refresh LCD 50 -FrequencyDomain HRV 4176 163

119868119861119868119904119898119900119900119905ℎ (2084)119905 (lt1)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 (1331)119875119878119863119904119894119892119899119886119897 (302)

119881119871119865 119871119865 119867119865 119871119865119867119865 119871119865119899119900119903119898119886119897119894119911119890119889 and119867119865119899119900119903119898119886119897119894119911119890119889 (458)

mHealth and eHealth services using systems embedded inmicrocontrollers On the other hand we will work to makethe proposed device as small as possible similar to smartband In this way it will be able to track heart rate variabilityduring the daily activity

Data Availability

The data supporting this study are from previously reportedstudies and datasets which have been cited or are includedwithin the article

Conflicts of Interest

The authors declare that they have no conflicts of interest

Acknowledgments

The authors would like to thank the ldquoFondo Social Europeordquothe ldquoDiputacion General de Aragonrdquo (reference groupEduQTech T49 17R) Victor H Rodriguez acknowledges agrant from ldquoCONACYT-Gobierno del Estado de DurangoMexico 330795386043rdquo

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 4: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

4 Wireless Communications and Mobile Computing

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000

2000

4000Raw Signal

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200

0

200Signal level 7 CD7 Energy0011866

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus400minus200

0200400

Signal level 6 CD6 Energy0014883

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus600minus400minus200

0200400

Signal level 5 CD5 Energy0018902

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus400minus200

0200400

Signal level 4 CD4 Energy0017893

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200minus100

0100

Signal level 3 CD3 Energy00078712

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200

0

200Signal level 2 CD2 Energy000064865

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000minus200

0200

Signal level 1 CD Energy66053e-05

Figure 3 Decomposition of the signal into wavelets and their energy levels in percentage

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000

1000

2000

3000

Raw Signal

0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000Samples

Signal ReconstructedSamples

AD

C Va

lues

(RAW

)

minus1000

minus500

0

500

1000

AD

C Va

lues

(RAW

)

Figure 4 Signal reconstructed with 4 levels of detail coefficients (54 6 and 7)

the decomposition of a signal in subbands by means of theuse of a pair of digital filters (low pass and high pass filters)The outputs of the low pass filter are named approximationcoefficients (119862119860119899) while the outputs of the high pass filterare named detail coefficients (119862119863119899) where 119899 represents thelevel of the subband This process of decomposition throughfiltering is repeated 119899 times In each iteration the signalis subsampled by a factor of 2 In practice the DWT isimplemented with the Mallat pyramid algorithm [28] Somestudies have shown that the use of a four order Daubechieswavelet is one of the most effective when processing ECGsignals [29] Afterwards the energy percentage of each levelwas calculated (see (1)-(3) and Figure 3) then the four oneswith more energy were selected to reconstruct the signal(Figure 4) In this way it was assured that the levels withmore information of the ECG signal were selected becausenoise or some interferences such as those of the electricalnetwork or the artifacts are usually found at low energylevels (high frequencies generally between 1198621198631 and 1198621198632)(see Figure 3) Therefore using energy levels to discriminate

the noise of QRS complex was a good option Finally weproceeded to remove the offset of the signal by leaving outthe approximation coefficients (1198621198607) In the present studya db4 mother wavelet with 7 levels of decomposition wasselected The number of levels was selected because the datawere processed in buffers of 1024 and thus the number ofiterations allowed was 7

119864119879119862119863 = 119873sum119895

( 119897sum119894

10038161003816100381610038161003816119862119863119894119895100381610038161003816100381610038162 + 119897sum119894

10038161003816100381610038161003816119862119860119894119895100381610038161003816100381610038162) (1)

119864119862119863119895 = 119897sum119894=1

10038161003816100381610038161003816119862119863119894119895100381610038161003816100381610038162 119895 = 1 2 119873 (2)

119875119862119863119895 = 119864119862119863119895119864119879119862119863 lowast 100 119895 = 1 2 119873 (3)

where 119864119879119862119863 is total energy of all 119862119863 119864119862119863119895 is energyon each 119862119863 119875119862119863119895 is percent of energy on each 119862119863119895 is number of decomposition levels 119894 is number ofcoefficient on each 119862119863 119897 is length of 119862119863 and 119873 ismaximum number of decomposition levels

The next step was to reconstruct the signal (119878119903) using onlythe coefficients of the 4 details with the highest energy (seeFigure 4)Then the first difference was applied (4) and later itwas squared to emphasize theR peaks (5) Finally bymeans ofan average filter the signal was smoothed using a window of02 s (119908119894119899119889119900119908119904119878119894119911119890 samples) (see (6))The size of the averagefilter is an important factor If the 119908119894119899119889119900119908119904119878119894119911119890 is too widethe filter will merge the QRS and T complexes If it is toonarrow the QRS complex will produce several peaks andit can cause difficulties in its detection Generally the sizeshould be approximately as wide as the QRS complex [11]

119878119889 [119899] = 119878119903 [119899] minus 119878119903 [119899 minus 1] (4)

119878119902 [119899] = (119878119889 [119899])2 (5)

119865119889 [119899] = 1119908119894119899119889119900119908119904119878119894119911119890 lowast (119878119902 [119899] + 119878119902 [119899 minus 1] + sdot sdot sdot+ 119878119902 [119899 minus (119908119894119899119889119900119908119904119878119894119911119890 minus 1)])

(6)

Wireless Communications and Mobile Computing 5

Sr signalFd signal

minus100

0

100

200

300

400

500

mill

ivol

ts m

V

times104204 206 208 21 212 214 216202

samples

Figure 5 Input signals to QRS detector (signal 100 from MITBIHdatabase)

(b) QRSDetector StageThe stage of the detector required twoinputs for its operation which are the reconstructed signal119878119903 (containing the ECG signal) and the 119865119889 signal that servesas a basis to find the possible location of the QRS complex(see Figure 5) The signal 119865119889 had to start from the half of119908119894119899119889119900119908119904119878119894119911119890 plus one (see (7)) so that both signals (119878119903 and119865119889) coincided in the location of the peaksThis is because theaverage filter introduced a delay in the signal

119865119889 = 119865119889 [( 1199081198941198991198891199001199081199041198781198941199111198902 ) + 1 119905119900 119890119899119889] (7)

The steps followed by the detector are as follows

(i) To calculate the initial threshold using the 119865119889 signalThe threshold (119879ℎ119904119894119892119899119886119897) was set to 15 of the maxi-mum peak that was located in the first 02 s of the 119865119889signal

(ii) To find a peak (119875119896 119886119898119901119908119886V119890) that exceeded 119879ℎ119904119894119892119899119886119897 inthe119865119889 signal When this occurred the index (119875119870119894119899119889119890119909)of the 119865119889 signal was stored

(iii) The next step was to find an 119877119908119886V119890 in the signal 119878119903using 119875119870119894119899119889119890119909 Then a window of 04 s was selectedaround119875119870119894119899119889119890119909Thewindow size was set 04 s becausethis detector is limited to a range of 40 to 150 BPMwhere 04 s equals 150 BPMThus themaximumpeakwas searched using (8)The peak obtained in this waywas a candidate for an 119877119908119886V119890 To determine if the peakfound was a true 119877119908119886V119890 two criteria were followed(a) For the first 10 peaks the time interval between

the current peak and the previous peak had tobe between 04 s and 15 s

(b) For the rest of peaks (more than 10) an averageof the intervals of all previous peaks was taken

(119898119875119896119905119894119898119890) and if the current interval was greaterthan 60of119898119875119896119905119894119898119890 without being greater than15 s the current peak was considered an 119877119908119886V119890With this we avoided confusing the 119877119908119886V119890 withthe 119875119908119886V119890 or the 119879119908119886V119890 sometimes they tend tohave similar amplitudes

119877119908119886V119890= max peak (119878119903 (119875119896119894119899119889119890119909 minus 02119904 119905119900 119875119896119894119899119889119890119909 + 02119904)) (8)

(iv) Finally the index (119877 119894119889119909119908119886V119890) in which the 119877119908119886V119890 wasfound was multiplied by the sampling period In thisway the time in which it had occurred was obtained(119879119894119898119890 119894119889119909119908119886V119890) and later storedThe amplitude of thepeak of the signal 119865119889 (119875119896 119886119898119901119908119886V119890) will be used in thenext stage (adaptive threshold)

(c) Adaptive Threshold In this stage the 119879ℎ119904119894119892119899119886119897 changed itsvalue according to the following two conditions

(i) If an 119877119908119886V119890 peak was confirmed the amplitude119875119896 119886119898119901119908119886V119890 was used to update the 119879ℎ119904119894119892119899119886119897 using (9)(ii) If after a time greater than 15 s (corresponding to

40 BPM) starting from the last 119877 119894119889119909119908119886V119890 no 119877119908119886V119890was found the 119879ℎ119904119894119892119899119886119897 was stored as 119879ℎ119904119894119892119899119886119897 119879119890119898119901 andthen it was reduced by 10 Then the search fromthe last 119877 119894119889119909119908119886V119890 was restarted This modification of119879ℎ119904119894119892119899119886119897 could be repeated up to 3 times If no 119877119908119886V119890was found afterwards the 119879ℎ119904119894119892119899119886119897 retrieved its valuefrom 119879ℎ119904119894119892119899119886119897 119879119890119898119901 and the algorithm continued withthe search for more peaks without returning to theprevious index With this process we could detect119877119908119886V119890 waves that had a smaller amplitude whichmight not exceed the 119879ℎ119904119894119892119899119886119897 because the previousone had a very large amplitude see Figure 6

119879ℎ119904119894119892119899119886119897 = 015 lowast 119875119896 119886119898119901119908119886V119890 (9)

22 HRV Analysis Table 1 shows the parameters obtainedin the different categories of HRV analysis methods Thefollowing subsections explain each category but we insist onthe nontrivial ones or the details required to reproduce ourresults

221 Preprocessing for HRV Analysis This section is devotedto the set of operations required to eliminate ectopic beatsThey are known to give erroneous measures in the HRVanalysis if they are not eliminated This preprocessing isperformed before the calculation of any of the parametersshown in Table 1 We used the method proposed by [30]following these steps

Step 1 The linear trend of the 119868119861119868 vector was removed using(10) For that purpose the line that best fits 119868119861119868was calculatedby least squares

119868119861119868119897119894119899119890119886119897 119889119890119905119903119890119899119889 = 119868119861119868 minus (119883 lowast 1198621 + 1198622) (10)

where 119883 = 119894119904 119886 119904119897119900119901119890 and 1198621 and 1198622 are the coefficients afterresolving the system by Least-Squares

6 Wireless Communications and Mobile Computing

Table 1 Parameters of the analysis HRV

Domain Description Symbol Unitslowast Biological meanTime Mean between IBI interval 119868119861119868119898119890119886119899 ms

Mean heart rate 119867119877119898119890119886119899 BPMStandard deviation of NN intervals SDNN ms Estimate of overall HRV

Measure the mean of standard deviation ofintervals RR in windows of 5 minutes iSDNN ms

Measure the standard deviation of the meanof the intervals RR in windows of 5 minutes SDANN ms

Root mean squared of successive differences RMSSD ms Short term componentPercentage of intervals that differs more than

50 ms pNN50

Standard deviation of the heart rate 119867119877119904119905119889 BPMMaximum time between IBI interval 119872119886119909 msMinimum time between IBI interval 119872119894119899 ms

Frequency Low frequency power LF 1198981199042 Sympathetic nervousSystem activity

High frequency power HF 1198981199042 parasympathetic nervousSystem activity

Ratio between low and high frequency LFHF Sympathovagal balanceLow frequency normalized LFn nuHigh frequency normalized HFn nu

Non linear Poincare SD1 SD2119878119863119903119886119905119894119900 ms Term variability

Geometric (time domain) Triangular index RRTrin Estimate of overall HRVTriangular Interpolation index TINN

lowast BPM(beats per minute) ms (milliseconds)1198981199042(milliseconds squared) nu (normalized units) (percent)

Sr signalFd signal

Small peak after a big peak

minus200

minus100

0

100

200

300

mill

ivol

ts m

V

204 206 208 21 212 214202samples times104

Figure 6 Portion of the signal 104 of theMITBIH database showinglarge differences in amplitude

Step 2 The standard deviation (119878119879119863119868119861119868) and the mean(119872119899119889119868119861119868) of 119868119861119868119897119894119899119890119886119897 119889119890119905119903119890119899119889 were calculated

Step 3 A threshold (119905119903119904ℎ119904119889) was set in order to find theectopic beats In this case it was equal to three times the119878119879119863119868119861119868

119905119903119904ℎ119904119889 = 3 lowast 119878119879119863119868119861119868 (11)

Step 4 Finally to find an ectopic beat the mean 119872119899119889119868119861119868 wassubtracted from the absolute value of the 119868119861119868[119909]119897119894119899119890119886119897 119889119890119905119903119890119899119889Ectopic beats were those beats in which the result was higherthan 119905119903119904ℎ119904119889 in those cases the sample 119868119861119868[119909] was substitutedby the mean of the five preceding samples and the fivefollowing samples of it

222 Analysis of HRV in the Time Domain After the ectopicbeats were removed the vector 119868119861119868 was transformed fromseconds to milliseconds (119898119868119861119868) and the statistical param-eters shown in Table 1 were calculated which correspondto widely known statistical measurements (means standarddeviations)

223 Analysis of HRV in the Frequency Domain Theanalysisin the frequency domain had three stages (a) preprocessingin this stage the signal went through a series of filters toeliminate its offset (b) interpolation the signal without offsetwas interpolated at 4 Hz (c) spectral analysis the spectraldensity (PSD) was calculated using the Welch method

Wireless Communications and Mobile Computing 7

Preprocessing

Step 1 It began by smoothing the 119868119861119868 vector Some authorshave shown that the smoothness prior filter is usually veryeffective in bioelectric signals like the ECG [37 38] It iseven used in commercial software such as Kubios for HRVanalysis [39] However its algorithm requires many resourcesin RAM memory to be implemented in an MCU Thereforein this paper we opted to do the filtering using waveletsThe filtering with the wavelets was done by eliminatingthe coefficients of the details In this case a wavelet 1198891198875with four decomposition levels was used in which afterhaving eliminated all the 119862119863 coefficients the signal wasreconstructed (119868119861119868119908119886V119890) Finally using (12) the signal wassmoothedThepurpose of this filtering processwas to removeany disturbance in low frequency that affects RR intervals

119868119861119868119904119898119900119900119905ℎ [119909] = (119868119861119868 [119909] minus 119868119861119868119908119886V119890 [119909]) (12)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(119868119861119868)Step 2 Calculate the temporary vector (119905) which will be usedto perform the interpolation The temporary vector is thecumulative sum of the 119868119861119868 vectorminus the first value of itself(13)

119905 = cumulativesum (119868119861I) minus 119868119861119868 [0] (13)

Interpolation The vector 119868119861119868119904119898119900119900119905ℎ was passed to ms(119898119868119861119868119904119898119900119900119905ℎ) Then the interpolation was carried out usingthe cubic spline algorithm at 4 Hz (14) Once 119898119868119861119868119904119898119900119900119905ℎ wasinterpolated the average was subtracted (15)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 = 119904119901119897119894119899119890 (119905 119898119868119861119868119904119898119900119900119905ℎ) (14)

119898119868119861119868119905119900119875119878119863 = 119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890minus 119898119890119886119899 (119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890) (15)

Calculation of the Spectral Density To calculate the PSDwith the Welch method the algorithm implemented usedthe fast Fourier transform (FFT) with a window of 256points (119863119886119905119886119908119894119899119889119900119908) and overlapping of 128 points Beforeapplying the FFT to each window the data were smoothed bymultiplying them by a Hamming function (119867119886119898119898119894119899119892119908119894119899119889119900119908)of the same width as 119863119886119905119886119908119894119899119889119900119908 In this way we avoidedabrupt discontinuities at the beginning and end of eachwindow

Obtaining the Parameters in the Frequency Domain Aftercomputing the PSD (119875119878119863119904119894119892119899119886119897) of the 119898119868119861119868119905119900119875119878119863 signalthe area under the curve was calculated for each band offrequencies associated with the HRV the 119881119871119865 band (0 to 004Hz) the 119871119865 band (004 to 015 Hz) and the 119867119865 band (015 to04 Hz) Once the areas for each band were calculated the119871119865119867119865 ratio was calculated by dividing the total area of 119871119865

650 700 750 800 850 900 950650

700

750

800

850

900

950

RRN (ms)

RRN+1(m

s) EpArea

SD1

SD2

Figure 7 Representation of the Poincare analysis

by the total area of 119867119865 (16)The normalized 119871119865 and 119867119865 werecalculated with (17) and (18)

119871119865119867119865 = 119871119865119867119865 (16)

119871119865119899119900119903119898119886119897119894119911119890119889 = 119871119865119871119865 + 119867119865 (17)

119867119865119899119900119903119898119886119897119894119911119890119889 = 119867119865119871119865 + 119867119865 (18)

224 Poincare Analysis The Poincare analysis is a graphicalmethod that evaluates the dynamics of the HRV from thecurrent (119877119877119873) and the next (119877119877119873+1) RR intervals

119877119877119873 = (119898119868119861119868 [0] 119898119868119861119868 [1] 119898119868119861119868 [119873 minus 1]) (19)

119877119877119873+1 = (119898119868119861119868 [1] 119898119868119861119868 [2] 119898119868119861119868 [119873]) (20)

where 119873 = 119897119890119899119892119905ℎ(119898119868119861119868)To perform a quantitative analysis and evaluate the HRV

an ellipse was fit to the data (see Figure 7) The width of theellipse is known as the standard deviation 1 (1198781198631) and thelength as the standard deviation 2 (1198781198632) From 1198781198631 and 1198781198632the area of the ellipse was calculated (119864119901119860119903119890119886) [6] It is saidthat 1198781198631 represents the HRV in short times (short term) andis correlated with the SNA while 1198781198632 represent long periods(long term) and is correlated with SNS [40] Due to thecorrelation between the standard deviation of the RR intervaldifference (119889119868119861119868) (see (21)) and 1198781198631 1198781198631 was calculated using(22)-(24) From the 119878119863119873119873 parameter and SD119889119868119861119868 (see (23))1198781198632 was calculated with (25) the area 119864119901119860119903119890119886 with (26) andfinally the ratio 119878119863119903119886119905119894119900 with (27) [41]

The Poincare plot represents the healthy case by a largeellipse area and small for critical diseases To perform theanalysis of Poincare periods between 5 to 20 minutes arerecommended [6] On the other hand [42 43] observed thata lowest 119878119863119903119886119905119894119900 value is present in healthy subjects In thesame way a small value in 1198781198631 for diseased subjects indicatesweakening of parasympathetic regulation by health disorder

8 Wireless Communications and Mobile Computing

As 1198781198632 decreases the SNS activity increases Figure 7 showsan arrhythmia case from the signal 215 (MITBIH) in which itcan observed that the most of the samples are focused in thecenter of the plot and represent a small ellipse area

119889119868119861119868 [119909] = 119898119868119861119868 [119909 + 1] minus 119898119868119861119868 [119909] (21)

119889119868119861119868119898119890119886119899 = sum119873119909=0 (119889119868119861119868 [119909])119873 (22)

SD119889119868119861119868 = radic sum119873119909=0 1003816100381610038161003816119889119868119861119868 [119909] minus 11988911986811986111986811989811989011988611989910038161003816100381610038162119873 (23)

1198781198631 = radic05 lowast SD1198891198681198611198682 (24)

1198781198632 = radic(2 lowast 1198781198631198731198732) minus (05 lowast SD1198891198681198611198682) (25)

119864119901119860119903119890119886 = 120587 lowast 1198781198631 lowast 1198781198632 (26)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(d119868119861119868)119878119863119903119886119905119894119900 = 11987811986311198781198632 (27)

225 Triangular Geometric Analysis Triangular geometricanalysis is usually considered as part of the analysis in thetime domain However it deserves further explanation sinceit is more complex than the rest This analysis is doneby calculating the histogram of the vector 119898119868119861119868 throughwhich two parameters can be calculated the triangular index(119877119877119879119903119894119899) and the index of triangular interpolation of the baseof the histogram (119879119868119873119873) The 119877119877119879119903119894119899 is equal to the totalnumber of RR intervals divided by the maximum value of thehistogram (119881119886119897119898119886119909) (28) This index gives an overall estimateof the HRV The width of the bins used in this analysiswas set to 78125 ms The 119879119868119873119873 index gives a value on thedistribution of the density of all the RR intervals as the baseof a triangle and it is usually calculated by means of a leastsquares estimateThus119860119903119890119886119905119894119899119899 (see (29)) was minimized andthe limiting points N and M were found Then 119879119868119873119873 wascalculated with (30) see Figure 8 [44]

119877119877119879119903119894119899 = 119873119881119886119897119898119886119909 (28)

119860119903119890119886119905119894119899119899 = intinfin0

(119863 (119905) minus 119902 (119905))2 119889119905 (29)

where 119863 is histogram output 119902 defines the base of triangle thatfits histogram and its cero for 119905 le 119873 119905 ge 119872 and 119902(119883) = 119884

119879119868119873119873 = 119872 minus 119873 (30)

where 119872 and 119873 are the limits of 11986011990311989011988611990511989411989911989923 Parameters and Databases Used to Evaluate the Perfor-mance of QRSDetector In order to compare the performanceof the QRS detector with those found in the literature weused the sensitivity parameter (119878119864) (see (31)) the positive

600 650 700 750 800 850 900 950 1000Time in ms

0

50

100

150

200

250

600 650 700 750 800 850 900 950 1000Time in (ms)

0

50

100

150

200

250

Y

N X M

Figure 8 Points of the histogram used to calculate the indexes ofthe triangular geometric analysis

predictive value (119875119875) (see (32)) and the percentage of theprediction error rate (119863119864119877) (see (33)) 119863119864119877 was also used toevaluate the accuracy of the algorithm

119878119864 = 119879119875119879119875 + 119865119873 lowast 100 (31)

119875119875 = 119879119875119879119875 + 119865119875 lowast 100 (32)

119863119864119877 = 119865119875 + 119865119873119879119875 lowast 100 (33)

where119879119875 are the true positives in detecting the 119877119908119886V119890 119865119873 arethe 119877119908119886V119890 peaks that have not been detected and 119865119875 are thepeaks that have been mistakenly detected as 119877119908119886V119890

In order to validate and compare our proposed algo-rithm for QRS complex detection the MIT-BIT arrhythmiadatabase (MITBIH) and the normal sinus rhythm database(NSRDB) both available online were used [45] Then theresults obtained were compared with other algorithms tosee their effectiveness The MITBIH database consists of 48recordings Each recording has two signals extracted fromhalf hour of a 24-hour recording which have been sampledat 360 Hz and belong to 47 patients in total The NSRDBdatabase contains 18 signals with a duration of 130 minutessampled at 128 Hz and belong to healthy adults aged 20 to 50years

24 Implementation on an MCU The MCU used for theimplementation of the QRS detector and the HRV analysiswas an STM32F407ZET6 MCU Two features can be high-lighted for the present study it has a set of instructions fordigital signal processing (DSP) and a floating point process-ing unit (FPU) whichmake it anMCUcapable of performingadvanced digital processing calculations Likewise it has aflash program memory of 512 Kbyte 192 Kbyte of SRAMmemory and a working frequency of 168 MHz

TheDSP libraries provided by CMSIS (Cortex Microcon-troller Software Interface Standard) were used for the signal

Wireless Communications and Mobile Computing 9

Figure 9 Analysis of the HRV in real time

Figure 10 Analysis of the HRV in frequency domain

processing and the open source wavelib library [46] was usedfor the wavelet implementation The wavelib library had tobe modified and optimized in terms of RAM resources to beused in an MCU

The MCU accessed the MITBIH and NSRDB databasesthrough a microSD card memory in which each recordingwas stored in a separate text data file They were processed inreal time in blocks of 1024 data The block size was chosen fortwo reasons the first one because this number of samples isenough to apply theDWTwith 7 levels of decomposition andthe second because the amount of RAM required is constant(25 kB) and did not compromise the rest of calculationsIt is worth explaining that for an application in real lifethe MCU could acquire data in real time from two externalsources selecting only one at a time The first one wouldinvolve a serial port through the HC-05 Bluetooth moduleat a baud rate of 230400 The second one could use theAD8232 module using the digital analog converter (ADC)with a sampling frequency of 500Hz In both cases interruptscould be used being activated whenever there is a new dataavailable Thus even while the signal is being processed theMCU can continue to fill new buffers for further processingTo display the data locally two LCD screens SSD1306 of128x64 pixels were incorporated using the I2C protocol Anexample of the information displayed on LCD are show inthe Figures 9 and 10 Figure 9 shows the data displayed inreal time while Figure 10 shows the analysis in the frequencydomain for the signal 215 (MITBIH database)

To reduceRAMconsumptionwhenprocessing the signalthe following programming techniques were applied

(i) Avoiding the creations of arrays or matrices withinfunctions it is better to use loops and perform thecorresponding calculations in each iteration

typedef union unsigned uint8 t AllFlags

struct unsigned flag 01

unsigned flag 11

unsigned flag 21

unsigned flag 31

unsigned flag 41

unsigned flag 51

unsigned flag 61

unsigned flag 71 DeviceStatusFlags

DeviceStatusFlags Flags

Used Bytes in RAM 1

uint8 t flag 0

uint8 t flag 1

uint8 t flag 2

uint8 t flag 3

uint8 t flag 4

uint8 t flag 5

uint8 t flag 6

uint8 t flag 7

Used Bytes in RAM 8

Code 1 Efficient use of RAMmemory using structures and unions

(ii) If possible using the input variables as output vari-ables in functions so that new variables are notneeded

(iii) Making use of structures and unions to pack data andtake control of system flags in this way the amount ofRAM required is fully utilized For example in Code 1you can see that less RAM is required using structuresand unions for the same number of flags

For example in Code 2 it is assumed that the inputvariable 119910 has a size of 2000 data In Matlab 64047 bytesis required to perform the same calculation (remove lineartrend) since it does so bymeans of arrays while the algorithmof Code 2 occupied only 48 bytes in the MCU (12 119891119897119900119886119905variables and an 119894119899119905 variable that require 4 bytes each one)since the result was stored in the same input variable

The algorithms optimized following the ideas shown inCode 2 were the average filter the peak detection and thethreshold updating in the QRS detector the calculation of119894119878119863119873119873 and 119878119863119860119873119873 the application of DWT (see (10)) thelinear trend removal (see (12)) and the calculation of the PSD(see (15))

3 Results

The results of Table 2 correspond to the performance of theQRS detector when evaluated with the MITBIH database119863119861 is the number of detected beats and 119879119861 is the totalnumber of beats in each ECG signal It can be observed that109086 pulses of a total of 109494 have been detected 108713

10 Wireless Communications and Mobile Computing

void arm lineal detrend f32 (float 32 t lowast y int size) float 32 t abcdefx1x2C1C2determinant

int i

a=0b=0c=0d=0e=0f=0

x2=1

determinant=0

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size create a slope

a=a+(x1 lowast x1)

b=b+x1

c=c+x1

d=d+x2

e=e+(x1 lowast y [ i ] )f=f+(x2 lowast y [ i ] )

determinant = a lowast d - b lowast c

if ( isnan (determinant) | | isinf(determinant)) return else

C1 = (e lowast d - b lowast f)determinant resolve the System

C2 = (a lowast f - e lowast c)determinant to find the coefficients C1 and C2

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size

y [ i ] =y [ i ] -(x1 lowast C1+C2) remove lineal trendCode 2 C-code to eliminate the linear trend

Table 2 Parameters used to evaluate the QRS detector

Record No TB DB TP FP FN SE PP DERTotal 109494 109086 108713 373 781 9930 9961 112

were true positives 781 were false negative and 373 werefalse positives In addition the QRS detector showed a 119878119864 of9930with a positive prediction of 9961 and an error ratein the detection of pulses of 112

Table 3 shows the results obtained between the differentalgorithms found in the literature and ours using the MIT-BIH database The results we have obtained are a little worseHowever the difference between the algorithm with better 119878119864[34] and ours is only 057 In119875119875 the difference with respectto [35] is 030 and in119863119864119877 the differencewith respect to [36]is only 084

Table 4 shows the comparison between the resultsobtained by our algorithm and those obtained by [32] usingthe 119873119878119877119863119861 database In this comparison [32] has betterresults than us in 119878119864 and 119875119875 by 001 while 119863119864119877 is only00002 better

The time required by the MCU for the HRV analysis willvary according to the size of the IBI vector Table 5 shows theexecution times that were required to analyze the signal 215 oftheMITBIH databaseThis particular file was chosen becauseit contains more QRS complex than the rest of the signals(3358 found by our algorithm)

On the other hand the execution times for the QRSdetector will always be the same (47ms for detection and 5msfor saving in a microSD the temporary location of the 119877119908119886V119890found) because the length of the input vector has a constantsize (1024 samples)

The time required to fill the 1024 data buffer is 1024 lowast(1119891119904) where 119891119904 is the sampling frequency In the case ofthe MITBIH 119891119904 is 360 Hz so it would take 284 s to fill itIn the case of the NSRDB 119891119904 is 128 Hz so that it would take8 s In both cases the detection of the QRS complex can bedone in real time since it only takes 52 ms The detector mayoperate in real time up to a maximum sampling frequencyof 195 kHz However some studies show that 500 Hz is avery reliable frequency forHRV analysis [47] Our system caneasily achieve real time for this recommended frequency

Although the times required for the analysis of the HRVvary depending on the size of 119868119861119868 inTable 5 it can be seen thatthe smoothing of the signal using wavelets and the analysis inthe frequency domain required more time for its executionOn the other side the Poincare analysis was the fastest Thetime required for the complete HRV analysis of signal 215(MITBIH database) was 4401 s

Wireless Communications and Mobile Computing 11

Table 3 Comparison of the results obtained using different algorithm in the MITBIH database

DB TP FP FN SE PP DERJP Martınez et al [31] 109428 109208 153 220 9980 9986 034J Pan amp Tompkins [11] 109809 109532 507 277 9975 9954 071Gutierrez-Rivas et al [32] - 109447 289 502 9954 9973 -Chouakri et al [33] 109488 108043 3068 1446 9868 9724 412Santanu et al [34] 109666 109351 315 144 9987 9969 042Moody amp Mark [35] 109428 107567 94 1861 9830 9991 179Merah et al[36] 109494 109316 126 178 9984 9988 028Proposed algorithm 109086 108713 373 781 9930 9961 112

Table 4 Comparison of the results using the NSRDB database

Algorithm TB TP FP FN SE PP DERGutierrez-Rivas et al [32] 192389 192325 64 17 9996 9999 00004Proposed algorithm 192389 192297 92 25 9995 9998 00006

Refreshing the LCD screens took 50 ms and it was donewhile the buffer was filling so that the update times of thescreens had no influence on the calculations of the HRV

The execution time on a regular PC with the processingperformed inMatlab is also shown in Table 5 for comparisonIt is lower than in the MCU implementation because of thepowerful processor The idea is not to be competitive witha PC server in this aspect but to avoid transmitting data toa server in the cloud which would be a great burden forthe network In addition this would imply a higher powerconsumption for the sensor node For instance the proposedsystem has these power consumption contributions 42 mAfor the MCU in sleep mode 49 mA while processing asignal from a micro SD card 75 mA while processing signalsfrom AD8232 or 169 mA while processing signals fromBluetooth (HC-05 module) Thus it is clear that avoidingcommunication is of great interest

4 Conclusions and Future Work

The results obtained with the QRS detector that we haveproposed based on wavelets and with automatic selection ofthe coefficients of the details have been higher than 99 in119878119864 and 119875119875 using the MITBIH database They are worse thanprevious studies but the difference does not exceed 09 inany of the parameters used in that comparison (119878119864 119875119875 119863119864119877)On the other hand using the NSRDB database the resultshave been better (119878119864 = 9995 119875119875 = 9998 and 119863119864119877 =00006) In comparison with [32] SE and PP have been only001 lower

The QRS detection algorithm was followed by an HRVanalysis In both stages several algorithms had to be opti-mized for the implementation on an MCU Thanks to theefficient use of RAM it has beenpossible to develop thewholeHRV analysis as a standalone application embedded on anMCU ARM

With the execution times shown in Table 5 it has beenshown that theQRSdetector is capable of running in real timefor the most common frequencies used in ECGs Likewise

given that some parameters such as 119868119861119868119898119890119886119899 119878119863119873119873119877119872119878119878119863and 119867119877119898119890119886119899 require very little time for their execution andthat they are in the time domain they could be displayed bysending them via Bluetooth or Wifi to a mobile applicationIn this way an HRV analysis would be done in real time Inaddition the energy consumption is low so it can facilitate itsintegration on portable devices

The time required for the complete analysis of the HRVwill be variable (depending on the amount of data) but it willbe in the order of seconds for practical purposes making it aviable application

Our system could also help in applications like the oneshown in [25] in which HRV and location are measured toevaluate wellness and recommend a place to live accordinglyAll the RR intervals are sent to the userrsquos mobile phone andfrom it to a server in which a time domain parameter of HRVis calculated The system could be improved if the wearabledevice measured itself HRV avoiding the battery consum-ing process of the communication with the mobile phoneBesides our system can calculate all the HRV parametersand could improve the determination of the userrsquos wellnessAnother application of our system could be the integrationinto the system to monitor asthma disease presented in [26]in which the heart rate is also a key component

This system developed on an ARM MCU could be com-plemented by developing a mobile application that displaysthe results of the HRV analysis in a more adequate wayto the user showing comparisons or statistics with respectto previous analyses In this way the user would get bettercontrol over hisher HRV

As future work several lines are devised In the first onethe QRS detector will be improved to obtain better resultsthan those seen in Tables 3 and 4 The second line will bedevoted to the optimization of the proposed system code tointegrate it in the most optimal way into an 119868119900119879 networkIt can be tested using Wifi ZigBee or Bluetooth networksfor short ranges For instance it could receive informationfrom a network edge and then send back to a server onlythe HRV results to be displayed This will help to improve

12 Wireless Communications and Mobile Computing

Table 5 Time required for HRV analysis of the signal 215 (MITBIH database)

Main function Sub functions (ms) Execution time (ms) inMCU

Execution time (ms) inIntel i7 (MatLab)

Detector QRS 47 39DWT perform (37)First difference (lt1)Squared signal (lt3)Filter average (lt3)

Find peaks and update threshold (lt3)Save data to SD 5 -Preprocessing Remove Artifacts 3 1Time DomainHRV 30 9

119868119861119868119898119890119886119899 (lt1)119867119877119898119890119886119899 (1)119878119863119873119873 (lt1)119894119878119863119873119873 (12)119878119863119860119873119873 (11)119877119872119878119878119863 (lt1)

11990111987311987350 11987311987350 (1)119867119877119904119905119889 (1)119872119886119909 (lt1)119872119894119899 (lt1)

Geometrictriangular HRV 89 2

119877119877119879119903119894119899 (17)119879119868119873119873 (62)

Poincare HRV 1 11198781198631 1198781198632 119886119899119889 119864119901119860119903119890119886 (1)

Refresh LCD 50 -FrequencyDomain HRV 4176 163

119868119861119868119904119898119900119900119905ℎ (2084)119905 (lt1)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 (1331)119875119878119863119904119894119892119899119886119897 (302)

119881119871119865 119871119865 119867119865 119871119865119867119865 119871119865119899119900119903119898119886119897119894119911119890119889 and119867119865119899119900119903119898119886119897119894119911119890119889 (458)

mHealth and eHealth services using systems embedded inmicrocontrollers On the other hand we will work to makethe proposed device as small as possible similar to smartband In this way it will be able to track heart rate variabilityduring the daily activity

Data Availability

The data supporting this study are from previously reportedstudies and datasets which have been cited or are includedwithin the article

Conflicts of Interest

The authors declare that they have no conflicts of interest

Acknowledgments

The authors would like to thank the ldquoFondo Social Europeordquothe ldquoDiputacion General de Aragonrdquo (reference groupEduQTech T49 17R) Victor H Rodriguez acknowledges agrant from ldquoCONACYT-Gobierno del Estado de DurangoMexico 330795386043rdquo

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 5: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

Wireless Communications and Mobile Computing 5

Sr signalFd signal

minus100

0

100

200

300

400

500

mill

ivol

ts m

V

times104204 206 208 21 212 214 216202

samples

Figure 5 Input signals to QRS detector (signal 100 from MITBIHdatabase)

(b) QRSDetector StageThe stage of the detector required twoinputs for its operation which are the reconstructed signal119878119903 (containing the ECG signal) and the 119865119889 signal that servesas a basis to find the possible location of the QRS complex(see Figure 5) The signal 119865119889 had to start from the half of119908119894119899119889119900119908119904119878119894119911119890 plus one (see (7)) so that both signals (119878119903 and119865119889) coincided in the location of the peaksThis is because theaverage filter introduced a delay in the signal

119865119889 = 119865119889 [( 1199081198941198991198891199001199081199041198781198941199111198902 ) + 1 119905119900 119890119899119889] (7)

The steps followed by the detector are as follows

(i) To calculate the initial threshold using the 119865119889 signalThe threshold (119879ℎ119904119894119892119899119886119897) was set to 15 of the maxi-mum peak that was located in the first 02 s of the 119865119889signal

(ii) To find a peak (119875119896 119886119898119901119908119886V119890) that exceeded 119879ℎ119904119894119892119899119886119897 inthe119865119889 signal When this occurred the index (119875119870119894119899119889119890119909)of the 119865119889 signal was stored

(iii) The next step was to find an 119877119908119886V119890 in the signal 119878119903using 119875119870119894119899119889119890119909 Then a window of 04 s was selectedaround119875119870119894119899119889119890119909Thewindow size was set 04 s becausethis detector is limited to a range of 40 to 150 BPMwhere 04 s equals 150 BPMThus themaximumpeakwas searched using (8)The peak obtained in this waywas a candidate for an 119877119908119886V119890 To determine if the peakfound was a true 119877119908119886V119890 two criteria were followed(a) For the first 10 peaks the time interval between

the current peak and the previous peak had tobe between 04 s and 15 s

(b) For the rest of peaks (more than 10) an averageof the intervals of all previous peaks was taken

(119898119875119896119905119894119898119890) and if the current interval was greaterthan 60of119898119875119896119905119894119898119890 without being greater than15 s the current peak was considered an 119877119908119886V119890With this we avoided confusing the 119877119908119886V119890 withthe 119875119908119886V119890 or the 119879119908119886V119890 sometimes they tend tohave similar amplitudes

119877119908119886V119890= max peak (119878119903 (119875119896119894119899119889119890119909 minus 02119904 119905119900 119875119896119894119899119889119890119909 + 02119904)) (8)

(iv) Finally the index (119877 119894119889119909119908119886V119890) in which the 119877119908119886V119890 wasfound was multiplied by the sampling period In thisway the time in which it had occurred was obtained(119879119894119898119890 119894119889119909119908119886V119890) and later storedThe amplitude of thepeak of the signal 119865119889 (119875119896 119886119898119901119908119886V119890) will be used in thenext stage (adaptive threshold)

(c) Adaptive Threshold In this stage the 119879ℎ119904119894119892119899119886119897 changed itsvalue according to the following two conditions

(i) If an 119877119908119886V119890 peak was confirmed the amplitude119875119896 119886119898119901119908119886V119890 was used to update the 119879ℎ119904119894119892119899119886119897 using (9)(ii) If after a time greater than 15 s (corresponding to

40 BPM) starting from the last 119877 119894119889119909119908119886V119890 no 119877119908119886V119890was found the 119879ℎ119904119894119892119899119886119897 was stored as 119879ℎ119904119894119892119899119886119897 119879119890119898119901 andthen it was reduced by 10 Then the search fromthe last 119877 119894119889119909119908119886V119890 was restarted This modification of119879ℎ119904119894119892119899119886119897 could be repeated up to 3 times If no 119877119908119886V119890was found afterwards the 119879ℎ119904119894119892119899119886119897 retrieved its valuefrom 119879ℎ119904119894119892119899119886119897 119879119890119898119901 and the algorithm continued withthe search for more peaks without returning to theprevious index With this process we could detect119877119908119886V119890 waves that had a smaller amplitude whichmight not exceed the 119879ℎ119904119894119892119899119886119897 because the previousone had a very large amplitude see Figure 6

119879ℎ119904119894119892119899119886119897 = 015 lowast 119875119896 119886119898119901119908119886V119890 (9)

22 HRV Analysis Table 1 shows the parameters obtainedin the different categories of HRV analysis methods Thefollowing subsections explain each category but we insist onthe nontrivial ones or the details required to reproduce ourresults

221 Preprocessing for HRV Analysis This section is devotedto the set of operations required to eliminate ectopic beatsThey are known to give erroneous measures in the HRVanalysis if they are not eliminated This preprocessing isperformed before the calculation of any of the parametersshown in Table 1 We used the method proposed by [30]following these steps

Step 1 The linear trend of the 119868119861119868 vector was removed using(10) For that purpose the line that best fits 119868119861119868was calculatedby least squares

119868119861119868119897119894119899119890119886119897 119889119890119905119903119890119899119889 = 119868119861119868 minus (119883 lowast 1198621 + 1198622) (10)

where 119883 = 119894119904 119886 119904119897119900119901119890 and 1198621 and 1198622 are the coefficients afterresolving the system by Least-Squares

6 Wireless Communications and Mobile Computing

Table 1 Parameters of the analysis HRV

Domain Description Symbol Unitslowast Biological meanTime Mean between IBI interval 119868119861119868119898119890119886119899 ms

Mean heart rate 119867119877119898119890119886119899 BPMStandard deviation of NN intervals SDNN ms Estimate of overall HRV

Measure the mean of standard deviation ofintervals RR in windows of 5 minutes iSDNN ms

Measure the standard deviation of the meanof the intervals RR in windows of 5 minutes SDANN ms

Root mean squared of successive differences RMSSD ms Short term componentPercentage of intervals that differs more than

50 ms pNN50

Standard deviation of the heart rate 119867119877119904119905119889 BPMMaximum time between IBI interval 119872119886119909 msMinimum time between IBI interval 119872119894119899 ms

Frequency Low frequency power LF 1198981199042 Sympathetic nervousSystem activity

High frequency power HF 1198981199042 parasympathetic nervousSystem activity

Ratio between low and high frequency LFHF Sympathovagal balanceLow frequency normalized LFn nuHigh frequency normalized HFn nu

Non linear Poincare SD1 SD2119878119863119903119886119905119894119900 ms Term variability

Geometric (time domain) Triangular index RRTrin Estimate of overall HRVTriangular Interpolation index TINN

lowast BPM(beats per minute) ms (milliseconds)1198981199042(milliseconds squared) nu (normalized units) (percent)

Sr signalFd signal

Small peak after a big peak

minus200

minus100

0

100

200

300

mill

ivol

ts m

V

204 206 208 21 212 214202samples times104

Figure 6 Portion of the signal 104 of theMITBIH database showinglarge differences in amplitude

Step 2 The standard deviation (119878119879119863119868119861119868) and the mean(119872119899119889119868119861119868) of 119868119861119868119897119894119899119890119886119897 119889119890119905119903119890119899119889 were calculated

Step 3 A threshold (119905119903119904ℎ119904119889) was set in order to find theectopic beats In this case it was equal to three times the119878119879119863119868119861119868

119905119903119904ℎ119904119889 = 3 lowast 119878119879119863119868119861119868 (11)

Step 4 Finally to find an ectopic beat the mean 119872119899119889119868119861119868 wassubtracted from the absolute value of the 119868119861119868[119909]119897119894119899119890119886119897 119889119890119905119903119890119899119889Ectopic beats were those beats in which the result was higherthan 119905119903119904ℎ119904119889 in those cases the sample 119868119861119868[119909] was substitutedby the mean of the five preceding samples and the fivefollowing samples of it

222 Analysis of HRV in the Time Domain After the ectopicbeats were removed the vector 119868119861119868 was transformed fromseconds to milliseconds (119898119868119861119868) and the statistical param-eters shown in Table 1 were calculated which correspondto widely known statistical measurements (means standarddeviations)

223 Analysis of HRV in the Frequency Domain Theanalysisin the frequency domain had three stages (a) preprocessingin this stage the signal went through a series of filters toeliminate its offset (b) interpolation the signal without offsetwas interpolated at 4 Hz (c) spectral analysis the spectraldensity (PSD) was calculated using the Welch method

Wireless Communications and Mobile Computing 7

Preprocessing

Step 1 It began by smoothing the 119868119861119868 vector Some authorshave shown that the smoothness prior filter is usually veryeffective in bioelectric signals like the ECG [37 38] It iseven used in commercial software such as Kubios for HRVanalysis [39] However its algorithm requires many resourcesin RAM memory to be implemented in an MCU Thereforein this paper we opted to do the filtering using waveletsThe filtering with the wavelets was done by eliminatingthe coefficients of the details In this case a wavelet 1198891198875with four decomposition levels was used in which afterhaving eliminated all the 119862119863 coefficients the signal wasreconstructed (119868119861119868119908119886V119890) Finally using (12) the signal wassmoothedThepurpose of this filtering processwas to removeany disturbance in low frequency that affects RR intervals

119868119861119868119904119898119900119900119905ℎ [119909] = (119868119861119868 [119909] minus 119868119861119868119908119886V119890 [119909]) (12)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(119868119861119868)Step 2 Calculate the temporary vector (119905) which will be usedto perform the interpolation The temporary vector is thecumulative sum of the 119868119861119868 vectorminus the first value of itself(13)

119905 = cumulativesum (119868119861I) minus 119868119861119868 [0] (13)

Interpolation The vector 119868119861119868119904119898119900119900119905ℎ was passed to ms(119898119868119861119868119904119898119900119900119905ℎ) Then the interpolation was carried out usingthe cubic spline algorithm at 4 Hz (14) Once 119898119868119861119868119904119898119900119900119905ℎ wasinterpolated the average was subtracted (15)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 = 119904119901119897119894119899119890 (119905 119898119868119861119868119904119898119900119900119905ℎ) (14)

119898119868119861119868119905119900119875119878119863 = 119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890minus 119898119890119886119899 (119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890) (15)

Calculation of the Spectral Density To calculate the PSDwith the Welch method the algorithm implemented usedthe fast Fourier transform (FFT) with a window of 256points (119863119886119905119886119908119894119899119889119900119908) and overlapping of 128 points Beforeapplying the FFT to each window the data were smoothed bymultiplying them by a Hamming function (119867119886119898119898119894119899119892119908119894119899119889119900119908)of the same width as 119863119886119905119886119908119894119899119889119900119908 In this way we avoidedabrupt discontinuities at the beginning and end of eachwindow

Obtaining the Parameters in the Frequency Domain Aftercomputing the PSD (119875119878119863119904119894119892119899119886119897) of the 119898119868119861119868119905119900119875119878119863 signalthe area under the curve was calculated for each band offrequencies associated with the HRV the 119881119871119865 band (0 to 004Hz) the 119871119865 band (004 to 015 Hz) and the 119867119865 band (015 to04 Hz) Once the areas for each band were calculated the119871119865119867119865 ratio was calculated by dividing the total area of 119871119865

650 700 750 800 850 900 950650

700

750

800

850

900

950

RRN (ms)

RRN+1(m

s) EpArea

SD1

SD2

Figure 7 Representation of the Poincare analysis

by the total area of 119867119865 (16)The normalized 119871119865 and 119867119865 werecalculated with (17) and (18)

119871119865119867119865 = 119871119865119867119865 (16)

119871119865119899119900119903119898119886119897119894119911119890119889 = 119871119865119871119865 + 119867119865 (17)

119867119865119899119900119903119898119886119897119894119911119890119889 = 119867119865119871119865 + 119867119865 (18)

224 Poincare Analysis The Poincare analysis is a graphicalmethod that evaluates the dynamics of the HRV from thecurrent (119877119877119873) and the next (119877119877119873+1) RR intervals

119877119877119873 = (119898119868119861119868 [0] 119898119868119861119868 [1] 119898119868119861119868 [119873 minus 1]) (19)

119877119877119873+1 = (119898119868119861119868 [1] 119898119868119861119868 [2] 119898119868119861119868 [119873]) (20)

where 119873 = 119897119890119899119892119905ℎ(119898119868119861119868)To perform a quantitative analysis and evaluate the HRV

an ellipse was fit to the data (see Figure 7) The width of theellipse is known as the standard deviation 1 (1198781198631) and thelength as the standard deviation 2 (1198781198632) From 1198781198631 and 1198781198632the area of the ellipse was calculated (119864119901119860119903119890119886) [6] It is saidthat 1198781198631 represents the HRV in short times (short term) andis correlated with the SNA while 1198781198632 represent long periods(long term) and is correlated with SNS [40] Due to thecorrelation between the standard deviation of the RR intervaldifference (119889119868119861119868) (see (21)) and 1198781198631 1198781198631 was calculated using(22)-(24) From the 119878119863119873119873 parameter and SD119889119868119861119868 (see (23))1198781198632 was calculated with (25) the area 119864119901119860119903119890119886 with (26) andfinally the ratio 119878119863119903119886119905119894119900 with (27) [41]

The Poincare plot represents the healthy case by a largeellipse area and small for critical diseases To perform theanalysis of Poincare periods between 5 to 20 minutes arerecommended [6] On the other hand [42 43] observed thata lowest 119878119863119903119886119905119894119900 value is present in healthy subjects In thesame way a small value in 1198781198631 for diseased subjects indicatesweakening of parasympathetic regulation by health disorder

8 Wireless Communications and Mobile Computing

As 1198781198632 decreases the SNS activity increases Figure 7 showsan arrhythmia case from the signal 215 (MITBIH) in which itcan observed that the most of the samples are focused in thecenter of the plot and represent a small ellipse area

119889119868119861119868 [119909] = 119898119868119861119868 [119909 + 1] minus 119898119868119861119868 [119909] (21)

119889119868119861119868119898119890119886119899 = sum119873119909=0 (119889119868119861119868 [119909])119873 (22)

SD119889119868119861119868 = radic sum119873119909=0 1003816100381610038161003816119889119868119861119868 [119909] minus 11988911986811986111986811989811989011988611989910038161003816100381610038162119873 (23)

1198781198631 = radic05 lowast SD1198891198681198611198682 (24)

1198781198632 = radic(2 lowast 1198781198631198731198732) minus (05 lowast SD1198891198681198611198682) (25)

119864119901119860119903119890119886 = 120587 lowast 1198781198631 lowast 1198781198632 (26)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(d119868119861119868)119878119863119903119886119905119894119900 = 11987811986311198781198632 (27)

225 Triangular Geometric Analysis Triangular geometricanalysis is usually considered as part of the analysis in thetime domain However it deserves further explanation sinceit is more complex than the rest This analysis is doneby calculating the histogram of the vector 119898119868119861119868 throughwhich two parameters can be calculated the triangular index(119877119877119879119903119894119899) and the index of triangular interpolation of the baseof the histogram (119879119868119873119873) The 119877119877119879119903119894119899 is equal to the totalnumber of RR intervals divided by the maximum value of thehistogram (119881119886119897119898119886119909) (28) This index gives an overall estimateof the HRV The width of the bins used in this analysiswas set to 78125 ms The 119879119868119873119873 index gives a value on thedistribution of the density of all the RR intervals as the baseof a triangle and it is usually calculated by means of a leastsquares estimateThus119860119903119890119886119905119894119899119899 (see (29)) was minimized andthe limiting points N and M were found Then 119879119868119873119873 wascalculated with (30) see Figure 8 [44]

119877119877119879119903119894119899 = 119873119881119886119897119898119886119909 (28)

119860119903119890119886119905119894119899119899 = intinfin0

(119863 (119905) minus 119902 (119905))2 119889119905 (29)

where 119863 is histogram output 119902 defines the base of triangle thatfits histogram and its cero for 119905 le 119873 119905 ge 119872 and 119902(119883) = 119884

119879119868119873119873 = 119872 minus 119873 (30)

where 119872 and 119873 are the limits of 11986011990311989011988611990511989411989911989923 Parameters and Databases Used to Evaluate the Perfor-mance of QRSDetector In order to compare the performanceof the QRS detector with those found in the literature weused the sensitivity parameter (119878119864) (see (31)) the positive

600 650 700 750 800 850 900 950 1000Time in ms

0

50

100

150

200

250

600 650 700 750 800 850 900 950 1000Time in (ms)

0

50

100

150

200

250

Y

N X M

Figure 8 Points of the histogram used to calculate the indexes ofthe triangular geometric analysis

predictive value (119875119875) (see (32)) and the percentage of theprediction error rate (119863119864119877) (see (33)) 119863119864119877 was also used toevaluate the accuracy of the algorithm

119878119864 = 119879119875119879119875 + 119865119873 lowast 100 (31)

119875119875 = 119879119875119879119875 + 119865119875 lowast 100 (32)

119863119864119877 = 119865119875 + 119865119873119879119875 lowast 100 (33)

where119879119875 are the true positives in detecting the 119877119908119886V119890 119865119873 arethe 119877119908119886V119890 peaks that have not been detected and 119865119875 are thepeaks that have been mistakenly detected as 119877119908119886V119890

In order to validate and compare our proposed algo-rithm for QRS complex detection the MIT-BIT arrhythmiadatabase (MITBIH) and the normal sinus rhythm database(NSRDB) both available online were used [45] Then theresults obtained were compared with other algorithms tosee their effectiveness The MITBIH database consists of 48recordings Each recording has two signals extracted fromhalf hour of a 24-hour recording which have been sampledat 360 Hz and belong to 47 patients in total The NSRDBdatabase contains 18 signals with a duration of 130 minutessampled at 128 Hz and belong to healthy adults aged 20 to 50years

24 Implementation on an MCU The MCU used for theimplementation of the QRS detector and the HRV analysiswas an STM32F407ZET6 MCU Two features can be high-lighted for the present study it has a set of instructions fordigital signal processing (DSP) and a floating point process-ing unit (FPU) whichmake it anMCUcapable of performingadvanced digital processing calculations Likewise it has aflash program memory of 512 Kbyte 192 Kbyte of SRAMmemory and a working frequency of 168 MHz

TheDSP libraries provided by CMSIS (Cortex Microcon-troller Software Interface Standard) were used for the signal

Wireless Communications and Mobile Computing 9

Figure 9 Analysis of the HRV in real time

Figure 10 Analysis of the HRV in frequency domain

processing and the open source wavelib library [46] was usedfor the wavelet implementation The wavelib library had tobe modified and optimized in terms of RAM resources to beused in an MCU

The MCU accessed the MITBIH and NSRDB databasesthrough a microSD card memory in which each recordingwas stored in a separate text data file They were processed inreal time in blocks of 1024 data The block size was chosen fortwo reasons the first one because this number of samples isenough to apply theDWTwith 7 levels of decomposition andthe second because the amount of RAM required is constant(25 kB) and did not compromise the rest of calculationsIt is worth explaining that for an application in real lifethe MCU could acquire data in real time from two externalsources selecting only one at a time The first one wouldinvolve a serial port through the HC-05 Bluetooth moduleat a baud rate of 230400 The second one could use theAD8232 module using the digital analog converter (ADC)with a sampling frequency of 500Hz In both cases interruptscould be used being activated whenever there is a new dataavailable Thus even while the signal is being processed theMCU can continue to fill new buffers for further processingTo display the data locally two LCD screens SSD1306 of128x64 pixels were incorporated using the I2C protocol Anexample of the information displayed on LCD are show inthe Figures 9 and 10 Figure 9 shows the data displayed inreal time while Figure 10 shows the analysis in the frequencydomain for the signal 215 (MITBIH database)

To reduceRAMconsumptionwhenprocessing the signalthe following programming techniques were applied

(i) Avoiding the creations of arrays or matrices withinfunctions it is better to use loops and perform thecorresponding calculations in each iteration

typedef union unsigned uint8 t AllFlags

struct unsigned flag 01

unsigned flag 11

unsigned flag 21

unsigned flag 31

unsigned flag 41

unsigned flag 51

unsigned flag 61

unsigned flag 71 DeviceStatusFlags

DeviceStatusFlags Flags

Used Bytes in RAM 1

uint8 t flag 0

uint8 t flag 1

uint8 t flag 2

uint8 t flag 3

uint8 t flag 4

uint8 t flag 5

uint8 t flag 6

uint8 t flag 7

Used Bytes in RAM 8

Code 1 Efficient use of RAMmemory using structures and unions

(ii) If possible using the input variables as output vari-ables in functions so that new variables are notneeded

(iii) Making use of structures and unions to pack data andtake control of system flags in this way the amount ofRAM required is fully utilized For example in Code 1you can see that less RAM is required using structuresand unions for the same number of flags

For example in Code 2 it is assumed that the inputvariable 119910 has a size of 2000 data In Matlab 64047 bytesis required to perform the same calculation (remove lineartrend) since it does so bymeans of arrays while the algorithmof Code 2 occupied only 48 bytes in the MCU (12 119891119897119900119886119905variables and an 119894119899119905 variable that require 4 bytes each one)since the result was stored in the same input variable

The algorithms optimized following the ideas shown inCode 2 were the average filter the peak detection and thethreshold updating in the QRS detector the calculation of119894119878119863119873119873 and 119878119863119860119873119873 the application of DWT (see (10)) thelinear trend removal (see (12)) and the calculation of the PSD(see (15))

3 Results

The results of Table 2 correspond to the performance of theQRS detector when evaluated with the MITBIH database119863119861 is the number of detected beats and 119879119861 is the totalnumber of beats in each ECG signal It can be observed that109086 pulses of a total of 109494 have been detected 108713

10 Wireless Communications and Mobile Computing

void arm lineal detrend f32 (float 32 t lowast y int size) float 32 t abcdefx1x2C1C2determinant

int i

a=0b=0c=0d=0e=0f=0

x2=1

determinant=0

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size create a slope

a=a+(x1 lowast x1)

b=b+x1

c=c+x1

d=d+x2

e=e+(x1 lowast y [ i ] )f=f+(x2 lowast y [ i ] )

determinant = a lowast d - b lowast c

if ( isnan (determinant) | | isinf(determinant)) return else

C1 = (e lowast d - b lowast f)determinant resolve the System

C2 = (a lowast f - e lowast c)determinant to find the coefficients C1 and C2

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size

y [ i ] =y [ i ] -(x1 lowast C1+C2) remove lineal trendCode 2 C-code to eliminate the linear trend

Table 2 Parameters used to evaluate the QRS detector

Record No TB DB TP FP FN SE PP DERTotal 109494 109086 108713 373 781 9930 9961 112

were true positives 781 were false negative and 373 werefalse positives In addition the QRS detector showed a 119878119864 of9930with a positive prediction of 9961 and an error ratein the detection of pulses of 112

Table 3 shows the results obtained between the differentalgorithms found in the literature and ours using the MIT-BIH database The results we have obtained are a little worseHowever the difference between the algorithm with better 119878119864[34] and ours is only 057 In119875119875 the difference with respectto [35] is 030 and in119863119864119877 the differencewith respect to [36]is only 084

Table 4 shows the comparison between the resultsobtained by our algorithm and those obtained by [32] usingthe 119873119878119877119863119861 database In this comparison [32] has betterresults than us in 119878119864 and 119875119875 by 001 while 119863119864119877 is only00002 better

The time required by the MCU for the HRV analysis willvary according to the size of the IBI vector Table 5 shows theexecution times that were required to analyze the signal 215 oftheMITBIH databaseThis particular file was chosen becauseit contains more QRS complex than the rest of the signals(3358 found by our algorithm)

On the other hand the execution times for the QRSdetector will always be the same (47ms for detection and 5msfor saving in a microSD the temporary location of the 119877119908119886V119890found) because the length of the input vector has a constantsize (1024 samples)

The time required to fill the 1024 data buffer is 1024 lowast(1119891119904) where 119891119904 is the sampling frequency In the case ofthe MITBIH 119891119904 is 360 Hz so it would take 284 s to fill itIn the case of the NSRDB 119891119904 is 128 Hz so that it would take8 s In both cases the detection of the QRS complex can bedone in real time since it only takes 52 ms The detector mayoperate in real time up to a maximum sampling frequencyof 195 kHz However some studies show that 500 Hz is avery reliable frequency forHRV analysis [47] Our system caneasily achieve real time for this recommended frequency

Although the times required for the analysis of the HRVvary depending on the size of 119868119861119868 inTable 5 it can be seen thatthe smoothing of the signal using wavelets and the analysis inthe frequency domain required more time for its executionOn the other side the Poincare analysis was the fastest Thetime required for the complete HRV analysis of signal 215(MITBIH database) was 4401 s

Wireless Communications and Mobile Computing 11

Table 3 Comparison of the results obtained using different algorithm in the MITBIH database

DB TP FP FN SE PP DERJP Martınez et al [31] 109428 109208 153 220 9980 9986 034J Pan amp Tompkins [11] 109809 109532 507 277 9975 9954 071Gutierrez-Rivas et al [32] - 109447 289 502 9954 9973 -Chouakri et al [33] 109488 108043 3068 1446 9868 9724 412Santanu et al [34] 109666 109351 315 144 9987 9969 042Moody amp Mark [35] 109428 107567 94 1861 9830 9991 179Merah et al[36] 109494 109316 126 178 9984 9988 028Proposed algorithm 109086 108713 373 781 9930 9961 112

Table 4 Comparison of the results using the NSRDB database

Algorithm TB TP FP FN SE PP DERGutierrez-Rivas et al [32] 192389 192325 64 17 9996 9999 00004Proposed algorithm 192389 192297 92 25 9995 9998 00006

Refreshing the LCD screens took 50 ms and it was donewhile the buffer was filling so that the update times of thescreens had no influence on the calculations of the HRV

The execution time on a regular PC with the processingperformed inMatlab is also shown in Table 5 for comparisonIt is lower than in the MCU implementation because of thepowerful processor The idea is not to be competitive witha PC server in this aspect but to avoid transmitting data toa server in the cloud which would be a great burden forthe network In addition this would imply a higher powerconsumption for the sensor node For instance the proposedsystem has these power consumption contributions 42 mAfor the MCU in sleep mode 49 mA while processing asignal from a micro SD card 75 mA while processing signalsfrom AD8232 or 169 mA while processing signals fromBluetooth (HC-05 module) Thus it is clear that avoidingcommunication is of great interest

4 Conclusions and Future Work

The results obtained with the QRS detector that we haveproposed based on wavelets and with automatic selection ofthe coefficients of the details have been higher than 99 in119878119864 and 119875119875 using the MITBIH database They are worse thanprevious studies but the difference does not exceed 09 inany of the parameters used in that comparison (119878119864 119875119875 119863119864119877)On the other hand using the NSRDB database the resultshave been better (119878119864 = 9995 119875119875 = 9998 and 119863119864119877 =00006) In comparison with [32] SE and PP have been only001 lower

The QRS detection algorithm was followed by an HRVanalysis In both stages several algorithms had to be opti-mized for the implementation on an MCU Thanks to theefficient use of RAM it has beenpossible to develop thewholeHRV analysis as a standalone application embedded on anMCU ARM

With the execution times shown in Table 5 it has beenshown that theQRSdetector is capable of running in real timefor the most common frequencies used in ECGs Likewise

given that some parameters such as 119868119861119868119898119890119886119899 119878119863119873119873119877119872119878119878119863and 119867119877119898119890119886119899 require very little time for their execution andthat they are in the time domain they could be displayed bysending them via Bluetooth or Wifi to a mobile applicationIn this way an HRV analysis would be done in real time Inaddition the energy consumption is low so it can facilitate itsintegration on portable devices

The time required for the complete analysis of the HRVwill be variable (depending on the amount of data) but it willbe in the order of seconds for practical purposes making it aviable application

Our system could also help in applications like the oneshown in [25] in which HRV and location are measured toevaluate wellness and recommend a place to live accordinglyAll the RR intervals are sent to the userrsquos mobile phone andfrom it to a server in which a time domain parameter of HRVis calculated The system could be improved if the wearabledevice measured itself HRV avoiding the battery consum-ing process of the communication with the mobile phoneBesides our system can calculate all the HRV parametersand could improve the determination of the userrsquos wellnessAnother application of our system could be the integrationinto the system to monitor asthma disease presented in [26]in which the heart rate is also a key component

This system developed on an ARM MCU could be com-plemented by developing a mobile application that displaysthe results of the HRV analysis in a more adequate wayto the user showing comparisons or statistics with respectto previous analyses In this way the user would get bettercontrol over hisher HRV

As future work several lines are devised In the first onethe QRS detector will be improved to obtain better resultsthan those seen in Tables 3 and 4 The second line will bedevoted to the optimization of the proposed system code tointegrate it in the most optimal way into an 119868119900119879 networkIt can be tested using Wifi ZigBee or Bluetooth networksfor short ranges For instance it could receive informationfrom a network edge and then send back to a server onlythe HRV results to be displayed This will help to improve

12 Wireless Communications and Mobile Computing

Table 5 Time required for HRV analysis of the signal 215 (MITBIH database)

Main function Sub functions (ms) Execution time (ms) inMCU

Execution time (ms) inIntel i7 (MatLab)

Detector QRS 47 39DWT perform (37)First difference (lt1)Squared signal (lt3)Filter average (lt3)

Find peaks and update threshold (lt3)Save data to SD 5 -Preprocessing Remove Artifacts 3 1Time DomainHRV 30 9

119868119861119868119898119890119886119899 (lt1)119867119877119898119890119886119899 (1)119878119863119873119873 (lt1)119894119878119863119873119873 (12)119878119863119860119873119873 (11)119877119872119878119878119863 (lt1)

11990111987311987350 11987311987350 (1)119867119877119904119905119889 (1)119872119886119909 (lt1)119872119894119899 (lt1)

Geometrictriangular HRV 89 2

119877119877119879119903119894119899 (17)119879119868119873119873 (62)

Poincare HRV 1 11198781198631 1198781198632 119886119899119889 119864119901119860119903119890119886 (1)

Refresh LCD 50 -FrequencyDomain HRV 4176 163

119868119861119868119904119898119900119900119905ℎ (2084)119905 (lt1)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 (1331)119875119878119863119904119894119892119899119886119897 (302)

119881119871119865 119871119865 119867119865 119871119865119867119865 119871119865119899119900119903119898119886119897119894119911119890119889 and119867119865119899119900119903119898119886119897119894119911119890119889 (458)

mHealth and eHealth services using systems embedded inmicrocontrollers On the other hand we will work to makethe proposed device as small as possible similar to smartband In this way it will be able to track heart rate variabilityduring the daily activity

Data Availability

The data supporting this study are from previously reportedstudies and datasets which have been cited or are includedwithin the article

Conflicts of Interest

The authors declare that they have no conflicts of interest

Acknowledgments

The authors would like to thank the ldquoFondo Social Europeordquothe ldquoDiputacion General de Aragonrdquo (reference groupEduQTech T49 17R) Victor H Rodriguez acknowledges agrant from ldquoCONACYT-Gobierno del Estado de DurangoMexico 330795386043rdquo

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 6: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

6 Wireless Communications and Mobile Computing

Table 1 Parameters of the analysis HRV

Domain Description Symbol Unitslowast Biological meanTime Mean between IBI interval 119868119861119868119898119890119886119899 ms

Mean heart rate 119867119877119898119890119886119899 BPMStandard deviation of NN intervals SDNN ms Estimate of overall HRV

Measure the mean of standard deviation ofintervals RR in windows of 5 minutes iSDNN ms

Measure the standard deviation of the meanof the intervals RR in windows of 5 minutes SDANN ms

Root mean squared of successive differences RMSSD ms Short term componentPercentage of intervals that differs more than

50 ms pNN50

Standard deviation of the heart rate 119867119877119904119905119889 BPMMaximum time between IBI interval 119872119886119909 msMinimum time between IBI interval 119872119894119899 ms

Frequency Low frequency power LF 1198981199042 Sympathetic nervousSystem activity

High frequency power HF 1198981199042 parasympathetic nervousSystem activity

Ratio between low and high frequency LFHF Sympathovagal balanceLow frequency normalized LFn nuHigh frequency normalized HFn nu

Non linear Poincare SD1 SD2119878119863119903119886119905119894119900 ms Term variability

Geometric (time domain) Triangular index RRTrin Estimate of overall HRVTriangular Interpolation index TINN

lowast BPM(beats per minute) ms (milliseconds)1198981199042(milliseconds squared) nu (normalized units) (percent)

Sr signalFd signal

Small peak after a big peak

minus200

minus100

0

100

200

300

mill

ivol

ts m

V

204 206 208 21 212 214202samples times104

Figure 6 Portion of the signal 104 of theMITBIH database showinglarge differences in amplitude

Step 2 The standard deviation (119878119879119863119868119861119868) and the mean(119872119899119889119868119861119868) of 119868119861119868119897119894119899119890119886119897 119889119890119905119903119890119899119889 were calculated

Step 3 A threshold (119905119903119904ℎ119904119889) was set in order to find theectopic beats In this case it was equal to three times the119878119879119863119868119861119868

119905119903119904ℎ119904119889 = 3 lowast 119878119879119863119868119861119868 (11)

Step 4 Finally to find an ectopic beat the mean 119872119899119889119868119861119868 wassubtracted from the absolute value of the 119868119861119868[119909]119897119894119899119890119886119897 119889119890119905119903119890119899119889Ectopic beats were those beats in which the result was higherthan 119905119903119904ℎ119904119889 in those cases the sample 119868119861119868[119909] was substitutedby the mean of the five preceding samples and the fivefollowing samples of it

222 Analysis of HRV in the Time Domain After the ectopicbeats were removed the vector 119868119861119868 was transformed fromseconds to milliseconds (119898119868119861119868) and the statistical param-eters shown in Table 1 were calculated which correspondto widely known statistical measurements (means standarddeviations)

223 Analysis of HRV in the Frequency Domain Theanalysisin the frequency domain had three stages (a) preprocessingin this stage the signal went through a series of filters toeliminate its offset (b) interpolation the signal without offsetwas interpolated at 4 Hz (c) spectral analysis the spectraldensity (PSD) was calculated using the Welch method

Wireless Communications and Mobile Computing 7

Preprocessing

Step 1 It began by smoothing the 119868119861119868 vector Some authorshave shown that the smoothness prior filter is usually veryeffective in bioelectric signals like the ECG [37 38] It iseven used in commercial software such as Kubios for HRVanalysis [39] However its algorithm requires many resourcesin RAM memory to be implemented in an MCU Thereforein this paper we opted to do the filtering using waveletsThe filtering with the wavelets was done by eliminatingthe coefficients of the details In this case a wavelet 1198891198875with four decomposition levels was used in which afterhaving eliminated all the 119862119863 coefficients the signal wasreconstructed (119868119861119868119908119886V119890) Finally using (12) the signal wassmoothedThepurpose of this filtering processwas to removeany disturbance in low frequency that affects RR intervals

119868119861119868119904119898119900119900119905ℎ [119909] = (119868119861119868 [119909] minus 119868119861119868119908119886V119890 [119909]) (12)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(119868119861119868)Step 2 Calculate the temporary vector (119905) which will be usedto perform the interpolation The temporary vector is thecumulative sum of the 119868119861119868 vectorminus the first value of itself(13)

119905 = cumulativesum (119868119861I) minus 119868119861119868 [0] (13)

Interpolation The vector 119868119861119868119904119898119900119900119905ℎ was passed to ms(119898119868119861119868119904119898119900119900119905ℎ) Then the interpolation was carried out usingthe cubic spline algorithm at 4 Hz (14) Once 119898119868119861119868119904119898119900119900119905ℎ wasinterpolated the average was subtracted (15)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 = 119904119901119897119894119899119890 (119905 119898119868119861119868119904119898119900119900119905ℎ) (14)

119898119868119861119868119905119900119875119878119863 = 119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890minus 119898119890119886119899 (119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890) (15)

Calculation of the Spectral Density To calculate the PSDwith the Welch method the algorithm implemented usedthe fast Fourier transform (FFT) with a window of 256points (119863119886119905119886119908119894119899119889119900119908) and overlapping of 128 points Beforeapplying the FFT to each window the data were smoothed bymultiplying them by a Hamming function (119867119886119898119898119894119899119892119908119894119899119889119900119908)of the same width as 119863119886119905119886119908119894119899119889119900119908 In this way we avoidedabrupt discontinuities at the beginning and end of eachwindow

Obtaining the Parameters in the Frequency Domain Aftercomputing the PSD (119875119878119863119904119894119892119899119886119897) of the 119898119868119861119868119905119900119875119878119863 signalthe area under the curve was calculated for each band offrequencies associated with the HRV the 119881119871119865 band (0 to 004Hz) the 119871119865 band (004 to 015 Hz) and the 119867119865 band (015 to04 Hz) Once the areas for each band were calculated the119871119865119867119865 ratio was calculated by dividing the total area of 119871119865

650 700 750 800 850 900 950650

700

750

800

850

900

950

RRN (ms)

RRN+1(m

s) EpArea

SD1

SD2

Figure 7 Representation of the Poincare analysis

by the total area of 119867119865 (16)The normalized 119871119865 and 119867119865 werecalculated with (17) and (18)

119871119865119867119865 = 119871119865119867119865 (16)

119871119865119899119900119903119898119886119897119894119911119890119889 = 119871119865119871119865 + 119867119865 (17)

119867119865119899119900119903119898119886119897119894119911119890119889 = 119867119865119871119865 + 119867119865 (18)

224 Poincare Analysis The Poincare analysis is a graphicalmethod that evaluates the dynamics of the HRV from thecurrent (119877119877119873) and the next (119877119877119873+1) RR intervals

119877119877119873 = (119898119868119861119868 [0] 119898119868119861119868 [1] 119898119868119861119868 [119873 minus 1]) (19)

119877119877119873+1 = (119898119868119861119868 [1] 119898119868119861119868 [2] 119898119868119861119868 [119873]) (20)

where 119873 = 119897119890119899119892119905ℎ(119898119868119861119868)To perform a quantitative analysis and evaluate the HRV

an ellipse was fit to the data (see Figure 7) The width of theellipse is known as the standard deviation 1 (1198781198631) and thelength as the standard deviation 2 (1198781198632) From 1198781198631 and 1198781198632the area of the ellipse was calculated (119864119901119860119903119890119886) [6] It is saidthat 1198781198631 represents the HRV in short times (short term) andis correlated with the SNA while 1198781198632 represent long periods(long term) and is correlated with SNS [40] Due to thecorrelation between the standard deviation of the RR intervaldifference (119889119868119861119868) (see (21)) and 1198781198631 1198781198631 was calculated using(22)-(24) From the 119878119863119873119873 parameter and SD119889119868119861119868 (see (23))1198781198632 was calculated with (25) the area 119864119901119860119903119890119886 with (26) andfinally the ratio 119878119863119903119886119905119894119900 with (27) [41]

The Poincare plot represents the healthy case by a largeellipse area and small for critical diseases To perform theanalysis of Poincare periods between 5 to 20 minutes arerecommended [6] On the other hand [42 43] observed thata lowest 119878119863119903119886119905119894119900 value is present in healthy subjects In thesame way a small value in 1198781198631 for diseased subjects indicatesweakening of parasympathetic regulation by health disorder

8 Wireless Communications and Mobile Computing

As 1198781198632 decreases the SNS activity increases Figure 7 showsan arrhythmia case from the signal 215 (MITBIH) in which itcan observed that the most of the samples are focused in thecenter of the plot and represent a small ellipse area

119889119868119861119868 [119909] = 119898119868119861119868 [119909 + 1] minus 119898119868119861119868 [119909] (21)

119889119868119861119868119898119890119886119899 = sum119873119909=0 (119889119868119861119868 [119909])119873 (22)

SD119889119868119861119868 = radic sum119873119909=0 1003816100381610038161003816119889119868119861119868 [119909] minus 11988911986811986111986811989811989011988611989910038161003816100381610038162119873 (23)

1198781198631 = radic05 lowast SD1198891198681198611198682 (24)

1198781198632 = radic(2 lowast 1198781198631198731198732) minus (05 lowast SD1198891198681198611198682) (25)

119864119901119860119903119890119886 = 120587 lowast 1198781198631 lowast 1198781198632 (26)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(d119868119861119868)119878119863119903119886119905119894119900 = 11987811986311198781198632 (27)

225 Triangular Geometric Analysis Triangular geometricanalysis is usually considered as part of the analysis in thetime domain However it deserves further explanation sinceit is more complex than the rest This analysis is doneby calculating the histogram of the vector 119898119868119861119868 throughwhich two parameters can be calculated the triangular index(119877119877119879119903119894119899) and the index of triangular interpolation of the baseof the histogram (119879119868119873119873) The 119877119877119879119903119894119899 is equal to the totalnumber of RR intervals divided by the maximum value of thehistogram (119881119886119897119898119886119909) (28) This index gives an overall estimateof the HRV The width of the bins used in this analysiswas set to 78125 ms The 119879119868119873119873 index gives a value on thedistribution of the density of all the RR intervals as the baseof a triangle and it is usually calculated by means of a leastsquares estimateThus119860119903119890119886119905119894119899119899 (see (29)) was minimized andthe limiting points N and M were found Then 119879119868119873119873 wascalculated with (30) see Figure 8 [44]

119877119877119879119903119894119899 = 119873119881119886119897119898119886119909 (28)

119860119903119890119886119905119894119899119899 = intinfin0

(119863 (119905) minus 119902 (119905))2 119889119905 (29)

where 119863 is histogram output 119902 defines the base of triangle thatfits histogram and its cero for 119905 le 119873 119905 ge 119872 and 119902(119883) = 119884

119879119868119873119873 = 119872 minus 119873 (30)

where 119872 and 119873 are the limits of 11986011990311989011988611990511989411989911989923 Parameters and Databases Used to Evaluate the Perfor-mance of QRSDetector In order to compare the performanceof the QRS detector with those found in the literature weused the sensitivity parameter (119878119864) (see (31)) the positive

600 650 700 750 800 850 900 950 1000Time in ms

0

50

100

150

200

250

600 650 700 750 800 850 900 950 1000Time in (ms)

0

50

100

150

200

250

Y

N X M

Figure 8 Points of the histogram used to calculate the indexes ofthe triangular geometric analysis

predictive value (119875119875) (see (32)) and the percentage of theprediction error rate (119863119864119877) (see (33)) 119863119864119877 was also used toevaluate the accuracy of the algorithm

119878119864 = 119879119875119879119875 + 119865119873 lowast 100 (31)

119875119875 = 119879119875119879119875 + 119865119875 lowast 100 (32)

119863119864119877 = 119865119875 + 119865119873119879119875 lowast 100 (33)

where119879119875 are the true positives in detecting the 119877119908119886V119890 119865119873 arethe 119877119908119886V119890 peaks that have not been detected and 119865119875 are thepeaks that have been mistakenly detected as 119877119908119886V119890

In order to validate and compare our proposed algo-rithm for QRS complex detection the MIT-BIT arrhythmiadatabase (MITBIH) and the normal sinus rhythm database(NSRDB) both available online were used [45] Then theresults obtained were compared with other algorithms tosee their effectiveness The MITBIH database consists of 48recordings Each recording has two signals extracted fromhalf hour of a 24-hour recording which have been sampledat 360 Hz and belong to 47 patients in total The NSRDBdatabase contains 18 signals with a duration of 130 minutessampled at 128 Hz and belong to healthy adults aged 20 to 50years

24 Implementation on an MCU The MCU used for theimplementation of the QRS detector and the HRV analysiswas an STM32F407ZET6 MCU Two features can be high-lighted for the present study it has a set of instructions fordigital signal processing (DSP) and a floating point process-ing unit (FPU) whichmake it anMCUcapable of performingadvanced digital processing calculations Likewise it has aflash program memory of 512 Kbyte 192 Kbyte of SRAMmemory and a working frequency of 168 MHz

TheDSP libraries provided by CMSIS (Cortex Microcon-troller Software Interface Standard) were used for the signal

Wireless Communications and Mobile Computing 9

Figure 9 Analysis of the HRV in real time

Figure 10 Analysis of the HRV in frequency domain

processing and the open source wavelib library [46] was usedfor the wavelet implementation The wavelib library had tobe modified and optimized in terms of RAM resources to beused in an MCU

The MCU accessed the MITBIH and NSRDB databasesthrough a microSD card memory in which each recordingwas stored in a separate text data file They were processed inreal time in blocks of 1024 data The block size was chosen fortwo reasons the first one because this number of samples isenough to apply theDWTwith 7 levels of decomposition andthe second because the amount of RAM required is constant(25 kB) and did not compromise the rest of calculationsIt is worth explaining that for an application in real lifethe MCU could acquire data in real time from two externalsources selecting only one at a time The first one wouldinvolve a serial port through the HC-05 Bluetooth moduleat a baud rate of 230400 The second one could use theAD8232 module using the digital analog converter (ADC)with a sampling frequency of 500Hz In both cases interruptscould be used being activated whenever there is a new dataavailable Thus even while the signal is being processed theMCU can continue to fill new buffers for further processingTo display the data locally two LCD screens SSD1306 of128x64 pixels were incorporated using the I2C protocol Anexample of the information displayed on LCD are show inthe Figures 9 and 10 Figure 9 shows the data displayed inreal time while Figure 10 shows the analysis in the frequencydomain for the signal 215 (MITBIH database)

To reduceRAMconsumptionwhenprocessing the signalthe following programming techniques were applied

(i) Avoiding the creations of arrays or matrices withinfunctions it is better to use loops and perform thecorresponding calculations in each iteration

typedef union unsigned uint8 t AllFlags

struct unsigned flag 01

unsigned flag 11

unsigned flag 21

unsigned flag 31

unsigned flag 41

unsigned flag 51

unsigned flag 61

unsigned flag 71 DeviceStatusFlags

DeviceStatusFlags Flags

Used Bytes in RAM 1

uint8 t flag 0

uint8 t flag 1

uint8 t flag 2

uint8 t flag 3

uint8 t flag 4

uint8 t flag 5

uint8 t flag 6

uint8 t flag 7

Used Bytes in RAM 8

Code 1 Efficient use of RAMmemory using structures and unions

(ii) If possible using the input variables as output vari-ables in functions so that new variables are notneeded

(iii) Making use of structures and unions to pack data andtake control of system flags in this way the amount ofRAM required is fully utilized For example in Code 1you can see that less RAM is required using structuresand unions for the same number of flags

For example in Code 2 it is assumed that the inputvariable 119910 has a size of 2000 data In Matlab 64047 bytesis required to perform the same calculation (remove lineartrend) since it does so bymeans of arrays while the algorithmof Code 2 occupied only 48 bytes in the MCU (12 119891119897119900119886119905variables and an 119894119899119905 variable that require 4 bytes each one)since the result was stored in the same input variable

The algorithms optimized following the ideas shown inCode 2 were the average filter the peak detection and thethreshold updating in the QRS detector the calculation of119894119878119863119873119873 and 119878119863119860119873119873 the application of DWT (see (10)) thelinear trend removal (see (12)) and the calculation of the PSD(see (15))

3 Results

The results of Table 2 correspond to the performance of theQRS detector when evaluated with the MITBIH database119863119861 is the number of detected beats and 119879119861 is the totalnumber of beats in each ECG signal It can be observed that109086 pulses of a total of 109494 have been detected 108713

10 Wireless Communications and Mobile Computing

void arm lineal detrend f32 (float 32 t lowast y int size) float 32 t abcdefx1x2C1C2determinant

int i

a=0b=0c=0d=0e=0f=0

x2=1

determinant=0

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size create a slope

a=a+(x1 lowast x1)

b=b+x1

c=c+x1

d=d+x2

e=e+(x1 lowast y [ i ] )f=f+(x2 lowast y [ i ] )

determinant = a lowast d - b lowast c

if ( isnan (determinant) | | isinf(determinant)) return else

C1 = (e lowast d - b lowast f)determinant resolve the System

C2 = (a lowast f - e lowast c)determinant to find the coefficients C1 and C2

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size

y [ i ] =y [ i ] -(x1 lowast C1+C2) remove lineal trendCode 2 C-code to eliminate the linear trend

Table 2 Parameters used to evaluate the QRS detector

Record No TB DB TP FP FN SE PP DERTotal 109494 109086 108713 373 781 9930 9961 112

were true positives 781 were false negative and 373 werefalse positives In addition the QRS detector showed a 119878119864 of9930with a positive prediction of 9961 and an error ratein the detection of pulses of 112

Table 3 shows the results obtained between the differentalgorithms found in the literature and ours using the MIT-BIH database The results we have obtained are a little worseHowever the difference between the algorithm with better 119878119864[34] and ours is only 057 In119875119875 the difference with respectto [35] is 030 and in119863119864119877 the differencewith respect to [36]is only 084

Table 4 shows the comparison between the resultsobtained by our algorithm and those obtained by [32] usingthe 119873119878119877119863119861 database In this comparison [32] has betterresults than us in 119878119864 and 119875119875 by 001 while 119863119864119877 is only00002 better

The time required by the MCU for the HRV analysis willvary according to the size of the IBI vector Table 5 shows theexecution times that were required to analyze the signal 215 oftheMITBIH databaseThis particular file was chosen becauseit contains more QRS complex than the rest of the signals(3358 found by our algorithm)

On the other hand the execution times for the QRSdetector will always be the same (47ms for detection and 5msfor saving in a microSD the temporary location of the 119877119908119886V119890found) because the length of the input vector has a constantsize (1024 samples)

The time required to fill the 1024 data buffer is 1024 lowast(1119891119904) where 119891119904 is the sampling frequency In the case ofthe MITBIH 119891119904 is 360 Hz so it would take 284 s to fill itIn the case of the NSRDB 119891119904 is 128 Hz so that it would take8 s In both cases the detection of the QRS complex can bedone in real time since it only takes 52 ms The detector mayoperate in real time up to a maximum sampling frequencyof 195 kHz However some studies show that 500 Hz is avery reliable frequency forHRV analysis [47] Our system caneasily achieve real time for this recommended frequency

Although the times required for the analysis of the HRVvary depending on the size of 119868119861119868 inTable 5 it can be seen thatthe smoothing of the signal using wavelets and the analysis inthe frequency domain required more time for its executionOn the other side the Poincare analysis was the fastest Thetime required for the complete HRV analysis of signal 215(MITBIH database) was 4401 s

Wireless Communications and Mobile Computing 11

Table 3 Comparison of the results obtained using different algorithm in the MITBIH database

DB TP FP FN SE PP DERJP Martınez et al [31] 109428 109208 153 220 9980 9986 034J Pan amp Tompkins [11] 109809 109532 507 277 9975 9954 071Gutierrez-Rivas et al [32] - 109447 289 502 9954 9973 -Chouakri et al [33] 109488 108043 3068 1446 9868 9724 412Santanu et al [34] 109666 109351 315 144 9987 9969 042Moody amp Mark [35] 109428 107567 94 1861 9830 9991 179Merah et al[36] 109494 109316 126 178 9984 9988 028Proposed algorithm 109086 108713 373 781 9930 9961 112

Table 4 Comparison of the results using the NSRDB database

Algorithm TB TP FP FN SE PP DERGutierrez-Rivas et al [32] 192389 192325 64 17 9996 9999 00004Proposed algorithm 192389 192297 92 25 9995 9998 00006

Refreshing the LCD screens took 50 ms and it was donewhile the buffer was filling so that the update times of thescreens had no influence on the calculations of the HRV

The execution time on a regular PC with the processingperformed inMatlab is also shown in Table 5 for comparisonIt is lower than in the MCU implementation because of thepowerful processor The idea is not to be competitive witha PC server in this aspect but to avoid transmitting data toa server in the cloud which would be a great burden forthe network In addition this would imply a higher powerconsumption for the sensor node For instance the proposedsystem has these power consumption contributions 42 mAfor the MCU in sleep mode 49 mA while processing asignal from a micro SD card 75 mA while processing signalsfrom AD8232 or 169 mA while processing signals fromBluetooth (HC-05 module) Thus it is clear that avoidingcommunication is of great interest

4 Conclusions and Future Work

The results obtained with the QRS detector that we haveproposed based on wavelets and with automatic selection ofthe coefficients of the details have been higher than 99 in119878119864 and 119875119875 using the MITBIH database They are worse thanprevious studies but the difference does not exceed 09 inany of the parameters used in that comparison (119878119864 119875119875 119863119864119877)On the other hand using the NSRDB database the resultshave been better (119878119864 = 9995 119875119875 = 9998 and 119863119864119877 =00006) In comparison with [32] SE and PP have been only001 lower

The QRS detection algorithm was followed by an HRVanalysis In both stages several algorithms had to be opti-mized for the implementation on an MCU Thanks to theefficient use of RAM it has beenpossible to develop thewholeHRV analysis as a standalone application embedded on anMCU ARM

With the execution times shown in Table 5 it has beenshown that theQRSdetector is capable of running in real timefor the most common frequencies used in ECGs Likewise

given that some parameters such as 119868119861119868119898119890119886119899 119878119863119873119873119877119872119878119878119863and 119867119877119898119890119886119899 require very little time for their execution andthat they are in the time domain they could be displayed bysending them via Bluetooth or Wifi to a mobile applicationIn this way an HRV analysis would be done in real time Inaddition the energy consumption is low so it can facilitate itsintegration on portable devices

The time required for the complete analysis of the HRVwill be variable (depending on the amount of data) but it willbe in the order of seconds for practical purposes making it aviable application

Our system could also help in applications like the oneshown in [25] in which HRV and location are measured toevaluate wellness and recommend a place to live accordinglyAll the RR intervals are sent to the userrsquos mobile phone andfrom it to a server in which a time domain parameter of HRVis calculated The system could be improved if the wearabledevice measured itself HRV avoiding the battery consum-ing process of the communication with the mobile phoneBesides our system can calculate all the HRV parametersand could improve the determination of the userrsquos wellnessAnother application of our system could be the integrationinto the system to monitor asthma disease presented in [26]in which the heart rate is also a key component

This system developed on an ARM MCU could be com-plemented by developing a mobile application that displaysthe results of the HRV analysis in a more adequate wayto the user showing comparisons or statistics with respectto previous analyses In this way the user would get bettercontrol over hisher HRV

As future work several lines are devised In the first onethe QRS detector will be improved to obtain better resultsthan those seen in Tables 3 and 4 The second line will bedevoted to the optimization of the proposed system code tointegrate it in the most optimal way into an 119868119900119879 networkIt can be tested using Wifi ZigBee or Bluetooth networksfor short ranges For instance it could receive informationfrom a network edge and then send back to a server onlythe HRV results to be displayed This will help to improve

12 Wireless Communications and Mobile Computing

Table 5 Time required for HRV analysis of the signal 215 (MITBIH database)

Main function Sub functions (ms) Execution time (ms) inMCU

Execution time (ms) inIntel i7 (MatLab)

Detector QRS 47 39DWT perform (37)First difference (lt1)Squared signal (lt3)Filter average (lt3)

Find peaks and update threshold (lt3)Save data to SD 5 -Preprocessing Remove Artifacts 3 1Time DomainHRV 30 9

119868119861119868119898119890119886119899 (lt1)119867119877119898119890119886119899 (1)119878119863119873119873 (lt1)119894119878119863119873119873 (12)119878119863119860119873119873 (11)119877119872119878119878119863 (lt1)

11990111987311987350 11987311987350 (1)119867119877119904119905119889 (1)119872119886119909 (lt1)119872119894119899 (lt1)

Geometrictriangular HRV 89 2

119877119877119879119903119894119899 (17)119879119868119873119873 (62)

Poincare HRV 1 11198781198631 1198781198632 119886119899119889 119864119901119860119903119890119886 (1)

Refresh LCD 50 -FrequencyDomain HRV 4176 163

119868119861119868119904119898119900119900119905ℎ (2084)119905 (lt1)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 (1331)119875119878119863119904119894119892119899119886119897 (302)

119881119871119865 119871119865 119867119865 119871119865119867119865 119871119865119899119900119903119898119886119897119894119911119890119889 and119867119865119899119900119903119898119886119897119894119911119890119889 (458)

mHealth and eHealth services using systems embedded inmicrocontrollers On the other hand we will work to makethe proposed device as small as possible similar to smartband In this way it will be able to track heart rate variabilityduring the daily activity

Data Availability

The data supporting this study are from previously reportedstudies and datasets which have been cited or are includedwithin the article

Conflicts of Interest

The authors declare that they have no conflicts of interest

Acknowledgments

The authors would like to thank the ldquoFondo Social Europeordquothe ldquoDiputacion General de Aragonrdquo (reference groupEduQTech T49 17R) Victor H Rodriguez acknowledges agrant from ldquoCONACYT-Gobierno del Estado de DurangoMexico 330795386043rdquo

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 7: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

Wireless Communications and Mobile Computing 7

Preprocessing

Step 1 It began by smoothing the 119868119861119868 vector Some authorshave shown that the smoothness prior filter is usually veryeffective in bioelectric signals like the ECG [37 38] It iseven used in commercial software such as Kubios for HRVanalysis [39] However its algorithm requires many resourcesin RAM memory to be implemented in an MCU Thereforein this paper we opted to do the filtering using waveletsThe filtering with the wavelets was done by eliminatingthe coefficients of the details In this case a wavelet 1198891198875with four decomposition levels was used in which afterhaving eliminated all the 119862119863 coefficients the signal wasreconstructed (119868119861119868119908119886V119890) Finally using (12) the signal wassmoothedThepurpose of this filtering processwas to removeany disturbance in low frequency that affects RR intervals

119868119861119868119904119898119900119900119905ℎ [119909] = (119868119861119868 [119909] minus 119868119861119868119908119886V119890 [119909]) (12)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(119868119861119868)Step 2 Calculate the temporary vector (119905) which will be usedto perform the interpolation The temporary vector is thecumulative sum of the 119868119861119868 vectorminus the first value of itself(13)

119905 = cumulativesum (119868119861I) minus 119868119861119868 [0] (13)

Interpolation The vector 119868119861119868119904119898119900119900119905ℎ was passed to ms(119898119868119861119868119904119898119900119900119905ℎ) Then the interpolation was carried out usingthe cubic spline algorithm at 4 Hz (14) Once 119898119868119861119868119904119898119900119900119905ℎ wasinterpolated the average was subtracted (15)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 = 119904119901119897119894119899119890 (119905 119898119868119861119868119904119898119900119900119905ℎ) (14)

119898119868119861119868119905119900119875119878119863 = 119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890minus 119898119890119886119899 (119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890) (15)

Calculation of the Spectral Density To calculate the PSDwith the Welch method the algorithm implemented usedthe fast Fourier transform (FFT) with a window of 256points (119863119886119905119886119908119894119899119889119900119908) and overlapping of 128 points Beforeapplying the FFT to each window the data were smoothed bymultiplying them by a Hamming function (119867119886119898119898119894119899119892119908119894119899119889119900119908)of the same width as 119863119886119905119886119908119894119899119889119900119908 In this way we avoidedabrupt discontinuities at the beginning and end of eachwindow

Obtaining the Parameters in the Frequency Domain Aftercomputing the PSD (119875119878119863119904119894119892119899119886119897) of the 119898119868119861119868119905119900119875119878119863 signalthe area under the curve was calculated for each band offrequencies associated with the HRV the 119881119871119865 band (0 to 004Hz) the 119871119865 band (004 to 015 Hz) and the 119867119865 band (015 to04 Hz) Once the areas for each band were calculated the119871119865119867119865 ratio was calculated by dividing the total area of 119871119865

650 700 750 800 850 900 950650

700

750

800

850

900

950

RRN (ms)

RRN+1(m

s) EpArea

SD1

SD2

Figure 7 Representation of the Poincare analysis

by the total area of 119867119865 (16)The normalized 119871119865 and 119867119865 werecalculated with (17) and (18)

119871119865119867119865 = 119871119865119867119865 (16)

119871119865119899119900119903119898119886119897119894119911119890119889 = 119871119865119871119865 + 119867119865 (17)

119867119865119899119900119903119898119886119897119894119911119890119889 = 119867119865119871119865 + 119867119865 (18)

224 Poincare Analysis The Poincare analysis is a graphicalmethod that evaluates the dynamics of the HRV from thecurrent (119877119877119873) and the next (119877119877119873+1) RR intervals

119877119877119873 = (119898119868119861119868 [0] 119898119868119861119868 [1] 119898119868119861119868 [119873 minus 1]) (19)

119877119877119873+1 = (119898119868119861119868 [1] 119898119868119861119868 [2] 119898119868119861119868 [119873]) (20)

where 119873 = 119897119890119899119892119905ℎ(119898119868119861119868)To perform a quantitative analysis and evaluate the HRV

an ellipse was fit to the data (see Figure 7) The width of theellipse is known as the standard deviation 1 (1198781198631) and thelength as the standard deviation 2 (1198781198632) From 1198781198631 and 1198781198632the area of the ellipse was calculated (119864119901119860119903119890119886) [6] It is saidthat 1198781198631 represents the HRV in short times (short term) andis correlated with the SNA while 1198781198632 represent long periods(long term) and is correlated with SNS [40] Due to thecorrelation between the standard deviation of the RR intervaldifference (119889119868119861119868) (see (21)) and 1198781198631 1198781198631 was calculated using(22)-(24) From the 119878119863119873119873 parameter and SD119889119868119861119868 (see (23))1198781198632 was calculated with (25) the area 119864119901119860119903119890119886 with (26) andfinally the ratio 119878119863119903119886119905119894119900 with (27) [41]

The Poincare plot represents the healthy case by a largeellipse area and small for critical diseases To perform theanalysis of Poincare periods between 5 to 20 minutes arerecommended [6] On the other hand [42 43] observed thata lowest 119878119863119903119886119905119894119900 value is present in healthy subjects In thesame way a small value in 1198781198631 for diseased subjects indicatesweakening of parasympathetic regulation by health disorder

8 Wireless Communications and Mobile Computing

As 1198781198632 decreases the SNS activity increases Figure 7 showsan arrhythmia case from the signal 215 (MITBIH) in which itcan observed that the most of the samples are focused in thecenter of the plot and represent a small ellipse area

119889119868119861119868 [119909] = 119898119868119861119868 [119909 + 1] minus 119898119868119861119868 [119909] (21)

119889119868119861119868119898119890119886119899 = sum119873119909=0 (119889119868119861119868 [119909])119873 (22)

SD119889119868119861119868 = radic sum119873119909=0 1003816100381610038161003816119889119868119861119868 [119909] minus 11988911986811986111986811989811989011988611989910038161003816100381610038162119873 (23)

1198781198631 = radic05 lowast SD1198891198681198611198682 (24)

1198781198632 = radic(2 lowast 1198781198631198731198732) minus (05 lowast SD1198891198681198611198682) (25)

119864119901119860119903119890119886 = 120587 lowast 1198781198631 lowast 1198781198632 (26)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(d119868119861119868)119878119863119903119886119905119894119900 = 11987811986311198781198632 (27)

225 Triangular Geometric Analysis Triangular geometricanalysis is usually considered as part of the analysis in thetime domain However it deserves further explanation sinceit is more complex than the rest This analysis is doneby calculating the histogram of the vector 119898119868119861119868 throughwhich two parameters can be calculated the triangular index(119877119877119879119903119894119899) and the index of triangular interpolation of the baseof the histogram (119879119868119873119873) The 119877119877119879119903119894119899 is equal to the totalnumber of RR intervals divided by the maximum value of thehistogram (119881119886119897119898119886119909) (28) This index gives an overall estimateof the HRV The width of the bins used in this analysiswas set to 78125 ms The 119879119868119873119873 index gives a value on thedistribution of the density of all the RR intervals as the baseof a triangle and it is usually calculated by means of a leastsquares estimateThus119860119903119890119886119905119894119899119899 (see (29)) was minimized andthe limiting points N and M were found Then 119879119868119873119873 wascalculated with (30) see Figure 8 [44]

119877119877119879119903119894119899 = 119873119881119886119897119898119886119909 (28)

119860119903119890119886119905119894119899119899 = intinfin0

(119863 (119905) minus 119902 (119905))2 119889119905 (29)

where 119863 is histogram output 119902 defines the base of triangle thatfits histogram and its cero for 119905 le 119873 119905 ge 119872 and 119902(119883) = 119884

119879119868119873119873 = 119872 minus 119873 (30)

where 119872 and 119873 are the limits of 11986011990311989011988611990511989411989911989923 Parameters and Databases Used to Evaluate the Perfor-mance of QRSDetector In order to compare the performanceof the QRS detector with those found in the literature weused the sensitivity parameter (119878119864) (see (31)) the positive

600 650 700 750 800 850 900 950 1000Time in ms

0

50

100

150

200

250

600 650 700 750 800 850 900 950 1000Time in (ms)

0

50

100

150

200

250

Y

N X M

Figure 8 Points of the histogram used to calculate the indexes ofthe triangular geometric analysis

predictive value (119875119875) (see (32)) and the percentage of theprediction error rate (119863119864119877) (see (33)) 119863119864119877 was also used toevaluate the accuracy of the algorithm

119878119864 = 119879119875119879119875 + 119865119873 lowast 100 (31)

119875119875 = 119879119875119879119875 + 119865119875 lowast 100 (32)

119863119864119877 = 119865119875 + 119865119873119879119875 lowast 100 (33)

where119879119875 are the true positives in detecting the 119877119908119886V119890 119865119873 arethe 119877119908119886V119890 peaks that have not been detected and 119865119875 are thepeaks that have been mistakenly detected as 119877119908119886V119890

In order to validate and compare our proposed algo-rithm for QRS complex detection the MIT-BIT arrhythmiadatabase (MITBIH) and the normal sinus rhythm database(NSRDB) both available online were used [45] Then theresults obtained were compared with other algorithms tosee their effectiveness The MITBIH database consists of 48recordings Each recording has two signals extracted fromhalf hour of a 24-hour recording which have been sampledat 360 Hz and belong to 47 patients in total The NSRDBdatabase contains 18 signals with a duration of 130 minutessampled at 128 Hz and belong to healthy adults aged 20 to 50years

24 Implementation on an MCU The MCU used for theimplementation of the QRS detector and the HRV analysiswas an STM32F407ZET6 MCU Two features can be high-lighted for the present study it has a set of instructions fordigital signal processing (DSP) and a floating point process-ing unit (FPU) whichmake it anMCUcapable of performingadvanced digital processing calculations Likewise it has aflash program memory of 512 Kbyte 192 Kbyte of SRAMmemory and a working frequency of 168 MHz

TheDSP libraries provided by CMSIS (Cortex Microcon-troller Software Interface Standard) were used for the signal

Wireless Communications and Mobile Computing 9

Figure 9 Analysis of the HRV in real time

Figure 10 Analysis of the HRV in frequency domain

processing and the open source wavelib library [46] was usedfor the wavelet implementation The wavelib library had tobe modified and optimized in terms of RAM resources to beused in an MCU

The MCU accessed the MITBIH and NSRDB databasesthrough a microSD card memory in which each recordingwas stored in a separate text data file They were processed inreal time in blocks of 1024 data The block size was chosen fortwo reasons the first one because this number of samples isenough to apply theDWTwith 7 levels of decomposition andthe second because the amount of RAM required is constant(25 kB) and did not compromise the rest of calculationsIt is worth explaining that for an application in real lifethe MCU could acquire data in real time from two externalsources selecting only one at a time The first one wouldinvolve a serial port through the HC-05 Bluetooth moduleat a baud rate of 230400 The second one could use theAD8232 module using the digital analog converter (ADC)with a sampling frequency of 500Hz In both cases interruptscould be used being activated whenever there is a new dataavailable Thus even while the signal is being processed theMCU can continue to fill new buffers for further processingTo display the data locally two LCD screens SSD1306 of128x64 pixels were incorporated using the I2C protocol Anexample of the information displayed on LCD are show inthe Figures 9 and 10 Figure 9 shows the data displayed inreal time while Figure 10 shows the analysis in the frequencydomain for the signal 215 (MITBIH database)

To reduceRAMconsumptionwhenprocessing the signalthe following programming techniques were applied

(i) Avoiding the creations of arrays or matrices withinfunctions it is better to use loops and perform thecorresponding calculations in each iteration

typedef union unsigned uint8 t AllFlags

struct unsigned flag 01

unsigned flag 11

unsigned flag 21

unsigned flag 31

unsigned flag 41

unsigned flag 51

unsigned flag 61

unsigned flag 71 DeviceStatusFlags

DeviceStatusFlags Flags

Used Bytes in RAM 1

uint8 t flag 0

uint8 t flag 1

uint8 t flag 2

uint8 t flag 3

uint8 t flag 4

uint8 t flag 5

uint8 t flag 6

uint8 t flag 7

Used Bytes in RAM 8

Code 1 Efficient use of RAMmemory using structures and unions

(ii) If possible using the input variables as output vari-ables in functions so that new variables are notneeded

(iii) Making use of structures and unions to pack data andtake control of system flags in this way the amount ofRAM required is fully utilized For example in Code 1you can see that less RAM is required using structuresand unions for the same number of flags

For example in Code 2 it is assumed that the inputvariable 119910 has a size of 2000 data In Matlab 64047 bytesis required to perform the same calculation (remove lineartrend) since it does so bymeans of arrays while the algorithmof Code 2 occupied only 48 bytes in the MCU (12 119891119897119900119886119905variables and an 119894119899119905 variable that require 4 bytes each one)since the result was stored in the same input variable

The algorithms optimized following the ideas shown inCode 2 were the average filter the peak detection and thethreshold updating in the QRS detector the calculation of119894119878119863119873119873 and 119878119863119860119873119873 the application of DWT (see (10)) thelinear trend removal (see (12)) and the calculation of the PSD(see (15))

3 Results

The results of Table 2 correspond to the performance of theQRS detector when evaluated with the MITBIH database119863119861 is the number of detected beats and 119879119861 is the totalnumber of beats in each ECG signal It can be observed that109086 pulses of a total of 109494 have been detected 108713

10 Wireless Communications and Mobile Computing

void arm lineal detrend f32 (float 32 t lowast y int size) float 32 t abcdefx1x2C1C2determinant

int i

a=0b=0c=0d=0e=0f=0

x2=1

determinant=0

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size create a slope

a=a+(x1 lowast x1)

b=b+x1

c=c+x1

d=d+x2

e=e+(x1 lowast y [ i ] )f=f+(x2 lowast y [ i ] )

determinant = a lowast d - b lowast c

if ( isnan (determinant) | | isinf(determinant)) return else

C1 = (e lowast d - b lowast f)determinant resolve the System

C2 = (a lowast f - e lowast c)determinant to find the coefficients C1 and C2

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size

y [ i ] =y [ i ] -(x1 lowast C1+C2) remove lineal trendCode 2 C-code to eliminate the linear trend

Table 2 Parameters used to evaluate the QRS detector

Record No TB DB TP FP FN SE PP DERTotal 109494 109086 108713 373 781 9930 9961 112

were true positives 781 were false negative and 373 werefalse positives In addition the QRS detector showed a 119878119864 of9930with a positive prediction of 9961 and an error ratein the detection of pulses of 112

Table 3 shows the results obtained between the differentalgorithms found in the literature and ours using the MIT-BIH database The results we have obtained are a little worseHowever the difference between the algorithm with better 119878119864[34] and ours is only 057 In119875119875 the difference with respectto [35] is 030 and in119863119864119877 the differencewith respect to [36]is only 084

Table 4 shows the comparison between the resultsobtained by our algorithm and those obtained by [32] usingthe 119873119878119877119863119861 database In this comparison [32] has betterresults than us in 119878119864 and 119875119875 by 001 while 119863119864119877 is only00002 better

The time required by the MCU for the HRV analysis willvary according to the size of the IBI vector Table 5 shows theexecution times that were required to analyze the signal 215 oftheMITBIH databaseThis particular file was chosen becauseit contains more QRS complex than the rest of the signals(3358 found by our algorithm)

On the other hand the execution times for the QRSdetector will always be the same (47ms for detection and 5msfor saving in a microSD the temporary location of the 119877119908119886V119890found) because the length of the input vector has a constantsize (1024 samples)

The time required to fill the 1024 data buffer is 1024 lowast(1119891119904) where 119891119904 is the sampling frequency In the case ofthe MITBIH 119891119904 is 360 Hz so it would take 284 s to fill itIn the case of the NSRDB 119891119904 is 128 Hz so that it would take8 s In both cases the detection of the QRS complex can bedone in real time since it only takes 52 ms The detector mayoperate in real time up to a maximum sampling frequencyof 195 kHz However some studies show that 500 Hz is avery reliable frequency forHRV analysis [47] Our system caneasily achieve real time for this recommended frequency

Although the times required for the analysis of the HRVvary depending on the size of 119868119861119868 inTable 5 it can be seen thatthe smoothing of the signal using wavelets and the analysis inthe frequency domain required more time for its executionOn the other side the Poincare analysis was the fastest Thetime required for the complete HRV analysis of signal 215(MITBIH database) was 4401 s

Wireless Communications and Mobile Computing 11

Table 3 Comparison of the results obtained using different algorithm in the MITBIH database

DB TP FP FN SE PP DERJP Martınez et al [31] 109428 109208 153 220 9980 9986 034J Pan amp Tompkins [11] 109809 109532 507 277 9975 9954 071Gutierrez-Rivas et al [32] - 109447 289 502 9954 9973 -Chouakri et al [33] 109488 108043 3068 1446 9868 9724 412Santanu et al [34] 109666 109351 315 144 9987 9969 042Moody amp Mark [35] 109428 107567 94 1861 9830 9991 179Merah et al[36] 109494 109316 126 178 9984 9988 028Proposed algorithm 109086 108713 373 781 9930 9961 112

Table 4 Comparison of the results using the NSRDB database

Algorithm TB TP FP FN SE PP DERGutierrez-Rivas et al [32] 192389 192325 64 17 9996 9999 00004Proposed algorithm 192389 192297 92 25 9995 9998 00006

Refreshing the LCD screens took 50 ms and it was donewhile the buffer was filling so that the update times of thescreens had no influence on the calculations of the HRV

The execution time on a regular PC with the processingperformed inMatlab is also shown in Table 5 for comparisonIt is lower than in the MCU implementation because of thepowerful processor The idea is not to be competitive witha PC server in this aspect but to avoid transmitting data toa server in the cloud which would be a great burden forthe network In addition this would imply a higher powerconsumption for the sensor node For instance the proposedsystem has these power consumption contributions 42 mAfor the MCU in sleep mode 49 mA while processing asignal from a micro SD card 75 mA while processing signalsfrom AD8232 or 169 mA while processing signals fromBluetooth (HC-05 module) Thus it is clear that avoidingcommunication is of great interest

4 Conclusions and Future Work

The results obtained with the QRS detector that we haveproposed based on wavelets and with automatic selection ofthe coefficients of the details have been higher than 99 in119878119864 and 119875119875 using the MITBIH database They are worse thanprevious studies but the difference does not exceed 09 inany of the parameters used in that comparison (119878119864 119875119875 119863119864119877)On the other hand using the NSRDB database the resultshave been better (119878119864 = 9995 119875119875 = 9998 and 119863119864119877 =00006) In comparison with [32] SE and PP have been only001 lower

The QRS detection algorithm was followed by an HRVanalysis In both stages several algorithms had to be opti-mized for the implementation on an MCU Thanks to theefficient use of RAM it has beenpossible to develop thewholeHRV analysis as a standalone application embedded on anMCU ARM

With the execution times shown in Table 5 it has beenshown that theQRSdetector is capable of running in real timefor the most common frequencies used in ECGs Likewise

given that some parameters such as 119868119861119868119898119890119886119899 119878119863119873119873119877119872119878119878119863and 119867119877119898119890119886119899 require very little time for their execution andthat they are in the time domain they could be displayed bysending them via Bluetooth or Wifi to a mobile applicationIn this way an HRV analysis would be done in real time Inaddition the energy consumption is low so it can facilitate itsintegration on portable devices

The time required for the complete analysis of the HRVwill be variable (depending on the amount of data) but it willbe in the order of seconds for practical purposes making it aviable application

Our system could also help in applications like the oneshown in [25] in which HRV and location are measured toevaluate wellness and recommend a place to live accordinglyAll the RR intervals are sent to the userrsquos mobile phone andfrom it to a server in which a time domain parameter of HRVis calculated The system could be improved if the wearabledevice measured itself HRV avoiding the battery consum-ing process of the communication with the mobile phoneBesides our system can calculate all the HRV parametersand could improve the determination of the userrsquos wellnessAnother application of our system could be the integrationinto the system to monitor asthma disease presented in [26]in which the heart rate is also a key component

This system developed on an ARM MCU could be com-plemented by developing a mobile application that displaysthe results of the HRV analysis in a more adequate wayto the user showing comparisons or statistics with respectto previous analyses In this way the user would get bettercontrol over hisher HRV

As future work several lines are devised In the first onethe QRS detector will be improved to obtain better resultsthan those seen in Tables 3 and 4 The second line will bedevoted to the optimization of the proposed system code tointegrate it in the most optimal way into an 119868119900119879 networkIt can be tested using Wifi ZigBee or Bluetooth networksfor short ranges For instance it could receive informationfrom a network edge and then send back to a server onlythe HRV results to be displayed This will help to improve

12 Wireless Communications and Mobile Computing

Table 5 Time required for HRV analysis of the signal 215 (MITBIH database)

Main function Sub functions (ms) Execution time (ms) inMCU

Execution time (ms) inIntel i7 (MatLab)

Detector QRS 47 39DWT perform (37)First difference (lt1)Squared signal (lt3)Filter average (lt3)

Find peaks and update threshold (lt3)Save data to SD 5 -Preprocessing Remove Artifacts 3 1Time DomainHRV 30 9

119868119861119868119898119890119886119899 (lt1)119867119877119898119890119886119899 (1)119878119863119873119873 (lt1)119894119878119863119873119873 (12)119878119863119860119873119873 (11)119877119872119878119878119863 (lt1)

11990111987311987350 11987311987350 (1)119867119877119904119905119889 (1)119872119886119909 (lt1)119872119894119899 (lt1)

Geometrictriangular HRV 89 2

119877119877119879119903119894119899 (17)119879119868119873119873 (62)

Poincare HRV 1 11198781198631 1198781198632 119886119899119889 119864119901119860119903119890119886 (1)

Refresh LCD 50 -FrequencyDomain HRV 4176 163

119868119861119868119904119898119900119900119905ℎ (2084)119905 (lt1)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 (1331)119875119878119863119904119894119892119899119886119897 (302)

119881119871119865 119871119865 119867119865 119871119865119867119865 119871119865119899119900119903119898119886119897119894119911119890119889 and119867119865119899119900119903119898119886119897119894119911119890119889 (458)

mHealth and eHealth services using systems embedded inmicrocontrollers On the other hand we will work to makethe proposed device as small as possible similar to smartband In this way it will be able to track heart rate variabilityduring the daily activity

Data Availability

The data supporting this study are from previously reportedstudies and datasets which have been cited or are includedwithin the article

Conflicts of Interest

The authors declare that they have no conflicts of interest

Acknowledgments

The authors would like to thank the ldquoFondo Social Europeordquothe ldquoDiputacion General de Aragonrdquo (reference groupEduQTech T49 17R) Victor H Rodriguez acknowledges agrant from ldquoCONACYT-Gobierno del Estado de DurangoMexico 330795386043rdquo

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 8: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

8 Wireless Communications and Mobile Computing

As 1198781198632 decreases the SNS activity increases Figure 7 showsan arrhythmia case from the signal 215 (MITBIH) in which itcan observed that the most of the samples are focused in thecenter of the plot and represent a small ellipse area

119889119868119861119868 [119909] = 119898119868119861119868 [119909 + 1] minus 119898119868119861119868 [119909] (21)

119889119868119861119868119898119890119886119899 = sum119873119909=0 (119889119868119861119868 [119909])119873 (22)

SD119889119868119861119868 = radic sum119873119909=0 1003816100381610038161003816119889119868119861119868 [119909] minus 11988911986811986111986811989811989011988611989910038161003816100381610038162119873 (23)

1198781198631 = radic05 lowast SD1198891198681198611198682 (24)

1198781198632 = radic(2 lowast 1198781198631198731198732) minus (05 lowast SD1198891198681198611198682) (25)

119864119901119860119903119890119886 = 120587 lowast 1198781198631 lowast 1198781198632 (26)

where 119909 = 0 1 119873 and 119873 = 119897119890119899119892119905ℎ(d119868119861119868)119878119863119903119886119905119894119900 = 11987811986311198781198632 (27)

225 Triangular Geometric Analysis Triangular geometricanalysis is usually considered as part of the analysis in thetime domain However it deserves further explanation sinceit is more complex than the rest This analysis is doneby calculating the histogram of the vector 119898119868119861119868 throughwhich two parameters can be calculated the triangular index(119877119877119879119903119894119899) and the index of triangular interpolation of the baseof the histogram (119879119868119873119873) The 119877119877119879119903119894119899 is equal to the totalnumber of RR intervals divided by the maximum value of thehistogram (119881119886119897119898119886119909) (28) This index gives an overall estimateof the HRV The width of the bins used in this analysiswas set to 78125 ms The 119879119868119873119873 index gives a value on thedistribution of the density of all the RR intervals as the baseof a triangle and it is usually calculated by means of a leastsquares estimateThus119860119903119890119886119905119894119899119899 (see (29)) was minimized andthe limiting points N and M were found Then 119879119868119873119873 wascalculated with (30) see Figure 8 [44]

119877119877119879119903119894119899 = 119873119881119886119897119898119886119909 (28)

119860119903119890119886119905119894119899119899 = intinfin0

(119863 (119905) minus 119902 (119905))2 119889119905 (29)

where 119863 is histogram output 119902 defines the base of triangle thatfits histogram and its cero for 119905 le 119873 119905 ge 119872 and 119902(119883) = 119884

119879119868119873119873 = 119872 minus 119873 (30)

where 119872 and 119873 are the limits of 11986011990311989011988611990511989411989911989923 Parameters and Databases Used to Evaluate the Perfor-mance of QRSDetector In order to compare the performanceof the QRS detector with those found in the literature weused the sensitivity parameter (119878119864) (see (31)) the positive

600 650 700 750 800 850 900 950 1000Time in ms

0

50

100

150

200

250

600 650 700 750 800 850 900 950 1000Time in (ms)

0

50

100

150

200

250

Y

N X M

Figure 8 Points of the histogram used to calculate the indexes ofthe triangular geometric analysis

predictive value (119875119875) (see (32)) and the percentage of theprediction error rate (119863119864119877) (see (33)) 119863119864119877 was also used toevaluate the accuracy of the algorithm

119878119864 = 119879119875119879119875 + 119865119873 lowast 100 (31)

119875119875 = 119879119875119879119875 + 119865119875 lowast 100 (32)

119863119864119877 = 119865119875 + 119865119873119879119875 lowast 100 (33)

where119879119875 are the true positives in detecting the 119877119908119886V119890 119865119873 arethe 119877119908119886V119890 peaks that have not been detected and 119865119875 are thepeaks that have been mistakenly detected as 119877119908119886V119890

In order to validate and compare our proposed algo-rithm for QRS complex detection the MIT-BIT arrhythmiadatabase (MITBIH) and the normal sinus rhythm database(NSRDB) both available online were used [45] Then theresults obtained were compared with other algorithms tosee their effectiveness The MITBIH database consists of 48recordings Each recording has two signals extracted fromhalf hour of a 24-hour recording which have been sampledat 360 Hz and belong to 47 patients in total The NSRDBdatabase contains 18 signals with a duration of 130 minutessampled at 128 Hz and belong to healthy adults aged 20 to 50years

24 Implementation on an MCU The MCU used for theimplementation of the QRS detector and the HRV analysiswas an STM32F407ZET6 MCU Two features can be high-lighted for the present study it has a set of instructions fordigital signal processing (DSP) and a floating point process-ing unit (FPU) whichmake it anMCUcapable of performingadvanced digital processing calculations Likewise it has aflash program memory of 512 Kbyte 192 Kbyte of SRAMmemory and a working frequency of 168 MHz

TheDSP libraries provided by CMSIS (Cortex Microcon-troller Software Interface Standard) were used for the signal

Wireless Communications and Mobile Computing 9

Figure 9 Analysis of the HRV in real time

Figure 10 Analysis of the HRV in frequency domain

processing and the open source wavelib library [46] was usedfor the wavelet implementation The wavelib library had tobe modified and optimized in terms of RAM resources to beused in an MCU

The MCU accessed the MITBIH and NSRDB databasesthrough a microSD card memory in which each recordingwas stored in a separate text data file They were processed inreal time in blocks of 1024 data The block size was chosen fortwo reasons the first one because this number of samples isenough to apply theDWTwith 7 levels of decomposition andthe second because the amount of RAM required is constant(25 kB) and did not compromise the rest of calculationsIt is worth explaining that for an application in real lifethe MCU could acquire data in real time from two externalsources selecting only one at a time The first one wouldinvolve a serial port through the HC-05 Bluetooth moduleat a baud rate of 230400 The second one could use theAD8232 module using the digital analog converter (ADC)with a sampling frequency of 500Hz In both cases interruptscould be used being activated whenever there is a new dataavailable Thus even while the signal is being processed theMCU can continue to fill new buffers for further processingTo display the data locally two LCD screens SSD1306 of128x64 pixels were incorporated using the I2C protocol Anexample of the information displayed on LCD are show inthe Figures 9 and 10 Figure 9 shows the data displayed inreal time while Figure 10 shows the analysis in the frequencydomain for the signal 215 (MITBIH database)

To reduceRAMconsumptionwhenprocessing the signalthe following programming techniques were applied

(i) Avoiding the creations of arrays or matrices withinfunctions it is better to use loops and perform thecorresponding calculations in each iteration

typedef union unsigned uint8 t AllFlags

struct unsigned flag 01

unsigned flag 11

unsigned flag 21

unsigned flag 31

unsigned flag 41

unsigned flag 51

unsigned flag 61

unsigned flag 71 DeviceStatusFlags

DeviceStatusFlags Flags

Used Bytes in RAM 1

uint8 t flag 0

uint8 t flag 1

uint8 t flag 2

uint8 t flag 3

uint8 t flag 4

uint8 t flag 5

uint8 t flag 6

uint8 t flag 7

Used Bytes in RAM 8

Code 1 Efficient use of RAMmemory using structures and unions

(ii) If possible using the input variables as output vari-ables in functions so that new variables are notneeded

(iii) Making use of structures and unions to pack data andtake control of system flags in this way the amount ofRAM required is fully utilized For example in Code 1you can see that less RAM is required using structuresand unions for the same number of flags

For example in Code 2 it is assumed that the inputvariable 119910 has a size of 2000 data In Matlab 64047 bytesis required to perform the same calculation (remove lineartrend) since it does so bymeans of arrays while the algorithmof Code 2 occupied only 48 bytes in the MCU (12 119891119897119900119886119905variables and an 119894119899119905 variable that require 4 bytes each one)since the result was stored in the same input variable

The algorithms optimized following the ideas shown inCode 2 were the average filter the peak detection and thethreshold updating in the QRS detector the calculation of119894119878119863119873119873 and 119878119863119860119873119873 the application of DWT (see (10)) thelinear trend removal (see (12)) and the calculation of the PSD(see (15))

3 Results

The results of Table 2 correspond to the performance of theQRS detector when evaluated with the MITBIH database119863119861 is the number of detected beats and 119879119861 is the totalnumber of beats in each ECG signal It can be observed that109086 pulses of a total of 109494 have been detected 108713

10 Wireless Communications and Mobile Computing

void arm lineal detrend f32 (float 32 t lowast y int size) float 32 t abcdefx1x2C1C2determinant

int i

a=0b=0c=0d=0e=0f=0

x2=1

determinant=0

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size create a slope

a=a+(x1 lowast x1)

b=b+x1

c=c+x1

d=d+x2

e=e+(x1 lowast y [ i ] )f=f+(x2 lowast y [ i ] )

determinant = a lowast d - b lowast c

if ( isnan (determinant) | | isinf(determinant)) return else

C1 = (e lowast d - b lowast f)determinant resolve the System

C2 = (a lowast f - e lowast c)determinant to find the coefficients C1 and C2

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size

y [ i ] =y [ i ] -(x1 lowast C1+C2) remove lineal trendCode 2 C-code to eliminate the linear trend

Table 2 Parameters used to evaluate the QRS detector

Record No TB DB TP FP FN SE PP DERTotal 109494 109086 108713 373 781 9930 9961 112

were true positives 781 were false negative and 373 werefalse positives In addition the QRS detector showed a 119878119864 of9930with a positive prediction of 9961 and an error ratein the detection of pulses of 112

Table 3 shows the results obtained between the differentalgorithms found in the literature and ours using the MIT-BIH database The results we have obtained are a little worseHowever the difference between the algorithm with better 119878119864[34] and ours is only 057 In119875119875 the difference with respectto [35] is 030 and in119863119864119877 the differencewith respect to [36]is only 084

Table 4 shows the comparison between the resultsobtained by our algorithm and those obtained by [32] usingthe 119873119878119877119863119861 database In this comparison [32] has betterresults than us in 119878119864 and 119875119875 by 001 while 119863119864119877 is only00002 better

The time required by the MCU for the HRV analysis willvary according to the size of the IBI vector Table 5 shows theexecution times that were required to analyze the signal 215 oftheMITBIH databaseThis particular file was chosen becauseit contains more QRS complex than the rest of the signals(3358 found by our algorithm)

On the other hand the execution times for the QRSdetector will always be the same (47ms for detection and 5msfor saving in a microSD the temporary location of the 119877119908119886V119890found) because the length of the input vector has a constantsize (1024 samples)

The time required to fill the 1024 data buffer is 1024 lowast(1119891119904) where 119891119904 is the sampling frequency In the case ofthe MITBIH 119891119904 is 360 Hz so it would take 284 s to fill itIn the case of the NSRDB 119891119904 is 128 Hz so that it would take8 s In both cases the detection of the QRS complex can bedone in real time since it only takes 52 ms The detector mayoperate in real time up to a maximum sampling frequencyof 195 kHz However some studies show that 500 Hz is avery reliable frequency forHRV analysis [47] Our system caneasily achieve real time for this recommended frequency

Although the times required for the analysis of the HRVvary depending on the size of 119868119861119868 inTable 5 it can be seen thatthe smoothing of the signal using wavelets and the analysis inthe frequency domain required more time for its executionOn the other side the Poincare analysis was the fastest Thetime required for the complete HRV analysis of signal 215(MITBIH database) was 4401 s

Wireless Communications and Mobile Computing 11

Table 3 Comparison of the results obtained using different algorithm in the MITBIH database

DB TP FP FN SE PP DERJP Martınez et al [31] 109428 109208 153 220 9980 9986 034J Pan amp Tompkins [11] 109809 109532 507 277 9975 9954 071Gutierrez-Rivas et al [32] - 109447 289 502 9954 9973 -Chouakri et al [33] 109488 108043 3068 1446 9868 9724 412Santanu et al [34] 109666 109351 315 144 9987 9969 042Moody amp Mark [35] 109428 107567 94 1861 9830 9991 179Merah et al[36] 109494 109316 126 178 9984 9988 028Proposed algorithm 109086 108713 373 781 9930 9961 112

Table 4 Comparison of the results using the NSRDB database

Algorithm TB TP FP FN SE PP DERGutierrez-Rivas et al [32] 192389 192325 64 17 9996 9999 00004Proposed algorithm 192389 192297 92 25 9995 9998 00006

Refreshing the LCD screens took 50 ms and it was donewhile the buffer was filling so that the update times of thescreens had no influence on the calculations of the HRV

The execution time on a regular PC with the processingperformed inMatlab is also shown in Table 5 for comparisonIt is lower than in the MCU implementation because of thepowerful processor The idea is not to be competitive witha PC server in this aspect but to avoid transmitting data toa server in the cloud which would be a great burden forthe network In addition this would imply a higher powerconsumption for the sensor node For instance the proposedsystem has these power consumption contributions 42 mAfor the MCU in sleep mode 49 mA while processing asignal from a micro SD card 75 mA while processing signalsfrom AD8232 or 169 mA while processing signals fromBluetooth (HC-05 module) Thus it is clear that avoidingcommunication is of great interest

4 Conclusions and Future Work

The results obtained with the QRS detector that we haveproposed based on wavelets and with automatic selection ofthe coefficients of the details have been higher than 99 in119878119864 and 119875119875 using the MITBIH database They are worse thanprevious studies but the difference does not exceed 09 inany of the parameters used in that comparison (119878119864 119875119875 119863119864119877)On the other hand using the NSRDB database the resultshave been better (119878119864 = 9995 119875119875 = 9998 and 119863119864119877 =00006) In comparison with [32] SE and PP have been only001 lower

The QRS detection algorithm was followed by an HRVanalysis In both stages several algorithms had to be opti-mized for the implementation on an MCU Thanks to theefficient use of RAM it has beenpossible to develop thewholeHRV analysis as a standalone application embedded on anMCU ARM

With the execution times shown in Table 5 it has beenshown that theQRSdetector is capable of running in real timefor the most common frequencies used in ECGs Likewise

given that some parameters such as 119868119861119868119898119890119886119899 119878119863119873119873119877119872119878119878119863and 119867119877119898119890119886119899 require very little time for their execution andthat they are in the time domain they could be displayed bysending them via Bluetooth or Wifi to a mobile applicationIn this way an HRV analysis would be done in real time Inaddition the energy consumption is low so it can facilitate itsintegration on portable devices

The time required for the complete analysis of the HRVwill be variable (depending on the amount of data) but it willbe in the order of seconds for practical purposes making it aviable application

Our system could also help in applications like the oneshown in [25] in which HRV and location are measured toevaluate wellness and recommend a place to live accordinglyAll the RR intervals are sent to the userrsquos mobile phone andfrom it to a server in which a time domain parameter of HRVis calculated The system could be improved if the wearabledevice measured itself HRV avoiding the battery consum-ing process of the communication with the mobile phoneBesides our system can calculate all the HRV parametersand could improve the determination of the userrsquos wellnessAnother application of our system could be the integrationinto the system to monitor asthma disease presented in [26]in which the heart rate is also a key component

This system developed on an ARM MCU could be com-plemented by developing a mobile application that displaysthe results of the HRV analysis in a more adequate wayto the user showing comparisons or statistics with respectto previous analyses In this way the user would get bettercontrol over hisher HRV

As future work several lines are devised In the first onethe QRS detector will be improved to obtain better resultsthan those seen in Tables 3 and 4 The second line will bedevoted to the optimization of the proposed system code tointegrate it in the most optimal way into an 119868119900119879 networkIt can be tested using Wifi ZigBee or Bluetooth networksfor short ranges For instance it could receive informationfrom a network edge and then send back to a server onlythe HRV results to be displayed This will help to improve

12 Wireless Communications and Mobile Computing

Table 5 Time required for HRV analysis of the signal 215 (MITBIH database)

Main function Sub functions (ms) Execution time (ms) inMCU

Execution time (ms) inIntel i7 (MatLab)

Detector QRS 47 39DWT perform (37)First difference (lt1)Squared signal (lt3)Filter average (lt3)

Find peaks and update threshold (lt3)Save data to SD 5 -Preprocessing Remove Artifacts 3 1Time DomainHRV 30 9

119868119861119868119898119890119886119899 (lt1)119867119877119898119890119886119899 (1)119878119863119873119873 (lt1)119894119878119863119873119873 (12)119878119863119860119873119873 (11)119877119872119878119878119863 (lt1)

11990111987311987350 11987311987350 (1)119867119877119904119905119889 (1)119872119886119909 (lt1)119872119894119899 (lt1)

Geometrictriangular HRV 89 2

119877119877119879119903119894119899 (17)119879119868119873119873 (62)

Poincare HRV 1 11198781198631 1198781198632 119886119899119889 119864119901119860119903119890119886 (1)

Refresh LCD 50 -FrequencyDomain HRV 4176 163

119868119861119868119904119898119900119900119905ℎ (2084)119905 (lt1)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 (1331)119875119878119863119904119894119892119899119886119897 (302)

119881119871119865 119871119865 119867119865 119871119865119867119865 119871119865119899119900119903119898119886119897119894119911119890119889 and119867119865119899119900119903119898119886119897119894119911119890119889 (458)

mHealth and eHealth services using systems embedded inmicrocontrollers On the other hand we will work to makethe proposed device as small as possible similar to smartband In this way it will be able to track heart rate variabilityduring the daily activity

Data Availability

The data supporting this study are from previously reportedstudies and datasets which have been cited or are includedwithin the article

Conflicts of Interest

The authors declare that they have no conflicts of interest

Acknowledgments

The authors would like to thank the ldquoFondo Social Europeordquothe ldquoDiputacion General de Aragonrdquo (reference groupEduQTech T49 17R) Victor H Rodriguez acknowledges agrant from ldquoCONACYT-Gobierno del Estado de DurangoMexico 330795386043rdquo

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 9: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

Wireless Communications and Mobile Computing 9

Figure 9 Analysis of the HRV in real time

Figure 10 Analysis of the HRV in frequency domain

processing and the open source wavelib library [46] was usedfor the wavelet implementation The wavelib library had tobe modified and optimized in terms of RAM resources to beused in an MCU

The MCU accessed the MITBIH and NSRDB databasesthrough a microSD card memory in which each recordingwas stored in a separate text data file They were processed inreal time in blocks of 1024 data The block size was chosen fortwo reasons the first one because this number of samples isenough to apply theDWTwith 7 levels of decomposition andthe second because the amount of RAM required is constant(25 kB) and did not compromise the rest of calculationsIt is worth explaining that for an application in real lifethe MCU could acquire data in real time from two externalsources selecting only one at a time The first one wouldinvolve a serial port through the HC-05 Bluetooth moduleat a baud rate of 230400 The second one could use theAD8232 module using the digital analog converter (ADC)with a sampling frequency of 500Hz In both cases interruptscould be used being activated whenever there is a new dataavailable Thus even while the signal is being processed theMCU can continue to fill new buffers for further processingTo display the data locally two LCD screens SSD1306 of128x64 pixels were incorporated using the I2C protocol Anexample of the information displayed on LCD are show inthe Figures 9 and 10 Figure 9 shows the data displayed inreal time while Figure 10 shows the analysis in the frequencydomain for the signal 215 (MITBIH database)

To reduceRAMconsumptionwhenprocessing the signalthe following programming techniques were applied

(i) Avoiding the creations of arrays or matrices withinfunctions it is better to use loops and perform thecorresponding calculations in each iteration

typedef union unsigned uint8 t AllFlags

struct unsigned flag 01

unsigned flag 11

unsigned flag 21

unsigned flag 31

unsigned flag 41

unsigned flag 51

unsigned flag 61

unsigned flag 71 DeviceStatusFlags

DeviceStatusFlags Flags

Used Bytes in RAM 1

uint8 t flag 0

uint8 t flag 1

uint8 t flag 2

uint8 t flag 3

uint8 t flag 4

uint8 t flag 5

uint8 t flag 6

uint8 t flag 7

Used Bytes in RAM 8

Code 1 Efficient use of RAMmemory using structures and unions

(ii) If possible using the input variables as output vari-ables in functions so that new variables are notneeded

(iii) Making use of structures and unions to pack data andtake control of system flags in this way the amount ofRAM required is fully utilized For example in Code 1you can see that less RAM is required using structuresand unions for the same number of flags

For example in Code 2 it is assumed that the inputvariable 119910 has a size of 2000 data In Matlab 64047 bytesis required to perform the same calculation (remove lineartrend) since it does so bymeans of arrays while the algorithmof Code 2 occupied only 48 bytes in the MCU (12 119891119897119900119886119905variables and an 119894119899119905 variable that require 4 bytes each one)since the result was stored in the same input variable

The algorithms optimized following the ideas shown inCode 2 were the average filter the peak detection and thethreshold updating in the QRS detector the calculation of119894119878119863119873119873 and 119878119863119860119873119873 the application of DWT (see (10)) thelinear trend removal (see (12)) and the calculation of the PSD(see (15))

3 Results

The results of Table 2 correspond to the performance of theQRS detector when evaluated with the MITBIH database119863119861 is the number of detected beats and 119879119861 is the totalnumber of beats in each ECG signal It can be observed that109086 pulses of a total of 109494 have been detected 108713

10 Wireless Communications and Mobile Computing

void arm lineal detrend f32 (float 32 t lowast y int size) float 32 t abcdefx1x2C1C2determinant

int i

a=0b=0c=0d=0e=0f=0

x2=1

determinant=0

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size create a slope

a=a+(x1 lowast x1)

b=b+x1

c=c+x1

d=d+x2

e=e+(x1 lowast y [ i ] )f=f+(x2 lowast y [ i ] )

determinant = a lowast d - b lowast c

if ( isnan (determinant) | | isinf(determinant)) return else

C1 = (e lowast d - b lowast f)determinant resolve the System

C2 = (a lowast f - e lowast c)determinant to find the coefficients C1 and C2

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size

y [ i ] =y [ i ] -(x1 lowast C1+C2) remove lineal trendCode 2 C-code to eliminate the linear trend

Table 2 Parameters used to evaluate the QRS detector

Record No TB DB TP FP FN SE PP DERTotal 109494 109086 108713 373 781 9930 9961 112

were true positives 781 were false negative and 373 werefalse positives In addition the QRS detector showed a 119878119864 of9930with a positive prediction of 9961 and an error ratein the detection of pulses of 112

Table 3 shows the results obtained between the differentalgorithms found in the literature and ours using the MIT-BIH database The results we have obtained are a little worseHowever the difference between the algorithm with better 119878119864[34] and ours is only 057 In119875119875 the difference with respectto [35] is 030 and in119863119864119877 the differencewith respect to [36]is only 084

Table 4 shows the comparison between the resultsobtained by our algorithm and those obtained by [32] usingthe 119873119878119877119863119861 database In this comparison [32] has betterresults than us in 119878119864 and 119875119875 by 001 while 119863119864119877 is only00002 better

The time required by the MCU for the HRV analysis willvary according to the size of the IBI vector Table 5 shows theexecution times that were required to analyze the signal 215 oftheMITBIH databaseThis particular file was chosen becauseit contains more QRS complex than the rest of the signals(3358 found by our algorithm)

On the other hand the execution times for the QRSdetector will always be the same (47ms for detection and 5msfor saving in a microSD the temporary location of the 119877119908119886V119890found) because the length of the input vector has a constantsize (1024 samples)

The time required to fill the 1024 data buffer is 1024 lowast(1119891119904) where 119891119904 is the sampling frequency In the case ofthe MITBIH 119891119904 is 360 Hz so it would take 284 s to fill itIn the case of the NSRDB 119891119904 is 128 Hz so that it would take8 s In both cases the detection of the QRS complex can bedone in real time since it only takes 52 ms The detector mayoperate in real time up to a maximum sampling frequencyof 195 kHz However some studies show that 500 Hz is avery reliable frequency forHRV analysis [47] Our system caneasily achieve real time for this recommended frequency

Although the times required for the analysis of the HRVvary depending on the size of 119868119861119868 inTable 5 it can be seen thatthe smoothing of the signal using wavelets and the analysis inthe frequency domain required more time for its executionOn the other side the Poincare analysis was the fastest Thetime required for the complete HRV analysis of signal 215(MITBIH database) was 4401 s

Wireless Communications and Mobile Computing 11

Table 3 Comparison of the results obtained using different algorithm in the MITBIH database

DB TP FP FN SE PP DERJP Martınez et al [31] 109428 109208 153 220 9980 9986 034J Pan amp Tompkins [11] 109809 109532 507 277 9975 9954 071Gutierrez-Rivas et al [32] - 109447 289 502 9954 9973 -Chouakri et al [33] 109488 108043 3068 1446 9868 9724 412Santanu et al [34] 109666 109351 315 144 9987 9969 042Moody amp Mark [35] 109428 107567 94 1861 9830 9991 179Merah et al[36] 109494 109316 126 178 9984 9988 028Proposed algorithm 109086 108713 373 781 9930 9961 112

Table 4 Comparison of the results using the NSRDB database

Algorithm TB TP FP FN SE PP DERGutierrez-Rivas et al [32] 192389 192325 64 17 9996 9999 00004Proposed algorithm 192389 192297 92 25 9995 9998 00006

Refreshing the LCD screens took 50 ms and it was donewhile the buffer was filling so that the update times of thescreens had no influence on the calculations of the HRV

The execution time on a regular PC with the processingperformed inMatlab is also shown in Table 5 for comparisonIt is lower than in the MCU implementation because of thepowerful processor The idea is not to be competitive witha PC server in this aspect but to avoid transmitting data toa server in the cloud which would be a great burden forthe network In addition this would imply a higher powerconsumption for the sensor node For instance the proposedsystem has these power consumption contributions 42 mAfor the MCU in sleep mode 49 mA while processing asignal from a micro SD card 75 mA while processing signalsfrom AD8232 or 169 mA while processing signals fromBluetooth (HC-05 module) Thus it is clear that avoidingcommunication is of great interest

4 Conclusions and Future Work

The results obtained with the QRS detector that we haveproposed based on wavelets and with automatic selection ofthe coefficients of the details have been higher than 99 in119878119864 and 119875119875 using the MITBIH database They are worse thanprevious studies but the difference does not exceed 09 inany of the parameters used in that comparison (119878119864 119875119875 119863119864119877)On the other hand using the NSRDB database the resultshave been better (119878119864 = 9995 119875119875 = 9998 and 119863119864119877 =00006) In comparison with [32] SE and PP have been only001 lower

The QRS detection algorithm was followed by an HRVanalysis In both stages several algorithms had to be opti-mized for the implementation on an MCU Thanks to theefficient use of RAM it has beenpossible to develop thewholeHRV analysis as a standalone application embedded on anMCU ARM

With the execution times shown in Table 5 it has beenshown that theQRSdetector is capable of running in real timefor the most common frequencies used in ECGs Likewise

given that some parameters such as 119868119861119868119898119890119886119899 119878119863119873119873119877119872119878119878119863and 119867119877119898119890119886119899 require very little time for their execution andthat they are in the time domain they could be displayed bysending them via Bluetooth or Wifi to a mobile applicationIn this way an HRV analysis would be done in real time Inaddition the energy consumption is low so it can facilitate itsintegration on portable devices

The time required for the complete analysis of the HRVwill be variable (depending on the amount of data) but it willbe in the order of seconds for practical purposes making it aviable application

Our system could also help in applications like the oneshown in [25] in which HRV and location are measured toevaluate wellness and recommend a place to live accordinglyAll the RR intervals are sent to the userrsquos mobile phone andfrom it to a server in which a time domain parameter of HRVis calculated The system could be improved if the wearabledevice measured itself HRV avoiding the battery consum-ing process of the communication with the mobile phoneBesides our system can calculate all the HRV parametersand could improve the determination of the userrsquos wellnessAnother application of our system could be the integrationinto the system to monitor asthma disease presented in [26]in which the heart rate is also a key component

This system developed on an ARM MCU could be com-plemented by developing a mobile application that displaysthe results of the HRV analysis in a more adequate wayto the user showing comparisons or statistics with respectto previous analyses In this way the user would get bettercontrol over hisher HRV

As future work several lines are devised In the first onethe QRS detector will be improved to obtain better resultsthan those seen in Tables 3 and 4 The second line will bedevoted to the optimization of the proposed system code tointegrate it in the most optimal way into an 119868119900119879 networkIt can be tested using Wifi ZigBee or Bluetooth networksfor short ranges For instance it could receive informationfrom a network edge and then send back to a server onlythe HRV results to be displayed This will help to improve

12 Wireless Communications and Mobile Computing

Table 5 Time required for HRV analysis of the signal 215 (MITBIH database)

Main function Sub functions (ms) Execution time (ms) inMCU

Execution time (ms) inIntel i7 (MatLab)

Detector QRS 47 39DWT perform (37)First difference (lt1)Squared signal (lt3)Filter average (lt3)

Find peaks and update threshold (lt3)Save data to SD 5 -Preprocessing Remove Artifacts 3 1Time DomainHRV 30 9

119868119861119868119898119890119886119899 (lt1)119867119877119898119890119886119899 (1)119878119863119873119873 (lt1)119894119878119863119873119873 (12)119878119863119860119873119873 (11)119877119872119878119878119863 (lt1)

11990111987311987350 11987311987350 (1)119867119877119904119905119889 (1)119872119886119909 (lt1)119872119894119899 (lt1)

Geometrictriangular HRV 89 2

119877119877119879119903119894119899 (17)119879119868119873119873 (62)

Poincare HRV 1 11198781198631 1198781198632 119886119899119889 119864119901119860119903119890119886 (1)

Refresh LCD 50 -FrequencyDomain HRV 4176 163

119868119861119868119904119898119900119900119905ℎ (2084)119905 (lt1)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 (1331)119875119878119863119904119894119892119899119886119897 (302)

119881119871119865 119871119865 119867119865 119871119865119867119865 119871119865119899119900119903119898119886119897119894119911119890119889 and119867119865119899119900119903119898119886119897119894119911119890119889 (458)

mHealth and eHealth services using systems embedded inmicrocontrollers On the other hand we will work to makethe proposed device as small as possible similar to smartband In this way it will be able to track heart rate variabilityduring the daily activity

Data Availability

The data supporting this study are from previously reportedstudies and datasets which have been cited or are includedwithin the article

Conflicts of Interest

The authors declare that they have no conflicts of interest

Acknowledgments

The authors would like to thank the ldquoFondo Social Europeordquothe ldquoDiputacion General de Aragonrdquo (reference groupEduQTech T49 17R) Victor H Rodriguez acknowledges agrant from ldquoCONACYT-Gobierno del Estado de DurangoMexico 330795386043rdquo

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 10: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

10 Wireless Communications and Mobile Computing

void arm lineal detrend f32 (float 32 t lowast y int size) float 32 t abcdefx1x2C1C2determinant

int i

a=0b=0c=0d=0e=0f=0

x2=1

determinant=0

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size create a slope

a=a+(x1 lowast x1)

b=b+x1

c=c+x1

d=d+x2

e=e+(x1 lowast y [ i ] )f=f+(x2 lowast y [ i ] )

determinant = a lowast d - b lowast c

if ( isnan (determinant) | | isinf(determinant)) return else

C1 = (e lowast d - b lowast f)determinant resolve the System

C2 = (a lowast f - e lowast c)determinant to find the coefficients C1 and C2

for (i=0 iltsize i++) x1=((float 32 t)i+1)(float 32 t)size

y [ i ] =y [ i ] -(x1 lowast C1+C2) remove lineal trendCode 2 C-code to eliminate the linear trend

Table 2 Parameters used to evaluate the QRS detector

Record No TB DB TP FP FN SE PP DERTotal 109494 109086 108713 373 781 9930 9961 112

were true positives 781 were false negative and 373 werefalse positives In addition the QRS detector showed a 119878119864 of9930with a positive prediction of 9961 and an error ratein the detection of pulses of 112

Table 3 shows the results obtained between the differentalgorithms found in the literature and ours using the MIT-BIH database The results we have obtained are a little worseHowever the difference between the algorithm with better 119878119864[34] and ours is only 057 In119875119875 the difference with respectto [35] is 030 and in119863119864119877 the differencewith respect to [36]is only 084

Table 4 shows the comparison between the resultsobtained by our algorithm and those obtained by [32] usingthe 119873119878119877119863119861 database In this comparison [32] has betterresults than us in 119878119864 and 119875119875 by 001 while 119863119864119877 is only00002 better

The time required by the MCU for the HRV analysis willvary according to the size of the IBI vector Table 5 shows theexecution times that were required to analyze the signal 215 oftheMITBIH databaseThis particular file was chosen becauseit contains more QRS complex than the rest of the signals(3358 found by our algorithm)

On the other hand the execution times for the QRSdetector will always be the same (47ms for detection and 5msfor saving in a microSD the temporary location of the 119877119908119886V119890found) because the length of the input vector has a constantsize (1024 samples)

The time required to fill the 1024 data buffer is 1024 lowast(1119891119904) where 119891119904 is the sampling frequency In the case ofthe MITBIH 119891119904 is 360 Hz so it would take 284 s to fill itIn the case of the NSRDB 119891119904 is 128 Hz so that it would take8 s In both cases the detection of the QRS complex can bedone in real time since it only takes 52 ms The detector mayoperate in real time up to a maximum sampling frequencyof 195 kHz However some studies show that 500 Hz is avery reliable frequency forHRV analysis [47] Our system caneasily achieve real time for this recommended frequency

Although the times required for the analysis of the HRVvary depending on the size of 119868119861119868 inTable 5 it can be seen thatthe smoothing of the signal using wavelets and the analysis inthe frequency domain required more time for its executionOn the other side the Poincare analysis was the fastest Thetime required for the complete HRV analysis of signal 215(MITBIH database) was 4401 s

Wireless Communications and Mobile Computing 11

Table 3 Comparison of the results obtained using different algorithm in the MITBIH database

DB TP FP FN SE PP DERJP Martınez et al [31] 109428 109208 153 220 9980 9986 034J Pan amp Tompkins [11] 109809 109532 507 277 9975 9954 071Gutierrez-Rivas et al [32] - 109447 289 502 9954 9973 -Chouakri et al [33] 109488 108043 3068 1446 9868 9724 412Santanu et al [34] 109666 109351 315 144 9987 9969 042Moody amp Mark [35] 109428 107567 94 1861 9830 9991 179Merah et al[36] 109494 109316 126 178 9984 9988 028Proposed algorithm 109086 108713 373 781 9930 9961 112

Table 4 Comparison of the results using the NSRDB database

Algorithm TB TP FP FN SE PP DERGutierrez-Rivas et al [32] 192389 192325 64 17 9996 9999 00004Proposed algorithm 192389 192297 92 25 9995 9998 00006

Refreshing the LCD screens took 50 ms and it was donewhile the buffer was filling so that the update times of thescreens had no influence on the calculations of the HRV

The execution time on a regular PC with the processingperformed inMatlab is also shown in Table 5 for comparisonIt is lower than in the MCU implementation because of thepowerful processor The idea is not to be competitive witha PC server in this aspect but to avoid transmitting data toa server in the cloud which would be a great burden forthe network In addition this would imply a higher powerconsumption for the sensor node For instance the proposedsystem has these power consumption contributions 42 mAfor the MCU in sleep mode 49 mA while processing asignal from a micro SD card 75 mA while processing signalsfrom AD8232 or 169 mA while processing signals fromBluetooth (HC-05 module) Thus it is clear that avoidingcommunication is of great interest

4 Conclusions and Future Work

The results obtained with the QRS detector that we haveproposed based on wavelets and with automatic selection ofthe coefficients of the details have been higher than 99 in119878119864 and 119875119875 using the MITBIH database They are worse thanprevious studies but the difference does not exceed 09 inany of the parameters used in that comparison (119878119864 119875119875 119863119864119877)On the other hand using the NSRDB database the resultshave been better (119878119864 = 9995 119875119875 = 9998 and 119863119864119877 =00006) In comparison with [32] SE and PP have been only001 lower

The QRS detection algorithm was followed by an HRVanalysis In both stages several algorithms had to be opti-mized for the implementation on an MCU Thanks to theefficient use of RAM it has beenpossible to develop thewholeHRV analysis as a standalone application embedded on anMCU ARM

With the execution times shown in Table 5 it has beenshown that theQRSdetector is capable of running in real timefor the most common frequencies used in ECGs Likewise

given that some parameters such as 119868119861119868119898119890119886119899 119878119863119873119873119877119872119878119878119863and 119867119877119898119890119886119899 require very little time for their execution andthat they are in the time domain they could be displayed bysending them via Bluetooth or Wifi to a mobile applicationIn this way an HRV analysis would be done in real time Inaddition the energy consumption is low so it can facilitate itsintegration on portable devices

The time required for the complete analysis of the HRVwill be variable (depending on the amount of data) but it willbe in the order of seconds for practical purposes making it aviable application

Our system could also help in applications like the oneshown in [25] in which HRV and location are measured toevaluate wellness and recommend a place to live accordinglyAll the RR intervals are sent to the userrsquos mobile phone andfrom it to a server in which a time domain parameter of HRVis calculated The system could be improved if the wearabledevice measured itself HRV avoiding the battery consum-ing process of the communication with the mobile phoneBesides our system can calculate all the HRV parametersand could improve the determination of the userrsquos wellnessAnother application of our system could be the integrationinto the system to monitor asthma disease presented in [26]in which the heart rate is also a key component

This system developed on an ARM MCU could be com-plemented by developing a mobile application that displaysthe results of the HRV analysis in a more adequate wayto the user showing comparisons or statistics with respectto previous analyses In this way the user would get bettercontrol over hisher HRV

As future work several lines are devised In the first onethe QRS detector will be improved to obtain better resultsthan those seen in Tables 3 and 4 The second line will bedevoted to the optimization of the proposed system code tointegrate it in the most optimal way into an 119868119900119879 networkIt can be tested using Wifi ZigBee or Bluetooth networksfor short ranges For instance it could receive informationfrom a network edge and then send back to a server onlythe HRV results to be displayed This will help to improve

12 Wireless Communications and Mobile Computing

Table 5 Time required for HRV analysis of the signal 215 (MITBIH database)

Main function Sub functions (ms) Execution time (ms) inMCU

Execution time (ms) inIntel i7 (MatLab)

Detector QRS 47 39DWT perform (37)First difference (lt1)Squared signal (lt3)Filter average (lt3)

Find peaks and update threshold (lt3)Save data to SD 5 -Preprocessing Remove Artifacts 3 1Time DomainHRV 30 9

119868119861119868119898119890119886119899 (lt1)119867119877119898119890119886119899 (1)119878119863119873119873 (lt1)119894119878119863119873119873 (12)119878119863119860119873119873 (11)119877119872119878119878119863 (lt1)

11990111987311987350 11987311987350 (1)119867119877119904119905119889 (1)119872119886119909 (lt1)119872119894119899 (lt1)

Geometrictriangular HRV 89 2

119877119877119879119903119894119899 (17)119879119868119873119873 (62)

Poincare HRV 1 11198781198631 1198781198632 119886119899119889 119864119901119860119903119890119886 (1)

Refresh LCD 50 -FrequencyDomain HRV 4176 163

119868119861119868119904119898119900119900119905ℎ (2084)119905 (lt1)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 (1331)119875119878119863119904119894119892119899119886119897 (302)

119881119871119865 119871119865 119867119865 119871119865119867119865 119871119865119899119900119903119898119886119897119894119911119890119889 and119867119865119899119900119903119898119886119897119894119911119890119889 (458)

mHealth and eHealth services using systems embedded inmicrocontrollers On the other hand we will work to makethe proposed device as small as possible similar to smartband In this way it will be able to track heart rate variabilityduring the daily activity

Data Availability

The data supporting this study are from previously reportedstudies and datasets which have been cited or are includedwithin the article

Conflicts of Interest

The authors declare that they have no conflicts of interest

Acknowledgments

The authors would like to thank the ldquoFondo Social Europeordquothe ldquoDiputacion General de Aragonrdquo (reference groupEduQTech T49 17R) Victor H Rodriguez acknowledges agrant from ldquoCONACYT-Gobierno del Estado de DurangoMexico 330795386043rdquo

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 11: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

Wireless Communications and Mobile Computing 11

Table 3 Comparison of the results obtained using different algorithm in the MITBIH database

DB TP FP FN SE PP DERJP Martınez et al [31] 109428 109208 153 220 9980 9986 034J Pan amp Tompkins [11] 109809 109532 507 277 9975 9954 071Gutierrez-Rivas et al [32] - 109447 289 502 9954 9973 -Chouakri et al [33] 109488 108043 3068 1446 9868 9724 412Santanu et al [34] 109666 109351 315 144 9987 9969 042Moody amp Mark [35] 109428 107567 94 1861 9830 9991 179Merah et al[36] 109494 109316 126 178 9984 9988 028Proposed algorithm 109086 108713 373 781 9930 9961 112

Table 4 Comparison of the results using the NSRDB database

Algorithm TB TP FP FN SE PP DERGutierrez-Rivas et al [32] 192389 192325 64 17 9996 9999 00004Proposed algorithm 192389 192297 92 25 9995 9998 00006

Refreshing the LCD screens took 50 ms and it was donewhile the buffer was filling so that the update times of thescreens had no influence on the calculations of the HRV

The execution time on a regular PC with the processingperformed inMatlab is also shown in Table 5 for comparisonIt is lower than in the MCU implementation because of thepowerful processor The idea is not to be competitive witha PC server in this aspect but to avoid transmitting data toa server in the cloud which would be a great burden forthe network In addition this would imply a higher powerconsumption for the sensor node For instance the proposedsystem has these power consumption contributions 42 mAfor the MCU in sleep mode 49 mA while processing asignal from a micro SD card 75 mA while processing signalsfrom AD8232 or 169 mA while processing signals fromBluetooth (HC-05 module) Thus it is clear that avoidingcommunication is of great interest

4 Conclusions and Future Work

The results obtained with the QRS detector that we haveproposed based on wavelets and with automatic selection ofthe coefficients of the details have been higher than 99 in119878119864 and 119875119875 using the MITBIH database They are worse thanprevious studies but the difference does not exceed 09 inany of the parameters used in that comparison (119878119864 119875119875 119863119864119877)On the other hand using the NSRDB database the resultshave been better (119878119864 = 9995 119875119875 = 9998 and 119863119864119877 =00006) In comparison with [32] SE and PP have been only001 lower

The QRS detection algorithm was followed by an HRVanalysis In both stages several algorithms had to be opti-mized for the implementation on an MCU Thanks to theefficient use of RAM it has beenpossible to develop thewholeHRV analysis as a standalone application embedded on anMCU ARM

With the execution times shown in Table 5 it has beenshown that theQRSdetector is capable of running in real timefor the most common frequencies used in ECGs Likewise

given that some parameters such as 119868119861119868119898119890119886119899 119878119863119873119873119877119872119878119878119863and 119867119877119898119890119886119899 require very little time for their execution andthat they are in the time domain they could be displayed bysending them via Bluetooth or Wifi to a mobile applicationIn this way an HRV analysis would be done in real time Inaddition the energy consumption is low so it can facilitate itsintegration on portable devices

The time required for the complete analysis of the HRVwill be variable (depending on the amount of data) but it willbe in the order of seconds for practical purposes making it aviable application

Our system could also help in applications like the oneshown in [25] in which HRV and location are measured toevaluate wellness and recommend a place to live accordinglyAll the RR intervals are sent to the userrsquos mobile phone andfrom it to a server in which a time domain parameter of HRVis calculated The system could be improved if the wearabledevice measured itself HRV avoiding the battery consum-ing process of the communication with the mobile phoneBesides our system can calculate all the HRV parametersand could improve the determination of the userrsquos wellnessAnother application of our system could be the integrationinto the system to monitor asthma disease presented in [26]in which the heart rate is also a key component

This system developed on an ARM MCU could be com-plemented by developing a mobile application that displaysthe results of the HRV analysis in a more adequate wayto the user showing comparisons or statistics with respectto previous analyses In this way the user would get bettercontrol over hisher HRV

As future work several lines are devised In the first onethe QRS detector will be improved to obtain better resultsthan those seen in Tables 3 and 4 The second line will bedevoted to the optimization of the proposed system code tointegrate it in the most optimal way into an 119868119900119879 networkIt can be tested using Wifi ZigBee or Bluetooth networksfor short ranges For instance it could receive informationfrom a network edge and then send back to a server onlythe HRV results to be displayed This will help to improve

12 Wireless Communications and Mobile Computing

Table 5 Time required for HRV analysis of the signal 215 (MITBIH database)

Main function Sub functions (ms) Execution time (ms) inMCU

Execution time (ms) inIntel i7 (MatLab)

Detector QRS 47 39DWT perform (37)First difference (lt1)Squared signal (lt3)Filter average (lt3)

Find peaks and update threshold (lt3)Save data to SD 5 -Preprocessing Remove Artifacts 3 1Time DomainHRV 30 9

119868119861119868119898119890119886119899 (lt1)119867119877119898119890119886119899 (1)119878119863119873119873 (lt1)119894119878119863119873119873 (12)119878119863119860119873119873 (11)119877119872119878119878119863 (lt1)

11990111987311987350 11987311987350 (1)119867119877119904119905119889 (1)119872119886119909 (lt1)119872119894119899 (lt1)

Geometrictriangular HRV 89 2

119877119877119879119903119894119899 (17)119879119868119873119873 (62)

Poincare HRV 1 11198781198631 1198781198632 119886119899119889 119864119901119860119903119890119886 (1)

Refresh LCD 50 -FrequencyDomain HRV 4176 163

119868119861119868119904119898119900119900119905ℎ (2084)119905 (lt1)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 (1331)119875119878119863119904119894119892119899119886119897 (302)

119881119871119865 119871119865 119867119865 119871119865119867119865 119871119865119899119900119903119898119886119897119894119911119890119889 and119867119865119899119900119903119898119886119897119894119911119890119889 (458)

mHealth and eHealth services using systems embedded inmicrocontrollers On the other hand we will work to makethe proposed device as small as possible similar to smartband In this way it will be able to track heart rate variabilityduring the daily activity

Data Availability

The data supporting this study are from previously reportedstudies and datasets which have been cited or are includedwithin the article

Conflicts of Interest

The authors declare that they have no conflicts of interest

Acknowledgments

The authors would like to thank the ldquoFondo Social Europeordquothe ldquoDiputacion General de Aragonrdquo (reference groupEduQTech T49 17R) Victor H Rodriguez acknowledges agrant from ldquoCONACYT-Gobierno del Estado de DurangoMexico 330795386043rdquo

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 12: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

12 Wireless Communications and Mobile Computing

Table 5 Time required for HRV analysis of the signal 215 (MITBIH database)

Main function Sub functions (ms) Execution time (ms) inMCU

Execution time (ms) inIntel i7 (MatLab)

Detector QRS 47 39DWT perform (37)First difference (lt1)Squared signal (lt3)Filter average (lt3)

Find peaks and update threshold (lt3)Save data to SD 5 -Preprocessing Remove Artifacts 3 1Time DomainHRV 30 9

119868119861119868119898119890119886119899 (lt1)119867119877119898119890119886119899 (1)119878119863119873119873 (lt1)119894119878119863119873119873 (12)119878119863119860119873119873 (11)119877119872119878119878119863 (lt1)

11990111987311987350 11987311987350 (1)119867119877119904119905119889 (1)119872119886119909 (lt1)119872119894119899 (lt1)

Geometrictriangular HRV 89 2

119877119877119879119903119894119899 (17)119879119868119873119873 (62)

Poincare HRV 1 11198781198631 1198781198632 119886119899119889 119864119901119860119903119890119886 (1)

Refresh LCD 50 -FrequencyDomain HRV 4176 163

119868119861119868119904119898119900119900119905ℎ (2084)119905 (lt1)

119898119868119861119868119894119899119905119890119903119901119900119897119886119905119890 (1331)119875119878119863119904119894119892119899119886119897 (302)

119881119871119865 119871119865 119867119865 119871119865119867119865 119871119865119899119900119903119898119886119897119894119911119890119889 and119867119865119899119900119903119898119886119897119894119911119890119889 (458)

mHealth and eHealth services using systems embedded inmicrocontrollers On the other hand we will work to makethe proposed device as small as possible similar to smartband In this way it will be able to track heart rate variabilityduring the daily activity

Data Availability

The data supporting this study are from previously reportedstudies and datasets which have been cited or are includedwithin the article

Conflicts of Interest

The authors declare that they have no conflicts of interest

Acknowledgments

The authors would like to thank the ldquoFondo Social Europeordquothe ldquoDiputacion General de Aragonrdquo (reference groupEduQTech T49 17R) Victor H Rodriguez acknowledges agrant from ldquoCONACYT-Gobierno del Estado de DurangoMexico 330795386043rdquo

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 13: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

Wireless Communications and Mobile Computing 13

References

[1] G Vega-Martınez C Alvarado-Serrano and L Leija-SalasldquoWavelet packet based algorithm for QRS region detection andRS wave identificationrdquo in Proceedings of the 12th InternationalConference on Electrical Engineering Computing Science andAutomatic Control CCE 2015 Mexico October 2015

[2] R Saktheeswari and K Adalarasu ldquoSurvey on signal processingtechniques for diagnoising cardiovascular diseasesrdquo in Proceed-ings of the 2017 4th International Conference on Innovations inInformation Embedded and Communication Systems pp 1ndash4Coimbatore March 2017

[3] H J Baek and J Shin ldquoEffect of Missing Inter-Beat IntervalData on Heart Rate Variability Analysis Using Wrist-WornWearablesrdquo Journal of Medical Systems vol 41 no 10 pp 1ndash92017

[4] F Shaffer R McCraty and C L Zerr ldquoA healthy heart is nota metronome an integrative review of the heartrsquos anatomy andheart rate variabilityrdquo Frontiers in Psychology vol 5 2014

[5] E K Kerut K W Swan F To T D Giles and P JKadowitz ldquoRespiratory sigh associated transient autonomicchanges detected with a continuous wavelet method of heartrate variability analysisrdquo Biomedical Signal Processing and Con-trol vol 38 pp 143ndash147 2017

[6] M B Tayel and E I AlSaba ldquoPoincare plot for heart ratevariabilityrdquo International Journal of Biomedical and BiologicalEngineering vol 9 pp 708ndash711 2015

[7] C Gentili S Messerotti Benvenuti D Palomba A Greco E PScilingo and G Valenza ldquoAssessing mood symptoms throughheartbeat dynamics An HRV study on cardiosurgical patientsrdquoJournal of Psychiatric Research vol 95 pp 179ndash188 2017

[8] Y Kubota L Y Chen E A Whitsel and A R Folsom ldquoHeartrate variability and lifetime risk of cardiovascular diseasethe Atherosclerosis Risk in Communities Studyrdquo Annals ofEpidemiology vol 27 no 10 pp 619ndash625 2017

[9] I Garcıa-Magarino and I Plaza ldquoABS-MindHeart An agentbased simulator of the influence of mindfulness programs onheart rate variabilityrdquo Journal of Computational Science vol 19pp 11ndash20 2017

[10] Butta Singh and Singh Manjit ldquoECG artifacts and poincareplot based heart rate variabilityrdquo International Journal of LatestTrends in Engineering and Technology vol 5 pp 304ndash309 2015

[11] J Pan and W J Tompkins ldquoA Real-Time QRS DetectionAlgorithmrdquo IEEE Transactions on Biomedical Engineering volBME-32 no 3 pp 230ndash236 1985

[12] M Rakshit and S Das ldquoAn efficient wavelet-based automatedR-peaks detection method using Hilbert transformrdquo Biocyber-netics and Biomedical Engineering vol 37 no 3 pp 566ndash5772017

[13] S Jain M K Ahirwal A Kumar V Bajaj and G K SinghldquoQRS detection using adaptive filters A comparative studyrdquo ISATransactions vol 66 pp 362ndash375 2017

[14] D Lai F Zhang and C Wang ldquoA real-time QRS complexdetection algorithm based on differential threshold methodrdquo inProceedings of the 2015 IEEE International Conference on DigitalSignal Processing (DSP) pp 129ndash133 Singapore 2015

[15] N Ravanshad andH Rezaee-Dehsorkh ldquoAn event-based ECG-monitoring and QRS-detection system based on level-crossingsamplingrdquo in Proceedings of the 2017 Iranian Conference onElectrical Engineering (ICEE) pp 302ndash307 Tehran Iran 2017

[16] M Belkadi and A Daamouche ldquoAn improved QRS detectionmethod using Hidden Markov Modelsrdquo in Proceedings of the

2017 6th International Conference on Systems and Control(ICSC) pp 81ndash84 Batna Algeria 2017

[17] Z Zidelmal A AmirouDOuld-AbdeslamAMoukadem andA Dieterlen ldquoQRS detection using S-Transform and Shannonenergyrdquo Computer Methods and Programs in Biomedicine vol116 no 1 pp 1ndash9 2014

[18] F Firouzi A M Rahmani K Mankodiya et al ldquoInternet-of-Things and big data for smarter healthcare From deviceto architecture applications and analyticsrdquo Future GenerationComputer Systems vol 78 pp 583ndash586 2018

[19] Y Ai M Peng and K Zhang ldquoEdge computing technologiesfor Internet of Things a primerrdquo Digital Communications andNetworks vol 4 no 2 pp 77ndash86 2018

[20] F Gonzalez-Landero I Garcıa-Magarino R Lacuesta andJ Lloret ldquoGreen Communication for Tracking Heart Ratewith Smartbands Sensorsrdquo in Sensors vol 18 p 2652 BaselSwitzerland 2018

[21] P Kochovski and V Stankovski ldquoSupporting smart construc-tion with dependable edge computing infrastructures andapplicationsrdquo Automation in Construction vol 85 pp 182ndash1922018

[22] A Ahmed and E Ahmed ldquoA survey on mobile edge com-putingrdquo in Proceedings of the 10th International Conferenceon Intelligent Systems and Control (ISCO) IEEE CoimbatoreIndia 2016

[23] R Craciunescu A Mihovska M Mihaylov S Kyriazakos RPrasad and S Halunga ldquoImplementation of Fog computing forreliable E-health applicationsrdquo in Proceedings of the 2015 49thAsilomar Conference on Signals Systems and Computers pp459ndash463 IEEE Pacific Grove CA USA 2015

[24] M Quintana-Suarez D Sanchez-Rodrıguez I Alonso-Gonzalez and J Alonso-Hernandez ldquoA low cost wirelessacoustic sensor for ambient assisted living systemsrdquo AppliedSciences vol 7 no 9 p 877 2017

[25] R Lacuesta L Garcia I Garcia-Magarino and J Lloret ldquoSys-tem to Recommend the Best Place to Live Based on WellnessState of the User Employing the Heart Rate Variabilityrdquo IEEEAccess vol 5 pp 10594ndash10604 2017

[26] S Sendra L Parra J Lloret and J Tomas ldquoSmart system forchildrenrsquos chronic illness monitoringrdquo Information Fusion vol40 pp 76ndash86 2018

[27] V H Rodriguez C Medrano and I Plaza ldquoA Real-Time QRSComplex Detector Based on Discrete Wavelet Transform andAdaptiveThreshold as Standalone Application on ARMMicro-controllersrdquo in Proceedings of the 2018 International Conferenceon Biomedical Engineering and Applications (ICBEA) pp 1ndash6IEEE Madeira Portugal 2018

[28] G Strang ldquoWavelets and dilation equations a brief introduc-tionrdquo SIAM Review vol 31 no 4 pp 614ndash627 1989

[29] A A Fedotov A S Akulova and S A Akulov ldquoApplicability ofmultiresolution wavelet analysis for QRS-waves detectionrdquo inProceedings of the 2016 38th Annual International Conference ofthe IEEE Engineering in Medicine and Biology Society (EMBC)pp 3793ndash3796 IEEE Orlando FL USA 2016

[30] A E Aubert D Ramaekers F Beckers et al ldquoThe analysis ofheart rate variability in unrestrained rats Validation of methodand resultsrdquo Computer Methods and Programs in Biomedicinevol 60 no 3 pp 197ndash213 1999

[31] J PMartınez R Almeida S Olmos A P Rocha and P LagunaldquoA wavelet-based ECG delineator evaluation on standarddatabasesrdquo IEEE Transactions on Biomedical Engineering vol51 no 4 pp 570ndash581 2004

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 14: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

14 Wireless Communications and Mobile Computing

[32] R Gutierrez-Rivas J J Garcıa W P Marnane and AHernandez ldquoNovel Real-Time Low-Complexity QRS ComplexDetector Based on Adaptive Thresholdingrdquo IEEE Sensors Jour-nal vol 15 no 10 pp 6036ndash6043 2015

[33] S A Chouakri F Bereksi-Reguig and A Taleb-Ahmed ldquoQRScomplex detection based on multi wavelet packet decomposi-tionrdquo Applied Mathematics and Computation vol 217 no 23pp 9508ndash9525 2011

[34] S Sahoo B Kanungo S Behera and S Sabut ldquoMultiresolutionwavelet transform based feature extraction and ECG classifica-tion to detect cardiac abnormalitiesrdquoMeasurement vol 108 pp55ndash66 2017

[35] G BMoody and R GMark ldquoDevelopment and evaluation of a2-lead ECG analysis programrdquo in Computers in Cardiology pp39ndash44 IEEE Computer Society Press Los Alamitos CA USA1982

[36] M Merah T A Abdelmalik and B H Larbi ldquoR-peaks detec-tion based on stationary wavelet transformrdquo Computer Methodsand Programs in Biomedicine vol 121 no 3 pp 149ndash160 2015

[37] F Zhang S Chen H Zhang X Zhang and G Li ldquoBioelectricsignal detrending using smoothness prior approachrdquo MedicalEngineering amp Physics vol 36 no 8 pp 1007ndash1013 2014

[38] R Sameni ldquoOnline filtering using piecewise smoothness priorsApplication tonormal andabnormal electrocardiogramdenois-ingrdquo Signal Processing vol 133 pp 52ndash63 2017

[39] M P Tarvainen J-P Niskanen J A Lipponen P O Ranta-ahoandPA Karjalainen ldquoKubiosHRVmdashheart rate variability anal-ysis softwarerdquoComputer Methods and Programs in Biomedicinevol 113 no 1 pp 210ndash220 2014

[40] Hugo Cerda-Kohler and Carlos Henrıquez-Olguın ldquoVariabil-idad del ritmo cardiaco y ejercicio fısicordquo Revista HorizonteCiencias de la Actividad Fısica vol 5 pp 140ndash158 2014

[41] M P Tulppo T H Makikallio T E Takala T Seppanenand H V Huikuri ldquoQuantitative beat-to-beat analysis of heartrate dynamics during exerciserdquoAmerican Journal of Physiology-Heart and Circulatory Physiology vol 271 no 1 pp H244ndashH252 1996

[42] A K Golinska ldquoPoincare plots in analysis of selected biomedi-cal signalsrdquo Studies in Logic Grammar and Rhetoric vol 35 no48 pp 117ndash127 2013

[43] Kumar Sobhendu Ghatak and Subhra Aditya ldquoPoincareparameters and principal component analysis of Heart ratevariability of subjects with health disorderrdquoMedical Physics pp1ndash12 2018

[44] Task Force of the European Society of Cardiology the NorthAmerican Society of Pacing Electrophysiology ldquoHeart rate vari-ability standards of measurement physiological interpretationand clinical userdquoCirculation vol 93 no 5 pp 1043ndash1065 1996

[45] Physionet ldquoPhysioBank ATMrdquo httpsphysionetorgcgi-binatmATM

[46] RafatHussain ldquoWavelibrdquo httpsgithubcomrafatwavelibwiki[47] M Baumert M Schmidt S Zaunseder and A Porta ldquoEffects

of ECG sampling rate on QT interval variability measurementrdquoBiomedical Signal Processing and Control vol 25 pp 159ndash1642016

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom

Page 15: Embedded System Based on an ARM Microcontroller to Analyze ...downloads.hindawi.com/journals/wcmc/2018/9138578.pdf · Embedded System Based on an ARM Microcontroller to Analyze Heart

International Journal of

AerospaceEngineeringHindawiwwwhindawicom Volume 2018

RoboticsJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Active and Passive Electronic Components

VLSI Design

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Shock and Vibration

Hindawiwwwhindawicom Volume 2018

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawiwwwhindawicom

Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Control Scienceand Engineering

Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Journal ofEngineeringVolume 2018

SensorsJournal of

Hindawiwwwhindawicom Volume 2018

International Journal of

RotatingMachinery

Hindawiwwwhindawicom Volume 2018

Modelling ampSimulationin EngineeringHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Navigation and Observation

International Journal of

Hindawi

wwwhindawicom Volume 2018

Advances in

Multimedia

Submit your manuscripts atwwwhindawicom