# Monitoring of Serum Potassium and Calcium Levels in End-Stage Renal Disease Patients by ECG Depolarization Morphology Analysis

Hassaan A Bukhari, Carlos Sánchez, José Esteban Ruiz, Mark Potse, Pablo Laguna, Esther Pueyo

<figure><img src="image_1.png" /></figure>

## ► To cite this version:

Hassaan A Bukhari, Carlos Sánchez, José Esteban Ruiz, Mark Potse, Pablo Laguna, et al.. Monitoring of Serum Potassium and Calcium Levels in End-Stage Renal Disease Patients by ECG Depolarization Morphology Analysis. Sensors, 2022, 22 (8), pp.2951. 10.3390/s22082951. hal-03937638

HAL Id: hal-03937638

https://inria.hal.science/hal-03937638

Submitted on 13 Jan 2023

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Article

# Monitoring of Serum Potassium and Calcium Levels in End-Stage Renal Disease Patients by ECG Depolarization Morphology Analysis

Hassaan A. Bukhari<sup>1,2,3,4,*</sup> <sup>1 ID</sup>, Carlos Sánchez<sup>1,2 ID</sup>, José Esteban Ruiz<sup>5</sup>, Mark Potse<sup>3,4 ID</sup>, Pablo Laguna<sup>1,2 ID</sup>
and Esther Pueyo<sup>1,2 ID</sup>

<figure><img src="image_3.png" /></figure>

check for
updates

**Citation:** Bukhari, H.A.; Sánchez, C.; Ruiz, J.E.; Potse, M.; Laguna, P.; Pueyo, E. Monitoring of Serum Potassium and Calcium Levels in End-Stage Renal Disease Patients by ECG Depolarization Morphology Analysis. *Sensors* **2022**, *22*, 2951.
https://doi.org/10.3390/s22082951

Academic Editors: Riccardo Pernice,
Massimo W. Rivolta and
Raquel Bailón

Received: 2 March 2022

Accepted: 7 April 2022

Published: 12 April 2022

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

<figure><img src="image_4.png" /></figure>

**Copyright:** © 2022 by the authors.
Licensee MDPI, Basel, Switzerland.
This article is an open access article
distributed under the terms and
conditions of the Creative Commons
Attribution (CC BY) license (https://
creativecommons.org/licenses/by/
4.0/).

**Abstract:** Objective: Non-invasive estimation of serum potassium, [K⁺], and calcium, [Ca<fnref n="2" />⁺], can help to prevent life-threatening ventricular arrhythmias in patients with advanced renal disease, but current methods for estimation of electrolyte levels have limitations. We aimed to develop new markers based on the morphology of the QRS complex of the electrocardiogram (ECG). Methods: ECG recordings from 29 patients undergoing hemodialysis (HD) were processed. Mean warped QRS complexes were computed in two-minute windows at the start of an HD session, at the end of each HD hour and 48 h after it. We quantified QRS width, amplitude and the proposed QRS morphology-based markers that were computed by warping techniques. Reference [K⁺] and [Ca<fnref n="2" />⁺] were determined from blood samples acquired at the time points where the markers were estimated. Linear regression models were used to estimate electrolyte levels from the QRS markers individually and in combination with T wave morphology markers. Leave-one-out cross-validation was used to assess the performance of the estimators. Results: All markers, except for QRS width, strongly correlated with [K⁺] (median Pearson correlation coefficients, *r*, ranging from 0.81 to 0.87) and with [Ca<fnref n="2" />⁺] (*r* ranging from 0.61 to 0.76). QRS morphology markers showed very low sensitivity to heart rate (HR). Actual and estimated serum electrolyte levels differed, on average, by less than 0.035 mM (relative error of 0.018) for [K⁺] and 0.010 mM (relative error of 0.004) for [Ca<fnref n="2" />⁺] when patient-specific multivariable estimators combining QRS and T wave markers were used. Conclusion: QRS morphological markers allow non-invasive estimation of [K⁺] and [Ca<fnref n="2" />⁺] with low sensitivity to HR. The estimation performance is improved when multivariable models, including T wave markers, are considered. Significance: Markers based on the QRS complex of the ECG could contribute to non-invasive monitoring of serum electrolyte levels and arrhythmia risk prediction in patients with renal disease.

**Keywords:** electrocardiogram; QRS complex morphology; T wave morphology; potassium estimation; calcium estimation; hemodialysis; time warping; regression

## 1. Introduction

Patients with chronic kidney disease (CKD), particularly at the most severe stages, are at high risk for life-threatening arrhythmias and sudden cardiac death [1–4], and millions of them die every year due to lack of access to affordable treatment. Between five and seven million end-stage renal disease (ESRD) patients need renal replacement therapy worldwide [5]. ESRD patients undergoing hemodialysis (HD) frequently have serum electrolyte levels outside normal ranges, which can increase the mortality risk [1–4].

<footnote n="1">1 BSICoS Group, I3A Institute, IIS Aragón, University of Zaragoza, 50018 Zaragoza, Spain; cstapia@unizar.es (C.S.); laguna@unizar.es (P.L.); epueyo@unizar.es (E.P.)</footnote>

<footnote n="2">2 CIBER en Bioingeniería, Biomateriales y Nanomedicina (CIBER-BBN), 50018 Zaragoza, Spain</footnote>

<footnote n="3">3 Carmen Team, Inria Bordeaux—Sud-Ouest, 33405 Talence, France; mark@potse.nl</footnote>

<footnote n="4">4 Université de Bordeaux, IMB, UMR 5251, 33400 Talence, France;</footnote>

<footnote n="5">5 Nephrology Department, Hospital Clínico Universitario Lozano Blesa, 50009 Zaragoza, Spain; jeruizl@salud.aragon.es</footnote>

<footnote>* Correspondence: hassaanahmed01@unizar.es</footnote>
Non-invasive monitoring of electrolyte levels can be useful for risk prediction and the triggering of early warnings. Electrocardiogram (ECG) ventricular depolarization and repolarization are, in particular, altered by variations in serum potassium ([$K^+$]) and calcium ([$Ca^{2+}$]) [1,2,6–8]. ECG markers have been proposed for the continuous monitoring of these two electrolyte levels, which could facilitate timely therapies for ESRD patients.

Most ECG-based estimators of [$K^+$] and [$Ca^{2+}$], such as those based on the QT interval or on T wave amplitude, slope and slope-to-amplitude ratio, are based exclusively on ventricular repolarization and commonly refer to a specific time interval, to an amplitude at a given time point or to a particular portion of the T wave [9–15]. Although the QT interval has long been used to monitor CKD patients during HD [16–21], contradictory findings have been presented, with many studies reporting QT prolongation [18,19,21–23] and others showing QT shortening or no effects during HD [24,25]. Other recent studies have investigated changes in markers of sympathetic activity-related T wave instability during HD [26] and in model-based descriptors of T wave morphology in the interdialytic interval [27]. These studies, however, have not established a tight correlation between the proposed markers and [$K^+$], thus limiting their possibilities for ambulatory [$K^+$] monitoring. In previous studies, we used nonlinear dynamics and time-warping techniques to characterize changes in the whole T wave at varying [$K^+$] and [$Ca^{2+}$] in patients and simulated ECGs [28–33]. We found a strong relationship between [$K^+$] and T wave linear and nonlinear features.

Assessment of ventricular depolarization for serum electrolyte estimation has been less explored. Similarly to QT studies, research on QRS complex duration has rendered inconsistent results, with some works reporting widened QRS complexes [1,34] and others reporting narrowed QRS complexes at high [$K^+$] [2,35]. Other works have assessed the time voltage area, amplitude and sine wave shape of the QRS complex, but limitations in terms of their significance or their dependence on blood volume have been acknowledged [14,36–38]. None of these studies have, however, quantitatively characterized overall variations in the morphology of the QRS complex during HD. We hypothesized that QRS morphology could provide complementary information on [$K^+$] and [$Ca^{2+}$], in addition to that provided by repolarization.

The aim of this study was to quantify changes in the QRS amplitude, duration and morphology, the latter both in the time and amplitude domains, at varying [$K^+$], [$Ca^{2+}$] and heart rate (HR) in ESRD patients. Univariable and multivariable electrolyte estimators, including novel QRS morphological markers in combination with already proposed T wave markers [28–30,39], were devised, and the contribution of depolarization analysis to [$K^+$] and [$Ca^{2+}$] monitoring was assessed.

## 2. Materials

Forty-eight-hour 12-lead ECGs with 3.75 µV resolution and a sampling frequency of 1 kHz (H12+, Mortara Instruments, Milwaukee, WI, USA) were acquired from 29 ESRD patients of Hospital Clínico Universitario de Zaragoza (HCUZ). ECG acquisition started 5 minutes before HD and lasted for 48 hours (Figure 1, bottom blue line), with patients in the supine position. Concurrently, six blood samples were taken during and after the HD session: the first one at HD onset and the next three samples every hour during the HD session (Figure 1, $h_0$ to $h_3$ in red). The fifth blood sample ($h_4$) was obtained at the end of the HD (minute 215 or 245, depending on the patient) while the sixth blood sample was taken after 48 hours ($h_{48}$), immediately before the next HD session. Serum [$K^+$] and [$Ca^{2+}$] were measured at those six time points, as shown in Figure 1 [28–30], using a Cobas 6000 c501 analyzer (Roche Diagnostics, Germany) by an indirect ion selective electrode method. We defined another time point for ECG analysis, corresponding to a segment taken two minutes before the end of HD (minute 213 or 243, depending on the patient), which we denoted by $h_4^-$. The [$K^+$] value at $h_4^-$ was assumed to be the same as at $h_4$, as the time difference between these two segments was just two minutes. All patients signed informed
consent. The study protocol was approved by the Research Ethics Committee of Aragón (CEICA, ref. PI18/003, 25 January 2018). Table 1 shows the population characteristics.

<figure><img src="image_5.png" /><figcaption>**Figure 1.** Diagram of the study protocol. *h*₀ to *h*₄₈ are the time points (in minutes) for blood sample extraction. Reproduced with permission from Bukhari et al., Computers in Biology and Medicine; published by Elsevier, 2022.</figcaption></figure>

