Next Article in Journal
Anterior Esthetic Restorations with the Stratified Stamp Technique: A Case Report
Next Article in Special Issue
Evolutionary Approach to Optimal Oil Skimmer Assignment for Oil Spill Response: A Case Study
Previous Article in Journal
Solving Engineering Optimization Problems Based on Multi-Strategy Particle Swarm Optimization Hybrid Dandelion Optimization Algorithm
Previous Article in Special Issue
Intelligent Learning-Based Methods for Determining the Ideal Team Size in Agile Practices
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Modeling the Electrical Activity of the Heart via Transfer Functions and Genetic Algorithms

by
Omar Rodríguez-Abreo
1,
Mayra Cruz-Fernandez
2,
Carlos Fuentes-Silva
2,
Mario A. Quiroz-Juárez
1,* and
José L. Aragón
1,*
1
Centro de Física Aplicada y Tecnología Avanzada, Universidad Nacional Autónoma de México, Santiago de Querétaro 76230, Mexico
2
Division de Tecnologías Industriales, Universidad Politécnica de Querétaro, Santiago de Querétaro 76240, Mexico
*
Authors to whom correspondence should be addressed.
Biomimetics 2024, 9(5), 300; https://doi.org/10.3390/biomimetics9050300
Submission received: 3 April 2024 / Revised: 13 May 2024 / Accepted: 14 May 2024 / Published: 18 May 2024
(This article belongs to the Special Issue Nature-Inspired Metaheuristic Optimization Algorithms 2024)

Abstract

:
Although healthcare and medical technology have advanced significantly over the past few decades, heart disease continues to be a major cause of mortality globally. Electrocardiography (ECG) is one of the most widely used tools for the detection of heart diseases. This study presents a mathematical model based on transfer functions that allows for the exploration and optimization of heart dynamics in Laplace space using a genetic algorithm (GA). The transfer function parameters were fine-tuned using the GA, with clinical ECG records serving as reference signals. The proposed model, which is based on polynomials and delays, approximates a real ECG with a root-mean-square error of 4.7% and an R 2 value of 0.72 . The model achieves the periodic nature of an ECG signal by using a single periodic impulse input. Its simplicity makes it possible to adjust waveform parameters with a predetermined understanding of their effects, which can be used to generate both arrhythmic patterns and healthy signals. This is a notable advantage over other models that are burdened by a large number of differential equations and many parameters.

1. Introduction

Mathematical models have become indispensable across many disciplines for predicting the dynamic behaviors of complex systems at different scales. Generally, these models are described by a set of differential equations that represent the variation in the system with respect to certain independent variables, typically time. Recently, there has been a notable advancement in the precision of mathematical models, particularly in the realm of biological phenomena. In the last century, these advancements were unattainable because of computational resource constraints. This progress has enabled the simulation of intricate biological processes with unprecedented accuracy, thereby revolutionizing our ability to understand and manipulate biological systems [1].
The human heart is one of the most intriguing biological systems and studied from various perspectives. The complexity inherent in this analysis demands the integration of biological, medical, and engineering disciplines to understand the dynamics of cardiac function. Many efforts have been made to understand the characteristics of the heart’s function, from its physiology [2] to its interactions with various systems and organs of the body, including the brain [3]. However, there are still many open questions that need to be answered. One such question revolves around the mechanisms underlying certain cardiac pathologies such as arrhythmias or heart failure. Importantly, diseases associated with the heart are considered primary causes of death worldwide [4]. Addressing investigations along this line not only holds the promise of improving diagnostic and therapeutic approaches but also deepens our fundamental understanding of cardiac function and paves the way for more effective interventions and treatments of these diseases in the future.
Although complete cardiac studies can be complicated or expensive, various experimental methods allow heart analysis, such as electrophysiological studies and optical imaging of the electrical activity of the heart. Electrocardiograms (ECG) are the most common analysis method [5], through which a wide variety of heart diseases can be detected in a non-invasive manner. ECG signals are captured through electrodes strategically placed on various parts of the body. These electrodes collect electrical information from different angles, leading to so-called “leads” that offer different perspectives on the heart’s electrical activity. These signals reflect transmembrane ionic currents in the heart [6]. Typically, a healthy heartbeat manifests in two phases: systole, corresponding to contraction, and diastole, which is indicative of relaxation. Given the accessibility and minimal risk to patients, coupled with the valuable information it provides, ECGs remain a cornerstone tool for diagnosing heart conditions [7,8].
As previously mentioned, comprehending electrical activity behavior from a mathematical standpoint is crucial for diagnosing heart conditions [9]. To this end, various mathematical models have been proposed [10] to detect arrhythmias or other pathologies, comprehend the defibrillation process, and analyze the impact of electrical disturbances on the heart [11]. Remarkably, incorporating all variables affecting the electrical activity of the heart results in a complex model that is impractical for real-world applications. Furthermore, certain variables or parameters of the model may be challenging or impossible to measure. Examples of these models include the bidomain model and the EMI model, which takes its name from the extracellular space (E), cell membrane (M), and intracellular space (I) [12]. Although these models offer high precision, they incur substantial computational costs [13]. Other research efforts have focused on proposing mathematical models to reproduce the electrical activity of the heart at a macroscopic level through ECG signals, allowing a balance between simplicity and precision [14,15]. The purpose of modeling is to provide simplified representations of complex phenomena. Each model adapts differently to the real characteristics of a phenomenon. A novel model of the heart’s electrical activity can offer fresh insights into its functioning. Regarding clinical use, the construction of a new model is an alternative that allows for generating a comparative database of synthetic ECG signals used to train arrhythmia and heart disease detection systems and make them more robust.
On the other hand, research on artificial intelligence (AI), including evolutionary computation, has witnessed exponential growth in recent years, largely attributed to a remarkable surge in computing power. This has facilitated the resolution of problems across numerous scientific domains that lack exact solution methods or are computationally infeasible owing to their complexities. Currently, there is a growing trend in the use of AI tools to diagnose cardiac issues by analyzing ECGs [7]. However, AI can also be used to assist in creating models that more accurately represent the dynamics of heartbeats through metaheuristic algorithms. An illustrative example is presented in [16], where a mathematical model was developed using metaheuristic algorithms.
In this study, we introduce a dynamical model, grounded in transfer functions [17,18], which describe the heart’s electrical activity at a macroscopic level. Our model comprises three low-order transfer functions coupled with time delays whose parameters are obtained through metaheuristic algorithms, specifically genetic algorithms (GA). Using a database of real electrocardiograms as reference signals, our model can be tailored to various ECG waveforms, a novel approach that has not been previously explored in the literature to our knowledge. Through minimization of the integral square error, the GA determines the parameter range for healthy ECGs, as well as for ECGs exhibiting arrhythmias. The results demonstrated that our model effectively captured real ECG signals, with a root mean square error (RMSE) of 4.7% for healthy signals and an average RMSE of 7.2% for arrhythmia signals. Finally, we compared our model with existing proposals, highlighting its distinctiveness in allowing each electrocardiogram wave to be independently adjusted, with parameters obtained through evolutionary computation rather than manual tuning. Thus, our study underscores the utility of AI-guided transfer function modeling as a practical and valuable tool for investigating ECG signals.

