Final Report. Implementation of algorithms for QRS detection from ECG signals using TMS320C6713 processor platform

Similar documents
Assessment of Reliability of Hamilton-Tompkins Algorithm to ECG Parameter Detection

ISSN: ISO 9001:2008 Certified International Journal of Engineering and Innovative Technology (IJEIT) Volume 2, Issue 10, April 2013

Biomedical. Measurement and Design ELEC4623. Lectures 15 and 16 Statistical Algorithms for Automated Signal Detection and Analysis

Heart Rate Calculation by Detection of R Peak

ECG Beat Recognition using Principal Components Analysis and Artificial Neural Network

HST-582J/6.555J/16.456J-Biomedical Signal and Image Processing-Spring Laboratory Project 1 The Electrocardiogram

DETECTION OF HEART ABNORMALITIES USING LABVIEW

Real-time Heart Monitoring and ECG Signal Processing

POWER EFFICIENT PROCESSOR FOR PREDICTING VENTRICULAR ARRHYTHMIA BASED ON ECG

Design of Software for an Electrocardiogram Analyzer

Temporal Analysis and Remote Monitoring of ECG Signal

Removal of Baseline wander and detection of QRS complex using wavelets

ECG Signal Analysis for Abnormality Detection in the Heart beat

Extraction of P wave and T wave in Electrocardiogram using Wavelet Transform

DETECTION OF EVENTS AND WAVES 183

Classification of ECG Data for Predictive Analysis to Assist in Medical Decisions.

Digital ECG and its Analysis

VLSI Implementation of the DWT based Arrhythmia Detection Architecture using Co- Simulation

Assessment of the Performance of the Adaptive Thresholding Algorithm for QRS Detection with the Use of AHA Database

PERFORMANCE CALCULATION OF WAVELET TRANSFORMS FOR REMOVAL OF BASELINE WANDER FROM ECG

Learning Decision Tree for Selecting QRS Detectors for Cardiac Monitoring

Vital Responder: Real-time Health Monitoring of First- Responders

Interpreting Electrocardiograms (ECG) Physiology Name: Per:

Performance Identification of Different Heart Diseases Based On Neural Network Classification

Extraction of Unwanted Noise in Electrocardiogram (ECG) Signals Using Discrete Wavelet Transformation

ECG QRS Detection. Valtino X. Afonso

Real-time Electrocardiogram Monitoring

ECG MONITORING OF A CARDIAC PATIENT USING EMBEDDED SYSTEM

ECG Rhythm Analysis by Using Neuro-Genetic Algorithms

An advanced ECG signal processing for ubiquitous healthcare system Bhardwaj, S.; Lee, D.S.; Chung, W.Y.

Wavelet Decomposition for Detection and Classification of Critical ECG Arrhythmias

A Novel Application of Wavelets to Real-Time Detection of R-waves

Design of the HRV Analysis System Based on AD8232

CHAPTER IV PREPROCESSING & FEATURE EXTRACTION IN ECG SIGNALS

DIFFERENCE-BASED PARAMETER SET FOR LOCAL HEARTBEAT CLASSIFICATION: RANKING OF THE PARAMETERS

Various Methods To Detect Respiration Rate From ECG Using LabVIEW

Robust system for patient specific classification of ECG signal using PCA and Neural Network

CARDIAC ARRYTHMIA CLASSIFICATION BY NEURONAL NETWORKS (MLP)

Keywords: Adaptive Neuro-Fuzzy Interface System (ANFIS), Electrocardiogram (ECG), Fuzzy logic, MIT-BHI database.

Comparative Analysis of QRS Detection Algorithms and Heart Rate Variability Monitor Implemented on Virtex-4 FPGA

SPECTRAL ANALYSIS OF LIFE-THREATENING CARDIAC ARRHYTHMIAS

A Review on Arrhythmia Detection Using ECG Signal

HST.582J / 6.555J / J Biomedical Signal and Image Processing Spring 2007

ECG Signal Characterization and Correlation To Heart Abnormalities

Quick detection of QRS complexes and R-waves using a wavelet transform and K-means clustering

