Large Language Models (LLMs) are increasingly being asked to act as multi-modal assistants, processing everything from images to complex medical signals. But how do you "show" a 12-lead electrocardiogram (ECG)—a high-frequency, multi-channel voltage recording—to a model that only understands text?
A new paper from researchers at Karabük University introduces ECG-26c, a deterministic text encoding designed to bridge the gap between clinical waveforms and the token-limited world of LLMs.
TL;DR
ECG-26c is a novel text-based encoding that compresses 12-lead ECG signals by over 60% while preserving their diagnostic utility. By using a specialized "alphabet" for amplitudes and exact timing gaps, it ensures full 10-second recordings fit within standard LLM context windows without losing the critical features needed for medical diagnosis.
What Problem Does This Paper Address?
The standard 12-lead ECG is a cornerstone of cardiology, but it is data-heavy. A typical 10-second recording sampled at 100 Hz contains 12,000 raw voltage values. If you simply transcribed these numbers into text, the resulting sequence would be massive—likely exceeding the "context window" (the memory limit) of most LLMs or making the computational cost of processing them (which grows quadratically with length) prohibitively expensive.
Previous attempts to solve this either used "black box" embeddings that humans can't read, or symbolic methods that truncated long records or lost timing precision. The authors identify a critical research gap: we need a way to quantify exactly how much diagnostic information is lost during the "translation" to text, independent of the specific LLM being used.
Methods
The authors developed ECG-26c, a pipeline that turns raw signals into a compact string of letters.
- Lead Reduction: Since the 12 leads of an ECG are mathematically related, the system only encodes 8 independent leads. The remaining 4 are reconstructed algebraically by the decoder, saving 33% of the token budget immediately.
- Smart Key-Point Selection: Instead of keeping every single sample, they use a variant of the Ramer–Douglas–Peucker (RDP) algorithm. Crucially, the "tolerance" for error changes based on the cardiac cycle: it stays very tight during the fast-moving QRS complex (the "heartbeat") and loosens up during the flatter baseline segments.
- The 26-Letter Alphabet: Amplitudes are mapped to a 26-letter lowercase alphabet (a–z) using a logarithmic ($\mu$-law) codebook. This provides high resolution for small signals near the baseline and lower resolution for large spikes, mimicking how human ears and eyes perceive intensity.
- Exact Timing: Unlike previous methods that "binned" time, ECG-26c uses uppercase letters (A–Z) to represent the exact number of samples between key points. This prevents "temporal drift," ensuring the heart rate and intervals remain perfectly accurate.
- Token Budgeting: If a record is too "noisy" and generates too many tokens, the system automatically re-encodes it with slightly coarser tolerances until it fits within a strict 4,080-token limit.
Datasets
The study utilized the PTB-XL database, a large, publicly available collection of 21,388 clinical 12-lead ECGs. The records were split into standard training, validation, and test folds to ensure results are comparable to other state-of-the-art benchmarks.
Key Insights and Ideas
- Fidelity $\neq$ Diagnosis: A major "aha moment" in the paper is that traditional signal error metrics (like PRD) are poor predictors of diagnostic loss. A tiny error in a short segment might look insignificant on a graph but could represent a missing "Q-wave," which is vital for identifying a past heart attack.
- Logarithmic Quantization: By using narrower bins near 0 mV, the encoding preserves the subtle "wiggles" of the P and T waves while still handling the large voltage of the QRS complex efficiently.
- Algebraic Recovery: The realization that 4 leads can be perfectly recovered from the other 8 allows for massive compression without any information loss in those specific channels beyond what is lost in the source leads.
Key Results
The researchers evaluated the "sufficiency" of their text by training a Convolutional Neural Network (CNN) on both the original signals and the decoded text-based signals.
- Compression: The average record was reduced to 2,866 tokens—a 64.3% reduction compared to raw transcription.
- Signal Fidelity: The average correlation between the original and decoded signals was a high 0.982.
- Diagnostic Performance: The CNN achieved a macro-AUROC of 0.9167 on original signals and 0.9157 on decoded signals. This tiny difference (-0.0010) was statistically non-inferior, meaning the text encoding successfully preserved the diagnostic "meat" of the ECG.
Limitations and Future Work
While the results are promising, the authors note a few hurdles:
- Small Feature Loss: A wave-level audit showed that about 2% of "Q-waves" were missing after decoding, which could impact specific diagnoses like myocardial infarction.
- Data Exposure: The test fold was partially used during the development of the encoder's tolerances, so these results should be confirmed on entirely unseen datasets.
- The "Reading" Challenge: This paper proves the information exists in the text; the next step is proving that an LLM can actually "read" and reason about these letter sequences as effectively as a dedicated CNN.
By providing a deterministic, decodable, and compact format, ECG-26c offers a standardized way for the research community to start feeding heart health data into the next generation of AI medical assistants.
Summary updated