Non-invasive electrolyte concentration estimation method based on single-lead ECG mask auto-encoder
Through a single-lead ECG mask autoencoder method, combined with heart beat blocking and data enhancement, the problem of insufficient accuracy of non-invasive electrolyte concentration detection is solved, and higher accuracy of electrolyte concentration estimation and model robustness are achieved.
Patent Information
- Application Number
- CN202510249420.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-07-08
AI Technical Summary
The existing non-invasive electrolyte concentration detection methods are mostly invasive and have a long or expensive detection time, and the non-invasive method lacks accuracy in electrolyte concentration estimation, especially under the influence of inter-individual differences.
Using a single-lead ECG masked autoencoder method, the autoencoder pretrained model and the introduction of reference samples is used to reduce inter-individual differences, and combined with heart-pitch blocking and data enhancement technology, the accuracy of electrolyte concentration estimation is improved.
It effectively reduces the impact of differentials among individuals, improves the accuracy of electrolyte concentration estimation, enhances the robustness of the model, and reduces detection errors.
Smart Images

Figure CN120277457A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of electrolyte concentration estimation, and more specifically, relates to a non-invasive electrolyte concentration estimation method based on a single-lead ECG masked autoencoder. Background Art
[0002] Electrolyte disorders are recognized risk factors for cardiovascular diseases. Among them, the physiological functions of potassium ions include not only maintaining the normal metabolism of cells, maintaining the relative balance of osmosis inside and outside cells, maintaining the acid-base balance and ion balance inside and outside cells, but also maintaining the excitability of the neuromuscular cell membrane and maintaining cardiac function. Therefore, early hyperkalemia is mostly manifested as fatigue, nausea, and bradycardia. As the blood potassium level increases, numbness in the extremities, muscle weakness, low blood pressure, mental confusion, and lethargy will gradually appear. In severe cases, it can even cause dyspnea, hypotension, and arrhythmia. If not treated in time, severe hyperkalemia can lead to cardiac arrest and even death. Hypokalemia also causes various adverse symptoms in muscles, such as fatigue and abdominal distension discomfort, and affects the myocardium, increasing the risk of arrhythmia. Even when the serum potassium concentration is within the normal range, that is, between 3.5 mmol / L and 5.5 mmol / L, its change is also related to the occurrence of cardiovascular diseases. Studies have shown that at the extreme values of the normal range of potassium, the risk ratio of death also increases. Therefore, in clinical practice, the real-time detection of serum potassium concentration is of great significance.
[0003] Currently, the commonly used clinical methods for serum potassium detection are invasive, that is, after drawing blood from the human body, the serum sample is subjected to certain processing, and the serum potassium concentration is calculated after a chemical reaction. For example, flame photometry, ion-selective electrode method, spectrophotometry, etc. Such methods not only cause certain harm to the human body, but also have a long detection time or are expensive. Therefore, it is important to study a non-invasive and affordable potassium concentration detection method.
[0004] Previous studies have found that the generation of electrocardiogram (ECG) signals is related to the flow of electrolytes such as potassium ions. Changes in the concentration of serum potassium can lead to changes in the electrocardiogram, mainly reflected in the changes of the T wave. In 2011, El-Sherif et al. reviewed the mechanisms of electrolyte disorders and their effects on electrophysiology, electrocardiogram, and clinical consequences. The report stated that when the serum potassium concentration is between 5.5 - 7.0 mmol / L, tall and narrow T waves can be observed, and when the serum potassium concentration is greater than 10.0 mmol / L, sinus arrest, obvious intraventricular conduction block, ventricular tachycardia, and ventricular fibrillation will occur. In 2015, Astan et al. manually analyzed the electrocardiograms of 62 dialysis patients before and after dialysis. The study showed that after dialysis, the P wave amplitude, QRS amplitude, QRS duration, QTc dispersion, the sum of the derived amplitudes of V1S peak + V5R peak, the total QRS amplitude, and duration all increased significantly, but the T wave amplitude and QTc duration decreased significantly. In recent years, Noordam et al. conducted a linear regression analysis on the association between electrolyte concentrations (calcium, potassium, sodium, and magnesium) and electrocardiogram intervals (RR, QT, QRS, JT, and PR intervals). The study showed that lower potassium is associated with longer QT, JT, QRS, and PR intervals.
[0005] Based on the above findings, in the past few years, many researchers have used ECG signals to quantify serum potassium concentration, and there are mainly two methods: one is to extract features from heartbeats and use a regression model to quantify the serum potassium concentration; the other is to use deep learning methods, input a segment of ECG signal or a single heartbeat to quantify the concentration.
[0006] For the method of manually extracting features, Corsi et al. extracted the single T wave feature T wave slope amplitude ratio T from 12 leads S / A , constructed a first-order linear regression model to estimate the potassium concentration, and the mean absolute error was 0.46 ± 0.39 mmol / L. The data for constructing the model in this study came from hemodialysis patients because the potassium concentration changes significantly during dialysis. In particular, this model was also verified in the data of patients with long QT syndrome type 2 (LQT2), and its mean absolute error was 1.1 ± 1.3 mmol / L, with a relatively large error. This result indicates that the patient's disease condition has an impact on the estimation of potassium. However, in this study, patients with anemia and myocardial ischemia were excluded, but these diseases are common complications of chronic kidney disease. Attia et al. used the least squares method to construct a first-order linear regression model, and the features used were the ratio of the right slope of the T wave and the square root of the T wave amplitude extracted from three leads The average absolute error of the model in the training group was 0.44±0.47mmol / L, and the average error in the validation group was 0.5±0.42mmol / L. Based on the team's previous research, Bukhari et al. used a linear regression model, and the features used were the divergence-related indicator η and the nonlinear dynamic feature dw. The average error mentioned in the literature was 0.00±0.88mmol / L. The features dw and η calculated in this study both require the use of the T wave in the electrocardiogram corresponding to the last blood draw during hemodialysis as the reference T wave for calculation, that is, the information in the feature comes not only from the current T wave but also from the last T wave information of hemodialysis.
[0007] As for deep learning methods, few of them are currently used, and most studies are aimed at the classification problem of hypo / hyperkalemia, and there are few studies on quantitative regression problems. Lin et al. constructed a convolutional neural network model ECG12Net, which uses a 12-lead electrocardiogram with a duration of 2.5 seconds to detect potassium disorders. The data comes from 66,321 electrocardiogram records of 40,180 patients in the emergency department, and the mean absolute error of the model is 0.531mmol / L. In the problem of using deep learning to analyze blood potassium concentration in ECG, most studies regard it as a classification problem. This study is rare in that it calculates both classification and regression indicators. However, this study used a large amount of undisclosed patient data to train the model, which is difficult to reproduce; secondly, it used 12-lead ECG input, while the model effect mentioned in the appendix that only uses a single lead I lead as input is 0.843mmol / L. It should be noted that there is currently no open source data set for the estimation of non-invasive electrolyte concentrations, and the error indicators mentioned in the above studies are all calculated on different undisclosed data sets. Summary of the invention
[0008] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a non-invasive electrolyte concentration estimation method based on a single-lead ECG masked autoencoder, which estimates electrolyte concentration based on the masked autoencoder and adds reference samples to reduce the influence of individual differences, thereby improving the accuracy of non-invasive electrolyte concentration estimation.
[0009] In order to achieve the above-mentioned object of the invention, the non-invasive electrolyte concentration estimation method based on a single-lead ECG masked autoencoder of the present invention comprises the following steps:
[0010] S1: For several chronic kidney disease patients who need hemodialysis, collect single-lead ECG signals of each patient during the entire hemodialysis process, and collect blood for testing before and after the start of hemodialysis to obtain electrolyte concentrations; use a preset time window T to divide the ECG signal of each patient throughout the process into several ECG data samples, and then use a preset block method to divide each ECG data sample into M blocks;
[0011] Construct an unlabeled dataset consisting of all ECG data samples;
[0012] Screen out the ECG data samples before the start of the patient's hemodialysis and the ECG data samples after the completion of hemodialysis from all ECG data samples. Use the ECG data samples before the start of hemodialysis as the ECG data samples to be estimated, use the ECG data samples after the completion of hemodialysis as the reference ECG data samples, use the electrolyte concentration corresponding to the ECG data samples after the completion of hemodialysis as the reference electrolyte concentration, construct the input with the ECG data samples to be estimated, the reference ECG data samples and the reference electrolyte concentration, and use the electrolyte concentration corresponding to the ECG data samples before the start of hemodialysis as the label to obtain a labeled dataset;
[0013] S2: Construct a single-lead ECG masked autoencoder pre-training model, including an encoder and a decoder, where:
[0014] The encoder is used to extract features from the ECG data samples and send the obtained data features F to the decoder; The encoder includes a block embedding module and N1 cascaded Transformer modules, where:
[0015] The block embedding module is used to perform embedding encoding on M ECG blocks in the ECG data samples respectively to obtain embedding vectors, and then add a classification embedding vector at the head, and send the obtained embedding features to the first Transformer module, where d represents the dimension of the embedding vector;
[0016] N1 cascaded Transformer Blocks are used to perform feature encoding on the embedding features f and send the obtained data features F to the decoder;
[0017] The decoder is used to decode the received data features F to obtain the reconstructed ECG data samples; The decoder includes a block embedding module, N2 cascaded Transformer modules and a prediction module, where:
[0018] The block embedding module is used to perform embedding encoding on the data features F to obtain embedding features f' and send them to the decoding Transformer module;
[0019] N2 cascaded Transformer modules are used to perform feature encoding on the embedding features f' and send the obtained data features f'' to the prediction module;
[0020] The prediction module is used to generate M ECG blocks according to the data features f'' and thus splice them to obtain the reconstructed ECG data samples;
[0021] S3: Use the unlabeled dataset to train the single-lead ECG mask autoencoder pre-trained model. The specific method is as follows:
[0022] For each ECG data sample in the unlabeled dataset, its M blocks are randomly masked according to the preset masking ratio λ, and then input into the encoder in the single-lead ECG mask autoencoder pre-training model for feature extraction. In the obtained data feature F, the features of the masked blocks are replaced with randomly generated features, and the replaced data feature F is input into the decoder to obtain the reconstructed ECG data sample; the reconstruction loss between the original ECG data sample and the reconstructed ECG data sample is calculated, and the parameters of the single-lead ECG mask autoencoder pre-training model are updated;
[0023] S4: Construct an electrolyte concentration estimation model, including encoder and contrast regression modules, where:
[0024] The encoder uses the encoder in the single-lead ECG masked autoencoder pre-training model to extract features from the ECG data samples to be estimated and the reference ECG data samples, respectively, and extracts the features of the data to be estimated F p and reference data feature F r Send to the comparative regression module;
[0025] The contrast regression module is used to estimate the data feature F p , reference data feature F r The electrolyte concentration of the ECG data sample to be estimated is estimated by estimating the reference electrolyte concentration corresponding to the reference ECG data sample;
[0026] S5: fine-tune the electrolyte concentration estimation model using the labeled data set obtained in step S1, wherein the encoder parameters are initialized according to the single-lead ECG masked autoencoder pre-trained model trained in step S4 to obtain a trained electrolyte concentration estimation model;
[0027] S6: When the patient is in the normal electrolyte concentration range, use the wearable device to collect a single-lead ECG signal of the patient for a period of T as a reference ECG data sample, and at the same time collect blood to obtain the electrolyte concentration as the reference electrolyte concentration; when non-invasive electrolyte concentration estimation is required, collect the patient's ECG signal for a period of T as the ECG data sample to be estimated, and then input the ECG data sample to be estimated, the reference ECG data sample and the reference electrolyte concentration into the electrolyte concentration estimation model trained in step S5 to obtain the patient's current electrolyte concentration estimate.
[0028] The non-invasive electrolyte concentration estimation method based on a single-lead ECG masked autoencoder of the present invention collects the single-lead ECG signals of each patient during the entire hemodialysis process, extracts a number of ECG data samples and divides them into blocks, forms an unlabeled data set with all the ECG data samples, uses the ECG data samples before the start of hemodialysis as the ECG data samples to be estimated, uses the ECG data samples after the completion of hemodialysis as the reference ECG data samples, and the corresponding electrolyte concentrations as the reference electrolyte concentrations, and uses the electrolyte concentrations corresponding to the ECG data samples to be estimated as labels to obtain a labeled data set; constructs a pre-training model of a single-lead ECG masked autoencoder and trains it using the unlabeled data set, then constructs an electrolyte concentration estimation model based on the pre-training model and performs fine-tuning training using the labeled data set, and uses the fine-tuned electrolyte concentration estimation model to perform non-invasive electrolyte concentration estimation on patients.
[0029] The present invention has the following beneficial effects:
[0030] 1) The present invention uses a masked autoencoder to estimate the electrolyte concentration, introduces reference samples into the electrolyte concentration estimation model, effectively reduces the influence of interindividual variation, and improves the accuracy of electrolyte concentration estimation;
[0031] 2) When dividing the ECG data samples in the present invention, heartbeat patch embed can be used to solve the problem of the destruction of the heartbeat structure caused by fixed-size patch embed;
[0032] 3) The present invention can also improve the model robustness by performing data augmentation on the ECG data samples in the labeled data set. Description of the Drawings
[0033] Figure 1 is a flowchart of the specific implementation manner of the non-invasive electrolyte concentration estimation method based on a single-lead ECG masked autoencoder of the present invention;
[0034] Figure 2 is a comparison diagram of the division of three ECG data samples in this embodiment;
[0035] Figure 3 is a structural diagram of the pre-training model of the single-lead ECG masked autoencoder of the present invention;
[0036] Figure 4 is a structural diagram of the electrolyte concentration estimation model of the present invention;
[0037] Figure 5 is a diagram of the non-invasive electrolyte concentration estimation results of two patients using the present invention in this embodiment. Detailed implementation manners
[0038] The following describes the detailed implementation manners of the present invention with reference to the accompanying drawings, so that those skilled in the art can better understand the present invention. It should be particularly noted that in the following description, when the detailed descriptions of known functions and designs may dilute the main content of the present invention, these descriptions will be omitted here.
[0039] Embodiment
[0040] Figure 1 is a flowchart of the detailed implementation manner of the non-invasive electrolyte concentration estimation method based on a single-lead ECG masked autoencoder of the present invention. As Figure 1 shown, the specific steps of the non-invasive electrolyte concentration estimation method based on a single-lead ECG masked autoencoder of the present invention include:
[0041] S101: Collect data samples:
[0042] The present invention will use self-supervised learning for model training. Self-supervised learning is divided into two stages: pre-training and fine-tuning. In pre-training, through pretext tasks and large-scale unlabeled datasets, the basic features and patterns of the data are captured. After pre-training, fine-tuning is performed through a small-scale labeled dataset to complete downstream tasks.
[0043] Therefore, the following method is adopted to collect data samples in the present invention:
[0044] For several chronic kidney disease patients who need hemodialysis, collect the single-lead ECG signals of each patient during the entire hemodialysis process, and collect blood samples for electrolyte concentration detection before the start and after the completion of hemodialysis. Use a preset time window T to divide the ECG signals of each patient's whole process into several ECG data samples, and then use a preset chunking method to divide each ECG data sample into M chunks.
[0045] Then, two datasets are constructed based on the collected ECG data samples:
[0046] All the ECG data samples are used to form an unlabeled dataset.
[0047] From all the ECG data samples, select the ECG data samples before the start of the patient's hemodialysis and the ECG data samples after the completion of hemodialysis. Take the ECG data samples before the start of hemodialysis as the ECG data samples to be estimated, take the ECG data samples after the completion of hemodialysis as the reference ECG data samples, take the electrolyte concentration corresponding to the ECG data samples after the completion of hemodialysis as the reference electrolyte concentration, form the input with the ECG data samples to be estimated, the reference ECG data samples and the reference electrolyte concentration, and take the electrolyte concentration corresponding to the ECG data samples before the start of hemodialysis as the label to obtain a labeled dataset.
[0048] The specific position of the single-lead ECG signal can be determined according to actual needs. In this embodiment, the I-lead ECG signal is used. To improve the accuracy of subsequent feature extraction, the ECG data samples can be preprocessed for denoising. The denoising preprocessing method adopted in this embodiment is as follows: perform anti-aliasing filtering on the ECG data samples to filter out the noise above 100 Hz; then downsample to 200 Hz to reduce the input dimension; then detect and remove the high-frequency noise; finally, perform z-score normalization.
[0049] To improve the robustness of the subsequent electrolyte concentration estimation model, in this embodiment, the ECG data samples in the labeled dataset can also be subjected to data augmentation. The specific method is as follows: First, randomly generate a mask value, the range of which is between the maximum value and the minimum value of the ECG data samples, and then randomly intercept a signal with a predetermined duration from the ECG data samples and set it as the mask value. Then randomly superimpose white noise on the obtained ECG data samples so that the signal-to-noise ratio is between 8 dB and 20 dB.
[0050] Regarding the block division of the ECG data samples, the prior art usually adopts fixed block division. However, the fixed block division does not consider the characteristics of the ECG data samples. Therefore, in this embodiment, a Heartbeat Patch Embed (HPB) method is proposed. The specific method is as follows:
[0051] First, locate the R peak of the ECG data samples. The R peak location method adopted in this embodiment is as follows: Convolve the ECG data sample x0 successively through two convolutional kernels with fixed parameters for signal smoothing (convolutional kernel: [0.2, 0.2, 0.2, 0.2, 0.2]) and R peak prominence (convolutional kernel: [-4, -4, 16, -4, -4]) to obtain the signal x1. Calculate the threshold t using the following formula:
[0052] t = (μ + 3×σ)×0.4
[0053]
[0054] Among them, x1[i] represents the i-th sampling value in the signal x1, where i = 1, 2, …, n, and n represents the number of sampling points in the signal x1.
[0055] Replace the signal below the threshold t after the R peak protrusion with the threshold to obtain the signal x2. Calculate the maximum value point of the signal x2 as the initial R peak position, and then adjust it according to the principle that the interval between R peaks is not less than 0.3 seconds to extract the R peaks.
[0056] Then, block the ECG data samples according to the R peak positions. If the number of heartbeats is greater than M, truncate it; if the number of heartbeats is less than M, pad with zeros. There are two specific block methods: the RR method and the PT method, where:
[0057] The specific method of the RR method is: use the previous R peak as the starting point of the heartbeat and the next R peak as the ending point of the heartbeat to segment the heartbeat; then pad zeros before a single heartbeat to unify the length of the heartbeat block to a preset number of points.
[0058] The specific method of the PT method is: after extracting the R peaks, segment the heartbeat according to the number of sample points from the starting point of the heartbeat to the R peak sample point being 0.4 times the current RR interval, and the number of sample points from the R peak to the ending point of the heartbeat being 0.6 times the current RR interval. Then fix the R peak at a certain sample point and intercept or pad zeros before and after to make the length of a single heartbeat be the preset number of points.
[0059] Figure 2 is a comparison chart of three ECG data sample blocks in this embodiment. As Figure 2 shown, compared with the fixed block, both block methods can better adapt to the characteristics of the ECG signal. In addition, through experiments with two different heartbeat segmentation methods, it is found that although the RR block can better ensure the integrity of the T wave, in actual pre-training, the first R peak cannot be restored well, and the representation learning related to the R peak is more difficult, resulting in the model performance in the fine-tuning stage being inferior to the PT block. Therefore, the heartbeat block method finally adopted in this embodiment is the PT block.
[0060] S102: Construct a single-lead ECG masked autoencoder pre-training model:
[0061] Figure 3 is the structural diagram of the single-lead ECG masked autoencoder pre-training model of the present invention. As Figure 3 shown, the single-lead ECG masked autoencoder pre-training model of the present invention includes an encoder (Encoder) and a decoder (Decoder).
[0062] The encoder is used to extract features from the ECG data samples and send the obtained data features F to the decoder. The encoder includes a block embedding module and N1 cascaded Transformer modules, where:
[0063] The block embedding module is used to perform embedding encoding on M ECG blocks in the ECG data sample respectively, and then add a classification embedding (cls token) at the head, and the obtained embedding features are sent to the first Transformer module, where d represents the dimension of the embedding vector.
[0064] N1 cascaded Transformer modules are used to perform feature encoding on the embedding feature f, and the obtained data feature F is sent to the decoder.
[0065] The decoder is used to decode the received data feature F to obtain the reconstructed ECG data sample. The decoder includes a block embedding module, N2 cascaded Transformer modules and a prediction module, where:
[0066] The block embedding module is used to perform embedding encoding on the data feature F to obtain the embedding feature f' and send it to the decoding Transformer module.
[0067] N2 cascaded Transformer modules are used to perform feature encoding on the embedding feature f', and the obtained data feature f'' is sent to the prediction module.
[0068] The prediction module is used to generate M ECG blocks according to the data feature f'', so as to splice and obtain the reconstructed ECG data sample.
[0069] S103: Train the single-lead ECG masked autoencoder pre-training model:
[0070] Use the unlabeled dataset to train the single-lead ECG masked autoencoder pre-training model. The specific method is:
[0071] For each ECG data sample in the unlabeled dataset, randomly mask its M blocks according to the preset masking ratio λ, and then input it into the encoder in the single-lead ECG masked autoencoder pre-training model for feature extraction. In the obtained data feature F, replace the features of the masked blocks with randomly generated features, and input the replaced data feature F into the decoder to obtain the reconstructed ECG data sample. Calculate the reconstruction loss between the original ECG data sample and the reconstructed ECG data sample, and update the parameters of the single-lead ECG masked autoencoder pre-training model.
[0072] The specific value of the masking ratio λ can be set according to actual needs. In this embodiment, the masking ratio λ = 75%. In this embodiment, the L1 loss is used for the reconstruction loss.
[0073] S104: Construct an electrolyte concentration estimation model:
[0074] Figure 4 This is the structural diagram of the electrolyte concentration estimation model in the present invention. As Figure 4 shown, the electrolyte concentration estimation model in the present invention includes an encoder and a contrast regression module, where:
[0075] The encoder uses the encoder in the single-lead ECG masked autoencoder pre-training model to extract features from the ECG data sample to be estimated and the reference ECG data sample respectively, and sends the obtained data features F to be estimated p and the reference data feature F r to the contrast regression module. To simplify the electrolyte concentration estimation model, in this embodiment, the 2nd to N1th Transformer modules in the encoder of the single-lead ECG masked autoencoder pre-training model are deleted and used as the encoder in the electrolyte concentration estimation model.
[0076] The contrast regression module is used to estimate the electrolyte concentration of the ECG data sample to be estimated according to the data feature F to be estimated p , the reference data feature F r and the reference electrolyte concentration corresponding to the reference ECG data sample. As Figure 3 shown, in this embodiment, the contrast regression module includes a feature splicing layer, a first linear layer, a concentration value splicing layer and a second linear layer, where:
[0077] The feature splicing layer is used to splice the data feature F to be estimated p and the reference data feature F r , and sends the obtained spliced feature to the first linear layer.
[0078] The first linear layer is used to reduce the dimension of the spliced feature, obtain a preliminary concentration estimation value with a dimension of 1 and send it to the concentration value splicing layer.
[0079] The concentration value splicing layer is used to splice the preliminary concentration estimation value and the reference electrolyte concentration into a two-dimensional vector, and then send it to the second linear layer.
[0080] The second linear layer is used to reduce the dimension of the two-dimensional vector, and use the obtained estimation value with a dimension of 1 as the electrolyte concentration of the ECG data sample to be estimated.
[0081] S105: Fine-tune and train the electrolyte concentration estimation model:
[0082] Use the labeled data set obtained in step S101 to fine-tune and train the electrolyte concentration estimation model, where the parameters of the encoder are initialized according to the single-lead ECG masked autoencoder pre-training model trained in step S104 to obtain a trained electrolyte concentration estimation model.
[0083] S106: Non-invasive electrolyte concentration estimation:
[0084] Previously, when the patient was within the normal electrolyte concentration range, a wearable device was used to collect an I-lead ECG signal of duration T from the patient as a reference ECG data sample, and at the same time, a blood sample was taken to obtain the electrolyte concentration as the reference electrolyte concentration. When non-invasive electrolyte concentration estimation is required, an ECG signal of duration T from the patient is collected as the ECG data sample to be estimated, and then the ECG data sample to be estimated, the reference ECG data sample, and the reference electrolyte concentration are input into the electrolyte concentration estimation model trained in step S105 to obtain the current electrolyte concentration estimation value of the patient.
[0085] To better illustrate the technical effects of the present invention, specific examples are used to experimentally verify the present invention.
[0086] In this embodiment, two data sets are collected by ourselves. In Data Set 1, during the hemodialysis of 20 patients (about four hours), an I-lead electrocardiogram signal is collected using a wearable device with a sampling frequency of 500 Hz. Five blood samples are taken from each patient. The first sample is taken at the start of hemodialysis, the second sample is taken 1 hour after the start, the third sample is taken 2 hours after the start, the fourth sample is taken 3 hours after the start, and the fifth sample is taken at the end of hemodialysis. The ECG data sample and electrolyte label at the last blood sampling point are extracted as reference information, and the electrocardiogram data at the previous 4 blood sampling points are used as the ECG data samples to be detected, that is, one patient can generate 4 samples. To increase the sample size, the electrocardiogram signal near each blood sampling point is intercepted for 1 minute and divided into 3 overlapping 30s signals, so one patient can generate 12 samples. In Data Set 2, 342 patients are subjected to hemodialysis, and each patient undergoes five experiments. Two blood samples are taken in each experiment, one at the start of hemodialysis and one at the end of hemodialysis.
[0087] Figure 5 It is the non-invasive electrolyte concentration estimation result diagram of two patients in Data Set 1 using the present invention in this embodiment. Figure 5 The red dots in the figure represent the true electrolyte concentration, the gray lines represent the electrolyte concentration estimation values obtained using the present invention every 1 minute, and the blue lines represent the median of the estimation values within 10 minutes. It can be seen that the present invention is relatively accurate in estimating potassium, calcium, magnesium, and phosphorus in the blood. Next, a comparative experiment is conducted between the present invention and the non-invasive electrolyte concentration estimation method based on the existing non-invasive electrolyte regression model. Table 1 is the comparison table of the non-invasive electrolyte concentration estimation results of the present invention and the comparative method for Data Set 2 without using reference samples in this embodiment. Table 2 is the comparison table of the non-invasive electrolyte concentration estimation results of the present invention and the comparative method for Data Set 2 using reference samples in this embodiment.
[0088]
[0089] Table 1
[0090]
[0091] Table 2
[0092] As shown in Table 1 and Table 2, the comparison methods include 4 types: ① Traditional machine learning algorithms. ② In the field of non-invasive electrolyte estimation, feature-based algorithms proposed by other scholars. Such algorithms generally construct linear regression models or quadratic functions. In the original literature, only the estimation of blood potassium concentration was discussed for this part of the model, and the other three electrolytes were not discussed. Therefore, the results of the other three electrolytes are not shown in the table. ③ In the field of non-invasive electrolyte estimation, signal-based algorithms proposed by other scholars. Such algorithms construct supervised deep learning models. Most of these methods are used for hyperkalemia classification tasks. ④ Models used in other tasks based on electrocardiogram input. To more rigorously compare the model effects, this embodiment gives the model results of the CNN+LSTM structure with a lower model complexity (in this method, the input is not 30s electrocardiogram signal, but the average heart beat), as well as the model results of the contrastive self-supervised model. From the results of the estimation of the concentration of the four electrolytes, it can be seen that the present invention is superior to most existing methods in the estimation of the concentrations of the four electrolytes, namely blood potassium, blood calcium, blood magnesium and blood phosphorus, and has good application prospects.
[0093] Although the above-described illustrative specific embodiments of the present invention have been described to facilitate the understanding of the present invention by those skilled in the art, it should be understood that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, as long as various changes are within the spirit and scope of the present invention defined and determined by the appended claims, these changes are obvious, and all inventions made using the concept of the present invention are within the scope of protection.
Claims
1. A non-invasive electrolyte concentration estimation method based on a single-lead ECG masked autoencoder, characterized in that It includes the following steps: S1: For several chronic kidney disease patients who need hemodialysis, collect the single-lead ECG signals of each patient during the entire hemodialysis process, and collect blood samples for electrolyte concentration detection before the start and after the completion of hemodialysis; use the preset time window T to divide the whole-process ECG signals of each patient into several ECG data samples, and then use the preset chunking method to divide each ECG data sample into M chunks; Construct an unlabeled dataset from all ECG data samples; Select the ECG data samples before the start of hemodialysis and the ECG data samples after the completion of hemodialysis from all ECG data samples. Take the ECG data samples before the start of hemodialysis as the ECG data samples to be estimated, take the ECG data samples after the completion of hemodialysis as the reference ECG data samples, take the electrolyte concentration corresponding to the ECG data samples after the completion of hemodialysis as the reference electrolyte concentration, take the ECG data samples to be estimated, the reference ECG data samples and the reference electrolyte concentration as the input, and take the electrolyte concentration corresponding to the ECG data samples before the start of hemodialysis as the label to obtain a labeled dataset; S2: Construct a single-lead ECG masked autoencoder pre-training model, including an encoder and a decoder, where: The encoder is used to extract features from the ECG data samples and send the obtained data features F to the decoder; the encoder includes a block embedding module and N1 cascaded Transformer modules, where: The block embedding module is used to perform embedding encoding on each of the M ECG blocks in the ECG data sample to obtain embedding vectors, and then add a classification embedding vector at the head to obtain the embedding features and send them to the first Transformer module, where d represents the dimension of the embedding vector; The N1 cascaded Transformer Blocks are used to perform feature encoding on the embedded features f and send the obtained data features F to the decoder; The decoder is used to decode the received data features F to obtain the reconstructed ECG data samples; the decoder includes a block embedding module, N2 cascaded Transformer modules and a prediction module, where: The block embedding module is used to perform embedded encoding on the data features F to obtain the embedded features f′ and send them to the decoding Transformer module; The N2 cascaded Transformer modules are used to perform feature encoding on the embedded features f′ and send the obtained data features f″ to the prediction module; The prediction module is used to generate M ECG chunks according to the data features f″, and then splice them to obtain the reconstructed ECG data samples; S3: Use the unlabeled dataset to train the single-lead ECG masked autoencoder pre-training model. The specific method is: For each ECG data sample in the unlabeled dataset, randomly mask its M chunks according to the preset masking ratio λ, and then input them into the encoder in the single-lead ECG masked autoencoder pre-training model for feature extraction. In the obtained data features F, replace the features of the masked chunks with randomly generated features, and input the replaced data features F into the decoder to obtain the reconstructed ECG data samples; calculate the reconstruction loss between the original ECG data samples and the reconstructed ECG data samples, and update the parameters of the single-lead ECG masked autoencoder pre-training model; S4: Construct an electrolyte concentration estimation model, including encoder and contrast regression modules, where: The encoder uses the encoder in the single-lead ECG masked autoencoder pre-training model to extract features from the ECG data samples to be estimated and the reference ECG data samples, respectively, and extracts the features of the data to be estimated F p and reference data feature F r Send to the comparative regression module; The contrast regression module is used to estimate the electrolyte concentration of the ECG data sample to be estimated based on the characteristics F of the data to be estimated p , the characteristics F of the reference data r and the reference electrolyte concentration corresponding to the reference ECG data sample S5: fine-tune the electrolyte concentration estimation model using the labeled data set obtained in step S1, wherein the encoder parameters are initialized according to the single-lead ECG masked autoencoder pre-trained model trained in step S4 to obtain a trained electrolyte concentration estimation model; S6: When the patient is in the normal electrolyte concentration range, use the wearable device to collect a single-lead ECG signal of the patient for a period of T as a reference ECG data sample, and at the same time collect blood to obtain the electrolyte concentration as the reference electrolyte concentration; when non-invasive electrolyte concentration estimation is required, collect the patient's ECG signal for a period of T as the ECG data sample to be estimated, and then input the ECG data sample to be estimated, the reference ECG data sample and the reference electrolyte concentration into the electrolyte concentration estimation model trained in step S5 to obtain the patient's current electrolyte concentration estimate.
2. The non-invasive electrolyte concentration estimation method according to claim 1, wherein In the step S1, the single-lead ECG signal adopts an I-lead ECG signal.
3. The non-invasive electrolyte concentration estimation method according to claim 1, wherein In step S1, data enhancement is also performed on the ECG data samples in the labeled data set. The specific method is: first, a mask value is randomly generated, and the range of the value is between the maximum value and the minimum value of the ECG data sample. Then, a signal of a predetermined duration is randomly intercepted from the ECG data sample and set as the mask value; then, white noise is randomly superimposed on the obtained ECG data sample so that the signal-to-noise ratio is between 8dB and 20dB.
4. The non-invasive electrolyte concentration estimation method according to claim 1, wherein The ECG data samples in step S1 are divided into blocks based on heart beats. Specifically, the R peak of the ECG data samples is located and then divided into blocks based on the R peak position. When the number of heart beats is greater than M, the ECG data samples are truncated, and when the number of heart beats is less than M, zeros are added.
5. The non-invasive electrolyte concentration estimation method according to claim 4, wherein The block division adopts the PT method, and the specific method is: after extracting the R peak, the heart beat is divided according to the number of sample points from the starting point of the heart beat to the R peak being 0.4 times the current RR interval, and the number of sample points from the R peak to the end point of the heart beat is 0.6 times the current RR interval; then the R peak is fixed at a certain sample point, and the front and back are truncated or filled with zeros, so that the length of a single heart beat is a preset number of points.
6. The non-invasive electrolyte concentration estimation method according to claim 1, wherein In the step S4, the 2nd to N1th Transformer modules in the encoder of the single-lead ECG mask autoencoder pre-training model are deleted and used as the encoder in the electrolyte concentration estimation model.
7. The non-invasive electrolyte concentration estimation method according to claim 1, wherein The comparative regression module in step S4 includes a feature concatenation layer, a first linear layer, a concentration value concatenation layer, and a second linear layer, wherein: The feature splicing layer is used to splice the feature F of the data to be estimated p and the feature F of the reference data r for splicing, and send the obtained spliced feature to the first linear layer; The first linear layer is used to reduce the dimension of the concatenated features, obtain a preliminary concentration estimate with a dimension of 1 and send it to the concentration value concatenation layer; The concentration value concatenation layer is used to concatenate the preliminary concentration estimate and the reference electrolyte concentration into a two-dimensional vector, which is then sent to the second linear layer; The second linear layer is used to reduce the dimension of the two-dimensional vector, and the estimated value with a dimension of 1 is used as the electrolyte concentration of the ECG data sample to be estimated.