2. Background and Related Works

An ECG is a recording of the electrical activity of the heart through electrodes placed on the skin. These electrodes collect the voltage changes caused by the depolarization and repolarization processes that occur with every heartbeat. The peaks and valleys of the ECG signal are labeled as the P wave, QRS complex, and T wave, as shown in Figure 1.
As depicted in Figure 1, an ECG is composed of segments, intervals, and waves. The P wave originates from the depolarization of the atria. In contrast, the QRS complex originates from contraction of the lower chambers of the heart (depolarization of the ventricles). The T-wave originates from the repolarization of the ventricles. The PR segment moves from the beginning of the P-wave to the beginning of the QRS complex, representing conduction through the atria. Finally, the QT interval extends from the start of the QRS complex to the final T wave, containing information on the processes of ventricular depolarization and repolarization. We refer the reader to ref. [19] for a detailed explanation.
Several models have been developed to represent electrical cardiac dynamics. The best-known model is the bidomain model, which is a set of mathematical equations that describe the electrical properties of cardiac tissue [20]. This model is widely used when maximum precision is required in numerical simulations and the computational cost is not important. However, mathematical modeling requires a balance between detail and tractability; thus, more manageable models have been proposed, which are briefly discussed below.

2.1. Ring of Three-Coupled Oscillators

One of the first ideas for obtaining simplified models of the heart was to consider a set of nonlinear oscillators. A notable example is a model consisting of a ring of three oscillators coupled with delays, which was developed by employing a set of six ordinary differential equations. In this model, each oscillator corresponded to a natural pacemaker in the heart [21]. The equations governing this model are as follows:
x ˙ 1 = x 2 , x ˙ 2 = a S A x 2 ( x 1 ω S A 1 ) ( x 1 ω S A 2 ) + ρ S A sin ( ω S A t ) x 1 ( x 1 d S A ) ( x 1 e S A ) K S A A V ( x 1 x 3 τ S A A V ) k S A H P ( x 1 x 5 τ S A A V ) , x ˙ 3 = x 4 , x ˙ 4 = a V A x 4 ( x 3 ω A V 1 ) ( x 3 ω A V 2 ) + ρ A V sin ( ω A V t ) x 3 ( x 3 d A V ) ( x 1 e A V ) K A V S A ( x 3 x 1 τ A V S A ) k A V H P ( x 3 x 1 τ S A A V ) , x ˙ 5 = x 6 , x ˙ 6 = a H P x 6 ( x 5 ω H P 1 ) ( x 5 ω H P 2 ) + ρ H P sin ( ω H P t ) x 5 ( x 5 d H P ) ( x 5 e H P ) K H P S A ( x 5 x 1 τ H P S A ) k H P A V ( x 3 x 3 τ S A A V ) ,
where a n o d e , ω n o d e i , d n o d e , and e n o d e are parameters of the system, and n o d e = S A , A V , H P , stand for sinoatrial, atrioventricular, and His–Purkinje nodes, respectively. τ is the time delay, ρ n o d e is the amplitude of the external stimulus, and ω n o d e is its frequency. Finally, the ECG signal can be determined by
E C G ( t ) = ( α 0 + α 1 x 1 + α 3 x 3 + α 5 x 5 ) β G ,
where α i , i = 1 , 2 , 3 , are parameters weighting each system variable and β G is used as a global scaling factor.

2.2. Heterogeneous Nonlinear Oscillators

Heterogeneous nonlinear oscillators consist of modified Van Der Pol and FitzHugh–Nagumo oscillators, which capture the action potentials of primary natural pacemakers and the electrical responses of cardiac muscle tissues (atrial and ventricular muscles) [22]. Subsequently, this model was adapted to represent ventricular fibrillation as an instance of chaos [23]. The equations governing natural pacemakers in this model are as follows:
x ˙ i = y i , y ˙ i = a i y i ( x 1 u i ) f i x i ( x i + e i ) + K n o d e ( y i 1 τ n o d e y i ) .
The sinoatrial node corresponds to i = 1 , the atrioventricular node corresponds to i = 2 , and the His–Purkinje term corresponds to i = 3 . Coefficients a i , f i , u i , d i , and e i are the parameters of each oscillator. Finally, a complete description of the ECG signal is given by
E C G ( t ) = z 0 + α 1 z 1 α 2 z 2 + α 3 z 3 + α 4 z 4 ,
where z 0 adjusts the baseline of the ECG signal and z i corresponds to the depolarization and repolarization processes represented by the P-wave ( i = 1 ), Ta-wave ( i = 2 ), QRS complex ( i = 3 ), and T-wave ( j = 4 ), which are defined as follows:
z ˙ j = k j ( c j z j ( z j ω j 1 ) ( z j ω j 2 ) b j v j g j v j z j + I j ) , v ˙ j = k j h j ( z j v j ) ,
where k j is a scaling factor; c j governs the amplitude of the pulse; b j and g j modify the rest state; and h j , ω j 1 , and ω j 2 control the duration of the action potential, the excitation threshold, and excited state of each oscillator, respectively. I j is the magnitude of the stimulation current that couples the natural pacemakers to the cardiac muscles.

