*Article* **Simulating Arbitrary Electrode Reversals in Standard 12-Lead ECG**

#### **Vessela Krasteva 1,\*, Irena Jekova <sup>1</sup> and Ramun Schmid <sup>2</sup>**


Received: 24 May 2019; Accepted: 29 June 2019; Published: 1 July 2019

**Abstract:** Electrode reversal errors in standard 12-lead electrocardiograms (ECG) can produce significant ECG changes and, in turn, misleading diagnoses. Their detection is important but mostly limited to the design of criteria using ECG databases with simulated reversals, without Wilson's central terminal (WCT) potential change. This is, to the best of our knowledge, the first study that presents an algebraic transformation for simulation of all possible ECG cable reversals, including those with displaced WCT, where most of the leads appear with distorted morphology. The simulation model of ECG electrode swaps and the resultant WCT potential change is derived in the standard 12-lead ECG setup. The transformation formulas are theoretically compared to known limb lead reversals and experimentally proven for unknown limb–chest electrode swaps using a 12-lead ECG database from 25 healthy volunteers (recordings without electrode swaps and with 5 unicolor pairs swaps, including red (right arm—C1), yellow (left arm—C2), green (left leg (LL) —C3), black (right leg (RL)—C5), all unicolor pairs). Two applications of the transformation are shown to be feasible: 'Forward' (simulation of reordered leads from correct leads) and 'Inverse' (reconstruction of correct leads from an ECG recorded with known electrode reversals). Deficiencies are found only when the ground RL electrode is swapped as this case requires guessing the unknown RL electrode potential. We suggest assuming that potential to be equal to that of the LL electrode. The 'Forward' transformation is important for comprehensive training platforms of humans and machines to reliably recognize simulated electrode swaps using the available resources of correctly recorded ECG databases. The 'Inverse' transformation can save time and costs for repeated ECG recordings by reconstructing the correct lead set if a lead swap is detected after the end of the recording. In cases when the electrode reversal is unknown but a prior correct ECG recording of the same patient is available, the 'Inverse' transformation is tested to detect the exact swapping of the electrodes with an accuracy of (96% to 100%).

**Keywords:** ECG electrode swaps; ECG electrode potentials; WCT potential change; reconstructing correct ECG leads; MSMinv transformation; unicolor limb–chest electrodes

#### **1. Introduction**

The routine use of the standard 12-lead electrocardiogram (ECG) for noninvasive clinical investigation of acute and chronic cardiovascular diseases makes it very important to ensure the generation of diagnostically interpretable ECG leads [1]. An essential problem in the recording of multilead ECGs is the improper placing of the electrodes on the patient's body [2], reported to be as frequent as 0.8% and 7.5% for limb lead reversals in 12-lead ECG and Holter devices, respectively [3]; 0.4% and 4% for 12-lead ECG interchanges in clinical and intensive care settings, respectively [4]. Errors in electrode placement can lead to significant ECG changes that could confuse physicians and

affect the clinical diagnosis. Studies and case reports dedicated to this problem are further grouped in the following three categories according to the affected ECG electrodes:


Such studies indicate that special measures should be taken to ensure the correct placement of ECG electrodes, e.g., staff training has been reported to improve electrode placement by 50% [17], while combined training and technical improvements have succeeded to reduce the rate of electrode cable reversals from 4.8 % down to 1.2 % [18]. ECG changes induced by ECG cable reversals have been analyzed in a number of studies [19–24]. Methods for the automatic detection of ECG electrode reversals within the limb and precordial set have been proposed, such as:


amplitude distances [31]; nine reversals (five adjacent leads, V1/V3, V4/V6, V4/V5/V6/V1/V2/V3, V6/V5/V4/V3/V2/V1) are evaluated via correlations between measured and reconstructed leads [33]; seven reversals (five adjacent leads, V1/V3, V4/V6) are handled by processing of both morphology and redundancy features [34]; 15 reversals, including all possible pairwise V1–V6 swaps, have been tested in our previous study by applying analysis of inter-lead correlation coefficients [38].

• *Limb and chest leads:* Interchanges between limb and C2 precordial electrodes specific for a telemonitoring system are detected by correlation to a previously recorded ECG [39]. This early work, together with our recent publication on the unicolor electrode interchange detection [11], are the only studies dealing with recognition of reversals between limb and precordial leads.

The methods for the detection of ECG cable reversals should be designed/tested using dedicated databases. Only a few of the mentioned studies [7,19,27,35,39,40] use real ECG recordings with erroneous electrode placements, which are, however, small-sized and proprietary. Typically, reversal detection algorithms are trained and validated using databases with correctly recorded 12-lead ECGs and simulated reversals within the limb lead set [11,26,28–34,36,38] or the precordial lead set [11,26,31,33,34,38], where the Wilson's central terminal (WCT) is not changed. All other reversals modifying the WCT, such as swaps between the limb and precordial electrodes, have not been simulated, although they are quite possible and should be detected due to the distorted morphology of most leads [6,8,21]. For example, the interactive web-based tool [41] for the rendering of ECG leads from body surface potential maps (BSPM) separately simulates two effects—precordial lead misplacement (by linear interpolation from neighboring BSPM leads) or limb lead interchange. However, considering that this tool uses bulky BSPM data and does not allow for electrode misplacements that change WCT potential, it has restricted application for machine learning on large arrhythmia datasets with arbitrary ECG electrode reversals.

