S2M2ECG: ECG Diagnostic State Space Model
- S2M2ECG is a multi-lead ECG diagnostic framework that employs structured state space models and a three-level fusion strategy to analyze temporal, morphological, and spatial features.
- It combines low-level spatio-temporal tokenization, intra-lead bi-directional scanning, and cross-lead fusion via FFN and SENet, thereby enhancing both rhythm and morphological diagnosis.
- Experimental results demonstrate robust performance across several datasets with efficient inference, while ablation studies highlight the importance of ECG-specific multi-branch design.
S2M2ECG, short for “Spatio-temporal bi-directional State Space Model Enabled Multi-branch Mamba for ECG,” is a multi-lead ECG diagnosis framework that adapts structured state space models, specifically Mamba, to automatic electrocardiogram interpretation. It is designed around a three-level fusion mechanism comprising low-level spatio-temporal fusion through segment tokenization and bi-directional SSMs, intra-lead temporal fusion through forward and backward scanning, and cross-lead spatial fusion through a dedicated lead fusion module. The stated objective is to maintain a balance among performance, computational complexity, and multi-source ECG feature fusion while remaining suitable for efficient inference and convenient deployment (Zhang et al., 3 Sep 2025).
1. Definition and diagnostic problem setting
S2M2ECG is formulated for multi-lead ECG diagnosis rather than signal compression, signal generation, or multimodal report-oriented reasoning. Its problem setting is grounded in the observation that a 12-lead ECG is not merely a 1D time series but a multi-lead physiological signal with three coupled structures: temporal structure, including rhythms, intervals, beat-to-beat evolution, and long-term dependencies; morphological structure, including local waveform shapes such as P waves, QRS complexes, ST segments, and T waves; and spatial or lead structure, because different leads observe different heart regions and therefore require fusion across leads rather than simple concatenation (Zhang et al., 3 Sep 2025).
The framework is motivated by limitations attributed to major deep-learning families previously used for ECGs. CNNs are described as strong on local morphology but weak on long-range rhythms; Transformers model long dependencies but are quadratic in sequence length; RNNs are sequential and harder to scale; and GNNs require predefined graph structure that may not reflect patient-specific lead relations. S2M2ECG addresses this by using Mamba and structured state space models, which are presented as offering linear-time sequence modeling, selective state transitions, and hardware-friendly parallelism for long ECG recordings (Zhang et al., 3 Sep 2025).
A central claim of the model is that a clinically adequate ECG architecture should simultaneously analyze each lead individually, model within-lead temporal dependencies, and integrate cross-lead spatial information. This positioning is significant because it departs from designs that either collapse the 12 leads into a shared stream too early or emphasize only one of morphology, rhythm, or lead interaction. This suggests that S2M2ECG is best understood as an ECG-specific Mamba system rather than as a generic sequence model applied unchanged to biosignals.
2. State-space foundation and three-level fusion
The formal starting point is the continuous-time state space model
where is the hidden state, is the input, is the output, is the state transition matrix, is the input matrix, is the output matrix, and is a direct feed-through term. To operate on discrete ECG tokens, the model uses Zero-Order Hold discretization:
with
The paper also gives the equivalent convolution form
0
which is used to motivate linear-complexity long-range temporal modeling for ECG sequences (Zhang et al., 3 Sep 2025).
On top of this SSM foundation, S2M2ECG organizes its representation learning into three levels. The first level is low-level spatio-temporal fusion through segment tokenization and bi-directional SSM processing. The second level is intra-lead temporal fusion through forward and backward scanning, intended to enhance recognition accuracy in both directions. The third level is cross-lead spatial fusion through a dedicated lead fusion module. These three levels are embedded in a multi-branch design in which each lead has its own branch before fusion (Zhang et al., 3 Sep 2025).
The architectural consequence is that lead-wise locality, long-range temporal context, and cross-lead interaction are not treated as interchangeable operations. Instead, they are separated and fused in stages. A plausible implication is that this decomposition is meant to preserve clinically meaningful lead-specific projections before introducing global integration.
3. Architectural components
At a high level, the pipeline is: segment tokenization of each lead’s ECG waveform, lead-specific Mamba encoding with bi-directional scanning, a lead fusion module to combine the 12 lead representations, and a classification head to predict the ECG diagnosis (Zhang et al., 3 Sep 2025).
For lead 1, the segment-token sequence is written as
2
where 3 is the classification token, 4 is the 5-th segment token of lead 6, 7 is positional embedding, and 8 denotes scan direction. The tokenization is described as synchronous across leads, which preserves correspondence across time segments between leads while still allowing lead-specific analysis (Zhang et al., 3 Sep 2025).
The intra-lead temporal module uses bi-directional scanning. For each direction, the model computes state input and gating projections, applies local feature extraction, forms adaptive discrete SSM parameters, and updates the state-space dynamics:
9
0
1
2
3
4
after which forward and backward outputs are combined:
5
The lead feature is then propagated through a residual connection:
6
This stage is explicitly interpreted as intra-lead temporal fusion, and its rationale is that ECG diagnosis benefits from both preceding and following context, especially for rhythm-related abnormalities (Zhang et al., 3 Sep 2025).
The cross-lead spatial module follows lead-wise encoding. Each lead has a separate branch, with a separate token stream, encoder path, and lead-specific representation. Fusion is performed by a lead fusion module with two components: an FFN to enrich temporal feature diversity and a SENet to perform channel-wise lead weighting. The FFN expands and then restores feature dimensions, with hidden width twice the input dimension, and SENet compresses along the temporal dimension and reweights lead channels. The paper states that this allows individual lead analysis while ensuring integration, and that different pathologies are visible more strongly in different leads (Zhang et al., 3 Sep 2025).
4. Experimental protocol and reported performance
The evaluation covers four datasets: PTB-XL for morphological diagnosis, Chapman for rhythmic diagnosis, SNPH as a private clinical dataset simulating real hospital practice, and NFH as another clinical dataset also used for cross-database generalization. The class definitions reported in the paper are reproduced below.
| Dataset | Scenario | Classes |
|---|---|---|
| PTB-XL | Morphological diagnosis | N, MI, STTC, CD, HYP |
| Chapman | Rhythmic diagnosis | SB, SR, AFIB, GSVT |
| SNPH | Clinical dataset | N, PVC, PAC, TACH, BRAD |
| NFH | Clinical dataset | SB, SR, AFIB, GSVT |
The preprocessing pipeline consists of resampling from 500 Hz to 250 Hz, wavelet denoising using 9-level db6 decomposition, removing noisy components 7, 8, and 9, and z-score normalization
0
The reported metrics are Accuracy, Precision, Recall, 1-score, and AUC / AUROC, with the explicit note that 2 and AUC are more reliable than accuracy under class imbalance (Zhang et al., 3 Sep 2025).
The main reported comparison numbers for S2M2ECG are as follows.
| Dataset | Reported metrics |
|---|---|
| Chapman | Acc 0.928, F1 0.918, AUC 0.981 |
| PTB-XL | Acc 0.757, F1 0.637, AUC 0.883 |
| SNPH | Acc 0.913, F1 0.921, AUC 0.985 |
The paper’s scenario-specific interpretation is that rhythmic scenarios are where S2M2ECG performs especially well, because Mamba’s long-range temporal modeling fits rhythm diagnosis; morphological scenarios are competitive but not always best, because CNNs’ local inductive bias is still very strong for fine waveform details; and clinical scenarios on SNPH and NFH show robust performance and generalization. A cross-database transfer experiment between Chapman and NFH is reported to remain strong with little degradation, including good performance from Chapman to NFH and from NFH to Chapman, sometimes even improved due to larger training scale in NFH (Zhang et al., 3 Sep 2025).
5. Efficiency profile, ablations, and limitations
A defining characteristic of S2M2ECG is its lightweight deployment profile. The paper reports about 3M parameters, states that compared with attention-based models it uses roughly one order of magnitude fewer parameters, and describes the model as linear-time because it is built on SSM/Mamba rather than attention. For CPU deployment using ONNX, inference time ranges from about 4 ms to 5 ms, with best settings around 6 ms, 7 ms, and 8 ms on the tested datasets. Memory usage is reported around 9 MB to 0 MB (Zhang et al., 3 Sep 2025).
The ablation study identifies several model-selection patterns. Segment length and scanning step are dataset-dependent: Chapman works best with segment length 1 and step 2; PTB-XL works best with 3 and 4; and SNPH works best with 5 and 6. The reported interpretation is that rhythm datasets prefer larger segments to capture long intervals, morphology datasets prefer smaller segments to preserve local detail, and there is a trade-off between local detail and computation. For block depth, the tested values are 6, 12, 18, and 24, with 12 Mamba blocks reported as the best overall setting. For feature dimension, the tested values are 24, 48, 96, 192, and 384, with the best dimension depending on dataset: 192 for Chapman and SNPH, and 48 for PTB-XL (Zhang et al., 3 Sep 2025).
Additional ablations reinforce the ECG-specific design choices. Bi-directional scanning improves performance across almost all metrics and datasets. Removing the ECG-specific multi-branch structure reduces performance substantially. Replacing the lead fusion module with simple concatenation degrades performance, so the FFN + SENet fusion is identified as important for effective cross-lead integration (Zhang et al., 3 Sep 2025).
The limitations stated in the paper are also specific. S2M2ECG is not universally best on morphology-heavy datasets such as PTB-XL, where CNNs still have an advantage, and explainability remains limited compared with attention maps or CNN heatmaps. These limitations are consequential because they identify the regime where the Mamba-centered design is strongest—rhythm and clinical scenarios—and where hybridization with stronger local morphology extractors may be a plausible next step.
6. Relation to adjacent ECG research and terminological distinctions
S2M2ECG belongs to a diagnostic modeling lineage centered on multi-lead ECG representation learning, but it should be distinguished from several neighboring directions. First, it is not the same as the 2019 “mixed-transform, 2D ECG compression method” that converts a 1D ECG record into a 2D array of aligned heartbeats and applies the 1D cdf97 DWT on the rows and the 1D DCT on the columns. That work is a lossy ECG compression codec evaluated on the MIT-BIH Arrhythmia database, and the summary explicitly states that “in this paper it is not named S2M2ECG” (Chagnon et al., 2019).
Second, S2M2ECG is distinct from multimodal ECG-language systems such as Heartcare Suite. Heartcare Suite comprises Heartcare-220K, Heartcare-Bench, and HeartcareGPT with the Beat tokenizer, where raw multi-lead ECG is converted into discrete tokens via patch embedding, query-centered Transformer encoding, dual-level vector quantization, and a query-guided bidirectional diffusion mechanism. That framework is directed toward fine-grained ECG multimodal understanding, including diagnosis, waveform morphology analysis, rhythm interpretation, report generation, and signal prediction, rather than toward a lightweight Mamba classifier (Xie et al., 6 Jun 2025).
Third, S2M2ECG is distinct from signal reconstruction systems such as the multi-channel masked autoencoder (MCMA), which reconstructs 12-lead ECG from an arbitrary single-lead ECG through a convolutional autoencoder and is evaluated with ECGGenEval at signal-level, feature-level, and diagnostic-level. The MCMA summary explicitly notes that the paper “does not mention S2M2ECG anywhere” and that MCMA is the paper’s actual named method (Chen et al., 2024).
A plausible implication of these distinctions is that S2M2ECG occupies a specific point in the ECG-method design space: it is a classification-oriented, ECG-tailored Mamba architecture emphasizing lead-wise processing, bidirectional temporal context, and lightweight inference. Compression-oriented 2D codecs, multimodal tokenization systems, and arbitrary-single-lead reconstruction models address adjacent but different objectives.