Thursday, November 12, 2015

Diabetic Autonomic Neuropathy - RR Intervals analysis part 2

Basic ECG Info.

When you record an ECG, you record the electrical activity generated by the heart's contraction. Each beat should produce something like this

The P Wave represents the atrial depolarization (contraction) triggered by the autonomic system. The PR segment measures the time it takes for the influx to travel from the atria to the ventricules. The QRS complex represents the ventricular depolarization (contraction) and the T wave represents the ventricular repolarization (relaxation). A beating heart produces (hopefully) a stream of PQRSTs. The autonomic "balance" controls the heart rhythm from a bundle of nerve tissue called the sinoatrial node (SA). Ideally, it is at the SA that the autonomic triggers occurs and where it should be measured but that would require intra-cardiac electrodes... That is why the very characteristic tip of the R wave is used as a proxy. RR Intervals variability analysis is simply a fine grained analysis of your base heart rythm variation.

Normal vs Diabetic vs poorly controlled diabetic.

Let's start by the chart showing the main point in Clarke's paper about RR Interval analysis in diabetics.
Non diabetics have a SDNN - which stands for Standard Deviation Normal (R) to Normal (R) - between 50 and 100 milliseconds. The diabetic population as a whole shows a very different distribution, from 0 to 100 milliseconds, heavily skewed to the sub 50 milliseconds variability zone. (with a possible outlier). Diabetics with proliferative diabetic neuropathy show a drastic reduction in RR variability. That looks simple enough...

But why the SDNN and not simply the SD? Well, even a normal healthy heart can offer some spectacular, but harmless, non normal beats such as ventricular extra systoles. At some point, your ventricule decides it has waited enough and contracts spontaneously. Here is one of those PVC (premature ventricular contraction) on my own heart. You have probably had those and call them "palpitations". Such a spectacular beat, however, introduces a significant variability in your heart rhythm and must be excluded for the analysis. SDNN is not always SD. Add other potential rhythm troubles and you realize that whole recordings used in RR analysis must be reviewed by a cardiologist in order to exclude abnormal beats. At that point, the optimal method to "fill the blanks" also starts to matter. No extra beats allowed - that is the first pit in which you must not fall when you are doing a RR analysis. (and if any MD happens to read this, yes, I know about my P-Wave)

Here is the recording of Max heart I used for the rest of our tests. I could use one of the many semi arbitrary reject filter used in the literature, manual beat by beat review. Depending on the threshold, 1 to 3 beats would be rejected, I had doubts on one of them visually and went for one reject.

How did I get that ECG? With an ECG machine, obviously. A somewhat amateurish Prince 180D. Does it matter? Yes and no.

Yes, it does matter because the consumer ECG machines on the market (very good site about consumer ECG machines) have one fundamental limit: their sampling frequency. The ECG signal is measured 150 times per second. To put things in perspective, an entry level decent professional machine will take 960 samples per second... but will cost ten times as much. (There are also other differences: denoising and signal cleanup algorithms, number of simultaneous channels etc...). Today, you wouldn't find a cardiologist that would consider 150 Hz sampling useful.

 But no, it does not matter because a lot of the RR interval analysis done in the late 80s and 90s was done on what would be considered an unacceptable sampling rate today. 128 Hz holters were frequent. ECG sampled at a low frequency: their signal only looked smooth because it was drawn by multiple moving pens...

Why worry about the sampling frequency? Because in order to find the exact timing of the R peaks, the signal must be processed. It is very hard, in a blog post, to detail that processing but lets simply say that you have to slice and dice the signal until you manage to transform the peaks into zero crossings that you can accurately measure. One of the best known algorithm used for that purpose is the Pan Tomkins algorithm (details here) and that is the one I used. Here is the result.

The red dots are the data points measured by the Prince 180D. The sampling frequency problem is obvious. Sampling 150 times per second gives enough resolution for most of the ECG, except the QRS. The trigger of the ventricular contraction happens in around 80 mseconds. That means you'll only get a dozen data points during a QRS... not exactly an optimal resolution. That's the "yes it does matter" part.