<table><caption>**Table 1.** Characteristics of the study population. Values are expressed as number (%) for categorical variables and median (interquartile range, IQR) for continuous variables. Reproduced with permission from Bukhari et al., Computers in Biology and Medicine; published by Elsevier, 2022.</caption><thead><tr><th>Characteristics</th><th>Quantity</th></tr></thead><tbody><tr><td>Age [years]</td><td>75 (12)</td></tr><tr><td>Gender [male/female]</td><td>20 (69%)/9 (31%)</td></tr><tr><td><strong>Electrolyte concentrations</strong></td><td></td></tr><tr><td>[K<sup>+</sup>] [Pre HD] (mM)</td><td>5.05 (1.57)</td></tr><tr><td>[K<sup>+</sup>] [End HD] (mM)</td><td>3.35 (0.62)</td></tr><tr><td>[Ca<sup>2+</sup>] [Pre HD] (mM)</td><td>2.15 (0.18)</td></tr><tr><td>[Ca<sup>2+</sup>] [End HD] (mM)</td><td>2.32 (0.2)</td></tr><tr><td><strong>#Patients (%)</strong></td><td></td></tr><tr><td><strong>HD session duration</strong></td><td></td></tr><tr><td>240 min</td><td>26 (90%)</td></tr><tr><td>210 min</td><td>3 (10%)</td></tr><tr><td><strong>Dialysate composition</strong></td><td></td></tr><tr><td>Potassium (1.5 mM)</td><td>21 (73%)</td></tr><tr><td>Potassium (3 mM)</td><td>5 (17%)</td></tr><tr><td>Potassium (variable mM)</td><td>3 (10%)</td></tr><tr><td>Calcium (0.75 mM)</td><td>8 (28%)</td></tr><tr><td>Calcium (0.63 mM)</td><td>21 (72%)</td></tr></tbody></table>

### 3. Methods

A flow chart showing all the stages of the signal processing starting with 12-lead ECG pre-processing, followed by principal component analysis (PCA) transformation, computation of mean warped QRS (MWQRS) complexes and QRS morphological markers, and finishing with the estimation of [K⁺] and [Ca²⁺] is shown in Figure 2.
<figure><img src="image_6.png" /><figcaption>**Figure 2.** Flow chart showing the ECG processing steps performed in this study, from the collection of raw ECGs to the estimation of [K⁺] and [Ca²⁺].</figcaption></figure>

## 3.1. ECG Pre-Processing

A band-pass filter (0.5 to 40 Hz) was used to remove baseline wander, muscular noise and powerline interference from measured ECG signals. A wavelet-based single-lead delineation method [40] was used for QRS detection and wave delineation. Spatial principal component (PC) analysis was performed on the complete ECG of the eight independent leads [41] to enhance QRS complex energy. PCs were obtained from the eigenvectors of the 8 × 8 inter-lead auto-correlation matrix of QRS complexes extracted from a stable (in terms of HR) 10-min ECG segment at the end of the HD session to emphasize the QRS complex components. This segment corresponded to the time when the patient was discharged from hospital with restored serum [K⁺] and [Ca²⁺]. The ECG recording from each time point during and after HD was subsequently projected onto the direction of the first PC. The QRS complexes from each time point in the first PC were delineated [40] to mark their onsets, peaks and ends.

## 3.2. QRS Descriptors

### 3.2.1. Computation of Mean Warped QRS Complexes

MWQRS complexes, which are optimal representative averages in both temporal and amplitude domains, were calculated from the two-minute ECG segment at the end of each HD hour following the methodology described in [39]. The two-minute ECG segment was short enough to maintain the assumption of stability for both electrolyte and HR values [30].
Only QRS complexes in each analyzed two-minute window that presented the dominant polarity were considered for MWQRS calculation, with the polarity defined as:

$$p_0 = \begin{cases} 1, & \text{if } \max_n \{|f(n)|\} = \max_n \{f(n)\} \\ -1, & \text{if } \max_n \{|f(n)|\} = -\min_n \{f(n)\}, \end{cases} \quad (1)$$

where $f(n)$ represents the QRS complex under analysis. An average of 92% of QRS complexes in each analyzed two-minute ECG segment were found to present such dominant polarity (see Figure S1 in Supplementary Material). An initial MWQRS was computed after aligning the QRS complexes having the dominant polarity with respect to their gravity center so that the calculated MWQRS was not affected by potential outlier QRS complex polarities and morphologies [39]. Outliers, defined as those QRS complexes having a Spearman's correlation coefficient with an initial MWQRS lower than 0.98, were rejected. The final MWQRS was computed from the remaining QRS complexes.

The QRS descriptors defined in the next sections were computed from MWQRS complexes for ECG segments during and after HD ($h_0, h_1, h_2, h_3, h_4, h_4, h_{48}$).

### 3.2.2. QRS Duration and Amplitude Markers

For each MWQRS, the following descriptors were computed:

* $QRS_w$, which represented the QRS width calculated from QRS onset to end (expressed in ms) [40].

* $QRS_a$, which represented the QRS amplitude calculated from the minimum to maximum amplitude of the QRS complex (expressed in mV).

### 3.2.3. QRS Morphology Markers

Morphology-based QRS descriptors were computed using the time-warping methodology, as previously described [39]. For each patient, a reference QRS complex, $f^r(t^r)$, was calculated from the MWQRS at the end of the HD session, the time when the patient was discharged from hospital with restored serum ion levels. Representative QRS complexes for each HD stage, $f^s(t^s)$, were calculated from the MWQRS at two-minute windows at the end of each hour during the HD session and 48 h after it. $f^s(t^s)$ is expressed as $f^s(t^s) = [f^s(t^s(1)), ..., f^s(t^s(N_s))]^\top$ and the reference QRS complex as $f^r(t^r) = [f^r(t^r(1)), ..., f^r(t^r(N_r))]^\top$. The vectors $t^r = [t^r(1), ..., t^r(N_r)]^\top$ and $t^s = [t^s(1), ..., t^s(N_s)]^\top$ are the uniformly sampled time vectors corresponding to the QRS complexes $f^s$ and $f^r$, respectively. $N_r$ and $N_s$ represent the total duration, in samples, of $t^r$ and $t^s$, respectively. Figure 3a shows an example of $f^r$ and $f^s$, with their respective time domains, $t^r$ and $t^s$.

Let $\gamma(t^r)$ be the warping function that relates $t^r$ and $t^s$ such that $f^s(\gamma(t^r))$ denotes the time-domain warping of $f^s(t^s)$ using $\gamma(t^r)$. The square-root slope function (SRSF) transformation was used to find the optimal warping function [39]. This transformation was defined as:

$$\mathbf{q}_f(t) = \mathrm{sign}(\dot{\mathbf{f}}(t)) |\dot{\mathbf{f}}(t)|^{\frac{1}{2}}. \quad (2)$$

The optimal warping function was determined as the one minimizing the amplitude difference between the SRSF of $f^r(t^r)$ and $f^s(\gamma(t^r))$:

$$\gamma^*(t^r) = \arg\min_{\gamma(t^r)} \left( \left\| \mathbf{q}_{f^r}(t^r) - \mathbf{q}_{f^s}(\gamma(t^r)) \right\| \sqrt{\dot{\gamma}(t^r)} \right). \quad (3)$$

A dynamic programming algorithm was used to obtain the function $\gamma^*(t^r)$ that optimally warped $f^r(t^r)$ into $f^s(t^s)$. This function is shown in Figure 3d. The warped QRS complex, $f^s(\gamma^*(t^r))$, is shown in Figure 3b, together with the reference QRS complex, $f^r(t^r)$.
The descriptor, $d_{w,Q}^u$, was used to quantify the level of warping required to optimally align the QRS complexes $f^s(\mathbf{t}^s)$ and $f^r(\mathbf{t}^r)$:

$$d_{w,Q}^u = \frac{1}{N_r} \sum_{n=1}^{N_r} |\gamma^*(t^r(n)) - t^r(n)|. \qquad (4)$$

The amplitude descriptor, $d_{a,Q}$, was computed from the area contained between $f^r(\mathbf{t}^r)$ and $f^s(\gamma^*(\mathbf{t}^r))$ normalized by the L2-norm of $f^r(\mathbf{t}^r)$, thus quantifying amplitude differences after time warping the two QRS complexes:

$$d_{a,Q} = p_0 \frac{\left\| \frac{f^s(\gamma^*(\mathbf{t}^r)) - f^r(\mathbf{t}^r)}{\|f^r(\mathbf{t}^r)\|} \right\|}{100}, \qquad (5)$$

where $s_a = \sum_{n=1}^{N_r} (f^s(\gamma^*(t^r(n))) - f^r(t^r(n)))$ was used to account for the sign.

The above described marker $d_{w,Q}^u$ accounted for both linear and nonlinear warping required to fit the two QRS complexes in the time domain. The nonlinear component marker $d_{w,Q}^{NL}$ was quantified as:

$$d_{w,Q}^{NL} = \frac{1}{N_r} \sum_{n=1}^{N_r} |\gamma^*(t^r(n)) - \gamma_l^*(t^r(n))|, \qquad (6)$$

where $\gamma_l^*(t^r)$ (green line in Figure 3d) was derived by linearly fitting $\gamma^*(t^r)$ using the least absolute residual method.

The nonlinear amplitude marker $d_{a,Q}^{NL}$ was defined by computing the $L_2$ norm of the difference between $L_2$-normalized versions of $f^r(\mathbf{t}^r)$ and $f^s(\gamma^*(\mathbf{t}^r))$:

$$d_{a,Q}^{NL} = \left\| \frac{f^r(\mathbf{t}^r)}{\|f^r(\mathbf{t}^r)\|} - \frac{f^s(\gamma^*(\mathbf{t}^r))}{\|f^s(\gamma^*(\mathbf{t}^r))\|} \right\| \times 100. \qquad (7)$$

Figure 3a shows $f^r$ and $f^s$, referring to their respective time domains, $t^r$ and $t^s$. The warped QRS complex (red), $f^s(\gamma^*(\mathbf{t}^r))$, is shown in Figure 3b, together with the reference QRS complex (blue), $f^r(\mathbf{t}^r)$.

The analyzed warping-based QRS descriptors, computed from MWQRS during and after HD stages, $h_i$, included:

* $d_{w,Q}^u$, which represented temporal variations in QRS morphology (expressed in ms),

* $d_{a,Q}$, which represented amplitude variations in QRS morphology (expressed as a percentage),