We have not found in the literature an algebraic transformation that can simulate all possible ECG electrode reversals. This paper presents the formula of such a transformation and its application in the standard 12-lead ECG setup, computing reordered leads and the WCT potential change from the correctly recorded leads. Additionally, we show the applicability of this method for reconstructing the correct leads from an ECG recorded with known electrode reversals, as well as for detection of the exact electrodes that were swapped, provided there are at least two ECGs from the same patient.

#### **2. Methods**

#### *2.1. Derivation of the Transformation Formula*

The presented transformation formula can be used to simulate reversals between arbitrary ECG electrodes in the standard 12-lead ECG, although the final transformation formula can be extended to an arbitrary number of leads.

According to the fundamental principles of electrocardiography [42], standard 12-lead ECG systems (Figure 1) use 10 electrodes on the LA, RA, LL, RL and 6 precordial positions (C1-C6), and acquire 8 independent signals (e.g. leads I, II, V1-V6):

$$\begin{cases} I = P\_E(LA) - P\_E(RA) \\ II = P\_E(LL) - P\_E(RA) \\ V\_X = P\_E(C\_X) - P\_{\text{WCT}} = P\_E(C\_X) - \frac{P\_E(LL) + P\_E(RA) + P\_E(LA)}{3} \end{cases} \tag{1}$$

where:


**Figure 1.** Acquisition of 12-lead ECG via a 10-electrode cable with standard IEC color coding, recording 8 independent leads I, II, V1-V6 (denoted as Vx) in the ECG device. The flow diagram shows the simulation of reversals between LL, RA, LA and one chest electrode (denoted as Cx) by conversion of the recorded leads (I, II, Vx) to reordered leads (ˆ I, "II, "VX) using the matrix transformations **<sup>~</sup> M**inv, **S**, **M** . The specific example shows an identity **S** matrix that corresponds to the correct order of LL, RA, LA, Cx electrodes. Other estimates of the **S** matrix are presented on Figure 2 and Section 4.1 in the description of different examples for electrode reversals.

The calculations in (1) are usually performed by the input circuits in ECG devices. As soon as an electrode swap can lead to a change in the WCT potential, it becomes difficult to imagine the changes in the standard 12-lead ECG. Therefore, the derivation and handling of the electrode potentials corresponding to the nine active ECG electrodes with respect to a common reference point is the main target of further mathematical transformations.

The basic 12-lead ECG computations (1) can also be presented using the matrix notation:

$$
\begin{bmatrix} I \\ II \\ V\_X \end{bmatrix} = \begin{bmatrix} 0 & -1 & 1 & 0 \\ 1 & -1 & 0 & 0 \\ -\frac{1}{3} & -\frac{1}{3} & -\frac{1}{3} & 1 \end{bmatrix} \begin{bmatrix} P\_E(LL) \\ P\_E(RA) \\ P\_E(LA) \\ P\_E(C\_X) \end{bmatrix} = \mathbf{M} \begin{bmatrix} 0 \\ P\_E(RA) \\ P\_E(LA) \\ P\_E(C\_X) \end{bmatrix} \tag{2}
$$

where **M** is the matrix that converts the raw electrode potentials PE(LL), PE(RA), PE(LA) and PE(Cx) into leads I, II, Vx. Formula (2) shows the setting (*PE*(*LL*) = 0), which defines our choice that *PE*(*LL*) is the reference potential. This is an arbitrary choice because we can set any electrode as the reference one without changing the final outcome of our derivations. We can further simplify (2):

$$
\begin{bmatrix} I \\ II \\ V\_X \end{bmatrix} = \begin{bmatrix} -1 & 1 & 0 \\ -1 & 0 & 0 \\ -\frac{1}{3} & -\frac{1}{3} & 1 \end{bmatrix} \begin{bmatrix} P\_E(RA) \\ P\_E(LA) \\ P\_E(\mathbb{C}\_X) \end{bmatrix} = \mathbf{M}\_\mathcal{F} \begin{bmatrix} P\_E(RA) \\ P\_E(LA) \\ P\_E(\mathbb{C}\_X) \end{bmatrix} \tag{3}
$$

where **M**<sup>F</sup> is a full-rank matrix that is further inverted (**M**−<sup>1</sup> <sup>F</sup> ) for solving of the opposite task for the conversion of leads into body electrode potentials:

