Maxim ECG AFE (MAX30001) is a complete biopotential and bio-impedance analog front end solution for wearable consumer products. In addition to the AFE amplifier and ADC commonly found in competitive parts, the MAX30001 has a built-in sophisticated ECG detection algorithm that minimizes software development time for the customer. Once proper register values are configured, the user can read heart rates detected by the built-in algorithm over SPI. For those who want to plot ECG over the screen, raw ECG data is also accessible through SPI from buffer storage.
The built-in algorithm is based on a differentiator-integrator algorithm modified from the popular Pan-Tompkins solution. Since the differentiator is used in the first phase of the algorithm, the user may want to carefully configure optimal register settings to detect various patterns of heart beats caused by an exercise-induced noise signal or underlying heart disease.
The table below lists configurable registers and a description of how these register values relate to heart beat detection. It is the purpose of this article to show the affect of these registers values on heart rate detection accuracy.
1. What are the configurable registers for heart beat detection?
RTOR_PTSF | RTOR_PTSF is the fraction of the average peak value of the integrated output in the Pan-Tompkins solution where the detection threshold is set. RTOR_PTSF is a 4 bit binary number that can have values of 0-15. The value of the threshold will be the AVE_PEAK*(1+RTOR_PTSF)/16. When the integrated output of the algorithm exceeds the threshold value, the algorithm starts to search for peaks. When the integrated output drops below the threshold, the algorithm stops looking for peaks and updates its findings. |
RTOR_WNDW | RTOR_WNDW is the number of sample averages in the integration filter, which is equivalent to the width of averaging window. |
RTOR_PAVG | RTOR_PAVG is the number of detected peaks of the integrated output of the modified Pan-Tompkins solution used in the calculation of the average peak value. Peak_Average(n)= [Peak(n) + (RTOR_PAVG-1) *Peak_Average(n-1)] / RTOR_PAVG |
RTOR_HOFF | RTOR_HOFF (R-to-R minimum holdoff interval) is the minimum number of samples that must occur from the previous qualified R-peak for a new R-peak to be qualified. |
RTOR_RAVG
| RTOR_RAVG is the R-to-R Interval averaging weight factor used in forming the average R-to-R value. Interval _Average(n)= [Interval (n) + (RTOR_RAVG-1)*Interval _Average(n-1)] /RTOR_RAVG |
RTOR_RHSF | RTOR RHSF (R-to-R interval hold off scaling factor) is the fraction of the R-to-R interval average used to qualify a new detected R-peak. If the new R-peak occurs before RR_AVE*RTOR_RHSF/8 samples then the new detected R-peak is rejected. RR_AVE is the average of R-to-R duration. |
RTOR_GAIN | RTOR_GAIN is the post input BPF gain applied to the signal for further processing through the detection algorithm. |
Table 1. Description of MAX30001 registers for ECG detection optimization.
2. How register value affects the outcome?
2.1 RTOR_PTSF register
RTOR_PTSF is the fraction factor for the average peak value of the processed output in the modified Pan-Tompkins solution and affects how detection threshold is set. RTOR_PTSF is a 4 bit number that can have values of 0-15. The value of the threshold will be determined by the formula AVG_PEAK*(1+RTOR_PTSF)/16. When the integrated output of the Pan-Tompkins solution exceeds the threshold value, the algorithm starts to search for peaks. When the integrated output drops below the threshold, the algorithm stops looking for peaks and updates its findings.
RTOR_PTSF and RTOR_WNDW need to be well-balanced between each other since an increased value of RTOR_WNDW will lower the amplitude of output of the differentiator-integrator. If RTOR_PTSF is set too high, the algorithm will be less likely to detect the integrator output caused by noise. If RTOR_PTSF is set too low, it will detect the noise peaks as a beat.
Decreased slope from SVC or PVC (example of slow sloped ECG pattern) would lower the integrator output. Therefore, it is necessary to find an optimal value for RTOR_PTSF which detects as many valid beats as possible while ignoring the noise-induced peaks.
Figure 1. PTSF =3 vs PTST=12
In example shown in Figure 1, normal heart rhythm called QRS complex is disrupted by SVC (supra ventricular contraction) four times. The amplitude of processed SVC output from the algorithm is smaller than the output of normal QRS ECG (bottom graphs). To detect both QRS and SVC correctly, it is necessary to have small PTSF value (3 in this case); PTSF value of 12 set the threshold too high and missed 4 SVC beats on right side panels. Too small PTST will make threshold close to 0 and susceptible to choose the noise spike as a beat.
2.2 RTOR_WNDW register
RTOR_WNDW is the number of samples used in calculation of averages in the integration filter of the modified Pan-Tompkins solution. RTOR_WNDW is a 3-bit number representing even values between 12 and 26. This allows the integration window size to be adjusted. Choosing a larger number for RTOR_WNDW increases the number of output from the integrator and results in lower/smoother amplitude; while reducing RTOR_WNDW decreases the number of output from the integrator with larger amplitude.
Figure 2. WNDW=3 vs WNDW=15
In Figure 2 example, setting WINDW =3 detected ventricular fibrillation event as separated beats as shown left bottom graph. When WINDW is changed to 15, increased integration window size makes the output from integration filter are fused as one cluster and ventricular fibrillation beats miss the detection.
2.3 RTOR_PAVG register
RTOR_PAVG is the number of detected peaks of the integrated output used in the creation of the average peak value. PTOR_PAVG is a 2 bit register and can have any value from {2, 4, 8, 16}. Peak average is a 1st order IIR average function. Smaller PAVG make average peak value adaptive to change quickly.
Figure 3. PAVG=0 vs PAVG=3.
In example described in Figure 3, averaged peaks of left side graphs are from 2 point peak average; while right side plot are from 16 point average. As expected, short average window made averaged value adapt quicker compared to the long average window. Linear fraction of this averaged peak value is used for the threshold for beat detection.
2.4 RTOR_HOFF register
RTOR_HOFF contains value for R-to-R minimum holdoff interval and it is the minimum number of samples that must occur from the past qualified R-peak for a new R-peak to be qualified. This is a 6 bit register in which the number of samples {0.. 63} required between qualified R-peaks. If sampling frequency is 125Hz and RTOR_HOFF is set to 63, this rejects any beat of new R-peaks that occur within 0ms to 504ms from a previous R-peak (63* 1000 ms /125) =504 ms ). RTOR_HOFF and RTOR_RHSF are similar methods of improving noise immunity of the algorithm.
Figure 4. HOFF=4 vs HOFF=32
In this example, let’s pay attention to the noise between 2nd and 3rd beats. When HOFF is 4, two noise peaks are classified as beats incorrectly. However only one noise peaks is classified as beat when HOFF is 32. On left graph, HOFF is too small enough to assume that new beat is detected as qualified beat even if it is not physiologically possible. Decision of HOFF value will be considered in consideration of physiological term. If device is specified to detect maximum heart rate of 250 beats per minutes, data point equivalent to 60000 ms/ 250 =240 ms should be set as HOFF.
2.5 RTOR_RAVG register
RTOR_PAVG is the number of detected peaks of the integrated output used in the creation of the average peak value. Same concept can be applied to create the average R-R interval value. This variable is used for internal dynamic Holdoff calculation. RTOR_RAVG is the R-to-R Interval averaging weight factor that are used in forming the average R-to-R value. RTOR_RAVG is a 2 bit registers and represents values of 2, 4, 8, 16. The R-to-R average is a 1st order IIR average function:
Interval _Average(n)= [Interval (n) + (RTOR_RAVG-1) * Interval _Average(n-1) ] /RTOR_RAVG
Figure 5. RAVG=2 vs RAVG=4
Above example shows how averaged interval is calculated with different weight factors on the past averaged interval. When R-R is varying a lot, smaller RAVG provide better tracking in the averaged interval. When RAVG is maximum, effect of past averaged interval to the current averaged interval is negligible.
2.6 RTOR_RHSF register
RTOR_RHSF (R-to-R interval hold off scaling factor) is the fraction of the R-to-R interval average used to qualify a new detected R-peak. RTOR_RHSF is a three bit numbers that can have values of 0 to 7. The average R-to-R duration is computed using RTOR_RRAVG samples and if the new R-peak occurs before RR_AVG*RTOR_RHSF/8 samples then the new detected R-peak is rejected. RR_AVG is average of R-to-R duration.
Figure 6. RHSF=1 vs RHSF=7
Let’s focus on first SVC beat (big amplitude one!). Corresponding average R-R interval is approximately 95 and internal Holdoff value would be 95*1/8 = ~12 samples. Therefore, two peaks separated by greater than 12 samples will be qualified to as valid beats and be reported.
If we applied the same thought on the right side, averaged R-R interval matched to first SVC beat is approximately 95 and internal Holdoff value would be 95*7/8 = ~83 samples. Raw R-R just before SVC is 60 samples (from left-top pane) which is less than Holdoff value. This is the reason why all SVCs are not detected when RHSF is equal to 7.
2.7 RTOR_GAIN register
RTOR_GAIN is the post input BPF gain applied to the signal for further processing through the detection algorithm. RTOR_GAIN is a four bit value resulting in post input BPF gain of 2^RTOR_GAIN. The input BPF is operated at full 18-bit dynamic range while downstream algorithm is implemented in 12-bit dynamic range. The mapping of from the 18-bit to 12-bit dynamic range is done through this gain setting.
Figure 7. GAIN=2 vs GAIN=12 (actual gain factor is 22 vs 214 )
In this example of Figure.7, raw ECG is collected with ADC setting of 12 bit over 10 mV. For this simulation of MAX30001 ECG AFE, ADC setting of 17 bit over 50 mV is used. Therefore, scaling factor is as follows: (10 mV/ 2^12)/50. By multiplying ADC codes to the scaling factor, we converted ADC codes to mV unit and this is y-axis unit on the two bottom graphs. After these raw ECG values are multiplied by the RTOR_GAIN and processed by modified Pan-Tompkins, top graphs are made. Using proper RTOR_GAIN allow the user take advantage of maximizing the dynamic range of algorithm. Poor granularity of data due to low RTOR_GAIN will be likely to produce becomes incorrect detection time in high sampling rate.