* $d_{w,Q}^{NL}$, which represented nonlinear temporal variations in QRS morphology (expressed in ms),

* $d_{a,Q}^{NL}$, which represented nonlinear amplitude variations in QRS morphology (expressed as a percentage).

### 3.3. Statistical Analysis

Pearson correlation coefficients ($r$) were computed to assess the strength of the linear relationship between $[K^+], [Ca^{2+}]$ or RR and each of the investigated QRS descriptors in each patient individually.

A Wilcoxon signed-rank test was applied to test for significant differences ($p < 0.05$) in $[K^+], [Ca^{2+}], RR, QRS_w, QRS_a, d_{w,Q}^u, d_{a,Q}, d_{w,Q}^{NL}$ and $d_{a,Q}^{NL}$ between consecutive HD stages. The reason for using a non-parametric statistical test was that, according to the Shapiro-Wilk test, the data distributions were not normal.

To test whether the Pearson correlation coefficient between each QRS marker and $[K^+], [Ca^{2+}]$ or RR was significantly different from 0, a Student's t-test was used after transforming the statistical distribution of $r$ into a normal distribution using Fisher's z transform [42].
<figure><img src="image_7.png" /><figcaption>**Figure 3.** Time warping of QRS complexes. Panel (a) shows the reference (blue) and investigated (red) QRS complexes obtained from an ECG segment during HD. Panel (b) shows the warped QRS complexes, which had the same duration whilst keeping the original amplitude. Panel (c) depicts the warped QRS complexes after normalization by their L2-norms. The yellow area in panel (d) represents $d_{w,Q}^u$, which quantified the total amount of warping. The green solid line is the linear regression function $\gamma_i^*(t^r)$ best fitted to $\gamma^*(t^r)$.</figcaption></figure>

All statistical analyses were performed using MATLAB version R2020b for Windows (MathWorks Inc., Novi, MI, USA).

### 3.4. Uni- and Multivariable Estimation of [K⁺] and [Ca²⁺]

To estimate [K⁺] and [Ca²⁺], univariable and multivariable estimators were developed. Of all the analyzed QRS descriptors, $d_{w,Q}^u$ was selected to build univariable estimators because it presented high median absolute Pearson correlation with [K⁺] and [Ca²⁺] and a relatively low IQR range, particularly for [K⁺]. Univariable estimators were additionally built using the repolarization descriptor $d_{w,T}^u$, which had shown strong correlation with electrolyte levels [29,30]. $d_{w,T}^u$ was calculated analogously to $d_{w,Q}^u$ but for the T wave instead of the QRS complex. Multivariable estimators were tested using both $d_{w,Q}^u$ and $d_{w,T}^u$.

The univariable $[\hat{K}^+]_u$ ($[\hat{Ca}^{2+}]_u$, respectively) and multivariable $[\hat{K}^+]_m$ ($[\hat{Ca}^{2+}]_m$, respectively) estimators were of the following form:

$$I_{d_{w,Q}^u} = \beta_0^{d_{w,Q}^u} + \beta_1^{d_{w,Q}^u} \cdot d_{w,Q}^u, \qquad (8)$$

$$I_{d_{w,T}^u} = \beta_0^{d_{w,T}^u} + \beta_1^{d_{w,T}^u} \cdot d_{w,T}^u, \qquad (9)$$

and

$$I_m = \beta_0^m + \beta_1^m \cdot d_{w,Q}^u + \beta_2^m \cdot d_{w,T}^u, \qquad (10)$$

where $I \in \{[\hat{K}^+] , [\hat{Ca}^{2+}] \}$. The performance of the estimators was tested by using the leave-one-out cross-validation approach.
For the univariable estimators, the coefficient vector $\beta = [\beta_0^{u_{w,Q}} \ \beta_1^{u_{w,Q}}]^T$ or $\beta = [\beta_0^{u_{w,T}} \ \beta_1^{u_{w,T}}]^T$ was estimated as [43,44]:

$$ \hat{\beta} = (\mathbf{X}^T\mathbf{X})^{-1}\mathbf{X}^T\mathbf{y}^T, \qquad (11) $$

with $\mathbf{X} = [\mathbf{j}^T \ \mathbf{x}_b^T]$. Three different types of estimators were considered, namely stage-specific, patient-specific and global estimators, as described in the following paragraphs. The definition of $\mathbf{j}^T$, $\mathbf{x}_b^T$ and $\mathbf{y}$ was different for each type of estimator:

* For an HD stage-specific (S) estimator, which estimates the electrolyte level at stage $h_i$ of a given patient $q$ from the marker's values of the remaining patients at that stage, the vector $\hat{\beta}$ was calculated from the vector $\mathbf{j} = [1 \ 1 \ \dots \ 1]$ of dimension $1 \times Q$, with $Q$ being the total number of patients minus 1, the vector $\mathbf{x}_b = [b_{i,1} \ b_{i,2} \ \dots \ b_{i,Q}]$ containing the values of the marker $b = d_{w,Q}^u$ or $d_{w,T}^u$ at stage $i$ from patients 1, ..., $Q$ (all except for patient $q$) and the vector $\mathbf{y} = [[\mathbf{K}^+]_{i,1} \ \mathbf{K}^+]_{i,2} \ \dots \ \mathbf{K}^+]_{i,Q}]$ containing the measured $[\mathbf{K}^+]$ values at stage $i$. The vector $\mathbf{y}$ was defined analogously for $[\mathbf{Ca}^{2+}]$. This procedure was carried out for each HD stage, $h_i$, separately.

* For a patient-specific (P) estimator, which estimates the electrolyte level at stage $h_i$ of a given patient $q$ from the marker's values at the remaining stages for that same patient, the vector $\hat{\beta}$ was calculated from the vector $\mathbf{j} = [1 \ 1 \ \dots \ 1 \ 1]$ of dimension $1 \times 6$ (if $h_i$ is $h_0$ or $h_{48}$) or $1 \times 7$ (if $h_i$ was different from $h_0$ or $h_{48}$), $\mathbf{x}_b = [b_{0,q} \ b_{0,q} \ b_{1,q} \ \dots \ b_{4,q} \ b_{4,q} \ b_{4,q}]$ containing the values of the marker $b = d_{w,Q}^u$ or $d_{w,T}^u$ for patient $q$ at the different time points except for $h_i$, with $h_0$ and $h_{48}$ being duplicated. The vector $\mathbf{y}$ was defined as $\mathbf{y} = [[\mathbf{K}^+]_{0,q} \ [\mathbf{K}^+]_{0,q} \ [\mathbf{K}^+]_{1,q} \ \dots \ [\mathbf{K}^+]_{4,q} \ [\mathbf{K}^+]_{4,q} \ [\mathbf{K}^+]_{4,q}]$ containing the measured $[\mathbf{K}^+]$ values for patient $q$ at all time points except for $h_i$. An analogous definition of vector $\mathbf{y}$ was applied for $[\mathbf{Ca}^{2+}]$. This process was repeated for each patient individually.

* For a global (G) estimator, which estimates the electrolyte level at stage $h_i$ of a given patient $q$ from the marker values at all other time points from all other patients, the vector $\hat{\beta}$ was calculated by defining vectors $\mathbf{x}_b$ and $\mathbf{y}$ to contain the marker values and the electrolyte measures from all patients at all stages except for patient $q$ at time $i$.

For the multivariable estimators, $\beta = [\beta_0^m \ \beta_1^m \ \beta_2^m]^T$ was estimated using Equation (11), where the matrix $\mathbf{X} = [\mathbf{j}^T \ \mathbf{x}_{b(1)}^T \ \mathbf{x}_{b(2)}^T]$, with $b^{(1)} = d_{w,Q}^u$ and $b^{(2)} = d_{w,T}^u$, was calculated as described for the univariable estimators depending on the type of estimator (stage-specific, patient-specific or global).

The error, $e$, between actual $[\mathbf{K}^+]$ (or $[\mathbf{Ca}^{2+}]$) and estimated $[\hat{\mathbf{K}}^+]$ (or $[\hat{\mathbf{Ca}}^{2+}]$) was computed as

$$ e = [\mathbf{K}^+] - [\hat{\mathbf{K}}^+]. \qquad (12) $$

The relative error, $e_r$, with respect to the range of electrolyte measurements was computed as

$$ e_r = \frac{[\mathbf{K}^+] - [\hat{\mathbf{K}}^+]}{[\mathbf{K}^+]_{\mathcal{R}}}. \qquad (13) $$

where $[\mathbf{K}^+]_{\mathcal{R}}$ was defined as the difference between the 75th and 25th percentiles of $[\mathbf{K}^+]$ across patients at each HD stage. An analogous definition for $[\mathbf{Ca}^{2+}]$ was used.

The relative error, $e_v$, with respect to the actual electrolyte measurement $[\mathbf{K}^+]$ for each patient at each HD stage (analogously for $[\mathbf{Ca}^{2+}]$) was computed as

$$ e_v = \frac{[\mathbf{K}^+] - [\hat{\mathbf{K}}^+]}{[\mathbf{K}^+]}. \qquad (14) $$
The mean absolute error was computed by averaging the absolute value of *e* defined in Equation (12). The root mean square error was computed by taking the root mean square of *e* defined in Equation (12).

To assess the agreement between actual and estimated [K⁺] and [Ca²⁺] values, Bland-Altman analysis was performed [45], in which the differences between the actual and estimated [K⁺] and [Ca²⁺] were plotted as a function of their averages, for all patients at all HD time points (see Supplementary Material). [K⁺] and [Ca²⁺] estimation accuracy using our investigated markers was also compared with those of the previously proposed markers T<sub>S/A</sub> [10,11] and T<sub>S/√A</sub> [12] (see Supplementary Material):

* T<sub>S/A</sub> represented the ratio between the maximal downward slope (in absolute value) and the amplitude of the T wave [10,11].

* T<sub>S/√A</sub> represented the ratio between the maximal downward slope (in absolute value) and the square root of the amplitude of the T wave [12].

It should be noted that estimations of [K⁺] and [Ca²⁺] could not be performed at the end of the HD session (*h*₄) since the morphological QRS complex markers were zero by definition due to the fact that the reference was taken at that time stage. Therefore, we defined an extra time point *h*₄⁻ just before the HD end (reference) so as to improve the estimation accuracy based on one additional HD point.