However, the green lines are the tips of the Rs detected by the Pan Tomkins algorithm. And they are extremely accurate. That's the "no, it does not matter" part. A higher sampling rate may provide a slightly more accurate result, but we don't need that for our purpose.

Sanity check: when I started this project, I had decided that I would be satisfied with an OK result given the confidence levels I could estimate (a couple of milliseconds) and that I would, of course, contact a specialized cardiologist to investigate further any abnormal results. I believe it is great to understand as fully as you can a clinical test or procedure, but one must be very careful not to overreach when it may matter.

Sampling frequency will matter more for spectral analysis (which I will possibly cover later) as explained here. So, remember, sampling frequency is the second pitfall to avoid (for "amateurs"). A decent RR interval analysis can not be achieved with any ECG that samples below 100Hz: no Arduino project, no cell phone without specialized hardware. Top of the line heart rate monitors might work (I haven't tried) and RR interval analysis can also be used to detect over training.

The third dark area is the lack of standard protocols, reference values or consistent results in the literature. Detailed methods descriptions have only recently been required/mandatory for publications. A lot of the medical literature is very fuzzy in that respect. Some attempts have been made to improve the situation over the years, but the RR Interval test isn't the recommended first test for autonomic neuropathy exploration (it is an eventual subset of the "breathing test" part of the Mayo recommended test array). A detailed look at why RR analysis is so interesting and why it hasn't been used in general can be found in this great article "Tests for early diagnosis of cardiovascular autonomic neuropathy: critical analysis and relevance."

But there is more! As we have previously seen, the autonomic balance is in a constant state of flux. It defines the ability of our cardio-vascular system to react to the thousands of events in our lives. The downside is that variability is affected by a lot of things: climb stairs to visit your doctor? stressed by the examination protocol? annoyed to undressed partly? cold? had coffee before the test? insulin? All these factors and dozens of others can significantly modify your RR variability test.

And, of course, age does matter! There are a lot of variables to take into account.

Some results

To conclude that RR analysis part 2, here are some of Max's results with a few comments.

File Size: 100240 bytes. It contains 10 pages
Hardware Version: 2.6
ECG Recorded on: 14/8/2015 at 20:38:0
Total ECG run time: 300.0 seconds
Number of samples:  45000 150 Hz

The Prince 180D ECG file format is totally non standard, some minor reverse engineering was required. If there is some interest, will detail in another post.

1st pass analysis
Detected Heart Beats : 402
Average FC (run length) : 80.4
Average FC(RR) : 80.48

First pass with Pan Tomkins. His resting heart rate is a bit higher than usual, probably because I had to run after him to organize the test and the novelty of it added some excitement. A lower frequency would have increased SDNN somewhat.

Cleaning artifacts
1 beats rejected. Reject List: [187] ...

One beat will be rejected on the criteria that it introduces a RR that is outside the 75% to 125% of the RR average of surrounding beats. Visually, it looks like a normal beat, but is a bit noisy from an electrical point of view. As I said, consumer ECG denoising isn't optimal.

Removing Extra beats
Duration of clean run 297.272 secs

Preparing RR Data
MRR (mean of RR intervals) : 745.18 msec
RMS Intervals : (RMSSD) 43.4575816574 msec
SDNN (standard deviation of normal to normal): 58.1472062957 msec
NN50, pNN50 (86, 21.55388471177945) n, %

SDNN is what we are after here. With a 58 +/- 2 msec SDNN, Max would be in the lowest bucket of the normal population and in the top half of the diabetic population. In other words, at this stage, no indication of autonomic diabetic neuropathy.

Final words for this part

There are tons of other interesting things you can do in RR interval analysis. Here is again a striking example of what it can achieve (Yang, 2006).

and the same vizualization for Max's recording which shows a healthy spread (but indicates he isn't totally well rested - again another story).

For the astute reader, look at Max's Poincare plot below, centered on 750 ms / 750 ms then look at the plot above. Can you guess Max's age? Correct, almost 15

The next part (whenever it comes) will cover more advanced analysis methods, a great professional free software that I used to double check my results and possibly some info on reversing the binary file format of the Prince 180D ECG and its interpretation.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.