Simulation Based R-peak and QRS complex detection in ECG Signal

1, 2, 3 * Corresponding Author: 1.

APPLICATION FOR OFF-LINE ANALYSIS OF BIOSIGNALS MEASURED DURING STIMULATIONS ON ISOLATED ANIMAL HEARTS

ECG Generation using AFG with Arrhythmia. Detection and Analysis

Artificial Neural Networks in Cardiology - ECG Wave Analysis and Diagnosis Using Backpropagation Neural Networks

USING CORRELATION COEFFICIENT IN ECG WAVEFORM FOR ARRHYTHMIA DETECTION

Neural Network based Heart Arrhythmia Detection and Classification from ECG Signal

VENTRICULAR DEFIBRILLATOR

MORPHOLOGICAL CHARACTERIZATION OF ECG SIGNAL ABNORMALITIES: A NEW APPROACH

Removing ECG Artifact from the Surface EMG Signal Using Adaptive Subtraction Technique

An electrocardiogram (ECG) is a recording of the electricity of the heart. Analysis of ECG

Analysis of Fetal Stress Developed from Mother Stress and Classification of ECG Signals

ECG Acquisition System and its Analysis using MATLAB

ECG - QRS detection method adopting wavelet parallel filter banks

CHAPTER 5 WAVELET BASED DETECTION OF VENTRICULAR ARRHYTHMIAS WITH NEURAL NETWORK CLASSIFIER

The Function of an ECG in Diagnosing Heart Conditions. A useful guide to the function of the heart s electrical system for patients receiving an ECG

Separation of fetal electrocardiography (ECG) from composite ECG using adaptive linear neural network for fetal monitoring

Body Surface and Intracardiac Mapping of SAI QRST Integral

Implementation of Spectral Maxima Sound processing for cochlear. implants by using Bark scale Frequency band partition

Comparison of Different ECG Signals on MATLAB

Robust Detection of Atrial Fibrillation for a Long Term Telemonitoring System

Powerline Interference Reduction in ECG Using Combination of MA Method and IIR Notch

Heart Abnormality Detection Technique using PPG Signal

RASPBERRY PI BASED ECG DATA ACQUISITION SYSTEM

A Novel Algorithm for ECG Signal Processing

LABVIEW based expert system for Detection of heart abnormalities

Automatic Detection of Heart Disease Using Discreet Wavelet Transform and Artificial Neural Network

An ECG Beat Classification Using Adaptive Neuro- Fuzzy Inference System

ABNORMALITY CLASSIFICATION OF ECG SIGNAL USING DSP PROCESSOR

AUTOMATIC ANALYSIS AND VISUALIZATION OF MULTILEAD LONG-TERM ECG RECORDINGS

Building an Electrocardiogram (ECG) Diagnostic System. Collection Editor: Christine Moran

Detection of Qrs Complexes in Ecg Signal Using K-Means Algorithm

ECG Noise Reduction By Different Filters A Comparative Analysis

WIRELESS PATIENT HEALTH MONITORING SYSTEM

QRS Detection of obstructive sleeps in long-term ECG recordings Using Savitzky-Golay Filter

The Rate-Adaptive Pacemaker: Developing Simulations and Applying Patient ECG Data

ELECTROCARDIOGRAM (ECG) SIGNAL PROCESSING ON FPGA FOR EMERGING HEALTHCARE APPLICATIONS

Premature Ventricular Contraction Arrhythmia Detection Using Wavelet Coefficients

Signal Processing of Stress Test ECG Using MATLAB

Portable ECG Electrodes for Detection of Heart Rate and Arrhythmia Classification

Designing scheme for Portable ECG System with Real-Time Application

Lab #3: Electrocardiogram (ECG / EKG)

Delineation of QRS-complex, P and T-wave in 12-lead ECG

On the Algorithm for QRS Complexes Localisation in Electrocardiogram

A Novel Approach for Different Morphological Characterization of ECG Signal

Fuzzy Based Early Detection of Myocardial Ischemia Using Wavelets

Combination Method for Powerline Interference Reduction in ECG

