What's your cardiovascular age?

In this article, I show how a Convolutional Neural Network can be used to predict a person's age based on the person's ECG

Bjørn-Jostein Singstad
4 min readJan 23, 2023

Attia et al 2019[1], showed that a person's age could be predicted from an ECG using convolutional neural networks (CNN). They also showed that the predicted age relates to the cardiovascular age, which means that the model generally will overestimate the age of people with severe cardiovascular diseases and underestimate the age of healthy people. In Attia et al 2019 they describe a very interesting case, highlighting this phenomenon:

Before age 54, he had numerous myocardial infarctions, and CNN predicted age significantly surpassed his actual age (predicted age ~70 years). At age 54, he underwent a heart transplant from a donor who died at the age of 16, with a subsequent decrease in CNN-predicted age to 50 years. He remained well for several years with subsequent loss of weight to normal weight and cessation of blood pressure and diabetes mellitus medications at the age of 60, with a further drop in CNN-predicted age to below chronologic age.

Could this be useful in a clinical setting? The answer is we don't know, but it shows that a CNN can detect some patterns from the ECG that correlates well with our age. This is something even skilled cardiologists cannot do, but it is even more interesting to see that the presence of cardiovascular disease or cardiac injury patterns makes the model overestimate the age. This could for instance be used for patient risk stratification or maybe we could use eXplainable AI (XAI) to better understand these patterns and teach the doctors how to look for them.

The development of these models (including Attia et al 2019) have mainly been done on patient data owned by the hospitals and not on open data. Even not any trained models have been publically available up to now. This is very unfortunate because these models would have benefited from being tested, tweaked and benchmarked by the large data science community outside of the hospitals. We wanted to do something with this and therefore conducted a study where we used several open ECG datasets from China, USA and Germany.

In addition to Attia’s model architecture we used another promising CNN architecture called Inception Time, proposed by Fawas H.I et al 2019[2]. The models were first trained on the datasets from China and USA, containing 59355 ECGs, and then tested on the separate cohort from Germany (PTB-XL dataset), containing 21748 ECGs. Figure 1 shows the normalized age distribution in both the training and test set. The distributions are skewed towards the right and this could possibly be due to the fact that the ECGs are gathered in a hospital setting, where one could assume an overweight of elderly people.

Figure 1. Normalized age distribution in training and test set [3]

The model was implemented in Python and stored in a public GitHub repository (containing source code and the trained models). The use of Jupyter Notebooks was done in order to make it possible to train and validate the models on Google Colab in order to get access to free GPUs.

The final model (Inception Time) achieved a mean absolute error of 7.90±0.04 doing cross-validation on the training set and a mean absolute error of 8.3 years on the test set. This shows that the model generalizes fairly well and could be applied to data outside of the hospitals it was trained and still perform ok. Figure 2 show the true age (x-axis) versus the predicted age (y-axis). The red line show the optimal relation between true and predicted age, while the green line shows the optimal linear fit given the current prediction.

Figure 2. True versus predicted age achieved by the Inception Time model on the test set [3]

Finally, we wanted to see whether there are any relationship between the annotated conditions, in the German ECG dataset, and the predicted age. In Figure 3 we show the predicted versus true age for 20 different cardiovascular conditions. The subfigures are sorted from the lowest to the highest mean absolute error starting at the upper left.

Figure 3. Relationship between predicted and true age for 20 different cardiovascular conditions

References

  1. Attia et al., Z. I. Age and Sex Estimation Using Artificial Intelligence From Standard 12-Lead ECGs. Circulation: Arrhythmia and Electrophysiology 12, e007284 (2019).
  2. Ismail Fawaz et al., H. InceptionTime: Finding AlexNet for Time Series Classification. Data Min Knowl Disc 34, 1936–1962 (2020).
  3. Singstad, B.-J. & Tavashi, B. Using deep convolutional neural networks to predict patients age based on ECGs from an independent test cohort. Proceedings of the Northern Lights Deep Learning Workshop 4, (2023).

--

--

Bjørn-Jostein Singstad

IT advisor at Vestfold Hospital Trust and PhD candidate at Akershus University Hospital with the objective of developing AI-enabled ECG interpretation algorithm