$$
\begin{bmatrix} P\_E(RA) \\ P\_E(LA) \\ P\_E(C\_X) \end{bmatrix} = \mathbf{M}\_\mathbf{F}^{-1} \begin{bmatrix} I \\ II \\ V\_X \end{bmatrix} = \begin{bmatrix} 0 & -1 & 0 \\ 1 & -1 & 0 \\ \frac{1}{3} & -\frac{2}{3} & 1 \end{bmatrix} \begin{bmatrix} I \\ II \\ V\_X \end{bmatrix}. \tag{4}
$$

Further, **M**−<sup>1</sup> <sup>F</sup> is extended so that (4) is able to reproduce the electrical potential of the left leg, using the definition (*PE*(*LL*) = 0):

$$
\begin{bmatrix} P\_E(LL) \\ P\_E(RA) \\ P\_E(LA) \\ P\_E(C\_X) \end{bmatrix} = \begin{bmatrix} 0 & 0 & 0 \\ & \mathbf{M\_F}^{-1} & 1 \end{bmatrix} \begin{bmatrix} I \\ II \\ V\_X \end{bmatrix} = \begin{bmatrix} 0 & 0 & 0 \\ 0 & -1 & 0 \\ 1 & -1 & 0 \\ \frac{1}{3} & -\frac{2}{3} & 1 \end{bmatrix} \begin{bmatrix} I \\ II \\ V\_X \end{bmatrix} = \tilde{\mathbf{M\_{inv}}} \begin{bmatrix} I \\ II \\ II \\ V\_X \end{bmatrix},\tag{5}
$$

where **<sup>~</sup> M**inv is the matrix that allows the computation of the raw body electrode potentials in the order # *PE*(*LL*), *PE*(*RA*), *PE*(*LA*), *PE*(*CX*) \$ using the recorded leads {*I*, *II*, *V*x}. Once the body electrode potentials are known, they can be reordered to simulate an arbitrary reversal between ECG electrodes. The simulated electrode order can be algebraically described by a binary swap matrix (**S**), which equals an identity matrix for the correct order:

$$
\begin{bmatrix} P\_S(\widehat{LL}) \\ P\_S(\widehat{RA}) \\ P\_S(\widehat{LA}) \\ P\_S(\widehat{CA}) \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} P\_E(LL) \\ P\_E(RA) \\ P\_E(LA) \\ P\_E(C\_X) \end{bmatrix} = \mathbf{S} \begin{bmatrix} P\_E(LL) \\ P\_E(RA) \\ P\_E(LA) \\ P\_E(C\_X) \end{bmatrix} \tag{6}
$$

where *PS* denotes the simulated electrical potential at the respective electrode & *LL*%, *RA*%, *LA*%,*C* %*X* ' . Different examples of matrix **S** are further given in Section 4.1 upon the description of the performed theoretical simulations of electrode reversals.

The correspondence between the leads recorded by the ECG device (*I*, *II*, *V*x) and the reordered leads (ˆ*I*, ˆ*II*, *V*ˆ *<sup>X</sup>*) after the simulation of ECG electrode reversals can be calculated by substituting successively (6) and (5) into (2):

$$
\begin{bmatrix}
\hat{I} \\
\hat{H} \\
\hat{\mathcal{V}}\_X
\end{bmatrix} = \mathbf{M} \begin{bmatrix}
P\_S \widehat{\{L\!\!\!A}} \\
P\_S \widehat{\{R\!\!\!A}} \\
P\_S \widehat{\{L\!\!\!A}} \\
P\_S \widehat{\{C\!\!\!X}}
\end{bmatrix} = \mathbf{M} \mathbf{S} \mathbf{\tilde{M}}\_{\text{inv}} \begin{bmatrix}
I \\
H \\
V\_X
\end{bmatrix}.
\tag{7}
$$

The flow diagram of (7), further denoted as 'MSMinv' transformation, which is presented on Figure 1, clearly indicates the embedded logic of matrix operations that have a general applicability to simulate arbitrary configurations of electrode swaps. It is just necessary to adapt the values of the matrices **<sup>M</sup>**, **<sup>S</sup>**, **<sup>~</sup> M**inv to the specific lead configuration, assuming that the derived mathematical proof shows the full set of two independent bipolar limb leads in 12-lead ECG (can be reduced) and one unipolar lead (can be deleted or extended to multiple unipolar leads by copy of the row (*C*x) in **<sup>M</sup>**, **<sup>~</sup> M**inv and expand *S* accordingly).

Note that the matrices in the 'MSMinv' transformation (7) take into account only the potentials of the active input electrodes, excluding the grounded RL. The result of a swap of an arbitrary active electrode with RL can be, however, approximated by setting the potential of the swapped active electrode equal to the LL potential in the matrix **S** (6):

$$P\_S(suppped\text{ electrode to RL}) = P\_E(RL) \approx P\_E(LL) \tag{8}$$

The assumption for equipotential legs can be considered from an anatomical perspective because the leg recording sites are sufficiently distant and similarly oriented to the heart, thus attaining the same electrical signal generated by the myocardium [24]. Generally, both (RL, LL) potentials are essentially very similar that is typically adopted in the known ECG lead transformations of rotated RL with other peripheral electrodes [7,8,21,22].

