1. Introduction
The human body produces a set of biological processes from which we can measure and collect signals that can be represented as time series. Different processes produce different signals, which distinguish a large range of physiological events, whose characteristics differ from case to case. As examples of such signals, the heartbeat can be calculated by, e.g., analyzing an electrocardiogram (ECG), and brain waves are usually represented by an electroencephalogram (EEG); yet there are many types of physiological processes that can be analyzed using other types of measurements, such as those represented by images or the concentration of chemicals in tissues or fluids.
The pervasiveness of computational devices, many of which can be wearable, has resulted in an increase in the use of devices that integrate sensors, including Internet of Things (IoT) devices, which are often used to collect such signals. Many of these devices allow for the registration and storage of large amounts of data and their re-utilization for several different lines of research [
1].
Despite the wide variety of these devices, most are available at affordable prices. According to the World Health Organization (WHO) [
2], it is estimated that 17.9 million people died from cardiovascular disease (CVD) in 2019, which represents 32% of all deaths worldwide and makes it the leading cause of death across the globe [
2,
3]. It is reasonable to assume that at least some of these deaths could have been prevented by timely diagnosis using ECG trace analysis, which is considered to be the gold standard of cardiovascular monitoring and offers a wealth of diverse information.
The interpretation of ECGs can be a complex task involving visual inspection; even so, the analysis of ECGs is routinely performed by specialized health professionals to assess cardiac health status. Recently, the use of computer-aided diagnosis systems has become regarded as a way to carry out the task of detecting or classifying CVD [
4,
5,
6,
7], at least in the initial screening stage.
Therefore, the early detection of anomalies in ECG signals, possibly using computer-aided diagnosis as a prediction mechanism for the occurrence of CVD, is a powerful tool for healthcare systems worldwide as it may help healthcare professionals in their decision-making processes or possibly to prevent dangerous clinical events [
4,
5,
8]. Different approaches can be followed in order to predict or detect issues regarding ECG signals [
3,
9,
10].
One of the techniques used for this is the forecasting approach. The time series forecasting methodology is used to make predictions about forthcoming events [
11]. The use of time series forecasting methods to predict physiological data has the potential to help healthcare providers to anticipate and mitigate the need to treat patients depending on their diagnosis [
12,
13].
Over recent years, the number of cardiovascular disease forecasting studies has grown and is now substantial [
14]. However, to our knowledge, relatively few works have been explicitly related to ECG signal forecasting. This constraint presents many benefits, including originality and possible noteworthy advancements in the domain of cardiovascular disease (CVD) detection and prediction, particularly in the exploration of uncharted challenges. However, it also entails drawbacks, such as the absence of established methodologies, limited benchmarking opportunities, and restricted guidance.
As previously indicated, electrocardiogram (ECG) analysis is the conventional instrument for monitoring and assessing cardiac activity. The ability to forecast electrocardiogram (ECG) patterns plays a crucial role in the identification and diagnosis of various cardiac ailments, including arrhythmias, myocardial infarction, heart blockages, and other significant heart-related problems. Additionally, this ability has the potential to make substantial contributions to the field of personalized medicine and preventative healthcare, mitigate the likelihood of cardiovascular problems, and enhance the overall quality of life of patients.
The main objective of this paper is to present a model that uses a deep learning technique based on a long short-term memory (LSTM) architecture to forecast long-term ECG signals, which is able to learn the nonlinearity, nonstationarity, and complexity of ECG signals. It can also possibly be used to create effective forecast signals with identical structures and behaviors to the original signals, with small differences in amplitude.
The rest of this paper is organized as follows:
Section 2 presents a literature review that embodies the work in this area;
Section 3 presents the materials and methods used to address ECG forecasting;
Section 4 presents the implementation of the proposed method;
Section 5 presents a discussion of the results;
Section 6 concludes the paper.
2. Literature Review
The scientific community has long been faced with the challenges of exploring machine learning algorithms for the processing of ECG data. Over the past decade, researchers have extensively utilized sophisticated machine learning algorithms to extract significant insights from ECG data. The MIT-BIH database has been a fundamental resource for these studies, offering a reliable and extensively used framework for assessing the effectiveness of different machine learning models. The MIT-BIH database has significantly influenced the field of machine learning-based ECG analysis for over 10 years. Scientists have utilized this large dataset to create and improve algorithms that can increase the accuracy and efficiency of automated ECG interpretation [
15,
16].
Forecasting techniques predict future events by analyzing past trends, on the assumption that future trends will remain similar to those in the past [
17,
18]. The basic idea is to extend underlying trends using predictable trials that are already in the data.
To deal with real-time series in modern applications, several methods are used, including statistical approaches [
17,
18,
19,
20,
21], machine learning techniques [
22,
23,
24,
25,
26], and deep learning architectures [
6,
27,
28,
29,
30]. These methods have been investigated and applied by the academic community in several areas, such as the economic and financial [
24,
26,
31,
32,
33,
34], industrial [
22,
31,
32,
35], scientific [
29,
33], and healthcare [
7,
14,
18,
34,
36,
37,
38] fields. Nevertheless, within healthcare, and considering the use of continuous physiological data in particular, there has been a very limited number of works on forecasting [
6,
7], with the possible exceptions of forecasting diabetes and COVID-19 [
12,
13]. Although there are limitations in the current body of research on ECG forecasting, the available literature does include some studies that have used hybrid methodologies, such as artificial neural networks and deep learning models.
In their study, Mohammadi, Ghofrani, and Nikseresht [
39] integrated a forecasting framework that incorporated ridge regression, high-order fuzzy cognitive maps (HFCMs), and empirical wavelet transform (EWT). They conducted experiments using 15 distinct time series datasets, one of which comprised 4170 samples of ECG data. However, their paper lacked some details; in particular, the specific lock-back length used in the analysis. The authors reported that the experiment successfully attained a root mean square error (RMSE) of 0.011.
Sun et al. [
40] proposed a method for predicting new ECG data based on a variational mode decomposition (VMD) and back-propagation (BP) neural network, using one ECG record retrieved from the MIT-BIH arrhythmia database. The authors extracted 15 segments from the signal, each with 2160 samples, and then split them into training, validation, and test (60-20-20) sets, reportedly achieving an RMSE of 0.00233 and a mean absolute error (MAE) of 0.0157. The same researchers conducted another study with the same goal using a similar methodology, changing only the VMD to mutual information, resulting in RMSE and MAE values of 0.0423 and 0.024, respectively [
41].
A novel ECG signal prediction method based on the autoregressive integrated moving average (ARIMA) model and discrete wavelet transform (DWT) was proposed by Huang et al. [
42]. The authors used 2768 samples from four different ECG records in the MIT-BIH arrhythmia database. These samples were then split into training and test sets (900 and 1868 samples, respectively). They obtained an RMSE of 0.0180775 and an MAE of 0.011105.
In another study by Prakarsha and Sharma [
43], an artificial neural network was applied to forecast ECG time series. To validate the model, two ECG signals were used: one was simulated using the Neurokit tool and the other was a real ECG signal retrieved from the Physio net ATM of sleep apnea. The number of samples used was 20,000, which were split 75/25% for training and testing. A slide windows technique with a sequence length of 64 samples was used and authors reported an MAE of 0.045.
Forecasting studies based on deep learning techniques have become increasingly present in the literature [
6,
32,
44] and here, we highlight cases related to ECG signals. The work of Dudukcu et al. [
45] proposed a temporal convolutional network (TCN) approach with an RNN for chaotic time series. In this study, TCN models were tested. In the first model, LTSM was used in the initial layers of the model and a TCN was applied in the fully connected layers, while in the second model, a TCN was considered in the initial phase of the GR network. The research included nine different time series, including an ECG series, for which 21 records were selected from the MIT-BIH arrhythmia database. In total, 100,000 samples were divided into training, validation, and test sets for each record (40,000-10,000-50,000), considering a sequence length of 10. The RMSE and MAE metrics were calculated and the following results were obtained: 0.0082 and 0.0051 for the first model; 0.0084 and 0.0052 for the second model.
Further, Festag and Spreckelsen [
46] presented a study on the imputation and forecasting of multivariate medical time series based on a recurrent conditional Wasserstein GAN and attention. Data from the Autonomic Aging Physio net (blood pressure series and ECG) were used. For the study, 411 records were selected (training = 275; testing = 6; validation = 65) and each record was segmented into up to 10-s samples. In the end, 26,939 samples were used in training, 5972 were used in validation, and 6062 were used in testing. Results were obtained separately for each series and three different forecasting scenarios were considered: (a) an output in one step with an error (MSE) of 0.0429; (b) an output of 30 steps with an MSE of 0.0858; (c) a forecast horizon of 250, with an MSE of 0.0891.
Table 1 serves as a thorough summary of the main cited articles, offering a consolidated overview of the employed techniques, the numbers of utilized ECG signals, the lengths of the sequences, and the values of the metrics used.
Although the use of deep learning (DL) algorithms is promising in forecasting tasks, the number of studies that have applied them to ECG signals remains small, which opens up the opportunity to explore different algorithms.
4. Implementation
To implement the proposed model, we used a computer with the following characteristics:
Operating system: Windows 11 Pro;
Processor: 12th Gen Intel® Core ™ i7-12,700 2.10 GHz;
RAM: 64 GB (16*4 of DDR4);
GPU: NVidia GeForce 1060—6 GB.
The code was written in Python 3.10.5 and developed with the help of the integrated development environment (IDE) PyCharm Community Edition 2022.1. A set of tools was utilized, specifically wfdb 4.0.0a4 for accessing the database’s files via downloading and reading.
The iirnotch and lfilter functions from the scipy signal and the MinMaxScalar function from sklearn were all utilized in the pre-processing step. The values of the chosen parameters are presented in
Figure 1 and the outcome is shown in
Figure 4.
We utilized a
TensorFlow 2.9’s Keras module to build the forecasting model. Imports included the sequential model, LSTM, Dense, and EarlyStopping Callbacks. The key features of the model are summarized in
Figure 5 and its parameters are presented in
Table 3. We evaluated the efficacy of the model by utilizing the inherent functionalities of the
math module.
Matplotlib was utilized to visually represent the pre-processing steps, loss functions, and graphs of the horizontal signals, as well as the training and test outcomes.
5. Results and Discussion
An ECG is a nonstationary, nonlinear, and nondeterministic time series, characteristics that are crucial for the effective development of forecasting models. Deep learning techniques have become viable alternatives for forecasting signals with such characteristics. Deep learning models demand a lot of computational power, and because the number of epochs of a term directly influences this, it is recommended to use a number of epochs that generates a good cost–benefit ratio. An example of a good strategy is the use of an early stopping criterion.
Despite implementing the initial proposal of 500 epochs, the model was stopped short of its full run-time after the loss function remained the same after 20 successive iterations, with an average value of
epochs.
Figure 6 displays the number of training epochs. It is interesting to notice that most training was completed using fewer than 200 epochs. Despite this, the model’s performance was quite good, with just marginal amounts of inaccuracy.
For the presentation of the results, one of the database signals was chosen at random and the referent loss function of this signal is shown in
Figure 7, where it can be seen that training was conducted over 119 epochs.
As described in
Section 4, the RMSE and MAE metrics were used to evaluate the efficacy of the developed model. For the study in question, the RMSE was 0.0039 and the MAE was 0.0426. The RMSE and MAE values for each record in the dataset are displayed in
Figure 8 and
Figure 9, respectively.
Table 4 presents the results by beat class, following
Table 2. In addition, it is important to note that the aggregate results for the entire investigation were
for RMSE and
for MAE.
A case-specific outcome is depicted in
Figure 10, which shows the behavior of an original signal along with the forecasted training and test signals.
Figure 11 depicts a portion of the same signal to enhance its visibility.
It can be observed that the proposed model generated a forecasted signal with a similar pattern to that of the original signal, thereby enabling the prediction of fundamental variations in the signal.
Due to the fact that an entire ECG can be observed in approximately 1 s, the prognostic procedures utilized had a direct effect on the final findings. This effect was typically positive since the differences between the predicted values and the actual series were so minor.
Table 4 demonstrates that the accuracy of the predictions across assessments. However, it also indicates that the results were comparable. This was largely due to the fact that (a) the levels of noise and interference in the initial signals were not the same, so in some cases, interference could persist after pre-processing, which could have influenced the model, and (b) the data exhibited temporal inconsistencies as a result of being captured with various anomalies. Nevertheless, we can assert that the proposed model is effective for various signals with comparable properties.
Table 5 illustrates a comparative analysis of the outcomes from prior research papers that used identical measures and data from the same database.
Based on the data shown in the table, it is noticeable that although our research was conducted using the same dataset as the others, none of the previous studies included all simulations in their experimental designs. In contrast, the technique under consideration demonstrated superior outcomes compared to those from prior research endeavors, particularly the study conducted by Dudikcu [
45], which similarly explored deep learning-based approaches. The findings of this study provide more support for the notion that deep learning models provide favorable predictive performance owing to their capacity to process both short-term and long-term signals effectively.
The relevance of ECG signals within the healthcare industry is well known. Therefore, the proposed model could be used in the following situations:
The early detection of cardiac abnormalities as ECG signal forecasting can detect heart irregularities and potentially fatal illnesses; therefore, ECG data can be used to diagnose cardiac anomalies, such as arrhythmia, ischemia, heart obstructions, and more, and early diagnosis can lead to better patient outcomes;
ECG signal forecasting aids in patient risk assessment and stratification as by studying ECG data and identifying problematic patterns or indications, healthcare providers can categorize patients and this information can help with resource allocation and treatment decisions;
Doctors can better comprehend a patient’s cardiac condition by predicting ECG patterns as by using a patient’s historical ECG data, forecasting algorithms can predict future trends and identify changes in heart function, which enables tailored therapy and interventions;
ECG signal forecasting is required for remote monitoring and telemedicine, so healthcare providers can remotely monitor patients with persistent heart conditions by continuously monitoring ECG data, which simplifies cardiac health management while also lowering healthcare costs and increasing patient convenience;
ECG signal forecasting aids in determining the success of cardiac treatment, so healthcare providers can assess a patient’s cardiac health by comparing expected ECG patterns to actual data, which can improve treatment strategies and guide ongoing care;
ECG signal forecasting provides information on long-term cardiac health, so ECG data can help healthcare personnel to monitor cardiac issues, treatments, and treatment plans as the R-peaks have larger amplitudes than the other waves in the signals, which are where the most noticeable changes may be seen.
6. Conclusions
According to the results presented, the following conclusions about the LSTM ECG signal forecasting model could be drawn:
The forecasting of ECG signals is, to a large extent, a rather unexplored field and this is one of the first papers to employ deep learning techniques (LSTM) to the forecasting of ECG time series;
The proposed LSTM model can predict the trends of changes in original data series (with the most visible differences being in the amplitudes of the R-peaks), which shows that the LSTM model can meet the requirement of forecasting accuracy;
Considering the accuracy of the proposed model and taking into account the properties of the physiological signals, a similar approach could be applied to ECG signals and help to improve the efficiency of healthcare systems;
Research within the field of ECG forecasting remains minimal, which allows for the development of other studies, such as the analysis of forecasting steps, the study of different forecasting strategies, or even the investigation of applications based on other methods.
Future Work
This study contributes to the field of ECG signal forecasting; nevertheless, several areas still need more investigation and potential improvements. In this subsection, we provide a comprehensive overview of potential directions for future studies.
The research reported in this paper and most of the existing literature adopted a one-step forecasting technique. However, the domain of multistep forecasting offers many opportunities for future research and exploration.
One identified challenge pertains to effectively considering the spatial and temporal aspects of signals during the forecasting procedure. Consequently, future efforts in spatiotemporal forecasting are necessary to mitigate the observed disparities in signal amplitudes. These findings were noticed in our investigation.
The development of real-time systems that are capable of using predictive analysis to anticipate cardiac abnormalities, with a particular focus on cardiac arrhythmia, is equally important.