Prediction of hyperkalemia in ESRD patients by identification of multiple leads and multiple features on ECG

Abstract Background Patients with end-stage renal disease (ESRD) especially those undergoing dialysis have a high prevalence of hyperkalemia, which must be detected and treated immediately. But the initial symptoms of hyperkalemia are insidious, and traditional laboratory serum potassium concentration testing takes time. Therefore, rapid and real-time measurement of serum potassium is urgently needed. In this study, different machine learning methods were used to make rapid predictions of different degrees of hyperkalemia by analyzing the ECG. Methods A total of 1024 datasets of ECG and serum potassium concentrations were analyzed from December 2020 to December 2021. The data were scaled into training and test sets. Different machine learning models (LR, SVM, CNN, XGB, Adaboost) were built for dichotomous prediction of hyperkalemia by analyzing 48 features of chest leads V2-V5. The performance of the models was also evaluated and compared using sensitivity, specificity, accuracy, accuracy, F1 score and AUC. Results We constructed different machine models to predict hyperkalemia using LR and four other common machine-learning methods. The AUCs of the different models ranged from 0.740 (0.661, 0.810) to 0.931 (0.912,0.953) when different serum potassium concentrations were used as the diagnostic threshold for hyperkalemia, respectively. As the diagnostic threshold of hyperkalemia was raised, the sensitivity, specificity, accuracy and precision of the model decreased to various degrees. And AUC also performed less well than when predicting mild hyperkalemia. Conclusion Noninvasive and rapid prediction of hyperkalemia can be achieved by analyzing specific waveforms on the ECG by machine learning methods. But overall, XGB had a higher AUC in mild hyperkalemia, but SVM performed better in predicting more severe hyperkalemia.


Introduction
Hyperkalemia is one of the most common electrolyte disturbances in clinical practice.according to the new standard, hyperkalemia is defined as a condition with serum potassium higher than 5.0 mmol/l.Factors that increase the risk of hyperkalemia include renal failure, diabetes mellitus, heart failure, adrenal disease and the use of angiotensin-converting enzyme inhibitors, angiotensin receptor blockers or potassium-sparing diuretics.among them, the main risk factor for hyperkalemia is impaired renal function -either acute kidney injury (aKi) or advanced chronic kidney disease (CKd) [1][2][3].
Hyperkalemia increases the risk of death through multiple mechanisms. in addition to its obvious effect on cardiac excitability potentially leading to arrhythmias, hyperkalemia may also give rise to peripheral neuropathy and renal tubular acidosis.When using serum potassium as a continuous variable, the correlation between serum potassium levels and mortality was u-shaped, which implies that hyperkalemia is associated with a higher risk of death, whereas more severe CKd stages and levels of hyperkalemia may synergistically increase mortality [4][5][6][7].When serum potassium concentration was >5.0 mmol/l, the more hyperkalemia occurs, the higher the mortality rate is [8].
Previous studies have shown that after hyperkalemia occurs in CKd patients, the interval between attacks will gradually shorten [9].increasing the frequency of monitoring can find more patients with hyperkalemia, while the lower frequency of serum potassium monitoring is prone to miss the diagnosis of patients with hyperkalemia, leading to adverse consequences [10].Hyperkalemia may lead to changes in an electrocardiogram (ECG), such as t-wave tenting, PR interval prolongation, P-wave flattening, P-wave disappearance, QRS interval prolongation, etc. [11].these patterns have been used by physicians qualitatively to infer probable hyperkalemia conditions, however, a computer-aided method that allows a more accurate diagnosis of hyperkalemia is seriously needed.With the development of science and technology, the machine learning method has more and more extensive applications in various disciplines in the field of medicine.Machine learning is emerging in areas such as the classification of images, ancillary diagnosis and treatment, and prediction of disease [12].therefore, we use different machine learning approaches to build practical prediction models to achieve non-hemorrhagic immediate prediction of serum potassium concentration by ECG, thus providing early warning of death due to sudden adverse consequences of hyperkalemia.

