HRV:Signal Processing

From OpenWetWare
Jump to navigationJump to search

HRVlogo.png

Home        Lab Members        Physiological Systems        Monitoring Parameters in the ICU        ECG        HRV        Clinician's Perspective        Cardiorespiratory Monitors        Signal Processing        Deliverables        Journal        Abbreviations       


Signal Processing

In order to create an algorithm that is able to accurately extract HRV and use it in a way which is useful to a clinician, the signal processing is broken down into the following steps:

  1. Obtaining ECG data from archives
  2. Using this data to plot a typical ECG waveform
  3. Removal of noise
  4. Detection of the R wave peak
  5. Extrapolation of R wave peak to HRV in the time domain
  6. Linking this is changes in physiological signal to predict medical events

More steps may be added through the process depending on what is found at each stage.

The team will be using Python to accomplish this.

Coding Plan
Our Coding Plan

Evolution of our Code

A more detailed guide to the steps included in the code can be seen in the diagram below.

FullCodingDiagram.PNG
A More Detailed View of Our Coding Plan

Opening a .csv File

Opening a .csv file and printing the ECG data, https://github.com/cay15/hrv/blob/master/52.py The ECG dataset which was used to produce these plots is the MIT-BIH Normal Sinus Rhythm Sample No.16265[1][2].

Pre-Processing

Resampling our input file to 1000Hz, so that it is consistent over different inputs, https://github.com/cay15/hrv/blob/master/upsample_ecg.py. This also splits the signal so a smaller, more manageable chunk is passed to the other modules. The ECG dataset which was used to produce these plots is the MIT-BIH Normal Sinus Rhythm Sample No.16265 [1][2].

Artificial ECG

Creating an artificial ECG to test out the filtering and peak detection modules, https://github.com/cay15/hrv/blob/master/fakeecg.py. The ECG QRS segment is modelled by a Daubechies wavelet, while the rest of the wave is given by an interval of rest. Gaussian noise and sinusoids of various frequencies are added to simulate mains noise, electromyogram noise, and baseline offset.

Artificialnoise.png
Section of the Artificial ECG

Filtering

Testing out filtering methods including a notch filter, high pass and low pass, https://github.com/cay15/hrv/blob/master/filter.py . The notch filter is designed to remove mains interference at 50Hz. The low pass filter is designed to remove electromyogram noise and other high-frequency noise with a cutoff of 150Hz. The high pass filter is designed to remove baseline drift and other low-frequency noise with a cutoff of 0.5Hz.

R Peak Detection

  1. Peak detection module which finds peaks based on whether surrounding samples have greater amplitudes than it, mirrors these peaks, for the case where peaks are inverted from medical conditions or lead placement. It then uses boundaries which can be specified to rule out peaks that are too close together by specifying a minimum amplitude, https://github.com/cay15/hrv/blob/master/peak_detection.py.

Here are the results obtained using a normal sinus rhythm ECG, the peaks are very clearly and accurately detected. The data used was from the MIT-BIH Normal Sinus Rhythm Database [1][2].

The sample used below is from the MIT-BIH Malignant Ventricular Database[1] [3] and was used to test the module on a much more difficult ECG than normal sinus rhythm.

The application of boundary conditions is not perfect and needs tweaks in order to be as accurate as possible.

Modules Combined

These functions have been combined to one code which takes in the .csv file, resamples it, removes noise and detects the peaks, https://github.com/cay15/hrv/blob/master/main.py

The previous code has been amended to allow more user input in terms of deciding whether to sample an artificial ECG or a raw .csv file and if it is a raw file, which lead of the ECG to process, https://github.com/cay15/hrv/blob/master/main12.py.

Results for Normal ECG

Results for Arrythmia

Results for Noise Stress Test

Results for Artificial ECG

References

  1. 1.0 1.1 1.2 1.3 Goldberger AL, Amaral LAN, Glass L, Hausdorff JM, Ivanov PCh, Mark RG, Mietus JE, Moody GB, Peng C-K, Stanley HE. PhysioBank, PhysioToolkit, and PhysioNet: Components of a New Research Resource for Complex Physiologic Signals. Circulation 101(23):e215-e220 [Circulation Electronic Pages; http://circ.ahajournals.org/content/101/23/e215.full]; 2000 (June 13).
  2. 2.0 2.1 2.2 T. A. L. The Beth Israel Deaconess Medical Center, ‘The MIT-BIH Normal Sinus Rhythm Database’. physionet.org, 1990, doi: 10.13026/C2NK5R.
  3. S. D. Greenwald, ‘The MIT-BIH Malignant Ventricular Arrhythmia Database’. physionet.org, 1992, doi: 10.13026/C22P44.