Clinical Accuracy QRS Detector with Automatic Parameter Adjustment in an Autonomous, Real-Time Physiologic Monitor*

Robust R Peak and QRS detection in Electrocardiogram using Wavelet Transform

DEVELOPMENT OF A SIMPLE SOFTWARE TOOL TO DETECT THE QRS COMPLEX FROM THE ECG SIGNAL

EHS QUICKSTART GUIDE RTLAB / CPU SECTION EFPGASIM TOOLBOX.

SSRG International Journal of Medical Science ( SSRG IJMS ) Volume 4 Issue 1 January 2017

A Simple Portable ECG Monitor with IOT

PCA Enhanced Kalman Filter for ECG Denoising

PART I. Disorders of the Heart Rhythm: Basic Principles

Transcription:

ELG 6163 - DSP Microprocessors, Software, and Applications Final Report Implementation of algorithms for QRS detection from ECG signals using TMS320C6713 processor platform Carleton Student # 100350275 geoffgreen@ieee.org March 31, 2006

Introduction and Application of Interest The electrocardiogram (ECG) provides a physician with a view of the heart s activity through electrical signals generated during the cardiac cycle, and measured with external electrodes. Its clinical importance in cardiology is well established, being used for example to determine heart rate, investigate abnormal heart rhythms, and causes of chest pain. As shown in Figure 1, the most important ECG signal features in a single cardiac cycle are labelled (along with the physiological cause of that feature) : P wave - due to depolarization of the atria Q wave - due to activation of the anterioseptal region of the ventricular myocardium R wave - due to depolarization of the ventricular myocardium S wave - due to activation of the posteriobasal portion of the ventricles T wave - due to rapid ventricular repolarization Figure 1: An ideal ECG signal from a healthy subject (time duration equivalent to one heartbeat). Key features, including the QRS complex, are identified. Because the QRS complex is the major feature of an ECG, a great deal of clinical information can be derived from its features. Identification of this feature in an ECG is known in the literature as QRS detection, and it is a vital task in automated ECG analysis, portable arrhythmia monitoring, and many other applications. Though trivial in an ideal ECG (as shown in Figure 1), the range in quality of real-world ECG signals obtained from a variety of subjects under different measurement conditions makes this task much more difficult (see Figure 2). QRS detection in ECG signals has been the focus of a wide body of research for the last few decades. One finds in the literature a diverse collection of techniques drawn from many fields (an excellent review of which is given in ), including: methods based on discrete derivatives, methods based on digital filtering, methods based on a wavelet representation of the ECG signal, methods based on neural networks, methods based on adaptive filtering, methods based on genetic algorithms, methods based on maximum a posteriori (MAP) estimation.

Figure 2: A variety of real world ECG signals (taken from the MIT/BIH Arrhythmia Database ) showing the effects of noise and time-varying morphology a) Record 101, b) 102, c) 104, d) 106. Project Scope In this course project, I focussed on the implementation of a QRS detection algorithm (algorithm details are in the next section) on a programmable DSP. The platform that I used is the TMS320C6713 DSP Starter Kit (DSK) and its associated tools, with the following features : floating point support advanced VLIW architecture up to eight 32-bit instructions executed each cycle on-board A/D and D/A converters Code Composer Studio IDE with C compiler, software pipeline support, profiler capability, debugging capabilities real time data exchange (RTDX) between target and host The bulk of the development effort was done in Simulink (and Matlab). Using the tools below (see Figure 3), the Simulink model files were programmed onto the DSP. Real Time Workshop Plug-in for Code Composer Studio Signal Processing Toolbox / Signal Processing Blockset Texas Instruments (TI) Embedded Target for C6000 QRS Detection Algorithm Description The first algorithm (Pan/Tompkins 1985) is summarized in the block diagram shown in Figure 3 (full details are given in [4]), as well as a series of plots showing intermediate results at various stages in the process. This algorithm uses a hybrid of several processing methods, drawing heavily on digital filtering techniques and sophisticated peak selection rules. Their QRS detector consists of three stages that are expanded on below: 1. Linear digital filtering 2. Nonlinear transformation 3. Decision rule algorithms