Inclusion and exclusion criteria
this study was conducted on patients who received standard hemodialysis regularly in the affiliated Hospital of Qingdao university.this study was approved by the institutional Ethics Committee (QyFy WZll 27298) and the patient's informed consent was obtained.all patients in this study received maintenance hemodialysis for more than three months, and four hours of hemodialysis three times a week.Of these, patients with vascular embolism disease, new cerebrovascular accident, heart failure, arrhythmia and acute coronary syndrome, acute cardiovascular events, previous cardiac surgery, pacemaker implantation, incomplete clinical data, and use of drugs that affect ECG conductions were excluded.

Serum potassium measurement
at the centre of this study, serum potassium concentration was regularly monitored monthly during dialysis and ECG was collected.Given the patients' dialysis schedule, hyperkalemia was more likely to precede the first dialysis session of each week, so hospitals tended to schedule serum collections at the first hemodialysis session of each week.Blood was drawn at two-time points during each dialysis session: (1) before dialysis and (2) after dialysis, dialysate flow was stopped and the blood flow rate was reduced to 100 ml/ min for at least 15 s.immediately after blood collection, blood samples were sent to the laboratory for serum potassium analysis.Standardized procedures are performed during blood collection to prevent hemolysis from affecting serum potassium concentration.

ECG measurement
in all patients, 12-lead ECG data were obtained using standard electrode placement.ECG measurements were also performed at two-time points, one pre-and one post-dialysis.the interval between ECG measurements and blood sampling in the same patient should not exceed 5 min in order to maintain a good correlation between ECG and serum potassium concentrations.

Signal processing
ECG data collected by nihon Kohden ECG-2550 were used as raw data.the original data is stored in PdF format.Refer to Mit-BiH arrhythmia database to save the data as a header file and data file, where the data file was stored in Format212 format, for the next step of data processing.after the initial treatment of the 12-lead data, we use the MatlaB R2018b tool to analyze and process the data.
the original ECG (Figure 1(a)) signal generally has baseline drift, power frequency interference and other noise, which needs data preprocessing before conducting data analysis.the mild baseline drift was corrected by polynomial fitting to the input ECG signals, and the corrected ECG data (Figure 1(B)) were obtained by subtracting the fitted function from the metadata.the length of the original ECG data was 30 s, and by liner fitting algorithm, the smoothest 10 s data were selected, and polynomial fitting was performed a second time, again correcting for baseline drift.(Figure 1(C)) Finally, the ECG signal was denoised through wavelet transform (Figure 1(d)) and band-pass filters (Figure 1(E)) to obtain ECGs that could be analyzed.

Feature extraction
For pretreatment ECGs, characteristic values on the ECG were extracted and calculated using MatlaB and Python software.after preceding repeated trials, the following three types of 12 ECG characteristics were selected among the initial multitude of characteristics: (1) characteristics of slope class: t right slope, t left slope, S-t band slope; (2) characteristics of amplitude class: t wave amplitude, R wave amplitude, S wave amplitude; and (3) characteristics related to area class: t wave area, R wave area, S wave area, t wave area per second, R wave area per second, S wave area per second.the above 12 ECG characteristics were extracted from V2-V5 on each of these four leads for a total of 48 feature values.

Model building
the 80 dialysis patients received ECG and blood tests every other month, from which we selected 1024 sets of matched data of serum potassium and ECG. to prevent data speculum bias, these 1024 sets of data were randomly divided into a training set and a test set in an 8:2 ratio before model building.in the training set, 5-fold cross-validation method was used to learn all the data sufficiently to finally determine the optimal hyperparameters of the individual models.For machine learning, four models of convolutional neural network (Cnn), support vector machine (SVM), eXtreme Gradient Boosting (XGB) and adaboost were compared.logistic regression (lR) as a traditional clinical prediction model was also incorporated for comparison.logistic regression is a generalized linear regression analysis model, which belongs to supervised learning in machine learning.it is effective and widely used in classification, especially in the study of secondary classification [13].SVM is also a powerful supervised learning method, which is widely used in classification and regression, and is more robust than lR [14].it has many unique advantages in solving small samples, nonlinear and high-dimensional pattern recognition.adaboost is an integrated learning technique that trains multiple weak classifiers for the same training set and weights each classifier according to their errors, resulting in a strong classifier [15].XGB is also a powerful supervised learning method which is a powerful gradient-boosted tree algorithm commonly used for regression, binary classification and multiclass classification problems [16].Cnn is a kind of feedforward neural network with convolution computation and depth structure, which was originally used for image recognition and classification [17].Currently, it is widely used in the medical field for classifying images in imaging and pathology [18][19][20], voice recognition [21,22], etc. the structure of the Cnn is shown in Figure S1, and the hyperparameters of the remaining 4 models are shown in table S1. these models all output dichotomous outcomes, hyperkalemia and non-hyperkalemia.to evaluate the diagnostic ability of the model for different degrees of hyperkalemia, multiple prediction models were developed and compared by using serum potassium concentrations of 5.0, 5.5, 6.0, 6.5 mmol/l as the diagnostic threshold (Figure 2).

