Close

Analyzing HRV for Arrhythmia

A project log for HeartyPatch: A single-lead ECG-HR patch with ESP32

HeartyPatch is a fully open-source, IoT connected, BLE enabled heart-rate variability & ECG patch with great accuracy

ashwin-k-whitchurchAshwin K Whitchurch 07/20/2017 at 18:424 Comments

So now that we had a good way to measure the heart rate and the R-R interval variance, we wanted to put it to test and see if we can actually differentiate between normal rhythms and some common forms of Arrhythmias using the R-R intervals. What we found was quite promising. 

For HRV analysis, we used Kubios (http://www.kubios.com/), a great piece of software to study heart-rate variability. This is commercial software, not open source, but they do have a version for "Personal use". Since this is an open source project, I'm assuming this would be fine. Please correct me if I'm wrong. 

The Hookup

We connected the left-arm and right-arm electrodes of the HeartyPatch to two pins on an ECG simulator that can also do Arrhythmia simulation. Using Kubios, we looked at the Poincare plot (the actual variance between the current sample and the immediate preceding sample) and some spectral analysis (the result of an FFT). These are the results.

Here are the Poincare plots:


Results of the spectral analysis:


As you can see, there are noticeable patterns in both the poincare time-domain data as well as the frequency-domain data to differentiate between these 3 forms of Arrhythmia and a normal sinus rhythm. 

Now, armed with this data, we can go into recognizing patterns when things go wrong, and even better, BEFORE things can go wrong. We are looking at using Tensorflow (https://www.tensorflow.org/) for creating a machine learning interface for predictive analysis. Of course, large amounts of data would be required to "train" this ML Network, and we're yet to figure out how. 

Please let us know if you have any comments.

Discussions

Ashwin K Whitchurch wrote 07/21/2017 at 18:22 point

Thanks so much Jean for your very detailed reply. I will go through some background material about this during the weekend and get back to you. 

  Are you sure? yes | no

Jean Pierre Le Rouzic wrote 07/21/2017 at 07:15 point

I will be honored to be of any help, I am a beginner in those fields.
You have to decide what features you will train your ML framework on, and from your post, you may have good results with both the Poincarré plot and FFT for ventricular fibrillation. I find the FFT of "second degree block" not being what I would have expected. Kubios provides you the HF and LF for the two other cases and they enable a clear differentiation between the normal and premature ventricular tachycardia, which is good.
There is at least one open source software (https://www.physionet.org/tutorials/hrv-toolkit/) that computes HF and LF. So you can easily have a first try with this small list of features (bigger list of 18 features at end of post):

    1. Approximate number of heart beats,
    2. Amplitude of additive uniformly distributed noise,
    3. Heart rate mean,
    4. Heart rate std,
    5. Low frequency,
    6. High frequency std,
    7. Low frequency std,
    8. High frequency,
    9. LF/HF ratio

In the Physionet 2016 challenge 18 types of features are often used (I do not pretend being familiar with the terms in this list :-) the list of 9 features above is enough difficult for me ):

    1. Time Domain (T1~T5): average of RR intervals (T1); standard deviation of RR intervals (T2); root mean square of successive RR interval difference (T3); percentage of successive RR interval difference larger than 50ms (T4) ; coefficient variation (ratio of T2 to T1) of RR intervals (T5) ;

    2. Frequency Domain (F1~F4): power of RR intervals in 0.04–0.15 Hz (F1); power of RR intervals in 0.15–0.4 Hz (F2); ratio of F1 to F2 (F3); total power (F4) ;

    3. Nonlinear (E1~E9): low frequency wavelet entropy (E1); high frequency wavelet entropy (E2); normalized low frequency wavelet entropy (E3); normalized high frequency wavelet entropy (E4); ratio of E1 to E2 (E5); total power wavelet entropy (E6); approximate entropy (E7); sample entropy (E8); fuzzy entropy (E9).

    4. D1: mean value of basic measures of 5-min segments, for robustness improvement (S4T1~S4E9).

    5. D2: standard deviation of each basic measure of 5-min segments (D1T1~D1E9);

    6. D3: root mean square of each basic measure of 5-min segments (D2T1~D2E9);

    7. D4: coefficient variation of each basic measure of 5-min segments (D3T1~D3E9);

    8. D5: percentage of abnormal value (value intervening M±S) of each basic measure of 5-min segments (D4T1~D4E9);

    9. D6: sample entropy of each basic measure of 5-min segments (D5T1~D5E9);

    10. D7: fuzzy entropy of each basic measure of 5-min segments (D6T1~D6E9).

    11. frequency-domain HRV measures using PSD estimation with the FFT algorithm.

    12. frequency-domain HRV measures using PSD estimation with the LS algorithm.

    13. frequency-domain HRV measures using Variance, Energy, and Entropy values from the Wavelet transform.

    14. non-linear HRV measures using Poincare plot.

    15. non-linear HRV measures using Symbolic dynamics.

    16. non-linear HRV measures using Detrended fluctuation analysis.

    17. non-linear HRV measures using Sample entropy

    18. time-domain HRV measures;

  Are you sure? yes | no

Ashwin K Whitchurch wrote 07/21/2017 at 04:14 point

Thanks Jean. I'll certainly take a look at all the resources, looks very interesting. I see that you have a project here too, https://hackaday.io/project/19685-early-and-low-cost-detection-of-heart-failure. That's amazing. We're just getting started with ML and maybe I'll ask for your help !

  Are you sure? yes | no

Jean Pierre Le Rouzic wrote 07/20/2017 at 20:03 point

Hi,
Nice ideas!
You can certainly use TensorFlow or another ML framework for predictions of heart problems as competitors in Physionet 2016 [0] did that kind of thing with excellent results. I forked the best submission in [1] and added some libraries, you can have a look, it is really interesting.
You can find hundred megabytes of data, some in the Physionet 2016 site and also at Peter Bentley's site [2] which was used in a 2012 Kaggle competition.

[0] https://physionet.org/challenge/2016/
[1] https://github.com/Hjertesvikt/Physionet_2016
[2] http://www.peterjbentley.com/heartchallenge/

  Are you sure? yes | no