Another application of the derived mathematical transformations is the calculation of the WCT potential change due to ECG electrode swaps:

$$
\Delta P\_{\rm WCT} = \mathcal{P}\_{\rm WCT} - P\_{\rm WCT} \tag{9}
$$

where *PWCT* and *P*ˆ*WCT* are the WCT potentials before and after the electrode swap, respectively. Both can be derived as a function of the recorded leads (*I*, *II*, *V*x) with a reference to a zero LL potential (*PE*(*LL*) = 0), as assumed in Equations (2) and (5):

$$P\_{\rm WCT} = \mathbf{W} \begin{bmatrix} P\_E(LL) \\ P\_E(RA) \\ P\_E(LA) \\ P\_E(C\_X) \end{bmatrix} = \mathbf{W}\mathbf{\tilde{M}}\_{\rm inv} \begin{bmatrix} I \\ II \\ V\_X \end{bmatrix} \tag{10}$$

$$\boldsymbol{\mathcal{P}}\_{\text{WCT}} = \mathbf{W} \begin{bmatrix} \boldsymbol{P\_S}(\overleftarrow{\boldsymbol{L}\boldsymbol{\tilde{A}}}) \\ \boldsymbol{P\_S}(\overleftarrow{\boldsymbol{R}\boldsymbol{\tilde{A}}}) \\ \boldsymbol{P\_S}(\overleftarrow{\boldsymbol{L}\boldsymbol{\tilde{A}}}) \\ \boldsymbol{P\_S}(\overleftarrow{\boldsymbol{C}\_X}) \end{bmatrix} = \mathbf{W} \mathbf{S} \mathbf{\tilde{M}}\_{\text{inv}} \begin{bmatrix} \boldsymbol{I} \\ \boldsymbol{I} \\ \boldsymbol{V\_X} \end{bmatrix}, \tag{11}$$

where *<sup>W</sup>* = 1/3 1/3 1/3 0 is the matrix that transforms electrode potentials intoWCT potential, taking the potentials for the correct electrode position # *PE*(*LL*), *PE*(*RA*), *PE*(*LA*), *PE*(*CX*) \$ from (5) and for the swapped position & *PS LL*% , *PS RA*% , *PS LA*% , *PS C* %*X* ' from (6) and (5). Although WCT potential is calculated only from the potentials of the three limb electrodes *LL*ˆ, *RA*%, *LA*% , Equation (11) covers the general option for a swap between some of them and the unipolar electrode *C* %*X* .

Substituting (10) and (11) in (9) gives the generalized notation of the 'WSMinv' transformation that is further used for estimating of the relative WCT potential change during different simulated swaps:

$$
\Delta P\_{\rm WCT} = (\mathbf{W}\mathbf{S} - \mathbf{W})\tilde{\mathbf{M}}\_{\rm inv} \begin{bmatrix} I \\ II \\ V\_X \end{bmatrix} . \tag{12}
$$

#### *2.2. Verification of 'MSMinv' Transformation*