1. Linear Digital Filtering This stage is intended to emphasize signal characteristics that are specific to the QRS complex while suppressing irrelevant information. This reduces the possibility of false positives. a) A bandpass filtering of the ECG (for noise reduction) is done by cascading the following filters: Low pass (IIR filter with 3dB frequency cutoff ~ 11 Hz): y[ n] = 2y[ n 1] y[ n 2] + x[ n] 2x[ n 6] + x[ n 12] High pass (IIR filter with 3dB frequency cutoff ~ 5 Hz): 1 1 y[ n] = y[ n 1] x[ n] + x[ n 16] x[ n 17] + x[ n 32] 32 32 b) A discrete derivative is computed in order to emphasize the high slope of the QRS complex: Derivative : 1 y[ n] = (2x[ n] + x[ n 1] x[ n 3] 2x[ n 4]) 8 c) A moving window integrator (MWI) is used to ensure that a measure of QRS complex width is included in the processed signal (since R-wave slope information is not sufficient to isolate the QRS complex). A window size of 30 samples (determined empirically) allows the capture of a wide QRS complex with a single pulse in the MWI output. Equally important, it is sufficiently small to avoid the possibility of including T wave contributions. Moving Window Integrator: 1 y[ n] = ( x[ n] + x[ n 1] + x[ n 2] + L + x[ n 29]) 30 (Note: The nonlinear squaring operation (see below) is performed before the MWI filter is applied). 2. Nonlinear Transformation The nonlinear step is a squaring operation, creating a positive-valued signal that emphasizes high frequencies (suitable for subsequent moving window integration). 3. Decision Rules At this point in the algorithm, the preceding stages have produced a roughly pulse-shaped waveform at the output of the MWI (see Figure 3). The determination as to whether this pulse corresponds to a QRS complex (as opposed to a high-sloped T-wave or a noise artefact) is performed with an adaptive thresholding operation and other decision rules outlined below. a) FIDUCIAL MARK - The waveform is first processed to produce a set of weighted unit samples at the location of the MWI maxima. This is done in order to localize the QRS complex to a single instant of time. The w[k] weighting is the maxima value. y [ n] = w[ k] δ[ n k] k = MWI peak locations b) THRESHOLDING - When analyzing the amplitude of the MWI output, the algorithm uses two threshold values (THR_SIG and THR_NOISE, appropriately initialized during a brief 2 second training phase) that continuously adapt to changing ECG signal quality. The first pass through y[n] uses these thresholds to classify the each non-zero sample (CURRENTPEAK) as either signal or noise: If CURRENTPEAK > THR_SIG, that location is identified as a QRS complex candidate and the signal level (SIG_LEV) is updated: SIG _ LEV = 0.125 CURRENTPEAK + 0.875 SIG _ LEV

If THR_NOISE < CURRENTPEAK < THR_SIG, then that location is identified as a noise peak and the noise level (NOISE_LEV) is updated: NOISE _ LEV = 0.125 CURRENTPEAK + 0.875 NOISE _ LEV Based on new estimates of the signal and noise levels (SIG_LEV and NOISE_LEV, respectively) at that point in the ECG, the thresholds are adjusted as follows: THR _ SIG = NOISE _ LEV + 0.25 ( SIG _ LEV NOISE _ LEV ) THR _ NOISE = 0.5 ( THR _ SIG) These adjustments lower the threshold gradually in signal segments that are deemed to be of poorer quality. c) SEARCHBACK FOR MISSED QRS COMPLEXES - In the thresholding step above, if CURRENTPEAK < THR_SIG, the peak is deemed not to have resulted from a QRS complex. If however, an unreasonably long period has expired without an abovethreshold peak, the algorithm will assume a QRS has been missed and perform a searchback. This limits the number of false negatives. The minimum time used to trigger a searchback is 1.66 times the current R peak to R peak time period (called the RR interval). This value has a physiological origin - the time value between adjacent heartbeats cannot change more quickly than this. The missed QRS complex is assumed to occur at the location of the highest peak in the interval that lies between THR_SIG and THR_NOISE. In this algorithm, the RR interval is calculated as an average of the last eight QRS locations in order to adapt to changing heart rate. d) ELIMINATION OF MULTIPLE DETECTIONS WITHIN REFRACTORY PERIOD - It is impossible for a legitimate QRS complex to occur if it lies within 200ms after a previously detected one. This constraint is a physiological one due to the refractory period during which ventricular depolarization cannot occur despite a stimulus[1]. As QRS complex candidates are generated, the algorithm eliminates such physically impossible events, thereby reducing false positives. e) T WAVE DISCRIMINATION - Finally, if a QRS candidate occurs after the 200ms refractory period but within 360ms of the previous QRS, the algorithm determines whether this is a genuine QRS complex of the next heartbeat or an abnormally prominent T wave. This decision is based on the slope of the waveform at that position. A slope of less than one half that of the previous QRS complex is consistent with the slower changing behaviour of a T wave otherwise, it becomes a QRS detection.

