8 A DSP Practical Application : Working on ECG Signal

An electrocardiogram (ECG) is a graphical record of bioelectrical signal generated by the human body during cardiac cycle (Goldschlager, 1989). ECG graphically gives useful information that relates to the heart functioning (Dubis, 1976) by means of a base line and waves representing the heart voltage changes during a period of time, usually a short period (Cuesta, 2001). Putting leads on specific part of the human body, it is possible to get changes of the bioelectrical heart signal (Goldschlager, 1989) where one of the most basic forms of organizing them is known as Einthoven lead system which is shown in Figure 1 (Vidal & Pavesi, 2004; Vidal et al., 2008).


Introduction
An electrocardiogram (ECG) is a graphical record of bioelectrical signal generated by the human body during cardiac cycle (Goldschlager, 1989).ECG graphically gives useful information that relates to the heart functioning (Dubis, 1976) by means of a base line and waves representing the heart voltage changes during a period of time, usually a short period (Cuesta, 2001).Putting leads on specific part of the human body, it is possible to get changes of the bioelectrical heart signal (Goldschlager, 1989) where one of the most basic forms of organizing them is known as Einthoven lead system which is shown in Figure 1 (Vidal & Pavesi, 2004;Vidal et al., 2008).


Generalized suffering affecting heart and blood pressure. Cardiac medicine effects, especially digital and quinidine. Electrolytic transformations.In spite of the special value, the ECG is considered only a laboratory test.It is not an absolute truth concerning the cardiac pathologies diagnosis.There are examples of patients presenting string heart diseases which present a normal ECG, and also perfectly normal patients getting an abnormal ECG (Goldschlager, 1989).Therefore, an ECG must always be interpreted with the patient clinical information.

Electrocardiographic signal
According to (Proakis & Manolakis, 2007) a signal can be analyzed and processed in two domains, time and frequency.ECG signal is one of the human body signals which can be analyzed and worked in these two domains.

Time domain of an ECG signal
P, Q, R, S, T and U are specific wave forms identified in the time domain of an ECG signal.The QRS complex, formed by Q, R and S waves, represents a relevant wave form because the heart rate can be identified locating two successive QRS complex.Figure 2 presents typical waves in an ECG signal.

Frequency domain of an ECG signal
Frequency values of an ECG signal vary from 0 Hz to 100 Hz (Cuesta, 2001;Vidal & Pavesi, 2004;Vidal et al., 2008;Vidal & Gatica, 2010) whereas the associated amplitude values vary from 0.02 mV to 5 mV.As it is appreciated, the amplitude values of human body bioelectrical signals are measured in micro volts (mV).Furthermore, the amplitude values of these signals are small voltage values and are being caught using traditional electronic devices.This is an important characteristic which must be considered to implement an electronic device in order to obtain bioelectrical signals.
There are different sources of noise at the moment of getting a human body signal.The frequency domain helps us to know of how additional sources affect the important signal in the time domain.
Figure 3 shows frequency range of QRS complex of an ECG signal next to the frequency range of common noise sources.

Digital ECG
Building a device to get and process the ECG signal must consider the signal characteristics.
According to (Cuesta, 2001;Vidal & Pavesi, 2004), facing individually each part of the global problems is a technique applicable in order to get good practical results.Figure 4 presents each part or block of a basic digital ECG according to reviewed literature Fig. 4. Blocks Diagram of a Basic Digital ECG.(Cuesta, 2001;Vidal et al., 2008;Vidal & Gatica, 2010) where the most important part corresponds to the amplifying module because of a bioelectrical signal that represents a low potential, and sophisticated amplifiers are required for obtaining and recording it (Vidal & Pavesi, 2004;Vidal et al., 2008;Vidal & Gatica, 2010).
The following sections present experiences building a device for getting the ECG signal, and works related to processing ECG signal.

Digital ECG design
Signals produced by bioelectric phenomenon are small potential values and due to this, sophisticated amplifiers are required so as to easily obtain signal values (Vidal & Pavesi, 2004).Against a physiologic backdrop, these ionic signals are transmitted at a fast-rate without synaptic delay in both direction directed by the electric synapse transmission model.This electric potential is later transformed in a mechanical signal as of using calcium ion that comes from extracellular condition which is also useful for cooking calcium that is released from the internal section of cardiac cells provoking a massive cardiac muscle like a sincitio or functional unit (Clusin, 2008).In this sense, the main finality of an amplifier is to increment the measurable level of the gotten signal by electrodes, avoiding any kind of interference.The capacitive interference of the patient body, electrical fields of electric installations, and other environment electronic devices are examples of interference or noise.(Proakis & Manolakis, 2007) indicate that the quantification can be done using single pole configurations or bipolar.In the single pole quantification, difference between a signal and a common base is measured whereas the bipolar mode measures the difference of two voltage sources (two electrodes) with respect to a common base where any interference voltage generated at the quantification point appears at the amplifier input as common-mode interference signals.Figure 5 illustrates this phenomenon in a bipolar quantification.