2.3. Reaction–Diffusion Model

The Reaction–diffusion spatially discretized model is a set of three nonlinear oscillators obtained from the spatial discretization of a reaction-diffusion model [24]. This model generates normal ECGs and cardiac arrhythmias. The set of ordinary differential equations that describe the model is as follows:
x ˙ 1 = x 1 x 2 C x 1 x 2 x 1 x 2 2 , x ˙ 2 = H x 1 3 x 2 + C x 1 x 2 + x 1 x 2 2 + β ( x 4 x 2 ) , x ˙ 3 = x 3 x 4 C x 3 x 4 x 3 x 4 2 , x ˙ 4 = H x 3 3 x 4 C x 3 x 4 x 3 x 4 2 + 2 β ( x 2 x 4 ) ,
where β is the coupling parameter between the oscillators, and H and C are parameters that control the dynamics of the system. The ECG signal is obtained using the following linear combination of variables:
E C G ( t ) = α 1 x 1 + α 2 x 2 + α 3 x 3 + α 4 x 4 ,
where the parameters α i and i = 1 , 2 , 3 are the weights.

2.4. Extended Dynamical Model Based on a Quasi-Periodic Motion

Originally developed in ref. [25], this model consists of a set of three coupled ordinary equations that can generate simple ECG signals for both normal heartbeats and arrhythmias, with simple parameter variations. The original equations for this model are as follows:
x ˙ = α x ω y , y ˙ = α y ω x , z ˙ = i ( P , Q , R , S , T ) a i Δ θ i exp Δ θ i 2 2 b i 2 ( z z 0 ) ,
where α = 1 x 2 + y 2 , Δ θ i = ( θ θ i ) mod 2 π , θ = arctan ( y , x ) , and ω is the angular velocity. z 0 = A sin ( 2 π f 2 t ) is the baseline, where A is the amplitude and f 2 represents the respiratory frequency. Here, the z variable yields a synthetic ECG waveform.
Subsequently, a Gaussian wavelet-based state space was developed using (8). In this modified model, characteristic waves, such as atrial and ventricular complexes, can be controlled individually [26], and it was shown that this model can accurately represent a human heartbeat. The modified model is described by the equations
x ˙ = α x ω y , y ˙ = α y ω x , P ˙ = i ϵ ( P , P + ) a i Δ θ i exp Δ θ i 2 2 b i 2 ( P P 0 ) , C ˙ = i ϵ ( Q , R , S ) a i Δ θ i exp Δ θ i 2 2 b i 2 ( C C 0 ) , T ˙ = i ϵ ( T , T + ) a i Δ θ i exp Δ θ i 2 2 b i 2 ( T T 0 ) .
Finally, the synthetic ECG is obtained as
E C G ( t ) = P ( t ) + C ( t ) + T ( t ) .

2.5. Periodically Kicked Network of RLC Oscillators

This linear model is based on two RLC linear oscillators excited by a pulse signal train, including a time delay to account for the delay in the electrical transport from the atria to the ventricles [27]. This model has the advantage that analytical solutions can be obtained when a single impulse is applied. A critical feature of this model is that each parameter modifies a specific waveform characteristic of the synthetic ECG signals produced. Although this model has some limitations, it can show that the main signals of an ECG can be reproduced using linear models. The equation describing the ECG is as follows:
E C G ( t ) = 2 A γ ω 0 2 e α + α 2 4 ω 0 2 2 u ( t τ ) e t τ α 2 4 ω 0 2 1 u ( t τ ) α 2 4 ω 0 2 + e α 2 sinh α 2 4 ω 0 2 2 t α 2 4 ω 0 2 e α 2 ( 1 + C X ω 0 ) t sinh α 2 4 ω 0 2 ( 1 + C X ω 0 ) 2 ( 1 + C X ω 0 ) t α 2 4 ω 0 2 ( 1 + C X ω 0 ) ,
where α = 1 R C denotes the damping factor, ω 0 = 1 L C denotes the natural frequency, and γ denotes the input pulse width. R, C, and L denote the resistance, capacitance, and inductance, respectively.

3. Materials and Methods