Figure 3: Stages of QRS Detection Algorithm (Pan/Tompkins 1985) Testing Inputs There are a couple of options for testing the algorithm with a real ECG signal one is to use my own ECG (suitably recorded with a electrodes and a biopotential amplifier) or to use a prerecorded one from a publicly available database. In this project, I opted for the second approach. The signals chosen were from the MIT/BIH Arrhythmia Database, a set of publicly available twolead ECG records (11-bit data, sampling rate = 360 sps, 30 minutes each) that have been annotated by cardiologists to indicate the location of the true QRS detections. After this signal had been read into Matlab, the sound command was used to play the signal, using the D/A converter of the computer s sound card. On the C6713 DSK board, that analog signal was subsequently digitized, then used as the input ECG signal for the DSP. The output of can be compared to the true QRS detections (in the annotations) to help identify whether or not the algorithm is working correctly. The setup is shown in Figure 4. Laptop running Matlab/Simulink and Code Composer Studio TI C6713 DSK board Sound Card Out (D/A) In (A/D) In (A/D) Out (D/A) Scope/ RTDX Figure 4: Testing setup

Project Workflow 1. Initial Testing of Algorithm (Simulink only) The first stage in the development was to implement the algorithm as a Simulink model file, to verify its operation. A model file was constructed that used only blocks from the main Simulink library (i.e. no DSP blockset or TI blocks). The model file was constructed in a modular fashion, using subsystems as required. The full model file is provided in Appendix A. At this stage, the input consisted of an ECG signal from the MIT/BIH database, which was read into the Matlab workspace using Physionet tools. It was then incorporated into the model file using the From workspace block. This signal was originally sampled at 360Hz. The model was verified by performing Simulink simulation and results from various algorithm stages (using the Scope block) are presented in Appendix A. The final signal consists of a single spike for each QRS complex in the ECG signal, which is the desired output. 2. Transfer of Algorithm to TI C6713 DSK Having successfully implemented the QRS detection algorithm in Simulink, the next step was to convert the model file into one that could be used to generate running code on the TI C6713 P- DSP. The development process is outlined in Figure 5 and explained below. Modification of model file It was not possible to simply use the model file developed above. Indeed, transferring this model file to one which was C6713-friendly took most of the development effort. Some issues that were encountered included: Introducing blocks from the TI Embedded Target for C6000 library, such as target board type, reset blocks, etc. Incorporating the DSK s A/D and D/A converters in place of software scope blocks. This stage, while conceptually simple, was complicated by several software incompatibility issues (see Discussion section) Switching from Simulink main library blocks to DSP blockset blocks for most of the components including digital filters, delay blocks, data type conversion, rate transitions, and switches. It was not immediately obvious which of the blocks needed to be changed in some cases, this was done quite easily but in other cases, it required a significant level of troubleshooting. Incorporating the RTDX blocks into the model file so that it would be possible to see the data being returned from the DSP board. Again, this stage should have been simple but was complicated by software incompatibility issues. Setting up Configuration Parameters There are several configuration parameters that are associated with the Simulink model file, specifying such things as model solvers, simulation diagnostics, and several Real-Time Workshop parameters such as hardware target board, compiler/linker options, byte ordering, etc. For the most part, these were easy to determine (based on an example provided in the TI documentation). A full list of these can be by selecting Simulation -> Configuration Parameters in the model file included with this report.

