Extracting heart rate from a noisy ECG signal

In general it is much better to collect high quality data than to spend time and effort formulating methods to extract information from data riddled with artifacts. For advice on biopotential data acquisition, see “Recording Good Data.”

If data have already been acquired and rate detector methods are not working well, there are a variety of approaches that may be used to help. The best approach depends on the nature of the problems in the data set. If using “Find Rate” it may be possible to adjust parameters of the rate detector to optimize it for the particular data set. App Note 142 provides a detailed explanation of the algorithms “Find Rate” uses.

Before applying any transformations to the data, it's a good idea to create a copy that will not be edited. Start by choosing the original ECG data and selecting “Edit > Duplicate Waveform” (make sure the entire data set is selected via “Edit > Select All”  if using AcqKnowledge 3). It may be helpful to repeat this step on data that have already been transformed but are about to be transformed again.  This will help to show the effect that a transformation has, and will allow the user to quickly 'go back' if the transformation made the situation worse.

What follows are some steps that may be helpful under specific circumstances.

  1. If there is a lot of drift (baseline wander) in the signal, applying an aggressive high pass filter can help considerably. Choose “Transform > Digital Filters > IIR > High Pass…” and enter a fixed cutoff frequency of, for instance, 1Hz. If drift is still apparent, this step may be repeated with a higher cutoff frequency.
  2. A frequent problem with electrophysiological data is electromagnetic interference from power lines. If the data look fuzzy (or when zoomed out, the lines look “thick”) then a band stop filter may be effective. Since harmonics of power line noise are also often problematic, it is best to use a comb band stop filter. This is a filter that has several notches in it, each notch centered at an integer multiple of the fundamental (base) frequency. Use “Transform > Digital Filters > Comb Band Stop.” AcqKnowledge should have been installed such that the “Line frequency” choice for the “Base frequency” matches the power line frequency of the area where the equipment is used (60 Hz in the US, 50 Hz through much of Europe; click for power line frequencies by country). If the line frequency is not correct, choose “Fixed at” and enter the correct frequency for the region where the data were collected. The default parameters for other settings should be fine, but make sure that “Transform entire wave” is checked. If using an older version of AcqKnowledge that doesn't have the comb band stop filter option, use “Transform > Digital Filters > IIR > Band Stop.” Start by removing the “Line Frequency,” and if the trace still looks fuzzy, apply the filter again at multiples of the line frequency (e.g., if in the U.S., use “Fixed at” “120” Hz the second time, “180” Hz the third time, etc.).
  3. If the trace still looks fuzzy, energy at higher frequencies may be removed with a low pass filter. Choose “Transform > Digital Filters > IIR > Low Pass…” and enter a fixed frequency of, for instance, 35 Hz.
  4. If electrodes were not placed in a standard LEAD II configuration or the subject has some anatomical abnormality, the largest peak associated with each heart beat may be negative (i.e., a trough). It may help to configure the rate detector to search for “Negative” peaks.
  5. If the T wave is very pronounced, applying a difference transformation (roughly equivalent to taking the first derivative of the signal) may help the R-waves to stand out against the T-waves as T-waves rise more slowly than R-waves. Choose “Transform > Difference…”, enter 1 for the number of intervals between samples, make sure “Transform entire wave” is checked, and click “OK.” Derivatives tend to be noisy, so running the data through another low pass filter may improve the situation again.
  6. In addition to or in lieu of taking the derivative, it may be useful to use a template correlation function. If there is a cleanly recorded heart beat in the waveform, select that section encompassing the entire beat and choose “Transform > Template Functions > Set Template.” Then select the entire waveform (“Edit > Select All”; Ctrl-a in Windows and Command-a in Mac), and choose “Transform > Template Functions > Normalized Cross Correlation.” This operation compares the area that was selected when “Set Template” was chosen to all other sections of the graph. It is a way of making the search look not for solitary peaks but to the entire time course of a good heart beat. There will be a peak in the resulting waveform everywhere that the data closely match the template. 
  7. The above steps are designed to deal with systemic issues. For local problems, such as brief movement artifacts, another set of techniques may be applied. If there is a segment of data during which it is not possible to see any peaks clearly assignable to cardiac R-waves, it may be best to remove the affected region from analysis. To do this without affecting the relative timing of all other segments of the data, use the I-beam tool to select the period from the beginning to the end of the artifact. Preferably have the two edges be close to the ECG baseline (which should be zero). Then choose “Transform > Math Functions > Connect Endpoints.” This will replace the data in the selected area with a line that literally connects the endpoints of the selected area. If instead there is an R wave but it is obscured because motion artifact brought it down or made adjacent sections of the signal large, selecting an area containing the R-wave (or adjacent areas) and using “Transform > Waveform Math” may allow the R-wave to be relatively accentuated. Adding to or multiplying by a constant factor greater than one will move the R-wave up. Subtracting from or dividing by a constant factor greater than one may be used to lower a segment corrupted by movement artifact. “Connect Endpoints” can also be used to 'remove' a segment that is large relative to the R-waves but not so wide as to encompass any R-waves.

Performing these steps can improve heart rate calculations significantly. If having trouble deciding which techniques might work best, please do not hesitate to send samples of data to support at BIOPAC.com and ask for advice.

Updated 12/24/2014

Associated Applications


New Citations | BIOPAC in Biology Research

Biology research covers a wide variety of studies all aiming to understand living organisms...

Join the BIOPAC Community

Stay Current

Stay Connected

Request a Demonstration
Request a Demonstration