Here, we will show that a set of three second-order transfer functions (one function per repolarization and depolarization process) can generate waveforms that resemble clinical ECGs. The model is stimulated by a cyclical impulse signal.
Second-order transfer functions have two basic polynomial representations: standard and non-standard forms. In this study, the non-standard form was used, since investigations like [28] explained that if the variations of a phenomenon can be measured or predicted theoretically, then they can be represented by a non-standard transfer function. Additionally, non-standard transfer functions allow the use of proper transfer functions; that is, with a polynomial in the numerator a degree lower than the polynomial of the numerator. Therefore, non-standard transfer functions can present much more complex dynamics than standard second-order transfer functions, adding parameters such as the coefficient of the zero in the numerator, which is not considered within a standard function. This explanation was added in Section 3. Subsequently, we use time delays to couple the different transfer functions. The model for reproducing a heartbeat (HB) is described by the sum of the three transfer functions, as follows:
H B ( s ) = i = 1 3 k i e r i s a i s b i s 2 + c i s + d i ,
where the transfer functions corresponding to i = 1 , 2, and 3 represent the P-wave, the QRS complex, and the T-wave, respectively. a , b , c , d , r , and k are the model parameters. In particular, k is a gain that allows controlling the response amplitude, a represents the position of the zero in the transfer function, r is the time delay associated with the coupling of every signal, c is a parameter that allows controlling the damping factor, and d and b are related to the natural frequency of the system.
Equation (12) is driven by a periodic pulse train, which represents the rhythmic nature of heartbeats. Hence, the entire ECG output can be defined as
E C G ( s ) = i = 1 3 k i e r i s 1 e s f a i s b i s 2 + c i s + d i ,
where f denotes the pulse train frequency. The next task is to find the parameter values for (12) and (13) to reproduce the particular synthetic ECG waveforms. Given the complexity of estimating multiple coefficients, metaheuristic algorithms have emerged as plausible choices. These algorithms exhibit versatility in addressing various problems across different domains, as evidenced by their widespread application [29]. Metaheuristic algorithms have the advantage of easily adapting to any problem and running in parallel when the processing time increases. However, it is essential to note that metaheuristic algorithms do not guarantee a global optimum, implying that they may not always converge to the best solution. Nevertheless, by appropriately configuring the algorithm, solutions that satisfy the constraints of the problem can be obtained.
Genetic algorithms (GA) stand out as one of the most widely used and well-known metaheuristic algorithms [30]. Inspired by natural selection, a GA mimics the process of selecting the most advantageous genes for inheritance by successive generations. The various versions of this algorithm can yield different results. Nonetheless, a fundamental phase common to most GA iterations is selection, in which a fitness function assesses all potential initial random solutions to identify the best-performing ones. Mutation introduces random variations in the solutions to prevent convergence to local maxima, whereas crossover facilitates the combination of two strong solutions.
We used a GA to explore the parameters of (12) and (13) to generate an ECG signal that closely resembles a real signal. Algorithm 1 is the pseudocode describing the GA utilized in this study. Note that elitism was employed to ensure descent of the most suitable genes.
Algorithm 1 Pseudocode for the used GA
1:
Begin
2:
Select hyperparameters
3:
Set the initial population P ; each individual is a vector with random coefficients corresponding to Equation (12).
4:
while fitness function ≤ 30,000 do
5:
    Calculate fitness of each individual of P , defined by the Integral Square Error.
6:
    Selection of P members with lower fitness value, according to biological pressure.
7:
    Crossover parents with lowest fitness, using a random single point to create the union.
8:
    Random change of a value in individuals (mutation).
9:
    Generate a new generation of individuals P using elitism and the members with the lowest fitness.
10:
end while
11:
Keep the best solution (minimum fitness)
12:
end
The GA starts with a random population and assigns a "fitness" value to each random solution. A fitness function is selected to define the performance of each solution, with the most common being the mean square error (MSE), root mean square error (RMSE), and integral square error (ISE). For this study, the ISE was used as the fitness function, as follows:
I S E = ε ( t ) 2 d t ,
where ε is defined as
ε ( t ) = E C G r e a l ( t ) E C G s i m u l a t e d ( t )
The selection was carried out using a tournament of size 3, and the remaining parameters of the GA are summarized in Table 1.
Once the fitness function and parameter values of the GA are defined, the parameter values of the proposed model itself must be fine-tuned using clinical ECG registers as reference waveforms. In this study, the publicly available database PhysioNet [31,32] was used. This extensively used database grants access to 12-lead ECGs and encompasses 310 electrocardiogram records from 90 individuals, comprising 46 women and 44 men aged between 13 and 75 years. The database comprises two channels: the first channel contains RAW data, and the second channel contains filtered data. Each ECG recorded in this database has a resolution of 12 bits and a range error rate of ±10 mV. Labeled as patients with normal ECGs, each ECG signal was stored for 20 s and digitized at a sample rate of 500 Hz. This database was selected owing to its widespread recognition, extensive acquisition of details, and comprehensive nature.
The heartbeats from each individual in the study were manually segmented using the filtered channel. The system exhibited improved performance with noise-free signals. Nonetheless, this enabled the assessment of the method’s efficacy against a complex database encompassing variations that can be expected in real ECGs. Upon segmentation of the data, one of the 90 patients selected from the database was randomly chosen to initiate the model parameterization. Subsequently, the range of each parameter was defined so that it could be better adjusted to the database.
After completing the process for a single patient, the results were replicated for the remaining 89 patients, to determine the range of variation for each parameter. The simulations were conducted in a MATLAB-Simulink environment. MATLAB utilizes a genetic algorithm to produce coefficients assessed in the transfer functions built in Simulink. Subsequently, Simulink returned the simulated ECG signals, and MATLAB continued to evaluate the fitness using the remainder of the genetic algorithm. The model was solved using a fixed step of 0.0001 s and an automatic solver selection. The simulation times were selected based on the ECG signals used. All simulations were conducted on a computer with the following specifications: an 11th generation Intel(R) Core(TM) i7-1165G7 processor running at 2.8 GHZ, with 16 GB of RAM.

4. Results and Discussion