Fig. 5. Common-Mode Interferences in a bipolar quantification
A strong source noise which interferes on the ECG signal is the capacitive interference of the patient body.This interference voltage is coupled to the ECG signal reaching values of 2.4 V approximately.A value which is very higher than the ECG signals value range (0.02 mV to 5 mV).In addition to this interference, the capacitive interference due to the equipment or device used to measure the ECG signal which is produced by the equipment power supply.Another noise source is the denominated inductive interference that is caused by the electric net which produces variable in time magnetic fields inducing extra voltages on the next of patient electrodes (Townsend, 2001).
For these reasons, common mode rejection ratio (CMRR) rate is a desirable characteristic of an amplifier working on differential mode.On a day today practice, a problem denominated contact impedance disbalance appears (Townsend, 2001) that is produced when there are different interfaces impedances between the skin and electrodes in a form that the commonmode potential is higher in one of the two voltage sources.Therefore, part of the commonmode voltage is worked as differential voltage and amplified according to the amplifier gain.This occasionally produces saturation on the next amplifying module stage, if the amplification module were composed by more stages.This voltage, which is generally continuous, can be eliminated using a simple high-pass filter.Hence, the output voltage of the differential amplifier would consist of 3 components (Townsend, 2001;Vidal & Pavesi, 2004):  Wished output due to the differential amplification on the ECG signal. Common-mode signal not wished due to the CMRR is not infinite. Common-mode signal not wished due to the disbalance on the impedance contact.(Wells & Crampton, 2006) indicate that weak signals require an amplification of 1000 at least to produce adequate signal levels for future works on it.(Vidal & Pavesi, 2004)

Acquiring and processing ECG signal
The acquisition data stage has a hardware part composed by the A/D converter, and a software part which is in charge of directing the A/D converter work.Any programming language allowing low level hardware instruction is usable.(Vidal & Pavesi, 2004) and (Vidal & Gatica, 2010) describe the use of C and Visual Basic programming languages for getting and processing the ECG signal.According to these works, the routine written in C language is used to direct the A/D converter functioning using non-standard functions to access the personal computer ports.The obtained quantity of samples is stored in a binary file which is rescued by the Visual Basic programming language routine to processing (applying filters and QRS detection algorithms) and showing the signal.Showing the signal at the computer is done "offline" from the generated file with the ECG signal samples.As (Vidal & Gatica, 2010) highlights using current high level programming languages would be possible to build a showing graphics routine.Using lineal interpolation it is possible to get high level graphic results.Even though the Nyquist's sample theorem indicates that a signal can be rebuild using an ideal interpolation method (Lindner, 2009;Proakis & Manolakis 2007), by means of lineal interpolation, and through this it is possible to get good results for low frequency signals like ECG.It is possible to build a universal graphics generator for getting signals (Vidal & Pavesi, 2004;Vidal & Gatica, 2010).Figures 8 and 9 present a universal graphics generator for a sine curve signal and a triangle signal, respectively.These signals are low frequency signals (2 Hz) generated by a function or electrical waves generator with some acquisition deformities (high negative values are not considered).Figure 10 shows a pure ECG signal got by means of an implemented ECG system (Vidal & Gatica, 2010).(Vidal & Pavesi, 2004;Vidal & Gatica, 2010) worked on the digital filters application to eliminate noise on an ECG signal, and the use of algorithms for QRS complex detecting.Following subsections describe digital filters to work on the ECG signal, and present the main principles of a QRS detector algorithm (Vidal et al., 2008).

Digital filters for ECG signal
To work the ECG signal it is necessary to apply digital filters which helps to diminish the noise present on it.One of the most useful filters is Lynn's filters (Goldschlager, 1989) and there are previous works where Lynn's filters are successfully applied to processing ECG signal (Thakor et al., 1984;Kohler et al., 2002;Ahlstrom & Tompkins, 1985).These filters present desirable properties of real-time filters like lineal phase and integer coefficients.There are low-pass and high-pass Lynn's filters versions which are described as follows.