# 4. Results

## 4.1. Characterization of QRS Complex Changes during and after HD

The top panels in Figure 4 show the results for the QRS markers (QRS<sub>w</sub>, QRS<sub>a</sub>, d<sup>u</sup><sub>w,Q</sub>, d<sub>a,Q</sub>, d<sup>NL</sup><sub>w,Q</sub> and d<sup>NL</sup><sub>a,Q</sub>) together with [K⁺], [Ca²⁺] and RR variations during and after HD for all patients. Statistically significant differences between consecutive HD stages were found for QRS<sub>a</sub>, d<sup>u</sup><sub>w,Q</sub>, d<sub>a,Q</sub>, d<sup>NL</sup><sub>w,Q</sub> and d<sup>NL</sup><sub>a,Q</sub> as well as for [K⁺] and [Ca²⁺] variations, but not for RR.

<figure><img src="image_8.png" /></figure>

**Figure 4.** Panels (a–f): changes in QRS<sub>w</sub>, QRS<sub>a</sub>, d<sup>u</sup><sub>w,Q</sub>, d<sub>a,Q</sub>, d<sup>NL</sup><sub>w,Q</sub> and d<sup>NL</sup><sub>a,Q</sub> during HD stages. Panels (g–i): corresponding variations in [K⁺], [Ca²⁺] and RR. In panels (a–i), * denotes *p* < 0.05 and ** denotes *p* < 0.01. In each panel, the central white dot indicates the median. Each dot corresponds to an individual patient. Panel (j): MWQRS (red) of a patient at different HD stages and reference MWQRS (blue). Δ denotes the change in [K⁺] with respect to the end of HD (*h*₄).
The bottom panels of Figure 4 show MWQRS during and after HD (red) compared to the reference MWQRS (blue) computed at the end of HD. Lower QRS<sub>a</sub> values could be observed at *h*<sub>0</sub> and *h*<sub>48</sub>, corresponding to the highest [K<sup>+</sup>] and the lowest [Ca<sup>2+</sup>].

## 4.2. Contribution of [K<sup>+</sup>], [Ca<sup>2+</sup>] and HR Variations to QRS Complex Changes

Figure 5 shows the Pearson correlation coefficient, *r*, between the analyzed QRS markers and [K<sup>+</sup>] (black), [Ca<sup>2+</sup>] (red) and RR (blue). QRS<sub>a</sub>, $d_{w,Q}^u$, $d_{a,Q}$, $d_{w,Q}^{NL}$ and $d_{a,Q}^{NL}$ were the most highly correlated, in median, with [K<sup>+</sup>] (median *r* being -0.87, 0.78, -0.80, 0.73 and 0.81, respectively) and [Ca<sup>2+</sup>] (0.76, -0.61, 0.63, -0.70 and -0.75, respectively). The IQR of *r* was the lowest for $d_{w,Q}^u$ when the correlation with [K<sup>+</sup>] was analyzed, and for QRS<sub>a</sub> in the case of [Ca<sup>2+</sup>]. Poor association between all the analyzed markers and RR was found.

<figure><img src="image_9.png" /><figcaption>**Figure 5.** Pearson correlation coefficients between QRS markers (QRS<sub>w</sub>, QRS<sub>a</sub>, $d_{w,Q}^u$, $d_{a,Q}$, $d_{w,Q}^{NL}$ and $d_{a,Q}^{NL}$) and [K<sup>+</sup>] (black), [Ca<sup>2+</sup>] (red) and RR (blue) for all patients at all HD points. The central white dot indicates the median. Each dot corresponds to an individual patient.</figcaption></figure>

Table 2 shows the *p*-values from the Student's *t*-test used to determine the statistical significance of non-zero mean Fisher z-transformed Pearson correlation coefficients between QRS markers and each of [K<sup>+</sup>], [Ca<sup>2+</sup>] and RR in the patient population, during and after HD. All the analyzed QRS markers showed significant association with [K<sup>+</sup>] and most of them (all but QRS<sub>w</sub>) with [Ca<sup>2+</sup>]. On the other hand, no marker presented significant association with RR.

<table><caption>**Table 2.** *p*-values from the parametric test (*t*-test) to evaluate statistical significance of non-zero mean Fisher z-transformed Pearson correlation coefficients between QRS markers and [K<sup>+</sup>], [Ca<sup>2+</sup>] and RR.</caption><thead><tr><th><i>p</i>-Values</th><th>QRS<sub>w</sub></th><th>QRS<sub>a</sub></th><th><i>d</i><sup><i>u</i></sup><sub>w,Q</sub></th><th><i>d</i><sub>a,Q</sub></th><th><i>d</i><sup>NL</sup><sub>w,Q</sub></th><th><i>d</i><sup>NL</sup><sub>a,Q</sub></th></tr></thead><tbody><tr><td>[K<sup>+</sup>]</td><td>0.01</td><td>&lt;0.01</td><td>&lt;0.01</td><td>&lt;0.01</td><td>&lt;0.01</td><td>&lt;0.01</td></tr><tr><td>[Ca<sup>2+</sup>]</td><td>0.09</td><td>&lt;0.01</td><td>&lt;0.01</td><td>0.02</td><td>&lt;0.01</td><td>&lt;0.01</td></tr><tr><td>RR</td><td>0.37</td><td>0.94</td><td>0.48</td><td>0.12</td><td>0.23</td><td>0.60</td></tr></tbody></table>

## 4.3. *Uni- and Multivariable Estimation of [K<sup>+</sup>] and [Ca<sup>2+</sup>]*

Figure 6 shows an illustrative example of the comparison between measured and estimated [K<sup>+</sup>] and [Ca<sup>2+</sup>] using stage-specific (S), patient-specific (P) and global (G) approaches during (*h*<sub>0</sub>, *h*<sub>1</sub>, *h*<sub>2</sub>, *h*<sub>3</sub>, *h*<sub>4</sub>) and after (*h*<sub>48</sub>) HD for a particular patient, for both univariable (panels a–b) and multivariable (panel c) estimators. The patient-specific approach provided better results in terms of reduced errors, particularly using multivariable estimation (mean *e*<sub>v</sub> over HD points being 0.071 (S), -0.008 (P), 0.001 (G) for [K<sup>+</sup>] and 0.019 (S), 0.001 (P), 0.031 (G) for [Ca<sup>2+</sup>]).
<figure><img src="image_10.png" /><figcaption>**Figure 6.** Actual (black) and estimated [K⁺] and [Ca²⁺] for a patient using stage-specific (red), patient-specific (green) and global (blue) approaches. Univariable $d_{w,Q}^u$-based estimation is shown in (panel a), $d_{w,T}^u$-based in (panel b) and multivariable $d_{w,Q}^u-d_{w,T}^u$-based in (panel c).</figcaption></figure>

Figure 7 shows the relative errors, $e_v$, for all patients and HD stages in the estimation of [K⁺] and [Ca²⁺] using stage-specific (top panel), patient-specific (middle panel) and global (bottom panel) approaches. Figure S2 in the Supplementary Material shows the relative errors, $e_r$.

Table 3 shows actual and estimated [K⁺] and [Ca²⁺] values over the study population at each HD stage. Multivariable estimation results using stage-specific, patient-specific and global approaches are presented.