To synthesize a single heartbeat, the model parameters were adjusted by executing the GA (Algorithm 1 and the parameters of Table 1), using a clinical heartbeat as a reference waveform. As mentioned above, a real heartbeat from a randomly selected patient in the database (randomly selected) was used. The numerical results of the adjustment are presented in Table 2, and the resulting signal is shown in Figure 2.
The cost graph per iteration is shown in Figure 3. Standard statistical metrics were used to analyze the behavior of the method. The statistical results for this model compared to the actual heartbeat had an RMSE of 0.0471, R 2 of 0.7153, and an MBE of −0.0204.
These results show that the proposed model could represent an ECG signal. However, the algorithm needed to be evaluated with more patients to determine the range of parameters in which a healthy ECG signal can be generated by our model. Therefore, we ran the algorithm for each of the 90 patients in the database, and the same procedure as shown in Algorithm 1 was executed, where a set of random solutions were proposed for each patient. Subsequently, the performance of each random solution was evaluated with Equation (14). The best solutions had a crossover and mutation stage, and, finally, a new selection of the best solutions was made. This procedure was repeated until the number of proposed iterations in Table 1 was completed. Once the algorithm had been executed for a heartbeat per patient, a set of 90 vectors were obtained with coefficients that fit each patient’s ECG with the model wave. The mean in each parameter and their standard deviation were registered in Table 3. Additionally, we calculated statistical indicators for the 90 patients, obtaining the following average values: RMSE of 0.0543, R 2 of 0.6913, and MBE of −0.0407.
Although the algorithm performed correctly and the model could generate a heartbeat, a series of quasi-cyclic heartbeats determined the periodic nature of the ECG signal. Therefore, we added a frequency parameter f to (13). The normal frequency of a healthy adult at rest is 60–90 beats per minute (bpm). Therefore, for the parameters listed in Table 2, a frequency of 1.11 Hz was added. This parameter value resulted in a cardiac frequency of 66 bpm. The periodic behavior of the ECG with the model based on the transfer functions is shown in Figure 4.
Notably, the natural frequency of the model was regulated by a single parameter, thereby simplifying the adjustment of the heart rate. The primary goal of this study was to ensure that the model effectively controlled the signal dynamics, producing ECGs representative of common heart conditions. To achieve this, four typical heart problems were modeled: sinus tachycardia, atrial flutter, atrial flutter, and ventricular Flutter.
Sinus tachycardia is an elevation in heart rate, even when an individual is at rest. Although the normal value depends on factors such as age and physical activity, a value greater than 100 bpm in healthy adults at rest is indicative of tachycardia. Therefore, a higher frequency is required for this type of pathology. To achieve this, we configured f at 2 Hz, resulting in a heart rate of 120 bpm, as shown in Figure 5.
The other arrhythmias considered in this work imply changes in the waveform, so the system parameters were readjusted to reproduce them. By employing the same methodology based on a GA, we determined the correct combination of parameters to produce ECG waveforms resembling cardiac arrhythmias. For this purpose, the public database MIT-BIH Arrhythmia Database was used, which is a set of more than 4000 long-term Holter records that were obtained by the Arrhythmia Laboratory of Beth Hospital [32,33].
This database contains 48 records with a duration of 30 min, corresponding to 25 men between 32 and 89 years old and 22 women between 23 and 89 years old. These records were selected to include a variety of rare but clinically essential phenomena that a small random sample would not represent well.
Signals were bandpass-filtered and digitized at 360 Hz using hardware built at the MIT Biomedical Engineering Center and BIH Biomedical Engineering Laboratory. The signals had a resolution of 11 bits in the range of ±5 mV. Therefore, the sample values ranged between 0 and 2047, where zero volts correspond to 1024.
After proper parameter adjustment, our model could reproduce atrial flutter, which indicates an abnormal heart rhythm that begins in the atrial chambers of the heart. It is generally associated with a rapid heart rate and is classified as supraventricular tachycardia. Atrial flutter is characterized by a frequency between 220 and 350 bpm. The rhythm can be regular, but P waves do not appear and are replaced by flutter (F) waves, which are more similar to sawtooth or triangular waves. A complex QRS usually lasts no more than 0.12 s. This type of pathology could be reproduced by the proposed model with the parameters listed in Table 4, and the resulting wave is shown in Figure 6.
Additionally, our model can generate ventricular tachycardia, which is characterized by atypical electrical signals in the ventricles, which can last a few seconds or longer. When ventricular tachycardia occurs, the heart beats faster than 100 bpm. A disorderly heartbeat prevents the chambers of the heart from adequately filling with blood. Consequently, the heart may be incapable of pumping sufficient blood. The parameters listed in Table 5 were used to simulate this arrhythmia. The resulting ECG is shown in Figure 7.
The model was also tested to reproduce ventricular flutter waveforms. Ventricular flutter is a severe ventricular arrhythmia (originates in the lower chambers of the heart or ventricles). It manifests as rapid heart contractions exceeding 200 bpm. In the ECG recordings, a continuous sinusoidal pattern devoid of QRS complexes or T waves emerges. Utilizing the parameter values in Table 6, the model generated a ventricular flutter signal, as depicted in Figure 8.
Thus far, we have shown that the model is capable of representing heartbeats, healthy electrocardiogram signals, and ECG signals for different diseased hearts.
Finally, it was adequate to compare the proposed model with other models with the same aim of generating ECG signals. This comparison is presented in Table 7.
From the comparison given in Table 7, we can conclude that the proposed model is linear and has a number of parameters similar to the model based on quasiperiodic motion [25], but the main advantage is the control of variables with parameter variations, which are determined by means of a GA, and no manual tuning is required. Each model may have advantages or disadvantages depending on the application and precision required.

5. Conclusions

In this study, we presented a mathematical model based on transfer functions to reproduce the electrical activity of the heart at the macroscopic level through ECG signals. Our model comprises a set of three transfer functions coupled with time delays with parameters adjusted via a GA. By fine-tuning the parameters with clinical ECG records as reference signals, we generated waveforms that resembled real ECG registers, with a root mean square error of 4.7% and an R 2 value of 0.72. The simplicity of our model allows for easy adjustment of the waveform parameters, enabling the generation of both normal and arrhythmic signals. Despite its linear nature, the ability of our model to reproduce specific heartbeats makes it a valuable tool for assessing and testing ECG-monitoring equipment.
Compared to existing models, our approach closely aligns with periodically kicked RLC oscillator models, but with a simpler trigonometric function-based approach. Unlike the manual adjustment in most of the existing models, our method offers a systematic approach for automatically tuning parameters through a GA. However, it is worth mentioning that the linear representation of the model makes it impossible to capture the nonlinear complexities of cardiac electrical activity. Nonetheless, the structured nature of our transfer functions holds potential for future arrhythmia control initiatives.
In future work, generalization to include multi-lead ECGs and the representation of bundle branch blocks and ischemia, such as ST elevation, present exciting avenues for research. Additionally, exploring ECG classification through parametric estimation using AI-based multidimensional classifiers offers further opportunities for advancement in this field.

Author Contributions