Low-pass filter
Lynn's filters described in (Ahlstrom & Tompkins, 1985) and used on ECG signal processing in (Pan & Tompkins, 1985;Hamilton & Tompkins, 1986), represent a simple and effective form of applying low-pass filter on ECG signals.These filters obey the next transfer function: This filter can be implemented by means of the following differences equation: 160 The amplitude answer of this filter is calculated as follows:   & Tompkins, 1985) and applied to ECG signal processing on (Pan & Tompkins, 1985;Hamilton & Tompkins, 1986).These filters are designed using an all-pass filter and resting over it a low-pass filter, and the result is a high-pass filter (Vidal & Pavesi, 2004).However for an effective design, low-pass filter and all-pass filter must be in phase (Smith, 1999).The High-Pass Lynn's filter starts using the following low-pass filter transfer equation: Amplitude and phase responses are got by: Finally, amplitude and phase responses are showed on Eq. 6 and Eq. 7, respectively.
Once completely characterized the low-pass filter, designing the high-pass filter is an easy task using the following transfer function: ( This filter can be implemented directly by the following difference equation: ( Getting amplitude response for this filter is mathematically complex.Nevertheless, theoretically this filter must have the same cut frequency of the subjacent low-pass filter in inverse order.Furthermore, the values of phase response and group delay of the high-pass filter are the equal to the same parameters for the low-pass filter (Smith, 1999).For a cut frequency of 430 Hz, α values and associated cut frequency (-3 dB.) are shown on Table 3.The filters application allows improving the ECG signal quality in a remarkable manner.
Figure 22 shows the application of a low-pass Lynn's filter of 48 Hz and a high-pass Lynn's filter of 0.5 Hz.

QRS detection algorithm on ECG signal
Within the automatic detection waveform of the ECG signal, it is important to detect QRS complex (Cuesta, 2001;Vidal & Pavesi, 2004).This is the dominant feature of the ECG signal.The QRS complex marks the beginning of the contraction of the left ventricle, so the detection of this event has many clinical applications (Vidal et al., 2008;Townsend, 2001).


Apply wavelets in the design and implementation of filtering algorithms and detector of waveforms.


Analyze other techniques for detection of parameters like, fuzzy logic, genetic approaches and neural networks. Make use of information technologies, such as a database in order to obtain relevant information of the patients and their pathologies.Finally, this work is a good demonstration of the potential applications of Hardware -Software, especially in the field of biotechnology.The quantity and quality of the possible future works show the validity of the affirmation in academic and professional aspects.In addition to the likely use of this work in medical settings, it also gives account of the scope of works such as ECG digital, which are practically limitless.

Acknowledgment
To Dr. David Cuesta of the Universidad Politécnica de Valencia for his valuable contributions and excellent disposition to the authors of this work; to cardiologist Dr. Patricio Maragaño, director of the Regional Hospital of Talca's Cardiology department, for his clinical assessment and technical recommendations for the development of the algorithmic procedures undertaken.

Fig. 2 .
Fig. 2. Typical wave forms of an ECG signal record

Fig. 3 .
Fig.3.Frequency range of QRS complex on an ECG signal next to noise sources(Vidal et al., 2008) used an instrument amplifier model INA131 which presents a fixed CMRR of 100, and according to the associated datasheet it is adequate for biomedical instrumentation.The analog to digital conversion stage (A/D conversion) is always d o n e w h en t h e s i g n a l is a m p l i f i e d .T h e electronic schemes of a digital electrocardiographic device according to(Vidal & Gatica, 2010) are presented on figures 6 and 7, respectively.(Vidal & Pavesi, 2004;Vidal & Gatica, 2010) use the TLC1541 A/D converter.It is necessary to indicate that both electronic items, INA131 and TLC1541, are less expensive.

Fig. 8 .
Fig. 8. Sine Signal obtained by the A/D Change Module

Fig. 11 .
Fig. 11.Amplitude Response of Low-Pass Lynn's Filter for α=3 Figures 14, 15 and 16 show the low-pass filter amplitude response which give an idea of the amplitude response of the associated high-pass filter because the cut frequencies are the same.

Fig. 22 .
Fig. 22. Filtered ECG Signal Using a Low-Pass 48 Hz Lynn's Filter and a High-Pass 0.5 Hz Lynn's Filter

Table 1 .
Table 1 describes the frequency and amplitude values of ECG, EMG (electromiogram), and EEG (electroencephalogram) signals.Amplitude and Frequency Range of Basic Bioelectrical Signals of the Human Being

Table 2 .
Cut Frequencies of Low-Pass Lynn Filter