<figure><img src="image_11.png" /><figcaption>**Figure 7.** Box plots of [K⁺] and [Ca²⁺] estimation errors $e_v$ during HD stages for all patients using $d_{w,Q}^u$(black), $d_{w,T}^u$(red) and the combination of $d_{w,Q}^u$ and $d_{w,T}^u$ (blue) for stage-specific (top), patient-specific (middle) and global (bottom) approaches. The central line indicates the median, whereas top and bottom edges show the 25th and 75th percentiles.</figcaption></figure>
<table><caption>**Table 3.** Actual and estimated [K⁺] and [Ca²⁺] values over the study population at each HD stage using multivariable (m) estimation and stage-specific (S), patient-specific (P) and global (G) approaches. Values are expressed as median (IQR) and the units are mM.</caption><thead><tr><th>Actual vs. Estimated [K<sup>+</sup>]</th><th>h<sub>0</sub></th><th>h<sub>1</sub></th><th>h<sub>2</sub></th><th>h<sub>3</sub></th><th>h<sub>4</sub><sup>-</sup></th><th>h<sub>48</sub></th></tr></thead><tbody><tr><td>[K<sup>+</sup>]</td><td>5.10 (1.30)</td><td>3.90 (0.86)</td><td>3.64 (0.81)</td><td>3.40 (0.71)</td><td>3.40 (0.56)</td><td>5.08 (1.53)</td></tr><tr><td>[K&#x0302;<sup>+</sup>]<sup>S</sup><sub>m</sub></td><td>5.31 (0.43)</td><td>4.03 (0.18)</td><td>3.70 (0.08)</td><td>3.49 (0.09)</td><td>3.43 (0.05)</td><td>4.56 (1.21)</td></tr><tr><td>[K&#x0302;<sup>+</sup>]<sup>P</sup><sub>m</sub></td><td>4.76 (1.90)</td><td>4.01 (1.33)</td><td>3.84 (1.16)</td><td>3.46 (0.97)</td><td>3.28 (0.44)</td><td>4.43 (1.46)</td></tr><tr><td>[K&#x0302;<sup>+</sup>]<sup>G</sup><sub>m</sub></td><td>4.50 (0.71)</td><td>4.33 (0.40)</td><td>4.07 (0.33)</td><td>3.97 (0.26)</td><td>3.84 (0.19)</td><td>4.57 (0.75)</td></tr><tr><td>[Ca<sup>2+</sup>]</td><td>2.15 (0.20)</td><td>2.23 (0.20)</td><td>2.29 (0.19)</td><td>2.31 (0.23)</td><td>2.36 (0.21)</td><td>2.17 (0.20)</td></tr><tr><td>[Ca&#x0302;<sup>2+</sup>]<sup>S</sup><sub>m</sub></td><td>2.13 (0.02)</td><td>2.21 (0.05)</td><td>2.25 (0.02)</td><td>2.31 (0.05)</td><td>2.28 (0.03)</td><td>2.07 (0.13)</td></tr><tr><td>[Ca&#x0302;<sup>2+</sup>]<sup>P</sup><sub>m</sub></td><td>2.06 (0.29)</td><td>2.27 (0.23)</td><td>2.21 (0.26)</td><td>2.29 (0.20)</td><td>2.25 (0.23)</td><td>2.18 (0.20)</td></tr><tr><td>[Ca&#x0302;<sup>2+</sup>]<sup>G</sup><sub>m</sub></td><td>2.19 (0.04)</td><td>2.20 (0.02)</td><td>2.22 (0.02)</td><td>2.23 (0.01)</td><td>2.23 (0.01)</td><td>2.19 (0.04)</td></tr></tbody></table>

Tables 4 and 5 show the median and IQR values of intra-patient Pearson correlation coefficients between actual and estimated [K⁺] ([Ca²⁺], respectively) using univariable and multivariable estimators.

<table><caption>**Table 4.** Intra-patient Pearson correlation coefficient *r* between actual and estimated [K⁺] using univariable and multivariable estimators, with stage-specific (S), patient-specific (P) and global (G) approaches. Values are expressed as median (IQR).</caption><thead><tr><th>r<sub>[K<sup>+</sup>], [K&#x0302;<sup>+</sup>]</sub></th><th>d<sup>u</sup><sub>w,Q</sub></th><th>d<sup>u</sup><sub>w,T</sub></th><th>d<sup>u</sup><sub>w,Q</sub>, d<sup>u</sup><sub>w,T</sub></th></tr></thead><tbody><tr><td>S</td><td>0.98 (0.08)</td><td>0.96 (0.06)</td><td>0.93 (0.30)</td></tr><tr><td>P</td><td>0.56 (0.75)</td><td>0.55 (0.90)</td><td>0.75 (0.51)</td></tr><tr><td>G</td><td>0.75 (0.15)</td><td>0.82 (0.35)</td><td>0.86 (0.32)</td></tr></tbody></table>

<table><caption>**Table 5.** Intra-patient Pearson correlation coefficient *r* between actual and estimated [Ca²⁺] using univariable and multivariable estimators, with stage-specific (S), patient-specific (P) and global (G) approaches. Values are expressed as median (IQR).</caption><thead><tr><th>r<sub>[Ca<sup>2+</sup>], [Ca&#x0302;<sup>2+</sup>]</sub></th><th>d<sup>u</sup><sub>w,Q</sub></th><th>d<sup>u</sup><sub>w,T</sub></th><th>d<sup>u</sup><sub>w,Q</sub>, d<sup>u</sup><sub>w,T</sub></th></tr></thead><tbody><tr><td>S</td><td>0.88 (0.38)</td><td>0.88 (0.22)</td><td>0.80 (0.78)</td></tr><tr><td>P</td><td>0.88 (0.22)</td><td>0.63 (0.59)</td><td>0.63 (0.37)</td></tr><tr><td>G</td><td>0.64 (0.73)</td><td>0.64 (0.49)</td><td>0.70 (0.55)</td></tr></tbody></table>

Bland–Altman plots between actual and estimated [K⁺] and [Ca²⁺] for the proposed markers are shown in Supplementary Material (Figures S3–S12).

Tables 6 and 7 show a comparison between estimation errors obtained for the markers analyzed in this study and in previous studies. Tables S6–S9 in the Supplementary Material show mean absolute and root mean square errors for the analyzed markers.

<table><caption>**Table 6.** Estimation errors (*e*) using stage-specific (S), patient-specific (P) and global (G) approach-based [K⁺] estimators, from all patients at all HD time points. Values are expressed as mean ± standard deviation and the units are mM.</caption><thead><tr><th>e</th><th>S</th><th>P</th><th>G</th></tr></thead><tbody><tr><td>d<sup>u</sup><sub>w,Q</sub></td><td>-0.041 ± 0.831</td><td>-0.091 ± 1.419</td><td>-0.204 ± 0.971</td></tr><tr><td>d<sup>u</sup><sub>w,T</sub></td><td>0.004 ± 0.806</td><td>-0.147 ± 0.809</td><td>-0.169 ± 0.959</td></tr><tr><td>T<sub>S/A</sub></td><td>0.005 ± 0.792</td><td>-0.157 ± 1.120</td><td>-0.213 ± 0.996</td></tr><tr><td>T<sub>S/√A</sub></td><td>0.003 ± 0.811</td><td>-0.149 ± 1.422</td><td>-0.238 ± 1.048</td></tr><tr><td>d<sup>u</sup><sub>w,Q</sub> and d<sup>u</sup><sub>w,T</sub></td><td>0.073 ± 0.808</td><td>-0.035 ± 1.113</td><td>-0.144 ± 0.883</td></tr></tbody></table>
<table><caption>**Table 7.** Estimation errors (e) using stage-specific (S), patient-specific (P) and global (G) approach-based [Ca²⁺] estimators, from all patients at all HD time points. Values are expressed as mean ± standard deviation and the units are mM.</caption><thead><tr><th>e</th><th>S</th><th>P</th><th>G</th></tr></thead><tbody><tr><td>d<sup>u</sup><sub>w,Q</sub></td><td>0.117 ± 0.134</td><td>-0.007 ± 0.300</td><td>0.018 ± 0.175</td></tr><tr><td>d<sup>u</sup><sub>w,T</sub></td><td>0.0003 ± 0.170</td><td>0.024 ± 0.178</td><td>0.018 ± 0.172</td></tr><tr><td>T<sub>S/A</sub></td><td>-0.002 ± 0.179</td><td>0.025 ± 0.191</td><td>0.023 ± 0.180</td></tr><tr><td>T<sub>S/√A</sub></td><td>-0.002 ± 0.183</td><td>0.027 ± 0.201</td><td>0.020 ± 0.183</td></tr><tr><td>d<sup>u</sup><sub>w,Q</sub> and d<sup>u</sup><sub>w,T</sub></td><td>0.023 ± 0.180</td><td>0.010 ± 0.125</td><td>0.016 ± 0.174</td></tr></tbody></table>

## 5. Discussion

We investigated changes in QRS duration, amplitude and morphology at varying [K⁺], [Ca²⁺] and HR in ESRD patients. We designed [K⁺] and [Ca²⁺] estimators based on our proposed QRS morphological characteristics, taken both individually and in combination with T wave morphology markers. We showed the accuracy of our proposed estimators using three different approaches, stage-specific, patient-specific and global estimation, which outperformed previously proposed methods. Our results offered new non-invasive tools to monitor serum [K⁺] and [Ca²⁺], which could have a significant role in clinical practice and could contribute to reduce the mortality risk associated with abnormal electrolyte levels in ESRD patients.

### 5.1. Characterization of QRS Complex Amplitude, Duration and Morphology in ESRD Patients during and after HD

In ECG recordings of ESRD patients, we evaluated QRS duration and amplitude, measured by markers QRS<sub>w</sub> and QRS<sub>a</sub>, and QRS morphological characteristics, measured by markers d<sup>u</sup><sub>w,Q</sub>, d<sub>a,Q</sub>, d<sup>NL</sup><sub>w,Q</sub> and d<sup>NL</sup><sub>a,Q</sub>, which was proposed here for the first time. All markers except for QRS<sub>w</sub> presented significant changes during and after HD. These changes were strongly associated with variations in [K⁺] and [Ca²⁺] but not in HR. The inconsistent relationship between QRS markers, such as QRS<sub>w</sub>, and HR has been investigated in previous works, including the study by Hnatkova et al. [46], who reported increases in QRS duration with increasing HR in 35% of their patients and decreases in QRS duration in the remaining 65%. In line with these results, we found that QRS became markedly wider at higher RR intervals for 34% of the patients; it became markedly narrower for 21% of the patients; its width moderately changed with RR for 21% of the patients; and it showed poor association with RR for the remaining 24% of the patients (see Table S2 in Supplementary Material). This led to a median *r* value of 0.42 between QRS<sub>w</sub> and RR over the 29 ESRD patients, reflecting a notably weaker relationship between QRS<sub>w</sub> and RR as compared to other depolarization markers. Regarding QRS amplitude, even if we found QRS<sub>a</sub> to remarkably change during HD, this marker depended on ECG amplitudes at specific time points, which, in noisy ambulatory recordings, could lead to large changes not associated with variations in electrolyte levels. On the other hand, changes in warping-based markers accounted for deviations in the whole QRS waveform and could thus be better suited for ambulatory monitoring. In particular, if QRS duration on top of amplitude changes occurred in the inter-dialytic interval, as, e.g., reported during advanced ischemia [47,48], these changes could be reflected in our proposed QRS warping markers.

On top of investigating the relationship between QRS markers and [K⁺] or [Ca²⁺], we also investigated the relationship between these markers and sodium concentration ([Na⁺]). [Na⁺] variations were less remarkable than those of [K⁺] and [Ca²⁺] during HD in our patients (see Table S3 in Supplementary Material). Importantly, none of the markers were strongly associated with [Na⁺] (see Figure S13 and Table S4 in Supplementary Material). [Na⁺] could have been expected to play a more important role in modulating depolarization markers because the fast sodium current was primarily responsible for phase 0 of the action potential and its changes might have manifested in QRS complex alterations. However,
we found that the QRS complex became markedly wider at higher [Na⁺] for 43% of the patients; it became markedly narrower for 7% of the patients; its width moderately changed with [Na⁺] for 14% of the patients; and it showed poor association with [Na⁺] for the remaining 36% of the patients (see Table S5 in Supplementary Material).

High inter-individual variability was found in the relationship between the analyzed QRS markers and [K⁺] or [Ca²⁺]. This was especially remarkable in the case of *d*<sub>a,Q</sub>, which presented high IQR in the intra-patient correlation coefficients with [K⁺] and [Ca²⁺]. Such high dispersion could be explained by QRS polarity effects, as a reduction (increase, respectively) in the absolute amplitude could be reflected as either positive or negative *d*<sub>a,Q</sub>, depending on QRS being predominantly positive or negative.

Changes in ECG characteristics induced by variations in [K⁺] and [Ca²⁺] have been extensively investigated in terms of ventricular repolarization. A number of studies have characterized changes in T wave width, amplitude, slope or slope-to-amplitude ratio [10,11,13,49,50]. We have recently quantified changes in T wave nonlinear dynamics and morphology and have shown their relationship with [K⁺] and [Ca²⁺] variations [28,29,31,33,51].

The analysis of electrolyte-induced alterations in ventricular depolarization remains, however, much more limited. In a study including 923 patients with severe hyperkalemia, sine wave-shaped QRS complexes were observed in almost 36.7% of patients [38]. In the present study, we could observe such behavior in most of the patients (Figure 4). Inconsistent results have been reported in relation to the effects of [K⁺] on QRS duration, with a larger proportion of studies reporting QRS widening [1,34,52–56] and others reporting QRS narrowing [2,35] with increased [K⁺]. Here, we observed no significant changes in QRS width during and after HD. Regarding QRS amplitude, we found QRS<sub>a</sub> to be strongly negatively correlated with [K⁺] and positively correlated with [Ca²⁺], in accordance with the increase in QRS<sub>a</sub> with decreasing [K⁺], as described by Astan et al. [35]. We observed similar results for the QRS morphology-based amplitude marker *d*<sub>a,Q</sub>. Our study characterized additional QRS morphological changes by the warping markers *d*<sub>w,Q</sub><sup>u</sup>, *d*<sub>w,Q</sub><sup>NL</sup> and *d*<sub>a,Q</sub><sup>NL</sup> further extended these results to provide a robust characterization of QRS changes during and after HD in ESRD patients. Figure 8 illustrates QRS complexes and T waves at the start and end of HD.

<figure><img src="image_12.png" /><figcaption>**Figure 8.** QRS and T wave variations at the start (red) and end (blue) of the HD session. Panels (a,b) show the waveforms related to the QRS complex and the T wave, respectively.</figcaption></figure>

## 5.2. Multivariable Predictors of [K⁺] and [Ca²⁺] Based on Depolarization and Repolarization Characteristics

Based on the novel QRS morphology markers of this study and on already proposed T wave markers [29,30,39], we designed linear univariable and multivariable [K⁺] and [Ca²⁺] estimators. In particular, we used *d*<sub>w,Q</sub><sup>u</sup> (QRS marker) and *d*<sub>w,T</sub><sup>u</sup> (T wave marker),
as these were strongly correlated with [K⁺] and [Ca²⁺] and poorly related to each other (see Table S1 of the Supplementary Material), thus potentially providing complementary information to monitor electrolyte variations.

For each of the constructed [K⁺] and [Ca²⁺] linear estimators, we used stage-specific, patient-specific and global estimation approaches. Overall, the stage-specific approach rendered results with both mean and median estimation errors very close to zero but with higher dispersion than in the patient-specific approach. The latter approach would be suitable for clinical application, as electrolyte levels could be predicted in each patient based on a short ECG recording of the same patient.

Multivariable estimators combining information from $d_{w,Q}^u$ and $d_{w,T}^u$ outperformed univariable estimators (the ones proposed by us and other authors [10–12]). The estimation errors for the multivariable estimators were lower (Figure 7, Figures S3–S12 in Supplementary Material, Tables 6 and 7) and the correlation coefficients *r* between actual and estimated electrolyte levels were higher than for univariable estimators, both for the patient-specific and global estimation approaches (see Tables 4 and 5). In particular, for the patient-specific approach, median, *r*, in [K⁺] estimation was 0.75 for the combination of $d_{w,Q}^u$ and $d_{w,T}^u$, while it was 0.56 for $d_{w,Q}^u$ and 0.55 for $d_{w,T}^u$. Similarly, for the global approach, median, *r*, in [Ca²⁺] estimation was 0.70 for the combination compared to 0.64 for $d_{w,Q}^u$ and 0.64 for $d_{w,T}^u$. It should be noted that these correlation coefficient values were computed between actual [K⁺] and estimated [K⁺] while the correlation between each of the tested markers and [K⁺] was higher, both for the QRS marker $d_{w,Q}^u$ proposed here and for the T wave marker $d_{w,T}^u$ analyzed in our previous studies [29,30].

These results supported the use of our proposed QRS markers to improve prediction of [K⁺] and [Ca²⁺] by ECG repolarization markers. ECG depolarization-based estimators have been scarcely investigated in the literature for serum electrolyte monitoring. In [57], an ECG-based [K⁺] estimator was designed using QRS duration in addition to T wave markers, but QRS duration was found not to be highly correlated with [K⁺], in agreement with our present results for QRS<sub>w</sub>. Pilia et al. [14] reviewed studies evaluating QRS amplitude and width features, but no improved serum electrolyte prediction by incorporating these features into repolarization-based estimators was provided. Here, we proposed univariable and multivariable [K⁺] and [Ca²⁺] estimators that included information from the whole morphology of the QRS complex. By accounting for characteristics beyond QRS amplitude and width, these estimators could offer more robust performance for ambulatory monitoring of ESRD patients and overcome some limitations of previously proposed markers, such as their dependence on blood volume [36,37].

For all the estimators we built, we found that the values of [K⁺] and [Ca²⁺] at the beginning of each of the two HD sessions, i.e., time points *h*₀ and *h*₄₈, were the more challenging to estimate, as could be observed from the largest estimation errors at those time points (Figure 4). Here, we duplicated the values of the ECG markers at *h*₀ and *h*₄₈ to give them more weight in the training step, as all other measures corresponding to *h*₁, *h*₂, *h*₃ and *h*₄ were more similar to one another and the learning could otherwise be biased towards such measures.

### 5.3. *Study Limitations and Future Research*

This study investigated 29 ECG recordings of ESRD patients. Although the dataset was originally planned to include a larger number of patients, ECG acquisition had to be stopped due to the situation generated by the COVID-19 pandemic. Future studies should investigate the application of the proposed methods to larger numbers of patients.

For each patient, six blood samples were available, five of them taken during an HD session and the sixth one at the beginning of the following HD session. Future studies could be designed to have more frequent [K⁺] and [Ca²⁺] measurements, especially during the first HD hour, when electrolyte levels vary most remarkably. This could help to improve the learning of the estimators.
We used linear estimators due to the small number of samples, particularly when using a patient-specific approach. Future work could investigate the use of nonlinear estimators [11,32], which could prove to be particularly relevant for the estimation of [K⁺] and [Ca²⁺] at the start of HD sessions when these take values far from those at other HD stages.

We did not have access to measurements of blood volume or of other variables that could be used to infer them. Studies on other datasets where such measurements were available could test the relationship between the markers $d_{w,Q}^u$ and $d_{w,T}^u$ used in our [K⁺] and [Ca²⁺] estimators and the blood volume. In addition, some of the patients analyzed in the study had diseases, such as diabetes mellitus. We did not find significant differences in the analyzed markers between diabetic and non-diabetic patients. Nevertheless, future studies addressing larger patient cohorts could investigate the impact of diseases additional to ESRD on the relationship between QRS markers and electrolytes.

Some publications have reported the use of deep learning methods for hypo- and hyperkalemia screening from the ECG. While such methods require large amounts of training data and could not be addressed with the database analyzed here, further investigations could extend the present work to include machine learning techniques for the same purpose [58–60].

We focused our research on [K⁺] and [Ca²⁺] estimation. [Na⁺] was found to present less notable variations during HD and none of our analyzed QRS markers showed significant association with it in the reduced dataset analyzed in this study, which should be further tested in larger patient cohorts. Although variations in other electrolytes, such as magnesium [Mg²⁺], have also been shown to alter the ECG to some extent [2,24,61–63], [Mg²⁺] measurements were not available for the present study.

An additional future research line related to this work will be aimed at extending the present investigations to include patient-specific electrophysiological simulations in biventricular models embedded in torso models. From those simulations, realistic ECGs could be computed and used to gain understanding on the relationship between ECG characteristics and [K⁺] or [Ca²⁺].

## 6. Conclusions

Our proposed QRS morphology markers presented remarkable changes during and after HD, which were strongly associated with [K⁺] and [Ca²⁺] in the ESRD patients. Multivariable estimators based on combined QRS and T wave morphological variability allowed accurate prediction of [K⁺] and [Ca²⁺], outperforming estimators based on only ECG depolarization or repolarization. These results could pave the way to ambulatory, non-invasive monitoring of electrolyte levels, which could help to prevent fatal ventricular arrhythmias in ESRD patients.

**Supplementary Materials:** The following supporting information can be downloaded at: https://www.mdpi.com/article/10.3390/s22082951/s1, Figure S1: QRS complexes, including dominant and non-dominant polarity; Figure S2: Box plots of [K⁺] and [Ca²⁺] estimation errors $e_r$; Figures S3–S12: Bland-Altman plots between actual and estimated [K⁺] and [Ca²⁺]; Figure S13: Changes in sodium levels ([Na⁺]) along HD stages; Table S1: Pearson correlation coefficient (r) to assess the association between QRS and T waves based multivariable estimators; Table S2: Pearson correlation coefficient (r) between QRS complex width and RR interval in 29 ESRD patients; Table S3: P-values to assess differences in [Na⁺] between consecutive time stages; Table S4: Pearson (r) and Spearman (ρ) correlation coefficients between QRS complex markers and [Na⁺] in 29 ESRD patients; Table S5: Pearson correlation coefficient (r) between QRS complex width and [Na⁺] in 29 ESRD patients; Tables S6–S9: Mean absolute errors (MAE) and Root mean square errors (RMSE) using stage-specific (S), patient-specific (P) and global (G) approach based [K⁺] and [Ca²⁺] estimators.

**Author Contributions:** Conceptualization, H.A.B., C.S., M.P., P.L. and E.P.; data curation, J.E.R., P.L. and E.P.; formal analysis, H.A.B.; funding acquisition, E.P.; investigation, H.A.B., C.S., P.L. and E.P.; methodology, H.A.B., P.L. and E.P.; project administration, J.E.R., P.L. and E.P.; resources,
E.P.; software, H.A.B.; supervision, C.S., M.P., P.L. and E.P.; validation, H.A.B., C.S., P.L. and E.P.; visualization, H.A.B.; writing—original draft, H.A.B.; writing—review and editing, H.A.B., C.S., M.P., P.L. and E.P. All authors have read and agreed to the published version of the manuscript.

**Funding:** This work was funded by projects PID2019-105674RB-I00 and PID2019-104881RB-I00 (Ministerio de Ciencia e Innovación), ERC-StG 638284 (ERC), Marie Skłodowska-Curie grant 764738 (European Commission) and by European Social Fund (EU) and Aragón Government through project LMP94_21 and BSICoS group T39_20R. M. Potse was funded by the French National Research Agency, grant reference ANR-10-IAHU04-LIRYC.

**Institutional Review Board Statement:** The study was approved by the Research Ethics Committee of Aragón (CEICA, ref. PI18/003, 25 January 2018).

**Informed Consent Statement:** Informed consent was obtained from all subjects involved in the study.

**Data Availability Statement:** The dataset is still ongoing and it is available upon request to the corresponding author.

**Acknowledgments:** Computations were performed by the ICTS NANBIOSIS (HPC Unit at University of Zaragoza).

**Conflicts of Interest:** The authors declare no conflict of interest. The funders had role in the design of the study but they had no role in the collection, analyses, or interpretation of data nor in the writing of the manuscript, or in the decision to publish the results.

## References

1. Weiss, J.N.; Qu, Z.; Shivkumar, K. Electrophysiology of hypokalemia and hyperkalemia. *Circ. Arrhythmia Electrophysiol.* **2017**, *10*, e004667. [CrossRef]

2. Noordam, R.; Young, W.J.; Salman, R.; Kanters, J.K.; van den Berg, M.E.; van Heemst, D.; Lin, H.J.; Barreto, S.M.; Biggs, M.L.; Biino, G.; et al. Effects of calcium, magnesium, and potassium concentrations on ventricular repolarization in unselected individuals. *J. Am. Coll. Cardiol.* **2019**, *73*, 3118–3131. [CrossRef] [PubMed]

3. Soar, J.; Perkins, G.D.; Abbas, G.; Alfonzo, A.; Barelli, A.; Bierens, J.J.; Brugger, H.; Deakin, C.D.; Dunning, J.; Georgiou, M.; et al. European Resuscitation Council Guidelines for Resuscitation 2010 Section 8. Cardiac arrest in special circumstances: Electrolyte abnormalities, poisoning, drowning, accidental hypothermia, hyperthermia, asthma, anaphylaxis, cardiac surgery, trauma, pregnancy, electrocution. *Resuscitation* **2010**, *81*, 1400–1433. [PubMed]

4. Levis, J.T. ECG diagnosis: Hypokalemia. *Perm. J.* **2012**, *16*, 57. [CrossRef] [PubMed]

5. Lv, J.C.; Zhang, L.X. Prevalence and disease burden of chronic kidney disease. *Adv. Exp. Med. Biol.* **2019**, *1165*, 3–15. [PubMed]

6. El-Sherif, N.; Turitto, G. Electrolyte disorders and arrhythmogenesis. *Cardiol. J.* **2011**, *18*, 233–245.

7. Lanari, A.; Chait, L.O.; Capurro, C. Electrocardiographic effects of potassium. I. Perfusion through the coronary bed. *Am. Heart J.* **1964**, *67*, 357–363. [CrossRef]

8. Van Mieghem, C.; Sabbe, M.; Knockaert, D. The clinical value of the ECG in noncardiac conditions. *Chest* **2004**, *125*, 1561–1576. [CrossRef] [PubMed]

9. Severi, S.; Corsi, C.; Haigney, M.; DeBie, J.; Mortara, D. Noninvasive potassium measurements from ECG analysis during hemodialysis sessions. In *Proceedings of the 2009 36th Annual Computers in Cardiology Conference (CinC)*, Park City, UT, USA, 13–16 September 2009; pp. 821–824.

10. Corsi, C.; DeBie, J.; Napolitano, C.; Priori, S.; Mortara, D.; Severi, S. Validation of a novel method for non-invasive blood potassium quantification from the ECG. In *Proceedings of the 2012 Computing in Cardiology, Krakow, Poland*, 9–12 September 2012; pp. 105–108.

11. Corsi, C.; Cortesi, M.; Callisesi, G.; De Bie, J.; Napolitano, C.; Santoro, A.; Mortara, D.; Severi, S. Noninvasive quantification of blood potassium concentration from ECG in hemodialysis patients. *Sci. Rep.* **2017**, *7*, 42492. [CrossRef]

12. Attia, Z.I.; DeSimone, C.V.; Dillon, J.J.; Sapir, Y.; Somers, V.K.; Dugan, J.L.; Bruce, C.J.; Ackerman, M.J.; Asirvatham, S.J.; Striemer, B.L.; et al. Novel bloodless potassium determination using a signal-processed single-lead ECG. *J. Am. Heart Assoc. Cardiovasc. Cerebrovasc. Dis.* **2016**, *5*, 1. [CrossRef]

13. Dillon, J.J.; DeSimone, C.V.; Sapir, Y.; Somers, V.K.; Dugan, J.L.; Bruce, C.J.; Ackerman, M.J.; Asirvatham, S.J.; Striemer, B.L.; Bukartyk, J.; et al. Noninvasive potassium determination using a mathematically processed ECG: Proof of concept for a novel “blood-less, blood test”. *J. Electrocardiol.* **2015**, *48*, 12–18. [CrossRef]

14. Pilia, N.; Severi, S.; Raimann, J.G.; Genovesi, S.; Dössel, O.; Kotanko, P.; Corsi, C.; Loewe, A. Quantification and classification of potassium and calcium disorders with the electrocardiogram: What do clinical studies, modeling, and reconstruction tell us? *APL Bioeng.* **2020**, *4*, 041501. [CrossRef] [PubMed]

15. Yoon, D.; Lim, H.S.; Jeong, J.C.; Kim, T.Y.; Choi, J.; Jang, J.; Jeong, E.; Park, C.M. Quantitative evaluation of the relationship between T-wave-based features and serum potassium level in real-world clinical practice. *BioMed Res. Int.* **2018**, *2018*, 3054316. [CrossRef] [PubMed]
16. Di Iorio, B.; Bellasi, A. QT interval in CKD and haemodialysis patients. *Clin. Kidney J.* **2013**, *6*, 137–143. [CrossRef] [PubMed]

17. Khosoosi Niaki, M.R.; Saravi, M.; Oliaee, F.; Akbari, R.; Noorkhomami, S.; Bozorgi Rad, S.H.; Fallahpoor, K.; Ramezani, M.S. Changes in QT interval before and after hemodialysis. *Casp. J. Intern. Med.* **2013**, *4*, 590–594.

18. Sohal, P.M.; Goel, A.; Gupta, D.; Aslam, N.; Sandhu, J.; Sandhu, J.S.; John, E.E.; Sharma, D. Effect of hemodialysis on corrected QT interval and QTc dispersion. *Indian J. Nephrol.* **2018**, *28*, 335–338.

19. Matsumoto, Y.; Mori, Y.; Kageyama, S.; Arihara, K.; Sato, H.; Nagata, K.; Shimada, Y.; Nojima, Y.; Iguchi, K.; Sugiyama, T. Changes in QTc interval in long-term hemodialysis patients. *PLoS ONE* **2019**, *14*, e0209297. [CrossRef]

20. Malhis, M.; Al-Bitar, S.; Farhood, S.; Zaiat, K.A. Changes in QT intervals in patients with end-stage renal disease before and after hemodialysis. *Saudi J. Kidney Dis. Transplant.* **2010**, *21*, 460–465.

21. Kim, E.D.; Watt, J.; Tereshchenko, L.G.; Jaar, B.G.; Sozio, S.M.; Kao, W.; Estrella, M.M.; Parekh, R.S. Associations of serum and dialysate electrolytes with QT interval and prolongation in incident hemodialysis: The predictors of arrhythmic and cardiovascular risk in end-stage renal disease (PACE) study. *BMC Nephrol.* **2019**, *20*, 133. [CrossRef]

22. Lorincz, I.; Mátyus, J.; Zilahi, Z.; Kun, C., Karányi, Z.; Kakuk, G. QT dispersion in patients with end-stage renal failure and during hemodialysis. *J. Am. Soc. Nephrol. JASN* **1999**, *10*, 1297–1302. [CrossRef]

23. Covic, A.; Diaconita, M.; Gusbeth-Tatomir, P.; Covic, M.; Botezan, A.; Ungureanu, G.; Goldsmith, D.J. Haemodialysis increases QTc interval but not QTc dispersion in ESRD patients without manifest cardiac disease. *Nephrol. Dial. Transplant.* **2002**, *17*, 2170–2177. [CrossRef]

24. Ozportakal, H.; Ozkok, A.; Alkan, O.; Bulut, A.S.; Boyraz, M.; Inanir, M.; Acar, G.; Odabas, A.R. Hemodialysis-induced repolarization abnormalities on ECG are influenced by serum calcium levels and ultrafiltration volumes. *Int. Urol. Nephrol.* **2017**, *49*, 509–515. [CrossRef]

25. Floccari, F.; Aloisi, E.; Nostro, L.; Caccamo, C.; Crisafulli, A.; Barillà, A.; Aloisi, C.; Romeo, A.; Corica, F.; Ientile, R.; et al. QTc interval and QTc dispersion during haemodialysis. *Nephrology* **2004**, *9*, 335–340. [CrossRef] [PubMed]

26. Schüttler, D.; Schönermarck, U.; Wenner, F.; Toepfer, M.; Rizas, K.D.; Bauer, A.; Brunner, S.; Hamm, W. Large potassium shifts during dialysis enhance cardiac repolarization instability. *J. Nephrol.* **2021**, *34*, 1301–1305. [CrossRef] [PubMed]

27. Rodrigues, A.S.; Petrènas, A.; Paliakaitė, B.; Kušleikaitė-Pere, N.; Jaruševičius, G.; Bumblytė, I.A.; Laguna, P.; Marozas, V. Noninvasive monitoring of potassium fluctuations during the long interdialytic interval. *IEEE Access* **2020**, *8*, 88488–88502. [CrossRef]

28. Bukhari, H.A.; Palmieri, F.; Ferreira, D.; Potse, M.; Ramírez, J.; Laguna, P.; Sánchez, C.; Pueyo, E. Transmural ventricular heterogeneities play a major role in determining T-wave morphology at different extracellular potassium levels. In *Proceedings of the 2019 Computing in Cardiology (CinC)*, Singapore, 8–11 September 2019; pp. 1–4.

29. Bukhari, H.A.; Palmieri, F.; Ramirez, J.; Laguna, P.; Ruiz, J.E.; Ferreira, D.; Potse, M.; Sanchez, C.; Pueyo, E. Characterization of T wave amplitude, duration and morphology changes during hemodialysis: Relationship with serum electrolyte levels and heart rate. *IEEE Trans. Biomed. Eng.* **2021**, *68*, 2467–2478. [CrossRef] [PubMed]

30. Palmieri, F.; Gomis, P.; Ferreira, D.; Ruiz, J.E.; Bergasa, B.; Martín-Yebra, A.; Bukhari, H.A.; Pueyo, E.; Martínez, J.P.; Ramírez, J.; et al. Monitoring blood potassium concentration in hemodialysis patients by quantifying T-wave morphology dynamics. *Sci. Rep.* **2021**, *11*, 3883. [CrossRef]

31. Srinivasan, S.; Bukhari, H.A.; Laguna, P.; Sánchez, C.; Pueyo, E. Analysis of T wave nonlinear dynamics for serum potassium monitoring in end-stage renal disease patients. In *Proceedings of the 2020 Computing in Cardiology, Rimini, Italy*, 13–16 September 2020; pp. 1–4.

32. Palmieri, F.; Gomis, P.; Ruiz, J.E.; Ferreira, D.; Martín-Yebra, A.; Pueyo, E.; Martínez, J.P.; Ramírez, J.; Laguna, P. Nonlinear T-wave time warping-based sensing model for non-invasive personalized blood potassium monitoring in hemodialysis patients. *Sensors* **2021**, *21*, 2710. [CrossRef]

33. Bukhari, H.A.; Sánchez, C.; Srinivasan, S.; Palmieri, F.; Potse, M.; Laguna, P.; Pueyo, E. Estimation of potassium levels in hemodialysis patients by T wave nonlinear dynamics and morphology markers. *Comput. Biol. Med.* **2022**, *143*, 105304. [CrossRef]

34. Parham, W.A.; Mehdirad, A.A.; Biermann, K.M.; Fredman, C.S. Hyperkalemia revisited. *Tex. Heart Inst. J.* **2006**, *33*, 40–47.

35. Astan, R.; Akpinar, I.; Karan, A.; Kacmaz, F.; Sokmen, E.; Baysal, E.; Ozeke, O.; Selçuk, M.T. The effect of hemodialysis on electrocardiographic parameters. *Ann. Noninvasive Electrocardiol.* **2015**, *20*, 253–257. [CrossRef]

36. Curione, M.; Castro, C.; Cammarota, C.; Tonnarini, G.; Pasquali, M. Progressive loss in circulating volume during haemodialysis can be monitored by time voltage integral area of QRS complex: Pilot study. *Arch. Med Sci. AMS* **2013**, *9*, 544–547. [CrossRef] [PubMed]

37. Ojanen, S.; Kööbi, T.; Korhonen, P.; Mustonen, J.; Pasternack, A. QRS amplitude and volume changes during hemodialysis. *Am. J. Nephrol.* **1999**, *19*, 423–427. [CrossRef] [PubMed]

38. An, J.N.; Lee, J.P.; Jeon, H.J.; Kim, D.H.; Oh, Y.K.; Kim, Y.S.; Lim, C.S. Severe hyperkalemia requiring hospitalization: Predictors of mortality. *Crit. Care* **2012**, *16*, R225. [CrossRef] [PubMed]

39. Ramirez, J.; Orini, M.; Tucker, J.D.; Pueyo, E.; Laguna, P. Variability of ventricular repolarization dispersion quantified by Time-warping the morphology of the T-Waves. *IEEE Trans. Biomed. Eng.* **2017**, *64*, 1619–1630.

40. Martínez, J.P.; Almeida, R.; Olmos, S.; Rocha, A.P.; Laguna, P. A wavelet-based ECG delineator: Evaluation on standard databases. *IEEE Trans. Biomed. Eng.* **2004**, *51*, 570–581. [CrossRef] [PubMed]
41. Castells, F.; Laguna, P.; Sörnmo, L.; Bollmann, A.; Roig, J.M. Principal component analysis in ECG signal processing. *EURASIP J. Adv. Signal Process.* **2007**, *2007*, 1–21. [CrossRef]

42. Fisher, R.A. Statistical methods for research workers. In *Breakthroughs in Statistics: Methodology and Distribution*; Ser. Springer Series in Statistics; Kotz, S., Johnson, N.L., Eds.; Springer: New York, NY, USA, 1992; pp. 66–70.

43. Rencher, A.C.; Christensen, W.F. *Methods of Multivariate Analysis*; Wiley: Hoboken, NJ, USA, 2012.

44. Freedman, D. *Statistical Models: Theory and Practice*; Cambridge University Press: New York, NY, USA, 2005.

45. Bland, J.M.; Altman, D.G. Statistical methods for assessing agreement between two methods of clinical measurement. *Lancet* **1986**, *1*, 307–310. [CrossRef]

46. Hnatkova, K.; Smetana, P.; Toman, O.; Schmidt, G.; Malik, M. Sex and race differences in QRS duration. *Europace* **2016**, *18*, 1842–1849. [CrossRef]

47. Pueyo, E.; Sornmo, L.; Laguna, P. QRS slopes for detection and characterization of myocardial ischemia. *IEEE Trans. Biomed. Eng.* **2008**, *55*, 468–477. [CrossRef]

48. Romero, D.; Ringborn, M.; Laguna, P.; Pahlm, O.; Pueyo, E. Evaluation of depolarization changes during acute myocardial ischemia by analysis of QRS slopes. *J. Electrocardiol.* **2011**, *44*, 416–424.

49. Kharche, S.; Callisesi, G.; Stary, T.; Bracci, A.; Severi, S. Simulating the effects of serum potassium on the ECG. In *Proceedings of the 2012 Computing in Cardiology, Krakow, Poland*, 9–12 September 2012; pp. 225–228.

50. Frohnert, P.P.; Giuliani, E.R.; Friedberg, M.; Johnson, W.J.; Tauxe, W.N. Statistical investigation of correlations between serum potassium levels and electrocardiographic findings in patients on intermittent hemodialysis therapy. *Circulation* **1970**, *41*, 667–676. [CrossRef] [PubMed]

51. Palmieri, F.; Gomis, P.; Ferreira, D.; Ruiz, J.E.; Bergasa, B.; Martín-Yebra, A.; Bukhari, H.A.; Pueyo, E.; Martínez, J.P.; Ramírez, J.; et al. T-wave morphology changes as surrogate for blood potassium concentration in hemodialysis patients. In *Proceedings of the 2019 Computing in Cardiology (CinC), Singapore*, 8–11 September 2019; pp. 1–4.

52. Ettinger, P.O.; Regan, T.J.; Oldewurtel, H.A. Hyperkalemia, cardiac conduction, and the electrocardiogram: A review. *Am. Heart J.* **1974**, *88*, 360–371. [CrossRef]

53. Aslam, S.; Friedman, E.A.; Ifudu, O. Electrocardiography is unreliable in detecting potentially lethal hyperkalaemia in haemodialysis patients. *Nephrol. Dial. Transplant.* **2002**, *17*, 1639–1642. [CrossRef]

54. Montague, B.T.; Ouellette, J.R.; Buller, G.K. Retrospective review of the frequency of ECG changes in hyperkalemia. *Clin. J. Am. Soc. Nephrol.* *CJASN* **2008**, *3*, 324–330. [CrossRef]

55. Martinez-Vea, A.; Bardaji, A.; Garcia, C.; Oliver, J.A. Severe hyperkalemia with minimal electrocardiographic manifestations: A report of seven cases. *J. Electrocardiol.* **1999**, *32*, 45–49. [CrossRef]

56. Fisch, C. Relation of electrolyte disturbances to cardiac arrhythmias. *Circulation* **1973**, *47*, 408–419. [CrossRef]

57. Velagapudi, V.; O'Horo, J.C.; Vellanki, A.; Baker, S.P.; Pidikiti, R.; Stoff, J.S.; Tighe, D.A. Computer-assisted image processing 12 lead ECG model to diagnose hyperkalemia. *J. Electrocardiol.* **2017**, *50*, 31–138. [CrossRef]

58. Lin, C.S.; Lin, C.; Fang, W.H.; Hsu, C.J.; Chen, S.J.; Huang, K.H.; Lin, W.S.; Tsai, C.S.; Kuo, C.C.; Chau, T.; et al. A deep-learning algorithm (ECG12Net) for detecting hypokalemia and hyperkalemia by electrocardiography: Algorithm development. *JMIR Med. Inform.* **2020**, *8*, 3. [CrossRef]

59. Galloway, C.D.; Valys, A.V.; Shreibati, J.B.; Treiman, D.L.; Petterson, F.L.; Gundotra, V.P.; Albert, D.E.; Attia, Z.I.; Carter, R.E.; Asirvatham, S.J.; et al. Development and validation of a deep-learning model to screen for hyperkalemia from the electrocardiogram. *JAMA Cardiol.* **2019**, *4*, 428–436. [CrossRef]

60. Kwon, J.M.; Jung, M.S.; Kim, K.H.; Jo, Y.Y.; Shin, J.H.; Cho, Y.H.; Lee, Y.J.; Ban, J.H.; Jeon, K.H.; Lee, S.Y.; et al. Artificial intelligence for detecting electrolyte imbalance using electrocardiography. *Ann. Noninvasive Electrocardiol.* **2021**, *26*, e12839. [CrossRef] [PubMed]

61. Naksuk, N.; Hu, T.; Krittanawong, C.; Thongprayoon, C.; Sharma, S.; Park, J.Y.; Rosenbaum, A.N.; Gaba, P.; Killu, A.M.; Sugrue, A.M.; et al. Association of serum magnesium on mortality in patients admitted to the intensive cardiac care unit. *Am. J. Med.* **2017**, *130*, 229.e5–229.e13. [CrossRef] [PubMed]

62. Jhang, W.K.; Lee, Y.J.; Kim, Y.A.; Park, S.J.; Park, Y.S. Severe hypermagnesemia presenting with abnormal electrocardiographic findings similar to those of hyperkalemia in a child undergoing peritoneal dialysis. *Korean J. Pediatr.* **2013**, *56*, 308–311. [CrossRef] [PubMed]

63. Van den Bergh, W.M.; Algra, A.; Rinkel, G.J. Electrocardiographic abnormalities and serum magnesium in patients with subarachnoid hemorrhage. *Stroke* **2004**, *35*, 644–648. [CrossRef]