Conceptualization, O.R.-A., J.L.A. and M.A.Q.-J.; methodology, O.R.-A., J.L.A., M.A.Q.-J. and M.C.-F.; software, O.R.-A., C.F.-S. and M.C.-F.; validation, O.R.-A., M.A.Q.-J. and M.C.-F.; formal analysis, O.R.-A., J.L.A. and M.A.Q.-J.; investigation, O.R.-A., J.L.A. and M.C.-F.; resources, O.R.-A., J.L.A. and M.A.Q.-J.; data curation, O.R.-A., C.F.-S. and M.C.-F.; writing—original draft preparation, O.R.-A., J.L.A. and M.C.-F.; writing—review and editing, O.R.-A., J.L.A. and M.C.-F.; visualization, O.R.-A., C.F.-S. and M.C.-F.; supervision, O.R.-A., M.A.Q.-J. and J.L.A.; project administration, O.R.-A., J.L.A. and M.C.-F.; funding acquisition, O.R.-A., C.F.-S. and M.C.-F. All authors have read and agreed to the published version of the manuscript.

Funding

This work was Funding by Consejo Nacional de Humanidades, Ciencias y Tecnologías (CONAHCyT) of Mexico under Grant CF-2023-I-1496 and Dirección General de Asuntos del Personal Académico (DGAPA)-National Autonomous University of Mexico (UNAM) under Project UNAMPAPIIT TA101023 and the postdoctoral fellowship DGAPA-UNAM for O.R.A.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

The database for healthy ECGs (ECG-ID database) is available at https://physionet.org/content/ecgiddb/1.0.0/ (accessed on 1 April 2024) and MIT-BIH Arrhythmia Database is available at: https://www.physionet.org/content/mitdb/1.0.0/ (accessed on 1 April 2024).

Acknowledgments

