Detecting and Correcting Electrocardiogram Limb-Lead Electrode Swapping via Deep Learning

Ritika Pandey1, Matthew A Reyna1, Zuzana Koscova2, Gari D. Clifford3, Reza Sameni3
1Emory University, 2Department of Biomedical Informatics, Emory University; Institute of Scientific Instruments of the Czech Academy of Sciences, 3Emory University and Georgia Institute of Technology


Abstract

The electrocardiogram (ECG) remains a fundamental tool for detecting and diagnosing cardiovascular diseases in clinical and ambulatory settings. However, misplacement and swapped ECG electrodes are common in high-volume urgent care and ambulatory data collection. Electrode swaps are estimated to occur in about 4% of acute care recordings, resulting in expert and programmatic misinterpretations and misdiagnoses via ECG. Automatic electrode swap detection methods remain limited, particularly for left-arm left-leg (LA-LL) swaps, which are the most common electrode misplacements.

Using the physical relationship between electrodes and ECG lead voltages, we developed deep learning models to detect and correct misplaced limb lead electrodes. Using mathematically derived lead-to-electrode space transformations and ECGs from the CODE–15% dataset, we generated 180,000 synthetic ECGs representing common limb electrode swaps. We developed binary and multiclass classifiers with one-dimensional depthwise separable convolutional neural networks, where the binary model distinguished "swapped" versus "non-swapped," while the multiclass model identified one of six possible limb electrode swaps. We further derive closed-form solutions that use the classifier outputs to correct retrospective data.

The binary classifier achieved an accuracy of 0.97 and an AUROC of 0.99 on a held-out validation set from the CODE–15% dataset; inference on about 42,000 synthetically swapped ECGs from the PTB–XL dataset achieved an AUROC of 0.99. The multiclass classifier achieved an accuracy of 0.94 and a macro-AUROC of 0.99 on the CODE–15% held-out validation set, and a macro-AUROC of 0.99 on the PTB–XL dataset. Applied to unmodified PTB–XL ECGs, the binary classifier identified 4.34% potentially swapped tracings, consistent with prior literature.

Our model demonstrated strong performance in accurately detecting and correcting ECG limb electrode swaps, with good generalizability to unseen datasets and applicability to retrospective archival data. Automated electrode swap identification could reduce diagnostic error and enable real-time ECG quality control in clinical and research settings.