Evaluation indicators and statistical analysis
in order to evaluate the performance of different models, the main evaluation index is the area under the ROC curve (auC).at the same time, the sensitivity, specificity, accuracy, accuracy and F1 score of these five models were calculated.differences between auCs were compared using the delong test.two-sided P values less than 0.05 were considered statistically significant.all statistical analyses were performed by Python (version 3.7, Python Software Foundation, Wilmington, dE).

Results
Based on the above criteria, we finally selected 80 patients for data collection from december 2020 to december 2021.We collected information on these 80 hemodialysis patients when data collection was initially initiated and the results are shown in table 1. these 80 patients included 50 males and 30 females, and their mean age was 53.7. at the beginning of data collection, the average number of years of hemodialysis for these people was 3, and the average serum creatinine (Scr) of these patients was 992.3 μmol/l.Most of these individuals (86.3%) had hypertension.a total of 1024 sets of serum potassium concentration and ECG data sets were included in this study.the mean potassium concentration of these 1024 datasets was 4.83 ± 1.01 mmol/l.the average values of different characteristics on each lead are shown in table S2. among them, 576 had serum potassium concentration less than 5.0 mmol/l, 173 had serum potassium concentration greater than or equal to 5 mmol/l and less than 5.5 mmol/l, 136 had serum potassium concentration greater than or equal to 5.5 mmol/l and less than 6.0 mmol/l, 85 had serum potassium concentration greater than or equal to 6.0 mmol/l and less than 6.5 mmol/l, and 54 had serum potassium concentration greater than or equal to 6.5 mmol/l.the concentration distribution of potassium ions is relatively concentrated between 3.5 mmol/l and 6.0 mmol/l (Figure 3). the prevalence of hyperkalemia was 43.8% when 5.0 mmol/l was used as the threshold for blood potassium concentration.When 5.5 mmol/l was used as the threshold for hyperkalemia, the prevalence was 26.9%.the prevalence of hyperkalemia with a blood potassium concentration above 6.0 mmol/l was 13.6%, and the prevalence of severe hyperkalemia with a blood potassium concentration above 6.5 mmol/l was 5.3%.
the sensitivity, specificity, accuracy, precision, and F1 score of the different models at different serum potassium concentration thresholds were varied (table 2).For the same machine learning method, the same evaluation indicators decreased as the threshold of serum potassium concentration increased.For instance, when 5.0 was used as the threshold concentration for hyperkalemia, the models performed more consistently and excellently.taking Cnn as an example, when using 5.0 mmol/l as the concentration threshold for hyperkalemia, the accuracy, precision, sensitivity, specificity and F1 score of the model were 0.815, 0.769, 0.851, 0.784 and 0.808.the F1 scores of Cnn (0.808), SVM (0.812), XGB (0.861), and adaBoost (0.844) performed better than lR (0.781) when a blood potassium concentration of 5.0 mmol/l was used as the diagnostic threshold for hyperkalemia.actually, when using 5.0 or 5.5 as diagnostic thresholds, the auC and F1-score of lR were inferior to the other four machine learning methods.