This work was supported by Consejo Nacional de Humanidades, Ciencias y Tecnologías (CONAHCyT) of Mexico under Grant CF-2023-I-1496. O.R.A would like to thank the support of Dirección General de Asuntos del Personal Académico (DGAPA)-National Autonomous University of Mexico (UNAM) by the postdoctoral fellowship DGAPA-UNAM. MAQJ would like to thank the support from DGAPA-UNAM under Project UNAM-PAPIIT TA101023.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Motta, S.; Pappalardo, F. Mathematical modeling of biological systems. Briefings Bioinform. 2012, 14, 411–422. [Google Scholar] [CrossRef] [PubMed]
  2. Michail, M.; Brown, A.J. Physiology of the normal heart. Medicine 2018, 46, 427–430. [Google Scholar] [CrossRef]
  3. Silvani, A.; Calandra-Buonaura, G.; Dampney, R.A.L.; Cortelli, P. Brain–heart interactions: Physiology and clinical implications. Philos. Trans. R. Soc. A Math. Phys. Eng. Sci. 2016, 374, 20150181. [Google Scholar] [CrossRef] [PubMed]
  4. Nowbar, A.N.; Gitto, M.; Howard, J.P.; Francis, D.P.; Al-Lamee, R. Mortality From Ischemic Heart Disease. Circ. Cardiovasc. Qual Outcomes 2019, 12, e005375. [Google Scholar] [CrossRef] [PubMed]
  5. Kaplan Berkaya, S.; Uysal, A.K.; Sora Gunal, E.; Ergin, S.; Gunal, S.; Gulmezoglu, M.B. A survey on ECG analysis. Biomed. Signal Process. Control. 2018, 43, 216–235. [Google Scholar] [CrossRef]
  6. Keener, J.; Sneyd, J. (Eds.) The Heart. In Mathematical Physiology: II: Systems Physiology; Springer: New York, NY, USA, 2009; pp. 523–626. [Google Scholar] [CrossRef]
  7. Liu, X.; Wang, H.; Li, Z.; Qin, L. Deep learning in ECG diagnosis: A review. Knowl.-Based Syst. 2021, 227, 107187. [Google Scholar] [CrossRef]
  8. Houssein, E.H.; Kilany, M.; Hassanien, A.E. ECG signals classification: A review. Int. J. Intell. Eng. Inform. 2017, 5, 376–396. [Google Scholar] [CrossRef]
  9. Prusty, M.R.; Pandey, T.N.; Lekha, P.S.; Lellapalli, G.; Gupta, A. Scalar invariant transform based deep learning framework for detecting heart failures using ECG signals. Sci. Rep. 2024, 14, 2633. [Google Scholar] [CrossRef] [PubMed]
  10. Alonso, S.; dos Santos, R.W. Modelling the Electrical Activity of the Heart. In Cardiovascular Computing—Methodologies and Clinical Applications; Springer: Singapore, 2019; pp. 211–229. [Google Scholar] [CrossRef]
  11. Peirlinck, M.; Costabal, F.S.; Yao, J.; Guccione, J.M.; Tripathy, S.; Wang, Y.; Ozturk, D.; Segars, P.; Morrison, T.M.; Levine, S.; et al. Precision medicine in human heart modeling. Biomech. Model. Mechanobiol. 2021, 20, 803–831. [Google Scholar] [CrossRef] [PubMed]
  12. Jæger, K.H.; Tveito, A. Deriving the Bidomain Model of Cardiac Electrophysiology from a Cell-Based Model; Properties and Comparisons. Front. Physiol. 2022, 12, 811029. [Google Scholar] [CrossRef] [PubMed]
  13. Trudel, M.C.; Dube, B.; Potse, M.; Gulrajani, R.; Leon, L. Simulation of QRST integral maps with a membrane-based computer heart model employing parallel processing. IEEE Trans. Biomed. Eng. 2004, 51, 1319–1329. [Google Scholar] [CrossRef] [PubMed]
  14. Barrio, R.A.; Dominguez-Roman, I.; Quiroz-Juarez, M.A.; Jimenez-Ramirez, O.; Vazquez-Medina, R.; Aragon, J.L. Modelling the electrical activity of the heart. In Mathematical Biology and Biological Physics; Springer: Singapore, 2019; pp. 51–59. [Google Scholar] [CrossRef]
  15. Quiroz-Juárez, M.A.; Rosales-Juárez, J.A.; Jiménez-Ramírez, O.; Vázquez-Medina, R.; Aragón, J.L. ECG Patient Simulator Based on Mathematical Models. Sensors 2022, 22, 5714. [Google Scholar] [CrossRef] [PubMed]
  16. Montoya-Santiyanes, L.A.; Chay-Canul, A.J.; Camacho-Pérez, E.; Rodríguez-Abreo, O. A novel model for estimating the body weight of Pelibuey sheep through Gray Wolf Optimizer algorithm. J. Appl. Anim. Res. 2022, 50, 635–642. [Google Scholar] [CrossRef]
  17. Ogata, K. Modern control engineering. Book Rev. 1999, 35, 1184. [Google Scholar] [CrossRef]
  18. Kuo, B.C. Automatic Control Systems; Prentice Hall PTR: Upper Saddle River, NJ, USA, 1987. [Google Scholar]
  19. Hampton, J.; Hampton, J. The ECG Made Easy E-Book; Elsevier Health Sciences: Edinburgh, UK, 2019. [Google Scholar]
  20. Bueno-Orovio, A.; Britton, O.; Muszkiewicz, A.; Rodriguez, B. Cardiac Modeling. In Encyclopedia of Cell Biology; Bradshaw, R.A., Stahl, P.D., Eds.; Academic Press: Waltham, MA, USA, 2016; pp. 86–94. [Google Scholar] [CrossRef]
  21. Gois, S.R.; Savi, M.A. An analysis of heart rhythm dynamics using a three-coupled oscillator model. Chaos Solitons Fractals 2009, 41, 2553–2565. [Google Scholar] [CrossRef]
  22. Ryzhii, E.; Ryzhii, M. A heterogeneous coupled oscillator model for simulation of ECG signals. Comput. Methods Programs Biomed. 2014, 117, 40–49. [Google Scholar] [CrossRef] [PubMed]
  23. Quiroz-Juárez, M.; Vázquez-Medina, R.; Ryzhii, E.; Ryzhii, M.; Aragón, J. Quasiperiodicity route to chaos in cardiac conduction model. Commun. Nonlinear Sci. Numer. Simul. 2017, 42, 370–378. [Google Scholar] [CrossRef]
  24. Quiroz-Juárez, M.A.; Jiménez-Ramírez, O.; Vázquez-Medina, R.; Breña-Medina, V.; Aragón, J.L.; Barrio, R.A. Generation of ECG signals from a reaction-diffusion model spatially discretized. Sci. Rep. 2019, 9, 19000. [Google Scholar] [CrossRef] [PubMed]
  25. McSharry, P.; Clifford, G.; Tarassenko, L.; Smith, L. A dynamical model for generating synthetic electrocardiogram signals. IEEE Trans. Biomed. Eng. 2003, 50, 289–294. [Google Scholar] [CrossRef] [PubMed]
  26. Sayadi, O.; Shamsollahi, M.B.; Clifford, G.D. Synthetic ECG generation and Bayesian filtering using a Gaussian wave-based dynamical model. Physiol. Meas. 2010, 31, 1309. [Google Scholar] [CrossRef] [PubMed]
  27. Quiroz-Juárez, M.; Jiménez-Ramírez, O.; Aragón, J.; Del Río-Correa, J.; Vázquez-Medina, R. Periodically kicked network of RLC oscillators to produce ECG signals. Comput. Biol. Med. 2019, 104, 87–96. [Google Scholar] [CrossRef] [PubMed]
  28. Taff, L. Expanding the scientific role of the hubble space telescope fine guidance sensors. Adv. Space Res. 1991, 11, 97–102. [Google Scholar] [CrossRef]
  29. Agrawal, P.; Abutarboush, H.F.; Ganesh, T.; Mohamed, A.W. Metaheuristic Algorithms on Feature Selection: A Survey of One Decade of Research (2009–2019). IEEE Access 2021, 9, 26766–26791. [Google Scholar] [CrossRef]
  30. Bhoskar, M.T.; Kulkarni, M.O.K.; Kulkarni, M.N.K.; Patekar, M.S.L.; Kakandikar, G.; Nandedkar, V. Genetic Algorithm and its Applications to Mechanical Engineering: A Review. Mater. Today Proc. 2015, 2, 2624–2630. [Google Scholar] [CrossRef]
  31. Lugovaya, T.S. Biometric Human Identification Based on Electrocardiogram. Ph.D. Thesis, Faculty of Computing Technologies and Informatics, Electrotechnical University “LETI”, Saint-Petersburg, Russia, 2005. [Google Scholar]
  32. Goldberger, A.; Amaral, L.; Glass, L.; Hausdorff, J.; Ivanov, P.; Mark, R.; Stanley, H.; PhysioBank, P. PhysioNet: PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals Components of a new research resource for complex physiologic signals. Circulation 2000, 101, e215–e220. [Google Scholar] [CrossRef] [PubMed]
  33. Moody, G.; Mark, R. The impact of the MIT-BIH Arrhythmia Database. IEEE Eng. Med. Biol. Mag. 2001, 20, 45–50. [Google Scholar] [CrossRef] [PubMed]
