Electrocardiogram reconstruction method and system based on machine learning
By combining the deep learning architecture of convolutional neural network and Transformer encoder, the problem of insufficient accuracy of traditional photovoltaic graph reconstruction is solved, and high-precision ECG reconstruction is achieved, suitable for diverse populations and low-power devices.
Patent Information
- Application Number
- CN202510184097.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-19
- Publication Date
- 2025-07-04
AI Technical Summary
Traditional photovoltaic to electrocardiogram conversion technology has limited accuracy in reconstruction of key ECG waveforms, especially in a diverse population, which is less adaptable and susceptible to motion artifacts and environmental interference, making it difficult to meet the precise diagnosis needs of the medical field.
A hybrid deep learning architecture based on convolutional neural network and Transformer encoder is adopted, combining iterative initialization, data preprocessing, model training and loss function optimization, and the model parameters are updated through the gradient descent method to achieve high-precision reconstruction of the electrocardiogram.
It significantly improves the quality of ECG reconstruction and the fidelity of key waveforms, adapts to different individuals and physiological states, reduces the computational complexity, and is suitable for wearable health monitoring devices and telemedicine scenarios.
Smart Images

Figure CN120241083A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of biomedical signal processing, and particularly relates to an electrocardiogram reconstruction method and system based on machine learning. Background Art
[0002] The cardiovascular system is one of the important physiological systems of the human body. It supplies oxygen and nutrients through blood circulation, while removing metabolic wastes to maintain physiological balance. In the assessment of the cardiovascular system, the electrocardiogram is a very important measurement index. The electrocardiogram can be used to evaluate different indexes of heart function, from heart rate to the intensity of each pulse, providing key information for diagnosing many diseases. For example, the absence of the P wave indicates atrial fibrillation; the premature appearance of the R wave represents premature beats of the heart; abnormal changes in the RR interval lead to sleep apnea. Therefore, electrocardiogram monitoring has been proven to be beneficial for the early detection of cardiovascular diseases, which is crucial for increasing the survival chances of patients, especially high-risk patients or the aging population. However, traditional wearable electrocardiogram devices for daily tracking may limit the activities of users, and long-term wearing of electrocardiogram electrodes may also cause skin irritation and discomfort. In particular, adhesive electrodes may cause skin allergic reactions or local irritation.
[0003] Photoplethysmogram measurement, as a medical monitoring technology, is a non-invasive physiological signal monitoring technology based on the optical principle, which can be used to detect changes in blood volume in tissue microvessels and reflect the activity of the heart. The photoplethysmogram technology mainly relies on a light source and a photodetector to capture changes in light absorption in tissues, so as to extract key physiological parameter information such as heart rate, blood pressure, respiratory rate, cardiac output, endothelial function, and blood oxygen saturation. The photoplethysmogram is driven by the arterial volume changes caused by the heart pumping blood, so it can effectively reflect the pulse wave in the blood circulation system. In recent years, wearable devices have developed rapidly and have become an important tool for individual health management and remote medical treatment. The photoplethysmogram technology has been widely applied to wearable devices such as smart bracelets and smart watches, making it an ideal choice for real-time health monitoring.
[0004] However, the traditional photoplethysmogram-to-electrocardiogram conversion technology has limited reconstruction accuracy for the key waveforms of the electrocardiogram, especially poor adaptability in diverse populations. For example: the existing signal reconstruction methods have limited reconstruction effects on the key waveform features (such as QRS waves, P waves, and T waves) in electrocardiogram signals, especially poor performance in terms of the fidelity of waveform details, and it is difficult to meet the accurate diagnosis requirements in the medical field. Moreover, the PPG signal is easily affected by motion artifacts and environmental interference during the acquisition process, and the existing methods perform poorly in dealing with high-noise signals, easily resulting in distorted reconstructed signals. In addition, the PPG signal characteristics of different individuals may vary significantly, and the traditional methods have poor adaptability to diverse populations and are difficult to be compatible with signals under different physiological states and pathological conditions. Summary of the Invention
[0005] The embodiments of the present application provide a method and system for electrocardiogram reconstruction based on machine learning, which can achieve high-precision reconstruction of electrocardiograms, especially excellent in the fidelity of key waveforms.
[0006] To solve the above technical problems, in a first aspect, the embodiments of the present application provide a method for electrocardiogram reconstruction based on machine learning, including the following steps: First, iterative initialization; then, perform data preprocessing on the PPG signal and the ECG signal respectively; next, based on a convolutional neural network and a Transformer encoder, construct a signal conversion model; then, input the preprocessed data into the signal conversion model for model training to output a predicted electrocardiogram signal; next, calculate the loss function between the predicted electrocardiogram signal and the target true signal, and optimize the model parameters based on the loss function; when the number of iterations is less than the threshold, continuously update the model parameters according to the gradient descent method and perform loop training, and at the same time evaluate the model performance in the validation stage and calculate the performance metrics; when the iteration is completed, save the network parameters after training is completed and output the reconstructed electrocardiogram signal.
[0007] In some exemplary embodiments, the iterative initialization includes: initializing the number of iterations to 1 and initializing the neural network model parameters to ensure that the training starts from a basic state.
[0008] In some exemplary embodiments, the data preprocessing includes: data cleaning and data alignment; the data cleaning includes: sequentially performing signal filtering, data segmentation, normalization, and missing value processing; the data alignment includes: performing time series alignment on the PPG signal and the ECG signal, calculating the optimal path between the signals, and ensuring the time consistency of the input and output signals.
[0009] In some exemplary embodiments, the signal conversion model includes: an input layer, a fully connected layer, a Transformer encoder module, and an output layer connected in sequence; wherein, the input layer is composed of 3 convolutional layers, 1 fully connected layer, and a structure of a 4-layer Transformer encoder module; the Transformer encoder module includes four stacked encoders, and each encoder includes a multi-head self-attention mechanism unit, a forward propagation network unit, a residual connection layer, and a normalization unit; the multi-head self-attention mechanism unit uses 8 attention heads, and the activation function is PReLU; the output layer is a decoding layer composed of 3 fully connected layers.
[0010] In some exemplary embodiments, the first convolutional layer of the input layer receives the original channels of the input signal, sets the convolutional kernel size to 5, the stride to 1, the padding to 2, the number of output feature channels to 32, and introduces non-linearity through the PReLU activation function; the second convolutional layer of the input layer, based on the number of input feature channels being 32, increases the number of output channels to 64, while setting the convolutional kernel size to 5, the stride to 2, and the padding to 2; the convolutional kernel size of the third convolutional layer of the input layer is 3, the stride is 2, the padding is 1, and the number of output channels is 128 to capture higher-level temporal dependencies; after the 3 convolutional layers of the input layer, the input feature dimension of the fully connected layer set is 128, and the output feature dimension is mapped to the feature dimension d_model = 64 of the Transformer encoder.
[0011] In some exemplary embodiments, the preprocessed data is input into the signal conversion model for model training to output a predicted electrocardiogram signal, including: using the preprocessed data as input, performing feature extraction and mapping through the signal conversion model; a convolutional neural network is used to extract local features, and a Transformer encoder is used to capture the global temporal relationship of the signal to output a predicted electrocardiogram signal.
[0012] In some exemplary embodiments, the loss function between the predicted electrocardiogram signal and the target true signal is calculated, and the model parameters are optimized based on the loss function, including: comparing the predicted electrocardiogram signal output by the signal conversion model with the target true signal, and calculating the mean square error MSE as the loss function to measure the difference between the predicted electrocardiogram signal and the target true signal.
[0013] In some exemplary embodiments, when the number of iterations is less than the threshold, the model parameters are continuously updated according to the gradient descent method and looped for training, and at the same time, the model performance is evaluated in the validation phase and performance metrics are calculated, including: when the number of iterations does not reach the maximum value, the model parameters are continuously updated according to the gradient descent method and looped for training; during the training process, a dynamic learning rate adjustment strategy and a regularization method are adopted to prevent overfitting; in the validation phase, the reconstruction performance of the model is evaluated through the validation set, and performance metrics are calculated to ensure the stability and generalization ability of the model; the performance metrics include: mean absolute error, peak error, and QRS wave recognition rate, P wave recognition rate, and T wave recognition rate.
[0014] Second aspect, the embodiments of the present application further provide an electrocardiogram reconstruction system based on machine learning, which adopts the electrocardiogram reconstruction method based on machine learning described in the above embodiments to achieve high-precision reconstruction of electrocardiograms, including: an initialization module, a preprocessing module, a model construction module, a model training module, a parameter optimization module, a model evaluation module, and an output module connected in sequence; wherein, the initialization module is used for iterative initialization; the preprocessing module is used for respectively performing data preprocessing on the PPG signal and the ECG signal; the model construction module is used for constructing a signal conversion model according to the convolutional neural network and the Transformer encoder; the model training module is used for inputting the preprocessed data into the signal conversion model for model training and outputting a predicted electrocardiogram signal; the parameter optimization module is used for calculating the loss function between the predicted electrocardiogram signal and the target true signal and optimizing the model parameters based on the loss function; the model evaluation module is used for continuously updating the model parameters and performing loop training according to the gradient descent method when the number of iterations is less than the threshold, and evaluating the model performance and calculating the performance metrics during the verification phase; the output module is used for saving the network parameters after training is completed and outputting the reconstructed electrocardiogram signal after the iteration is completed.
[0015] In some exemplary embodiments, the initialization module includes an iteration number initialization unit and a parameter initialization unit; the iteration number initialization unit is used for initializing the iteration number to 1; the parameter initialization unit is used for initializing the neural network model parameters to ensure that the training starts from the basic state; the preprocessing module includes a data cleaning unit and a data alignment unit; the data cleaning unit is used for sequentially performing signal filtering, data segmentation, normalization, and missing value processing; the data alignment unit is used for performing time series alignment on the PPG signal and the ECG signal, calculating the optimal path between the signals, and ensuring the time consistency of the input and output signals.
[0016] The technical solutions provided by the embodiments of the present application have at least the following advantages:
[0017] The embodiments of the present application provide an electrocardiogram reconstruction method and system based on machine learning. The method includes the following steps: First, perform iterative initialization; then, respectively perform data preprocessing on the PPG signal and the ECG signal; next, construct a signal conversion model based on the convolutional neural network and the Transformer encoder; then, input the preprocessed data into the signal conversion model for model training and output a predicted electrocardiogram signal; next, calculate the loss function between the predicted electrocardiogram signal and the target true signal and optimize the model parameters based on the loss function; when the number of iterations is less than the threshold, continuously update the model parameters and perform loop training according to the gradient descent method, and evaluate the model performance and calculate the performance metrics during the verification phase; when the iteration is completed, save the network parameters after training is completed and output the reconstructed electrocardiogram signal.
[0018] To address the technical problems of the traditional photoplethysmogram-to-electrocardiogram conversion technology, which has limited reconstruction accuracy for the key waveforms of electrocardiograms, especially poor adaptability in diverse populations, this application designs a novel deep learning architecture that combines convolutional neural networks and attention mechanisms to achieve high-precision reconstruction of electrocardiograms, especially excelling in the fidelity of key waveforms. The application of the technology in this application can not only significantly improve the reconstruction quality of electrocardiograms, but also be extended to wearable health monitoring devices and remote medical scenarios, providing a more efficient and convenient solution for cardiovascular health monitoring. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] One or more embodiments are exemplarily illustrated by the pictures in the corresponding drawings. These exemplary illustrations do not constitute limitations on the embodiments. Unless otherwise stated, the figures in the drawings do not constitute a scale limitation.
[0020] Figure 1 It is a flowchart of a machine learning-based electrocardiogram reconstruction method provided by an embodiment of this application.
[0021] Figure 2 It is a training flowchart of a neural network provided by an embodiment of this application.
[0022] Figure 3 It is an architecture diagram of a neural network provided by an embodiment of this application.
[0023] Figure 4 It is a structural diagram of a machine learning-based electrocardiogram reconstruction system provided by an embodiment of this application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0024] As can be seen from the background art, the traditional photoplethysmogram-to-electrocardiogram conversion technology has limited reconstruction accuracy for the key waveforms of electrocardiograms, especially poor adaptability in diverse populations.
[0025] A typical photoplethysmogram includes two main components: a fluctuation caused by the change in blood volume due to the pulse pressure that varies with each heartbeat, and a relatively stable component that reflects the baseline absorbance of blood and tissue. By analyzing the alternating current component, the time series of the pulse can be accurately inferred, while the direct current component provides background information related to vascular tone or respiration. Photoplethysmogram technology is widely used in wearable devices such as smart bracelets and smart watches, making it an ideal choice for real-time health monitoring. However, since photoplethysmogram signals are vulnerable to external factors such as environmental light changes and motion artifacts, how to improve the signal-to-noise ratio of photoplethysmograms and extract reliable cardiovascular information from them remains a hot topic in current research. Despite these challenges, the potential of photoplethysmogram technology cannot be ignored. It can obtain long-term blood flow change data and effectively track an individual's health status and change trends. Whether during exercise, sleep, or daily work, photoplethysmograms can provide high-quality physiological signal monitoring. This flexibility makes photoplethysmogram one of the core technologies in health management, especially showing great application potential in chronic disease management and remote monitoring.
[0026] Photoplethysmogram and electrocardiogram are physiologically related because they reflect the same cardiac process in two different signal sensing domains. Compared with traditional physiological signal acquisition methods such as electrocardiogram, photoplethysmogram does not require electrode patches or complex wire connections, has a lower sensor cost, and is more convenient to operate without the continuous participation of the user, making it more friendly for long-term continuous cardiac monitoring. In recent years, with the rapid development of machine learning, especially deep learning, significant progress has been made, particularly in time series modeling. Traditional linear models such as autoregressive models and moving average models have been replaced by more complex non-linear models such as convolutional neural networks, recurrent neural networks, long short-term memory networks, self-attention models, etc. These models show significant advantages in processing multi-dimensional time series, capturing temporal dependencies, and learning deep features, making it possible to reconstruct electrocardiogram signals using photoplethysmogram signals. The change in peripheral blood volume recorded by photoplethysmogram is greatly affected by the contraction and relaxation of cardiac muscle, which is controlled by the cardiac electrical signals triggered by the sinoatrial node. The inherent correlation between photoplethysmogram and electrocardiogram fundamentally inspires this research, which combines the advantages of these two signals: the convenience of photoplethysmogram and the accuracy of electrocardiogram, making an effective and continuous cardiac monitoring scheme possible.
[0027] Currently, there is little research on electrocardiogram (ECG) reconstruction based on photoplethysmogram (PPG). The earliest exploration was to estimate the possibility of ECG parameters according to the time-frequency characteristics in the PPG signal. The PhotoECG method proposed by related technologies extracts a series of time-domain and frequency-domain features from the PPG signal and uses the maximum information coefficient for feature selection to predict several key parameters of the ECG. This method was first tested on a standard dataset of a hospital. The results showed that under clean PPG signals, the model could estimate ECG parameters with an accuracy of over 90%. Even on PPG data with high noise, the accuracy also reached about 80%. However, it has high requirements for signal quality and is very sensitive to motion artifacts. There have also been many studies starting to explore the possibility of machine learning in the task of reconstructing ECG from PPG, such as the method of reconstructing ECG signals from PPG signals based on discrete cosine transform and machine learning. The specific approach is to align, detrend, cycle segment, time scale, and normalize the simultaneously measured ECG signal and PPG signal, then perform DCT transformation on the paired ECG and PPG cycles. Use the linear regression analysis method (ordinary least squares, ridge regression, and least absolute shrinkage and selection operator, choose one of the three) to learn the linear transformation coefficient F, and then reconstruct the ECG signal based on the known PPG signal through this linear transformation F*. The advantage of using DCT is that it has an advantage in signal compression. It can effectively reduce the amount of data when processing signals and filter out high-frequency noise while retaining the key information of the signal, thus improving the quality and accuracy of signal conversion and reconstruction from PPG to ECG.
[0028] The existing signal reconstruction methods mainly have the following problems: (1) The reconstruction effect of the existing methods on the key waveform features (such as QRS wave, P wave, and T wave) in the ECG signal is limited, especially in terms of the fidelity of waveform details, and it is difficult to meet the accurate diagnosis requirements in the medical field. (2) The PPG signal characteristics of different individuals may vary significantly. Traditional methods have poor adaptability to diverse populations and are difficult to be compatible with signals under different physiological states and pathological conditions. (3) The existing signal reconstruction methods have a large amount of parameter training, rely on high-performance hardware devices in practical applications, have high computational complexity, limit their promotion in low-power and portable devices, and are not conducive to subsequent embedded integration into portable devices. (4) The PPG signal is easily affected by motion artifacts and environmental interference during the acquisition process. The existing methods perform poorly in dealing with high-noise signals and are prone to signal distortion in the reconstructed signals.
[0029] To solve the technical problem of accurately reconstructing an electrocardiogram (ECG) through photoplethysmogram (PPG), this application provides a machine learning-based ECG reconstruction method and system. This method mainly realizes the machine learning-based ECG reconstruction method by applying machine learning technology, including the following steps: First, iterative initialization; then, data preprocessing is performed on the PPG signal and the ECG signal respectively; next, a signal conversion model is constructed based on a convolutional neural network and a Transformer encoder; then, the preprocessed data is input into the signal conversion model for model training to output a predicted ECG signal; next, the loss function between the predicted ECG signal and the target true signal is calculated, and the model parameters are optimized based on the loss function; when the number of iterations is less than the threshold, the model parameters are continuously updated according to the gradient descent method and loop training is performed, and at the same time, the model performance is evaluated in the verification stage and the performance metrics are calculated; when the iteration is completed, the trained network parameters are saved and the reconstructed ECG signal is output. This application provides a machine learning-based ECG reconstruction method and system to achieve high-precision reconstruction of the ECG, especially excellent in the fidelity of key waveforms. The application of the technology in this application can not only significantly improve the reconstruction quality of the ECG, but also be extended to wearable health monitoring devices and remote medical scenarios, providing a more efficient and convenient solution for cardiovascular health monitoring.
[0030] The following will elaborate on each embodiment of this application in conjunction with the accompanying drawings. However, those of ordinary skill in the art can understand that in each embodiment of this application, many technical details are presented to help readers better understand this application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical solutions claimed in this application can still be implemented.
[0031] See Figure 1 , an embodiment of this application provides a machine learning-based ECG reconstruction method, including the following steps:
[0032] Step S101, iterative initialization.
[0033] Step S102, perform data preprocessing on the PPG signal and the ECG signal respectively.
[0034] Step S103, construct a signal conversion model based on a convolutional neural network and a Transformer encoder.
[0035] Step S104, input the preprocessed data into the signal conversion model for model training and output a predicted ECG signal.
[0036] Step S105, calculate the loss function between the predicted ECG signal and the target true signal, and optimize the model parameters based on the loss function.
[0037] Step S106: When the number of iterations is less than the threshold, continuously update the model parameters according to the gradient descent method and perform loop training. At the same time, evaluate the model performance during the validation phase and calculate the performance metrics.
[0038] Step S107: When the iteration is completed, save the network parameters after training and output the reconstructed electrocardiogram signal.
[0039] To solve the technical problem of accurately reconstructing the electrocardiogram from the photoplethysmogram, this application mainly implements an electrocardiogram reconstruction method based on machine learning by applying machine learning techniques, trains the model using a large-scale and diverse individual data set, and adapts to different individual characteristics through the self-attention mechanism, enabling the system to have stronger generalization ability for diverse physiological and pathological signals. Moreover, this application utilizes the long-term dependence modeling ability of the self-attention mechanism to break through the bottleneck of insufficient capture of the global features of the signal by traditional methods and improve the dynamic signal modeling effect. In addition, a lightweight network architecture is designed for wearable devices to optimize the model parameters and computational efficiency, enabling it to operate efficiently in a low-power hardware environment and promoting its wide application in practical scenarios.
[0040] The flow chart of the neural network algorithm of this application is as Figure 2 shown. The execution process of the neural network proposed in this application mainly includes steps such as iterative initialization, data preprocessing, model training, loss calculation, parameter optimization, performance evaluation, and signal output. First, initialize the number of iterations and the neural network model parameters to ensure that the training starts from a basic state. Subsequently, perform data preprocessing operations such as normalization, time alignment, and feature extraction on the input photoplethysmogram (PPG) signal and the target electrocardiogram (ECG) signal to improve the signal quality and model adaptability. The processed data is input into a hybrid model composed of a convolutional neural network (CNN) and a Transformer encoder (Encoder). The CNN is used to extract local features, and the Transformer is used to capture the global temporal relationship of the signal, and finally output the reconstructed ECG signal. The model optimizes the parameters of the neural network by calculating the loss function between the predicted signal and the true signal. When the number of iterations does not reach the maximum value, the model continuously updates the parameters according to the gradient descent method and performs loop training. At the same time, evaluate the model performance during the validation phase and calculate relevant metrics (such as the mean absolute error MAE and the QRS wave recognition rate) to ensure the stability and accuracy of the model. When the iteration is completed, save the trained network parameters and output the final high-quality electrocardiogram signal.
[0041] In some embodiments, the iterative initialization in step S101 includes: initializing the number of iterations to 1 and initializing the neural network model parameters to ensure that the training starts from a basic state.
[0042] In some embodiments, the data preprocessing in step S102 includes: data cleaning and data alignment; data cleaning includes: sequentially performing signal filtering, data segmentation, normalization, and missing value processing; data alignment includes: performing time series alignment on the PPG signal and the ECG signal, calculating the optimal path between the signals, and ensuring the time consistency of the input and output signals.
[0043] During the data cleaning process, considering that the PPG signal and the ECG signal are susceptible to environmental light changes, motion artifacts, and sensor noise during the acquisition process, resulting in a decrease in signal quality. Therefore, in the data cleaning stage, the signals are respectively preprocessed using band-pass filters specific to the frequency domain: the PPG signal passes through a 0.5 Hz - 10 Hz band-pass filter, and the ECG signal passes through a 0.1 Hz - 50 Hz band-pass filter to effectively remove low-frequency drift and high-frequency noise and retain the key components of the signals. Subsequently, in order to unify the signal sample length, the original signals in the dataset are equally segmented into data segments of 20 seconds each to ensure the consistency of the model input samples. In the normalization stage, in order to eliminate the differences in signal amplitude and offset between different individuals, the maximum-minimum normalization method is used to perform amplitude normalization on the signals, standardizing the signal amplitude to the range of [0, 1]. The normalization formula is as follows:
[0044]
[0045] where X norm is the normalized signal, X min and X max respectively represent the minimum and maximum values of the signal. Finally, for the parts of the signal with missing values, the linear interpolation method is used to complete them to ensure the integrity and continuity of the data, thereby providing high-quality input data for subsequent model training.
[0046] During the data alignment process, since there are differences in the sampling frequency and dynamic characteristics of the PPG signal and the ECG signal in the time dimension, time alignment processing is required. This application uses a time alignment method based on the dynamic time warping algorithm. First, the peak points of the PPG signal are extracted through the findpeaks function of the software matlab, and the R wave points of the ECG signal are extracted through the improved Pan-Tompkins algorithm. The dynamic time warping (DTW) algorithm is used to perform time series alignment on the PPG and ECG signals, calculate the optimal path between the signals, and ensure the time consistency X of the input and output signals. The dynamic time warping algorithm is as follows:
[0047]
[0048] where X and Y respectively represent the sequences of the PPG signal and the ECG signal, and i and j are time steps.
[0049] In some embodiments, the signal conversion model in step S103 includes: an input layer, a fully connected layer, a Transformer encoder module, and an output layer connected in sequence; wherein, the input layer is composed of 3 convolutional layers, 1 fully connected layer, and a structure of a 4-layer Transformer encoder module; the Transformer encoder module includes four stacked encoders, and each encoder includes a multi-head self-attention mechanism unit, a feed-forward network unit, a residual connection layer, and a normalization unit; the multi-head self-attention mechanism unit uses 8 attention heads, and the activation function is PReLU; the output layer is a decoding layer, which is composed of 3 fully connected layers.
[0050] The architecture of this model is as Figure 3 shown. The network model is designed by the Pytorch open-source framework. This neural network is a signal conversion model based on a hybrid deep learning architecture, mainly composed of a deep learning architecture combining an encoder part (encoder) based on CNN and Transformer. The entire model is mainly composed of a convolutional layer, a fully connected layer in the input layer, a Transformer encoder module (Transformer Encoder), and a fully connected layer in the decoding layer. Among them, the input layer is composed of 3 convolutional layers, 1 fully connected layer, and a structure of 4 layers of Transformer Encoder, and the decoder is composed of 3 fully connected layers.
[0051] In some embodiments, the first convolutional layer of the input layer receives the original channels of the input signal, sets the convolutional kernel size to 5, the stride to 1, the padding to 2, and the output feature channel number to 32, and introduces non-linearity through the PReLU activation function; on the basis of the input feature channel number of 32 in the second convolutional layer of the input layer, the output channel number is increased to 64, and at the same time, the convolutional kernel size is set to 5, the stride to 2, and the padding to 2; the convolutional kernel size of the third convolutional layer of the input layer is 3, the stride is 2, the padding is 1, and the output channel number is 128 to capture higher-level temporal dependencies; after the 3 convolutional layers in the input layer, the input feature dimension of the set fully connected layer is 128, and the output feature dimension is mapped to the feature dimension d_model = 64 of the Transformer encoder.
[0052] The encoder part of the Transformer consists of four stacked encoders. Each layer includes a multi-head self-attention mechanism, a feed-forward network (FFN), a residual connection, and layer normalization. The multi-head self-attention mechanism uses eight attention heads, and the activation function is selected as PReLU.
[0053] The output layer consists of three fully connected layers, aiming to gradually map the high-dimensional features of the Transformer encoder into time series data consistent with the target ECG signal. The dimension of the hidden layer is 1024, and the output dimension of the last layer is 1 to achieve time-domain alignment and complete reconstruction of the signal.
[0054] In some embodiments, in step S104, the preprocessed data is input into the signal conversion model for model training to output a predicted electrocardiogram signal, including: using the preprocessed data as input, performing feature extraction and mapping through the signal conversion model; a convolutional neural network is used to extract local features, and a Transformer encoder is used to capture the global temporal relationship of the signal to output a predicted electrocardiogram signal.
[0055] In some embodiments, in step S105, the loss function between the predicted electrocardiogram signal and the target true signal is calculated, and the model parameters are optimized based on the loss function, including: comparing the predicted electrocardiogram signal output by the signal conversion model with the target true signal, and calculating the mean square error MSE as the loss function to measure the difference between the predicted electrocardiogram signal and the target true signal.
[0056] In some embodiments, in step S106, when the number of iterations is less than the threshold, the model parameters are continuously updated according to the gradient descent method and loop training is performed. At the same time, the model performance is evaluated in the validation stage, and performance metrics are calculated, including: when the number of iterations does not reach the maximum value, the model parameters are continuously updated according to the gradient descent method and loop training is performed; during the training process, a dynamic learning rate adjustment strategy and a regularization method are used to prevent overfitting; in the validation stage, the reconstruction performance of the model is evaluated through the validation set, and performance metrics are calculated to ensure the stability and generalization ability of the model; the performance metrics include: mean absolute error, peak error, and QRS wave recognition rate, P wave recognition rate, and T wave recognition rate.
[0057] The model training of this application is mainly completed through deep learning methods, which includes multiple key steps from data input to model optimization. First, the preprocessed photoplethysmogram signal is used as input, and feature extraction and mapping are performed through a designed neural network model. Then, the network outputs the predicted electrocardiogram signal, which is compared with the target true signal, and the loss function (such as mean square error MSE) is calculated to measure the difference between the predicted signal and the true signal. Through the error backpropagation algorithm, the network weights and bias parameters are updated to optimize the model performance. During the entire training process, a dynamic learning rate adjustment strategy and regularization methods are adopted to prevent overfitting. At the same time, the reconstruction performance of the model is evaluated through a validation set, and relevant metrics (such as mean absolute error MAE, peak error PE, and QRS wave recognition rate, P wave recognition rate, T wave recognition rate) are calculated to ensure the stability and generalization ability of the model. After multiple rounds of iterative optimization, the trained network parameters are saved to provide a high-precision and robust model basis for signal reconstruction and practical applications.
[0058] See Figure 4 , the embodiment of this application also provides a machine learning-based electrocardiogram reconstruction system, which adopts the machine learning-based electrocardiogram reconstruction method described in the above embodiment to achieve high-precision reconstruction of the electrocardiogram, including: an initialization module 101, a preprocessing module 102, a model construction module 103, a model training module 104, a parameter optimization module 105, a model evaluation module 106, and an output module 107 connected in sequence; among them, the initialization module 101 is used for iterative initialization; the preprocessing module 102 is used for respectively performing data preprocessing on the PPG signal and the ECG signal; the model construction module 103 is used to construct a signal conversion model according to the convolutional neural network and the Transformer encoder; the model training module 104 is used to input the preprocessed data into the signal conversion model for model training and output the predicted electrocardiogram signal; the parameter optimization module 105 is used to calculate the loss function between the predicted electrocardiogram signal and the target true signal, and optimize the model parameters based on the loss function; the model evaluation module 106 is used to continuously update the model parameters and perform loop training according to the gradient descent method when the number of iterations is less than the threshold, and at the same time evaluate the model performance during the validation stage and calculate the performance metrics; the output module 107 is used to save the trained network parameters and output the reconstructed electrocardiogram signal after the iteration is completed.
[0059] In some embodiments, the initialization module 101 includes an iteration number initialization unit and a parameter initialization unit; the iteration number initialization unit is used to initialize the iteration number to 1; the parameter initialization unit is used to initialize the neural network model parameters to ensure that the training starts from the basic state; the preprocessing module 102 includes a data cleaning unit and a data alignment unit; the data cleaning unit is used to perform signal filtering, data segmentation, normalization, and missing value processing in sequence; the data alignment unit is used to perform time series alignment on the PPG signal and the ECG signal, calculate the optimal path between the signals, and ensure the time consistency of the input and output signals.
[0060] Compared with the prior art, the electrocardiogram reconstruction method and system based on machine learning provided by this application have the following advantages:
[0061] 1. It has higher reconstruction accuracy, waveform fitting degree, and correlation coefficient for the key waveforms in the electrocardiogram signal than the existing signal reconstruction methods, and improves the recognition rates of the P wave and the T wave.
[0062] 2. It is trained using multiple public datasets. Through the data preprocessing method of the system and the deep learning model adapting to different individual characteristics, it has strong robustness to common environmental noises, motion artifacts, and other interferences, and the reconstruction effect has stronger generalization ability for diverse physiological and pathological signals.
[0063] 3. This application adopts a modular architecture design, including an input layer, a convolutional feature extraction module, a Transformer encoder, and an output layer. The parameters of each module can be flexibly adjusted according to the task requirements, so as to balance the signal reconstruction accuracy and the consumption of computing resources and adapt to different hardware devices.
[0064] 4. The model of this application fully considers the computational efficiency during design, adopts a lightweight network structure. The floating-point operation count (FLOPs) of the proposed deep learning network is 12.5G, the prediction time for a single signal is about 5ms, and the model deduction time is short, which can meet the real-time requirements and is easy to be easily integrated into existing health monitoring devices and medical systems to improve the overall performance of the system.
[0065] With the above technical solutions, the embodiments of the present application provide an electrocardiogram reconstruction method and system based on machine learning. The method includes the following steps: First, perform iterative initialization; then, perform data preprocessing on the PPG signal and the ECG signal respectively; next, construct a signal conversion model based on a convolutional neural network and a Transformer encoder; then, input the preprocessed data into the signal conversion model for model training to output a predicted electrocardiogram signal; next, calculate the loss function between the predicted electrocardiogram signal and the target true signal, and optimize the model parameters based on the loss function; when the number of iterations is less than the threshold, continuously update the model parameters according to the gradient descent method and perform cyclic training, and at the same time evaluate the model performance in the verification stage and calculate the performance metrics; when the iteration is completed, save the network parameters after training is completed and output the reconstructed electrocardiogram signal.
[0066] To solve the technical problems that the traditional photoplethysmogram to electrocardiogram conversion technology has limited reconstruction accuracy for the key waveforms of electrocardiograms, especially poor adaptability in diverse populations, the present application designs a novel deep learning architecture that combines a convolutional neural network and an attention mechanism to achieve high-precision reconstruction of electrocardiograms, especially excellent performance in the fidelity of key waveforms. The application of the technology of the present application can not only significantly improve the reconstruction quality of electrocardiograms, but also be extended to wearable health monitoring devices and remote medical scenarios, providing a more efficient and convenient solution for cardiovascular health monitoring.
[0067] Those of ordinary skill in the art can understand that the above embodiments are specific embodiments for implementing the present application, and in actual applications, various changes can be made in form and details without departing from the spirit and scope of the present application. Any person skilled in the art can make their own changes and modifications without departing from the spirit and scope of the present application. Therefore, the protection scope of the present application should be subject to the scope defined by the claims.
Claims
1. An electrocardiogram reconstruction method based on machine learning, characterized in that, It includes the following steps: Iterative initialization; Perform data preprocessing on the PPG signal and the ECG signal respectively; Based on a convolutional neural network and a Transformer encoder, construct a signal conversion model; Input the preprocessed data into the signal conversion model, conduct model training, and output the predicted electrocardiogram signal; Calculate the loss function between the predicted electrocardiogram signal and the target true signal, and optimize the model parameters based on the loss function; When the number of iterations is less than the threshold, continuously update the model parameters according to the gradient descent method and perform cyclic training. At the same time, evaluate the model performance in the validation stage and calculate the performance metrics; When the iteration is completed, save the network parameters after training is completed and output the reconstructed electrocardiogram signal.
2. The electrocardiogram reconstruction method based on machine learning according to claim 1, wherein The iterative initialization includes: initializing the number of iterations to 1 and initializing the neural network model parameters to ensure that the training starts from the basic state.
3. The electrocardiogram reconstruction method based on machine learning according to claim 1, wherein The data preprocessing includes: data cleaning and data alignment; The data cleaning includes: sequentially performing signal filtering, data segmentation, normalization, and missing value processing; The data alignment includes: performing time series alignment on the PPG signal and the ECG signal, calculating the optimal path between the signals, and ensuring the time consistency of the input and output signals.
4. The electrocardiogram reconstruction method based on machine learning according to claim 1, wherein The signal conversion model includes: an input layer, a fully connected layer, a Transformer encoder module, and an output layer connected in sequence; Among them, the input layer is composed of the structure of 3 convolutional layers, 1 fully connected layer, and a 4-layer Transformer encoder module; The Transformer encoder module includes four stacked encoders. Each encoder includes a multi-head self-attention mechanism unit, a feed-forward network unit, a residual connection layer, and a normalization unit; the multi-head self-attention mechanism unit uses 8 attention heads, and the activation function is PReLU; The output layer is a decoding layer, which is composed of 3 fully connected layers.
5. The electrocardiogram reconstruction method based on machine learning according to claim 4, characterized in that The first convolutional layer of the input layer receives the original channels of the input signal, sets the convolutional kernel size to 5, the stride to 1, the padding to 2, and the output feature channel number to 32, and introduces non-linearity through the PReLU activation function; the second convolutional layer of the input layer increases the output channel number to 64 on the basis of the input feature channel number of 32, while setting the convolutional kernel size to 5, the stride to 2, and the padding to 2; the convolutional kernel size of the third convolutional layer of the input layer is 3, the stride is 2, the padding is 1, and the output channel number is 128 to capture higher-level temporal dependencies; After the 3 convolutional layers of the input layer, the input feature dimension of the set fully connected layer is 128, and the output feature dimension is mapped to the feature dimension d_model = 64 of the Transformer encoder.
6. The electrocardiogram reconstruction method based on machine learning according to claim 1, wherein, Input the preprocessed data into the signal conversion model, conduct model training, and output the predicted electrocardiogram signal, including: Use the preprocessed data as the input, and perform feature extraction and mapping through the signal conversion model; The convolutional neural network is used to extract local features, and the Transformer encoder is used to capture the global temporal relationship of the signal, and output the predicted electrocardiogram signal.
7. The electrocardiogram reconstruction method based on machine learning according to claim 1, wherein Calculate the loss function between the predicted electrocardiogram signal and the target true signal, and optimize the model parameters based on the loss function, including: Compare the predicted electrocardiogram signal output by the signal conversion model with the target true signal, and calculate the mean square error MSE as the loss function to measure the difference between the predicted electrocardiogram signal and the target true signal.
8. The electrocardiogram reconstruction method based on machine learning according to claim 1, wherein When the number of iterations is less than the threshold, continuously update the model parameters according to the gradient descent method and perform cyclic training. At the same time, evaluate the model performance in the validation phase and calculate the performance metrics, including: When the number of iterations does not reach the maximum value, continuously update the model parameters according to the gradient descent method and perform cyclic training; during the training process, adopt a dynamic learning rate adjustment strategy and a regularization method to prevent overfitting; Evaluate the reconstruction performance of the model through the validation set in the validation phase and calculate the performance metrics to ensure the stability and generalization ability of the model; the performance metrics include: mean absolute error, peak error, and QRS wave recognition rate, P wave recognition rate, and T wave recognition rate.
9. An electrocardiogram reconstruction system based on machine learning, which adopts the electrocardiogram reconstruction method based on machine learning according to any one of claims 1 to 8 to achieve high-precision reconstruction of the electrocardiogram, and is characterized in that, Including: An initialization module, a preprocessing module, a model construction module, a model training module, a parameter optimization module, a model evaluation module, and an output module connected in sequence; among them, The initialization module is used for iterative initialization; The preprocessing module is used for respectively performing data preprocessing on the PPG signal and the ECG signal; The model construction module is used to construct a signal conversion model according to the convolutional neural network and the Transformer encoder; The model training module is used to input the preprocessed data into the signal conversion model, perform model training, and output the predicted electrocardiogram signal; The parameter optimization module is used to calculate the loss function between the predicted electrocardiogram signal and the target true signal, and optimize the model parameters based on the loss function; The model evaluation module is used to continuously update the model parameters according to the gradient descent method and perform cyclic training when the number of iterations is less than the threshold, and at the same time evaluate the model performance in the validation phase and calculate the performance metrics; The output module is used to save the trained network parameters and output the reconstructed electrocardiogram signal after the iteration is completed.
10. The electrocardiogram reconstruction system based on machine learning according to claim 9, wherein The initialization module includes: an iteration number initialization unit and a parameter initialization unit; The iteration number initialization unit is used to initialize the iteration number to 1; The parameter initialization unit is used to initialize the neural network model parameters to ensure that the training starts from the basic state; The preprocessing module includes a data cleaning unit and a data alignment unit; The data cleaning unit is used to perform signal filtering, data segmentation, normalization, and missing value processing in sequence; The data alignment unit is used to perform time series alignment on the PPG signal and the ECG signal, calculate the optimal path between the signals, and ensure the time consistency of the input and output signals.
Citation Information
Cited By
Pilot mental load evaluation model construction method based on multi-physiological parameter fusion
CN121549824A