The correctness of the 'MSMinv' transformation (7) is verified by two approaches, depending on the kind of simulated ECG electrode reversals:

	- (*LRC vs*. *LRS*)*: No transformation* is applied to study the lead-specific differences between recordings with correct vs. swapped electrodes.
	- (*L* (*RC vs*. *LRS*): *Forward 'MSMinv' transformation* is applied on the recording with correct lead set to simulate lead swap *L* (*RC* <sup>=</sup> **MS <sup>~</sup> <sup>M</sup>**inv*LRC* and to study the lead-specific differences of simulated vs. recorded electrode reversals (*LRS*).

◦ (*LRC vs*. *L* (*RS*): *Inverse 'MSMinv' transformation* is applied on the recording with reversed lead set to simulate correct electrode positions (*L* (*RS* <sup>=</sup> **MS <sup>~</sup> M**inv*LRS*) and to study the lead-specific differences of simulated vs. recorded, correctly placed electrodes (*LRC*).

The lead-specific differences in each of the above 3 scenarios (denoted as *L* )*RC vs*. *L* )*RS*) are estimated for the average beat (*BEATi*), indexed within a window of 500ms (*i* = *QRSf* − 150*ms to QRSf* + 350*ms*, where *QRSf* denotes the QRS fiducial point), using three quantitative measures:

◦ Root-mean-square error:

$$RMS\ Error = \sqrt{\frac{1}{500ms\astFs} \sum \left( BEAT\_i \boxed{L\_{RC}} - BEAT\_i \boxed{L\_{RS}} \right)^2},\tag{13}$$

where Fs denotes the sampling frequency of the average beat.

◦ Peak error:

$$Peak\ Error = \max\{\left| BEAT\_i \left(\widehat{L\_{RC}}\right) - BEAT\_i \left(\widehat{L\_{RS}}\right)\right|.\tag{14}$$

◦ Correlation coefficient:

$$CorCoef = \frac{\sum BEAT\_i \widehat{\left(L\_{RC}\right)} BEAT\_i \widehat{\left(L\_{RS}\right)}}{\sqrt{\sum BEAT\_i^2 \left(\widehat{L\_{RC}}\right)} \cdot \sum BEAT\_i^2 \widehat{\left(L\_{RS}\right)}}.\tag{15}$$

Statistical results of all quantitative measurements over the whole ECG database are reported as a mean value and standard deviation (std). The level of significant differences between different scenarios is measured with paired Student's t-test and one-tailed *p*-value < 0.05.

#### **3. Database**

The database used for verification of the 'MSMinv' transformation contains 10s recordings of standard 12-lead resting ECGs taken from 25 volunteers with no history of heart diseases—gender: 28% (male), age: 49 ± 11 years (mean value ± standard deviation), 28–67 years (range). The ECGs are acquired via a 10-electrode cable with standard IEC color coding [44]. Six ECG recordings per subject are collected, applying prospective electrode cable reversals at the time of the recording, including:


The ECG signals are recorded at 1 kHz sampling rate, 1 μV resolution, and pre-filtered in a bandwidth (0.5 to 25 Hz). Each 10s ECG recording is processed by a commercial ECG measurement and interpretation module (ETM, Schiller AG, Switzerland) for the extraction of a 12-lead average beat [45]. The average beats are commonly used for the measurement of ECG features with diagnostic precision because they provide higher signal-to-noise ratio and are more robust to respiration induced morphology changes than the single beats.

#### **4. Results and Discussion**

#### *4.1. Theoretical Simulations of Electrode Reversals*

This section simulates three major types of ECG electrode reversals (reversals of peripheral electrodes involving RL; not involving RL; reversals of peripheral and chest electrodes ), applying 'WSMinv' transformation (12) for the calculation of WCT potential change (Table 1) and 'MSMinv' transformation (7) for the calculation of the reordered leads (Tables 2–4). Several general examples are shown on Figure 2. Details will be further discussed in Sections 4.1.1–4.1.3

**Figure 2.** Classic depiction of the Einthoven's triangle, WCT and lead vectors (I, II, Vx), projected in the frontal plane for correct electrode position (**a**) and their displacement (ˆ I, "II,Vˆ X) in case of four types of limb electrode reversals: (**b**) CW rotation of 3 active limb electrodes (RA% →LA%→LL%→RA%); (**c**) CW rotation of 4 limb electrodes, including RL (RL%→RA%→LA%→LL%→RL%); (**d**) swap of an active limb electrode and chest electrode, illustrated for the green couple (LL%↔C3%); (**e**) swap of the grounded and chest electrode, illustrated for the black couple (RL%↔C5%). The text with red font color highlights the electrodes in wrong geometrical positions, and the swap matrix entries different from the identity matrix in (**a**).


**Table 1.** Calculation of the WCT potential change from the recorded leads via the 'WSMinv' transformation (12), applying the swap matrices **S** in Tables 2–4.

*Note:* For comprehension purposes of various electrode combinations, the reversed electrodes are depicted with their respective colors according to the IEC color coding [44]. *\** ΔPWCT = 0 corresponds to the correct position of the active limb electrodes (*LL*%, *RA*%, *LA*%).

4.1.1. Reversals of Peripheral Electrodes Not Involving RL

All 5 possible rotations of the 3 active limb electrodes (*LL*%, *RA*%, *LA*%) are simulated (Table 2) and none of them is related to the displacement of WCT, as illustrated in the example of clockwise (CW) electrode rotation (Figure 2b), where the Einthoven's triangle remains geometrically unaffected. This is theoretically proven by the 'WSMinv' transformation (12), where all swap matrices **S** (Table 2) are consequently applied, and zero WCT potential differences to the correct electrode position (Δ*PWCT* = 0) are detected (Table 1). The rearranged limb leads (ˆ*I*, ˆ*II*) obtained by the 'MSMinv' transformation (Table 2) match the expressions in other studies, applying geometrical perspectives between leads (I, II, III) [5,12,21,24,36–38]. Furthermore, the unipolar chest lead *V*ˆ *<sup>X</sup>* is unchanged for all simulated swap matrices **S** that corresponds to the real case scenario of unchanged WCT (Figure 2a,b).


**Table 2.** Reversals of peripheral electrodes not involving RL.

*Note:* For comprehension purposes of various electrode combinations, the reversed electrodes are depicted with their respective colors according to the IEC color coding [44], *- 1st column:* The simulated placement of ECG electrodes & *LL*%, *RA*%, *LA*%,*C* %*X* ' referring to their geometrical positions {*LL*, *RA*, *LA*, *CX*}. The electrodes which are assumed to be in the wrong geometrical positions are indicated with red font color as being reversed. *- 2nd column:* The values of the swap matrix **S**, where red font colored entries indicate the difference to the identity matrix as defined in (6) for the correct electrode placement. *- 3rd column:* The result of matrix multiplication **MS <sup>~</sup> <sup>M</sup>**inv, considering **<sup>M</sup>** and **<sup>~</sup> M**inv equal to their definitions in (2) and (5), respectively. *- 4th column:* The formula for calculation of the reordered leads (ˆ*I*, <sup>ˆ</sup>*II*, *<sup>V</sup>*<sup>ˆ</sup> *<sup>X</sup>*) using the recorded leads (*I*, *II*, *<sup>V</sup>*x) that is obtained after substituting **MS <sup>~</sup> M**inv in (7). For simplification, the substitution (*III* = *II* − *I*) is applied in some formulas.

#### 4.1.2. Reversals of Peripheral Electrodes Involving RL

Seven rotations of the 4 limb electrodes (*LL*%, *RA*%, *LA*%,*RL*<sup>ˆ</sup> ) are simulated (Table 3) and normally they should be related to the displacement of WCT, as illustrated in the example (Figure 2c), where the Einthoven's triangle is transformed to a thin 'slice'.

Table 1 shows that all electrode reversals present WCT potential change, depending only on the position of the neutral electrode RL, such that:



**Table 3.** Reversals of peripheral electrodes involving RL.

*Note:* All columns correspond to the description in the footer of Table 2.

These results and the 'MSMinv' transformation (Table 3) are obtained with the general approximation for equipotential legs that is coded in the swap matrix **S** with an entry of '1' in the position of LL (first column) for both cases: & *<sup>X</sup>*<sup>ˆ</sup> <sup>=</sup> *LL*, *<sup>X</sup>*<sup>ˆ</sup> <sup>=</sup> *RL*' , whereas *X*ˆ denotes an arbitrary ECG electrode. Thus, all electrode reversals leading to a 'sliced' Einthoven's triangle with two tips on both legs appear with two '1' entries in the first column of matrix **S** (Table 3), while '1' is deficient in the second (RA) or third (LA) columns (equal to '0'). Only two reversals (RL-LL and the counter-clockwise (CCW) rotation with RL) have '1' entries in each of the first three columns of matrix **S** (corresponding to the three active limb electrodes in the Einthoven's triangle tips). Just for them, the WCT potential is correctly found to be unchanged (Table 1), although the reordered limb leads (ˆ*I*, ˆ*II*) in CCW rotation appear to be different (Table 3). Generally, all simulated reversals show that (ˆ*I*, ˆ*II*) leads, resulting from the 'MSMinv' transformation, are matching the expressions in other studies that have been derived by geometrical analysis of the leads, assuming "0" [6,12,19,21,22,24,35,36] or "near zero" signal <100 μV [5,7,8,38] for the lead between the active electrodes on both legs.

Considering the chest lead *VX*, we find a correspondence between 'MSMinv' and 'WSMinv' transformations so that the reordered lead *<sup>V</sup>*<sup>ˆ</sup> *<sup>X</sup>* = *VX* <sup>−</sup> <sup>Δ</sup>*PWCT* (Table 3) is corrected exactly with the term Δ*PWCT* (Table 1). Generally, no chest lead *VX* is considered in case of limb leads reversals, so we cannot compare the derived *V*ˆ *<sup>X</sup>* expressions to published studies. We can justify the unchanged *V*ˆ *<sup>X</sup>* in both aforementioned reversals with WCT not being displaced (RL-LL and CCW rotation), as well as *<sup>V</sup>*<sup>ˆ</sup> *<sup>X</sup>* = *VX* <sup>−</sup> 1/3*II* for the RL-RA reversal. This reversal has been analytically described in Haisty et

al. [8], who explained that WCT potential difference is equal to one third of the difference between RA and RL potentials that approximates one third of the standard lead II.


**Table 4.** Reversals of unicolor chest and peripheral electrodes.

*Note:* All columns correspond to the description in the footer of Table 2. Cx represents all chest electrodes with unchanged positions, Vx denotes their unipolar leads.

#### 4.1.3. Reversals of Chest and Peripheral Electrodes

Five swaps are simulated (Table 4) involving the matching-color electrode pairs in the peripheral and precordial cables (IEC color coding standard [44]), i.e., red (RA-C1), yellow (LA-C2), green (LL-C3), black (RL-C5) and all pairs (RA-C1, LA-C2, LL-C3, RL-C5).

Figure 2d,e illustrates the two principal types of reversals where the unipolar chest electrode is swapped either with an active limb electrode (WCT is displaced in Figure 2d) or with the grounded electrode (WCT is not displaced in Figure 2e). In both cases, we highlight two types of unipolar leads:


The calculation of two different unipolar leads is achieved by an extension of the swap matrix **S** (4 <sup>×</sup> 4) to (5 <sup>×</sup> 5) to include 3 limb electrodes and 2 chest electrodes (*LL*%, *RA*%, *LA*%, *Cn*<sup>ˆ</sup> , *<sup>C</sup>*ˆx), as shown in Table 4 and Figure 2d,e. The last row of Table 4 presents the most complex example for simulation of swaps between all unicolor electrode pairs, which requires the use of a swap matrix **S** (9 × 9), configured for the full set of electrodes (*LL*%, *RA*%, *LA*%, *<sup>C</sup>*ˆ1 <sup>−</sup> *<sup>C</sup>*ˆ6). All expressions of the rearranged leads (ˆ*I*, ˆ*II*, *Vx*ˆ , *Vn*ˆ ) in Table 4 are further verified in the experimental study of Section 4.2 because they have not been investigated in any other study. The respective WCT potential changes (Table 1) cannot be compared to examples in the literature either. We can only justify the result for the RL-C5 reversal, which corresponds to non-displaced WCT, exactly as shown in the example (Figure 2e).

#### *4.2. Experimental Verification of Simulated Swaps Between Unicolor Chest and Peripheral Electrodes*

The experimental study is used to verify the 'MSMinv' transformation for simulation of reversals between unicolor chest and peripheral electrodes (using the expressions in Table 4), according to the concept in Section 2.2 (*ECG electrode reversals with unknown lead transformations*). For this purpose, all ECG recordings in the database are analyzed and the three measurements (RMS Error, Peak Error, CorCoef) are calculated to estimate the average beat waveform differences in 3 scenarios (Table 5):

	- V1 (120 μV, 529 μV, 0.832) for RA-C1,
	- V2 (246 μV, 1121 μV, 0.456) for LA-C2,
	- V3 (206 μV, 868 μV, 0.512) for LL-C3,
	- V5 (131 μV, 639 μV, 0.785) for RL-C5,
	- V1-V3 (225-289 μV, 967-1235 μV, 0.365-0.652) for all unicolor pairs.


**Table 5.** Statistical analysis (mean value ± standard deviation) of measures (RMS Error, Peak Error, CorCoef) calculated for the average beat in 8 independent leads(I, II, V1-V6), quantifying the lead-specific differences between experimentally recorded ECGs – raw leads vs. reordered leads (based on the expressions in Table for3differentscenarios:.Notransformation;Forward'MSMinv'transformationappliedontherecordingwithcorrectelectrodes;Inverse'MSMinv'transformation

in

transformation (Forward or Inverse) compared to 'None' transformation. \$: Approximation effect of the Forward 'MSMinv' transformation to simulate a swapped lead V5, whileplaced on the RL and its potential is assumed equal to the LL. #: Deficiency of the Inverse 'MSMinv' transformation to reconstruct the correct lead V5 from a recording with RL electrode the position of C5 electrode.

4)

Figure 3 illustrates the average ECG beats in leads (I, II, V1-V6) recorded with all types of swapped unicolor chest and peripheral electrodes. This ECG trace is almost fully overlapping with the simulated electrode reversals from the ECG raw data with correct electrode positions, applying Forward 'MSMinv' transformation. This once again validates the derived algebraic transformations in Table 4, which are able to exactly reproduce the diversity of lead-specific morphologies (amplitudes, polarities and durations) that each swap introduces to any lead via change of its electrode position and/or WCT potential.

**Figure 3.** The average beat of 8 independent leads (I, II, V1-V6) taken from the same subject in two scenarios: (1) Red trace: Recorded ECG with swapped unicolor electrodes; (2) Blue trace: Simulated ECG with swapped unicolor electrodes, applying Forward 'MSMinv' transformation on the ECG recorded with the correct lead set.

*4.3. Application of the 'MSMinv' Transformation for Automatic Detection of the Exact ECG Electrode Reversals*

We further show an important practical application of the Inverse 'MSMinv' transformation for the detection of the exact reversals between ECG electrodes. This application is relevant to the case when two ECG recordings in a patient are available:

(1) an ECG recording with correct lead set (*LRC*);

(2) an ECG recording with an unknown/suspected lead swap (*LRS*).

The 'MSMinv' transformation is applied to the swapped ECG recording, iteratively simulating all possible permutations of the nine active ECG electrodes (i = 9! = 362 880):

$$
\widehat{L\_{RS}}(\mathbf{i}) = \mathbf{M} \mathbf{S} \mathbf{i} \tilde{\mathbf{M}}\_{\text{inv}} L\_{RS} \tag{16}
$$

The swap matrix **Si**, which produces the lead set reconstruction *L* (*RS*(*i*) with the minimal difference *d*(·) to the correct lead set can indicate the true lead swap (TLS):

$$TLS = \underset{1 \le i \le 9!}{\arg\min} \left( d\widehat{\left(L\_{\text{RS}}(i) - L\_{\text{RC}}\right)} \right) \tag{17}$$

We test this swap detection criterion using our ECG database under the following conditions:


$$\text{Accuracy} = \sum\_{\mathbf{P}=1}^{N} \frac{\text{TP}\_{\mathbf{P}}}{N} \,\text{}\tag{18}$$

where *TP* = *f*(*x*) = + 1, *correct lead swap detected* 0, *otherwise*

Table 6 presents the experimental verification of the Inverse 'MSMinv' transformation, applied for automatic detection of the exact ECG electrode reversals. We have achieved 100% accuracy in the detection of (RA-C1) and (LL-C3) reversals, and 96% for the detection of (LA-C2) reversal when the decision rule (17) uses a minimal difference metric equal to the minimal RMS Error or the maximal correlation between the reconstructed swap and the correct recording. All false negatives are observed to present TLS with either the 2nd or the 3rd ranked minimal differences, while the decision rule (17) is presently adjusted to simply report the exact lead swap with the 1st ranked minimal difference. For example, the lowest LA-C2 accuracy is due to one case, where the true LA-C2 is 2nd ranked, while the true LA-C2 in combination with RA-C1 is 1st ranked. Obviously, the detection of the exact electrode swap among many electrodes with close geometrical positions might include a portion of uncertainty due to indistinguishable geometrical perspectives of the heart vector in neighboring leads. Further updates of the decision rule (17) could potentially improve the accuracy for TLS detection, e.g., by majority voting of many distance metrics after exclusion of those with the lowest accuracy (i.e., the peak Error with 88% to 96%).

**Table 6.** Accuracy for the detection of the exact lead swaps, applying the 'MSMinv' transformation on 3 swapped recordings (RA-C1), (LA-C2), (LL-C3) from 25 patients in our database. Color of electrodes follows IEC standard [44];


\* 1 false negative case due to TLS with the 2nd ranked minimal difference in the decision rule (17). # 3 false negative cases due to TLS with either the 2nd or the 3rd ranked minimal differences in (17).

The presented rules are easily applicable in a warning system that can alert the medical staff to check the electrodes suggested for reversal within the first seconds of 12-lead ECG acquisition. Principally, the analysis is not fixed exactly to 10 s but can take a single beat or an average beat over ECGs with an arbitrary duration. It is important to note that the results reported in this section represent the best-case results, because they are based on resting ECG recordings that were taken within a short window of time and with exactly the same electrode positions (only the electrode cables were swapped). In a clinically relevant application, the ECGs under question will most likely have a substantially different recording date (leading to possible physiological changes in the ECG), and they will most likely be recorded with slightly different electrode positions. Although the average beat pattern of the same individual has been shown to have a long-term stability independent of recording sessions and physiological factors (age, gender, heart rate) [46,47], the reliable clinical application should always consider a final approval of the alarmed electrode reversals by the medical staff and electrode correction at the time of the recording.

#### **5. Conclusions**

This study derives a novel algebraic transformation which converts the standard 12-lead ECG leads from a correct to reordered set in case of arbitrary reversals between ECG electrodes. The formula of the 'MSMinv' transformation (7) is generalized to the calculation of all kinds of electrode reversals, giving the exact lead reordering for:


The validity of the 'MSMinv' transformation is proven in our experimental study for two bilateral applications with a certain practical significance:


specific population with "normal" ECG during rest could fail on cardiac patients or patients under environmental stress with lead-wise ECG morphology change). As this work is focused only on the problem of simulating all possible ECG cable reversals, the design and validation of criteria for a self-consistency check for detection of the ECG cable reversals is an extensive problem for a future study.

Another important derivation of the present study is the 'WSMinv' transformation (12), which computes WCT potential change for all kinds of electrode reversals. It quantifies the common distortion that all unipolar leads would meet while their reference potential is changed, regardless of whether or not they maintain their correct position. Table 1 shows that WCT distortion is proportional to leads I, II, and the displaced unipolar leads (V1-V3 in the simulation) with fractions, which are hardly envisaged without the derived transformation. The overall influence of WCT change on all unipolar leads is also reproduced by the 'MSMinv' transformation in Tables 3 and 4.

This study provides the means for calculation of the potentials of the ECG electrodes and WCT toward a common reference potential using Equations (5) and (10), respectively. These mathematical transformations can be applied to any standard 12-lead ECG for deriving the 'true' unipolar ECG leads and WCT measurements that have recently been experimentally acquired via special ECG machines [43,47]. The experimental studies have considered the position of the reference potential on the right leg, while this study shows the values of the matrix **<sup>~</sup> M**inv for the reference left leg leading to the same global observations (WCT measured with respect to the left leg does not have a stable voltage and is correlated to the limb leads (I, II), exhibiting all ECG waves). Although both legs have essentially insignificant potential difference, its value is the only unknown and approximated to be a zero measurement while applying our transformation equations.

**Author Contributions:** Conceptualization, R.S.; data curation, V.K. and I.J.; formal analysis, V.K. and I.J.; investigation, V.K. and I.J.; methodology, V.K., I.J., and R.S.; project administration, R.S.; resources, V.K. and I.J.; software, V.K. and I.J.; supervision, R.S.; validation, V.K., I.J., and R.S.; visualization, V.K.; writing – original draft, V.K.; writing – review and editing, I.J. and R.S.

**Funding:** This research received no external funding.

**Conflicts of Interest:** The authors declare no conflicts of interest.

#### **References**


© 2019 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 (http://creativecommons.org/licenses/by/4.0/).
