Artificial intelligence for detecting heartbeats

Artificial intelligence has received a tremendous amount of press coverage.
In this blog post, we will discuss deep learning – this is what people usually mean by AI.

Disclaimer: no AI engines were harmed – nor abused – in the making of this blog post!

Deep learning has created an original way to solve an old problem: how a computer can “understand” what is in a picture, an electrocardiogram (ECG), a lab report, or any of the digital objects surrounding us.

Medicine is increasingly digitized

Medicine, like so many other things in our lives, has increasingly become digitized. Patient data such as medical images, vital signs, reports or notes are all stored in databases. In healthcare, making sense of this data has two immediate applications:

  1. To support individual patient diagnoses;

  2. To perform statistical analyses on patient populations.

The first application echoes a common belief – a dystopic vision for some – that computers can enhance the work of clinicians. The second, is an indispensable tool of modern scientific proof-based medicine.

With the explosion of digital data, human brains – that can only process a maximum of 7 to 9 pieces of information at a given time1 – need computers for automated analyses. Let us focus on ECG data: not only has the acquisition of such data become ubiquitous, but also their automated analyses. This started in the 80s with visionary researchers Pan and Tompkins who invented a benchmark algorithm bearing their names2. 40 years later, it is still in use.

Variations and adaptations of the Pan-Tompkins are too numerous to be listed here. Epsidy’s latest article, recently published in a special issue of Sensors, provides a good review3. Pan-Tompkins belong to the family of conventional algorithms. Conventional algorithms are described by a set of heuristics, including a manageable number of parameters (thresholds, window sizes, etc.) and behave in a deterministic way. For a given task, a conventional algorithm should always provide the same results, especially when it is applied on data matching the heuristics defined by its inventors.

ECG databases everywhere

In parallel to the development of ECG conventional algorithms, several ECG databases have been made publicly available. They not only include key features (P, QRS, T waves, with onset and offset times for some of them) but also specific diagnostic information (bundle branch blocks, arrhythmias, etc.). They are regularly used in contests, serving as a common test material to compare various ECG analysis algorithms.  

ECG waveform features: P: atrial depolarization; QRS: ventricular depolarization; T: ventricular repolarization.

ECG waveform features: P: atrial depolarization; QRS: ventricular depolarization; T: ventricular repolarization.

Detecting R-peaks is the first step, conditioning the rest of an automated ECG analysis (P-, QRS- and T-waves delineation, beat classification, arrhythmia detection, etc.). The latest published results of conventional algorithms often exceed 99%, both in recall and precision. Recall is the ability of not missing peaks; it is also called sensitivity and linked to the number of false negatives. Precision, also called positive predictive value, is the certainty that a detected R-peak is real; it is linked to the number of false positives. With results that high, why bother using more complicated architectures such as deep learning based ones? Especially when these architectures are often dubbed “black-boxes” and eyed with suspicions.

The statistical power of deep learning architectures

Conventional algorithms are defined by a modeling process based on few observations related to data patterns. Only a human brain can perform this task, which provides a technique able to extract features such as R-peaks from a digital signal such as ECG traces.

Conversely, machine learning algorithms, and especially deep learning architectures, are based on using a large mass of data to automatically deduce a few observations. They are inherently statistical. In computer recognition tasks, from the early years of 2000 to today, deep learning has improved accuracy from a plateau between 50% and 60% to the current value of 99%. Conventional algorithms were not able to cross this chasm, deep learning did the job.

Scientific articles on Pubmed proposing deep learning architectures dealing with ECG data.

Scientific articles on Pubmed proposing deep learning based architectures dealing with ECG data.

Deep learning architectures are particularly relevant in natural processes, in which a high statistical variation is to be expected. Statistical variation is captured in training datasets, which make them crucial for the quality of the training phase. Roughly speaking, deep learning proceeds by encoding information in a training phase, and decoding it when it comes to analyzing unseen data samples (a process called “inference”).

The beauty of deep learning is that it relies on data to automatically tune its parameters. It is as good as the datasets used to “train” it. Furthermore, improving results of deep learning can often be carried out by training the same architecture again on different datasets, a process called transfer learning. Many authors now use the technique of data augmentation: starting from existing datasets, they gradually incorporate modified versions of such datasets (like in other recipes, the key is to balance the ingredients). This has been proven to provide more consistent results.

The proof is in the pudding

Epsidy’s experience with deep learning has been in the form of a steep learning curve, and we have quickly obtained impressive results outperforming data published merely a few months or years ago.

Our focus has been on reducing the number of false positives (precision). In our published article, false positives were as low as 27/3,973 beats in a first ECG database, 4/1,831 beats in a second one and 276/175,907 in a much larger, third database (respectively 0.68%, 0.22% and 0.16%). ECG databases feature signals of reasonably good quality, yet representative of what can be expected in clinical practice.

Epsidy’s deep learning architecture was trained on regular ECG data. Applying it to “MRI-ECG” data (i.e. measured when the volunteer lies in a 3 Tesla MRI) caused a drop in precision. This is due to large magneto-hydrodynamic artifacts described in a previous blog. Since there is no “MRI-ECG” database, except for a small one, this could have been a dead end. However, we could make use of a small MHD artifacts database to augment non-MRI ECG databases and obtain good precision results.

Why is this critical? Firstly, looping back to our main objective, i.e. individual patient diagnoses, we do not want algorithms to work statistically, we want them to work for every single patient. Detecting R-peaks is not only the first step conditioning automated ECG analyses, it can also be used when synchronizing diagnostic or therapeutic devices that rely on a systolic trigger. This is the workflow of Cardiac MRI: a device (the MRI sequencer) expects a trigger telling it that the heart is in a given phase. The price to pay for poor R-peak detection is poor image quality. But for an invasive task, such as a tissue ablation using radiotherapy4 or a minimally invasive roboticized procedure, stakes are higher and cardiac gating must become rock-solid.

These are the kind of challenges Epsidy is willing to address to empower clinicians to understand and treat cardiac diseases more accurately.

What now?

Sign up for our newsletter to stay tuned for our latest developments, or contact us directly to schedule a demo (hello at epsidy dot com). For technical details, you should come meet us at one of the upcoming MRI congresses (SFRMBM and ISMRM).

Sources and references

  1. https://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two

  2. A real-time QRS detection algorithm. J Pan, WJ Tompkins.  IEEE Trans. Biomed. Eng. 1985, 32, 230–236. doi: 10.1109/tbme.1985.325532.

  3. A deep learning architecture using 3D vectorcardiogram to detect R-peaks in ECG with enhanced precision. M Mehri, G Calmon, F Odille and J Oster. Sensors (Basel) 2023, 23, 2288, doi:10.3390/s23042288.

  4. Noninvasive Cardiac Radiation for Ablation of Ventricular Tachycardia. PS Cuculich, MR Schill, R Kashani et al. N Engl J Med 2017 Dec 14;377(24):2325-2336. doi: 10.1056/NEJMoa1613773.

Previous
Previous

Building a secure IT infrastructure for a startup

Next
Next

Quantitative MRI – an innovation in need of reinventing