Discussion
Hyperkalemia, an invisible killer in the clinic, has a high prevalence, especially in people with renal failure.However, the traditional method to detect serum levels of potassium by blood sampling often takes time to obtain the results, and cannot meet the requirement of multiple, real-time detection and management of serum potassium.How to quickly identify hyperkalemia at an early stage before admission and how to more conveniently carry out long-term monitoring of hyperkalemia in high-risk individuals with hyperkalemia are urgent issues.ECG, as a basic and comparable test for outpatients and inpatients, its waveform is affected by the change in potassium ion concentration in the body.therefore, feature extraction from the ECG waveform and analysis using machine learning methods can achieve noninvasive and rapid prediction of hyperkalemia.the usual definition of hyperkalemia is a blood potassium concentration >5.5 mmol/l.the KdiGO [23]   concentrations greater than 5.0 mmol/l, the five machine learning methods included in this study performed better for sensitivity, specificity, accuracy, precision, F1 score as well as auC, and better for other degrees of hyperkalemia.
Basal narrow and high sharp t waves can be present on the ECG of patients with mild to moderate hyperkalemia, which is also the earliest and most common ECG change in this subset of hyperkalemia patients [11,24,25].When the extracellular potassium ion concentration is higher, equivalent to when the cell membrane is in a hyperpolarized state.inwardly rectifying potassium channels in atrial myocytes increases potassium permeability, which accelerates repolarization.So the t wave base narrowed and the waveform became tall, peaked, and tented [26][27][28].in addition to t wave changes, patients with hyperkalemia may exhibit S-t segment elevation, PR interval prolongation, QRS duration prolongation, absent P waves, and sinusoidal waveforms on their ECG [29][30][31].On the other hand, hyperkalemia can also cause some atypical ECG changes, such as t wave inversion, St segment depression, etc. [3].therefore, this study has tried to include as comprehensively as possible the features of area class, slope class, interval class and amplitude class associated with t wave, P wave, QRS wave, St segment, etc.We did not include all chest leads because we observed that some waveforms on leads V1 and V6 did not perform as well as the other four chest leads.the waveform of the electrocardiogram will be affected by subjects' mental and psychological factors, abnormal breathing [32], body temperature [33,34], chest lead electrode pressure and lead position [35], etc., so these accidental factors will have an impact on the prediction results of the prediction model.
Zubaid et al. [36] collected 528 ECGs from ESRd patients presenting to the emergency department and found that the mean sensitivity and specificity for detecting hyperkalemia by the emergency physician were 0.19 and 0.97, respectively.in severe hyperkalemia with serum potassium concentrations above 6.5 mmol/l, the average sensitivity improved to 0.29, while the specificity decreased to 0.95. it can be seen that when clinicians empirically predict hyperkalemia by analyzing the ECG, the sensitivity is often inadequate, the diagnosis is prone to be missed and the likelihood of associated adverse events increases.Brian et al. [37] studied ECG in patients with blood potassium concentrations above 6.0 mmol/l and concluded that electrocardiograms were not sensitive to the diagnosis of hyperkalemia and only approached the minimum predictive ability at potassium levels of 7.2-9.4mmol/l.darren et al. [38] also showed that both t-and R-wave amplitudes on the ECG were less sensitive in detecting hyperkalemia in ESRd patients.limei Zhou et al. [39] previously included 401 samples to construct a prediction model by multiple logistic regression, using the number of hemodialysis sessions, blood urea nitrogen (Bun), serum sodium, serum calcium, serum phosphorus and diabetes mellitus to identify hyperkalemia and predict serum potassium concentrations higher than 5.5 mmol/l.the auC of this model was 0.82 (0.77, 0.88) in the training set and 0.81 (0.74, 0.88) in the validation set.Previously, studies have utilized different machine learning methods and different ECG leads and features to predict hyperkalemia.dennis et al. [40] used the general linear mixed model to diagnose hyperkalemia by analyzing the 12-lead ECG, and finally established a model incorporating the t-wave width, descending t-wave slope and new QRS prolongation.the auC in the validation set was 0.78. the maximum specificity and sensitivity of the model for serum potassium above 5.91 mmol/l were 84% and 63% respectively.the inclusion criterion for the study was a time interval of less than 4 h between the measurement of potassium concentration and the 12 lead ECG, but this time interval is too long was an inadequacy of the study because the interventions given during this period may have changed the ECG.also defining the time gap of inclusion criteria as 4 h is the study of Friedman et al. [41] which previously used 1,576,581 ECGs from 449,380 patients seen at Mayo Clinic, Rochester, from 1994 to 2017, as a training set and 5.5 mmol/l as the diagnostic threshold to predict hyperkalemia by learning 2 (leads i and ii) or 4 (leads i, ii, V3, and V5) ECG leads using a deep convolutional neural network model.and validated using retrospective data from the Mayo Clinic in Minnesota, Florida, and arizona. in this study, using only 2 ECG leads, the deep learning model detected hyperkalemia in renal disease patients with an auC of 0.853 to 0.883.However, in our study, specific features on leads V2 to V5 were converted to digital format for subsequent model training, achieving a better auC in the prediction of mild hyperkalemia.and, the criterion for the inclusion of data in this study was that the interval between ECG examination and blood sampling did not exceed 5 min in order to maintain a good correlation between ECG and blood potassium concentration. in the present study, when using a serum potassium concentration of 5.0 mmol/l as the diagnostic threshold for hyperkalemia, the other 4 machine models had similar auCs and were significantly better than lR.and the auCs of all five machine learning methods were highest at that point, probably because the data distribution was more balanced when blood potassium concentration 5.0 was used as the threshold value, which was more conducive to the model for feature learning.as the diagnostic threshold increased, the auCs of the models decreased to different degrees.this may be because the data for extreme hyperkalemia decreased as the diagnostic threshold increased, and the imbalance in the data resulted in lower model power [42].this situation will improve to some extent in the future as more data are collected and the population involved increases.the auC of XGB was highest in severe hyperkalemia with serum potassium concentrations above 5.0 and 5.5mmol/l, which suggested that XGB was preferable in the case of mild hyperkalemia.in previous studies by Zhang et al. [43] and Saraiva et al. [44], XGB also had better performance in the comparison of models.But in extreme hyperkalemia with serum potassium concentration higher than 6.5mmol/l, SVM had higher auC, which might be related to the small sample size of extreme hyperkalemia.this study only made the comparison between different models, while the ensemble model developed by fuzing multiple machine learning algorithms was able to have a better calibration and discrimination ability [45].
this study excluded patients with diseases that may cause ECG changes.different results and conclusions may be obtained in these populations, and the universality of the model was insufficient.in addition, this study lacks relevant biochemical parameters, age, sex and other information, and only uses ECG to train the model, which may lead to other factors of hyperkalemia not being included in the model, so the ability of the model was not further improved.due to conditional limitations, this study included fewer patients.On the other hand, the present study, being a prospective study, strictly limited the time interval between ECG and blood sampling to 5 min, although it could be ensured that the time interval between ECG and blood sampling had no other contributing factors to the ECG.However, this also resulted in a smaller sample size for acquisition and a smaller sample size for severe hyperkalemia, leading to inadequate model learning and uneven sample distribution, all of which may explain the poor performance of these five models in predicting severe hyperkalemia.another weakness is that this study was a single-center study and lacked the results of external data validation.

Conclusion
in conclusion, although the performance of the different models is related to the severity of hyperkalemia, and these models all performed better in predicting mild hyperkalemia with concentrations greater than 5 mmol/l, at this time XGB, adaBoost, SVM and Cnn performed significantly better than lR.XGB had a higher auC in mild hyperkalemia, but SVM performed better in predicting more severe hyperkalemia.

Figure 1 .
Figure 1. a preprocessing is required for the original eCG to become analyzable.(a) The original eCG.(B) eCGs after correction for mild baseline drift by polynomial fitting.(C) eCG after the second baseline correction.(D) eCG after wavelet transform.(e) eCG after bandpass filters.

Figure 2 .
Figure 2. The flowchart of this study.

Figure 4 .
Figure 4. ROC of different machine learning models for different degrees of hyperkalemia.

Figure 5 .
Figure 5.Comparison of auC of machine learning models at different hyperkalemia concentration thresholds.

Table 2 .
Performance of different models at different serum potassium concentration thresholds.