Generating Code After modifying the model file, it was necessary to get the algorithm code into a form so that it could be programmed on the P-DSP. This was done with Real-time Workshop, a Matlab toolbox that converts the Simulink.mdl (model) file into C code. For my project, the following source files were generated by Real-time Workshop. This was essentially a push button stage that went quite easily (since the bulk of the development effort was spent generating the model file). Investigation of the C source files that were generated revealed that there was a substantial amount of overhead but the crux of the algorithm seemed to be quite efficient, especially for the digital filtering stages. Building Executable and Sending to C6713 DSK board Having produced the required C files (along with an associated CCS project (.pjt) file), the Realtime Workshop build process (in association with the Matlab Link for Code Composer Studio (CCS) toolbox) then launches the CCS package. In CCS, the code is compiled (convert C to assembly code), assembled (convert assembly code to machine code) and linked in order to produce an executable (COFF format -.out file) which is then downloaded to the C6713 board and executed.

Matlab Matlab workspace Link for Code Composer Simulink Model (.mdl) file Main Simulink block library Signal Processing Blockset TI Embedded target for C6000 REAL TIME WORKSHOP C Code Code Composer Studio - C compiler - Assembler - Linker COFF file (.out) C6713 DSK RTDX Data JTAG over USB Figure 5: Overall development process using TI C6713 target with Simulink/Matlab and associated toolboxes. Discussion of Problems Resolved / Outstanding Issues / Future Work (preliminary) There was an incompatibility between the versions of Code Composer Studio (2.2) and Matlab (7.0.1) that I was using that prevented any RTDX data from being sent from the DSP to Matlab for debugging/algorithm validation. This issue was a significant setback and it is document in the following URL: http://www.mathworks.com/support/solutions/data/1-q28ib.html?solution=1-q28i This problem was resolved by upgrading to Matlab 7.0.4.

Right now, the algorithm implementation easily works at 8000Hz. It would be interesting to increase the sampling frequency to see when overrun condition appears (i.e. when the output can t keep up with the processing to maintain real-time operation). The feedback loop for adaptive thresholding works perfectly during Simulink simulation, but not during Real-time Workshop code generation. The T-wave discrimination and Searchback for Missing QRS parts of the QRS detection algorithm have not been implemented yet. In the interests of moving ahead with the P-DSP part of the project, a simplified version of the algorithm (that still performs QRS detection) was used. I have still not been able to successfully interface the A/D converter due to another incompatibility between Code Composer 2.2 and Matlab 7.0.4. To workaround this, I have stored the ECG input sample in RAM on the P-DSP. I had no time to investigate the wavelet-based QRS detection algorithm (Kadambe et al.1999) in the original project proposal. A detailed profiling during code execution (this can be performed at both the Simulink level and the Code Composer level) would be interesting to possibly isolate areas where the efficiency of the implementation can be improved. References Rangayyan, R. M. Biomedical Signal Analysis A Case-Study Approach, IEEE Press/Wiley, New York, NY, 2002. B-U. Köhler, C. Hennig, and R. Orglmeister, The Principles of QRS Software Detection IEEE Eng. Med. Biol. Mag., pp. 42-57, 2002. PhysioNet, http://www.physionet.org J. Pan and W.T Tompkins, A Real-Time QRS Detection Algorithm IEEE Trans. Biomed. Eng. vol 32, pp.230-236, 1985. S. Kadambe, R. Murray, G.F. Boudreaux-Bartels, Wavelet Transform-Based QRS Complex Detector, IEEE Trans. Biomed. Eng. vol. 46, pp.838-848, 1999. Texas Instruments, http://focus.ti.com/docs/toolsw/folders/print/tmdsdsk6713.html The Mathworks, http://www.mathworks.com