Figure 1. Ideal ECG for a healthy heart.
Figure 1. Ideal ECG for a healthy heart.
Biomimetics 09 00300 g001
Figure 2. Comparison between a heartbeat obtained from the database and a heartbeat generated by the transfer function Model (13) tuned by a genetic algorithm.
Figure 2. Comparison between a heartbeat obtained from the database and a heartbeat generated by the transfer function Model (13) tuned by a genetic algorithm.
Biomimetics 09 00300 g002
Figure 3. Cost evolution for each evaluation of the fitness function.
Figure 3. Cost evolution for each evaluation of the fitness function.
Biomimetics 09 00300 g003
Figure 4. Response of the proposed model to a periodic impulse input.
Figure 4. Response of the proposed model to a periodic impulse input.
Biomimetics 09 00300 g004
Figure 5. Synus Tachycardia signal obtained with the proposed model, with an input frequency of 2 Hz.
Figure 5. Synus Tachycardia signal obtained with the proposed model, with an input frequency of 2 Hz.
Biomimetics 09 00300 g005
Figure 6. Atrial flutter signal obtained with the proposed model with parameter values given in Table 4.
Figure 6. Atrial flutter signal obtained with the proposed model with parameter values given in Table 4.
Biomimetics 09 00300 g006
Figure 7. Ventricular tachycardia signal obtained with the proposed model with parameter values given in Table 5.
Figure 7. Ventricular tachycardia signal obtained with the proposed model with parameter values given in Table 5.
Biomimetics 09 00300 g007
Figure 8. Ventricular flutter signal obtained with the proposed model with the parameters given in Table 6.
Figure 8. Ventricular flutter signal obtained with the proposed model with the parameters given in Table 6.
Biomimetics 09 00300 g008
Table 1. Parameter values of the Genetic Algorithm.
Table 1. Parameter values of the Genetic Algorithm.
GA HyperparametersValueDetails
Population5000Numbers of vectors with random coefficients
Upper search limit[300 300 80,000 80,000 300 0.2 0.6 0.8 5]Maximum values allowed for parameters 
a i , b i , c i , d i , k i , r 1 , r 2 , r 3 , and f, respectively (parameters with subscript i indicate that they share the same limit for the 3 values of i).
Lower search limit[−300 0 0 0 −300 0.001 0.2 0.4 1]Minimum values allowed for parameters a i , b i , c i , d i , k i , r 1 , r 2 , r 3 , and f, respectively
Generations6Stop condition
Fitness function I S E = ε 2 d t Function for evaluate the performance of each individual (integral square error)
Elitism10%Numbers of individuals in the search
Biological pressure70%Percentage of individuals that reproduce
Mutation probability30%Probability of random mutation occurs
Table 2. Results of the genetic algorithm for estimating the coefficients in a heartbeat.
Table 2. Results of the genetic algorithm for estimating the coefficients in a heartbeat.
Parameteri = 1i = 2i = 3
r0.07940.1920.28
a0−0.4650
b40.92349.9635.12
c120.22223.3538.90
d0.85 × 10 3 48.3 × 10 3 2.28 × 10 3
k50.1194.8157.57
Table 3. Range of parameter values in transfer function model for healthy ECG signals.
Table 3. Range of parameter values in transfer function model for healthy ECG signals.
Parameteri = 1i = 2i = 3
meanSDmeanSDmeanSD
r0.08010.03950.280.320.430.27
a0.0930.19−0.530.270.0760.08
b42.8719.76310.4962.1124.5812.56
c106.6531.21218.7722.6555.4344.45
d3.5 × 10 3 5.8 × 10 3 35.1 × 10 3 25.2 × 10 3 6.7 × 10 3 8.4  × 10 3
k51.2944.7788.931.544.921.5
Table 4. Coefficients in the transfer function Model (13) used to generate an atrial flutter signal.
Table 4. Coefficients in the transfer function Model (13) used to generate an atrial flutter signal.
Parameteri = 1i = 2i = 3
r0.00010.230.34
a−0.03−0.1−0.006
b49.84501.0458.34
c79.81100.5644.33
d1.02 × 10 3 2.98 × 10 3 0.5 × 10 3
f2.118
k99.98101.340.009
Table 5. Coefficients of the proposed model to generate a ventricular tachycardia signal.
Table 5. Coefficients of the proposed model to generate a ventricular tachycardia signal.
Parameteri = 1i = 2i = 3
r0.150.531.07
a0.004−14.23−5.8
b119.82148.360.007
c31.514.6522.41
d401.12102.3410.65
f0.92
k80.0149.8089.78
Table 6. Coefficients of the proposed model to generate a ventricular tachycardia signal.
Table 6. Coefficients of the proposed model to generate a ventricular tachycardia signal.
Parameteri = 1i = 2i = 3
r0.000950.0680.2
a000
b10.29.7810.02
c23.0222.9122.97
d300.12299.88300.09
f4.01
k500.11599.11149.34
Table 7. Comparison of the proposed model with some other models with similar purposes.
Table 7. Comparison of the proposed model with some other models with similar purposes.
ModelReferenceNumber of EquationsNumber of ParametersLinearityParameter Adjustment
Proposed here-3 (transfer functions)19YesCGA
Discretized reaction–diffusion[24]4 (differential equations)9NoManual
Heterogeneous nonlinear oscillators[22]4 (differential equations)48NoManual
Ring of three coupled oscillators[21]6 (differential equations)34NoManual
Model based on a quasiperiodic motion[25]5 (differential equations)19NoManual
Periodically kicked network of RLC oscillators[27]4 (differential equations)8YesManual
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Rodríguez-Abreo, O.; Cruz-Fernandez, M.; Fuentes-Silva, C.; Quiroz-Juárez, M.A.; Aragón, J.L. Modeling the Electrical Activity of the Heart via Transfer Functions and Genetic Algorithms. Biomimetics 2024, 9, 300. https://doi.org/10.3390/biomimetics9050300

AMA Style

Rodríguez-Abreo O, Cruz-Fernandez M, Fuentes-Silva C, Quiroz-Juárez MA, Aragón JL. Modeling the Electrical Activity of the Heart via Transfer Functions and Genetic Algorithms. Biomimetics. 2024; 9(5):300. https://doi.org/10.3390/biomimetics9050300

Chicago/Turabian Style

Rodríguez-Abreo, Omar, Mayra Cruz-Fernandez, Carlos Fuentes-Silva, Mario A. Quiroz-Juárez, and José L. Aragón. 2024. "Modeling the Electrical Activity of the Heart via Transfer Functions and Genetic Algorithms" Biomimetics 9, no. 5: 300. https://doi.org/10.3390/biomimetics9050300

APA Style

Rodríguez-Abreo, O., Cruz-Fernandez, M., Fuentes-Silva, C., Quiroz-Juárez, M. A., & Aragón, J. L. (2024). Modeling the Electrical Activity of the Heart via Transfer Functions and Genetic Algorithms. Biomimetics, 9(5), 300. https://doi.org/10.3390/biomimetics9050300

Article Metrics

Back to TopTop