# Explainable Electrocardiogram Analysis with Wave Decomposition: Application to Myocardial Infarction Detection

Yingyu Yang, Marie Rocher, Pamela Moceri, Maxime Sermesant

► To cite this version:

Yingyu Yang, Marie Rocher, Pamela Moceri, Maxime Sermesant. Explainable Electrocardiogram Analysis with Wave Decomposition: Application to Myocardial Infarction Detection. STACOM 2022 - 13th workshop on Statistical Atlases and Computational Models of the Heart, Sep 2022, Singapore, Singapore. hal-03888791v2

HAL Id: hal-03888791

https://inria.hal.science/hal-03888791v2

Submitted on 3 Jun 2024

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_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Explainable Electrocardiogram Analysis with Wave Decomposition: Application to Myocardial Infarction Detection

Yingyu Yang, Marie Rocher, Pamela Moceri, Maxime Sermesant

► To cite this version:

Yingyu Yang, Marie Rocher, Pamela Moceri, Maxime Sermesant. Explainable Electrocardiogram Analysis with Wave Decomposition: Application to Myocardial Infarction Detection. STACOM 2022 - 13th workshop on Statistical Atlases and Computational Models of the Heart, Sep 2022, Singapore, Singapore. hal-03888791v2

HAL Id: hal-03888791

https://inria.hal.science/hal-03888791v2

Submitted on 3 Jun 2024

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_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Explainable Electrocardiogram Analysis with Wave Decomposition: Application to Myocardial Infarction Detection

Yingyu Yang¹, Marie Rocher², Pamela Moceri², Maxime Sermesant¹

¹ Université Côte d'Azur, Inria Epione Team, Sophia Antipolis, France

² UR2CA, Université Côte d'Azur, Faculté de Médecine, Nice, France

**Abstract.** Automatic analysis of electrocardiograms with adequate explainability is a challenging task. Many deep learning based methods have been proposed for automatic classification of electrocardiograms. However, very few of them provide detailed explainable classification evidence. In our study, we explore explainable ECG classification through explicit decomposition of single-beat (median-beat) ECG signal. In particular, every single-beat ECG sample is decomposed into five subwaves and each subwave is parameterised by a Frequency Modulated Moebius. Those parameters have explicit meanings for ECG interpretation. Instead of solving the optimisation problem iteratively which is time-consuming, we make use of a Cascaded CNN network to estimate the parameters for each single-beat ECG signal. Our preliminary results show that with appropriate position regularisation strategy, our neural network is able to estimate the subwave for P, Q, R, S, T events and maintain a good reconstruction accuracy (with R2 score 0.94 on test dataset of PTB-XL) in an unsupervised manner. Using the estimated parameters, we achieve very good classification and generalisation performance on myocardial infarction detection on four different datasets. The features of high importance are in accordance with clinical interpretations. Our project is open-source (https://gitlab.inria.fr/epione/ecgdecomposition).

**Keywords:** ECG analysis · Reconstruction · Explainable ML · Myocardial infarction classification.

## 1 Introduction

Myocardial infarction (MI) is a kind of pathology where myocardial cells are dead due to the prolonged lack of oxygen (ischaemia). A patient is diagnosed as MI if he/she has elevated cardiac troponin values and falls into at least one of the following conditions: symptoms of myocardial ischaemia, new changes of ST-segment/T-wave in electrocardiogram (ECG), development of pathological Q waves in ECG, abnormal myocardium motion and presence of coronary thrombus [22]. Among all the diagnostic approaches, ECG is very easy and fast to perform on patients, even with non-experts. Whereas, to diagnose MI patients with ECG is a challenging task. For example, one study shows that experienced
Explainable Electrocardiogram Analysis with
Wave Decomposition: Application to Myocardial
Infarction Detection

Yingyu Yang¹, Marie Rocher², Pamela Moceri², Maxime Sermesant¹

¹ Université Côte d'Azur, Inria Epione Team, Sophia Antipolis, France

² UR2CA, Université Côte d'Azur, Faculté de Médecine, Nice, France

**Abstract.** Automatic analysis of electrocardiograms with adequate explainability is a challenging task. Many deep learning based methods have been proposed for automatic classification of electrocardiograms. However, very few of them provide detailed explainable classification evidence. In our study, we explore explainable ECG classification through explicit decomposition of single-beat (median-beat) ECG signal. In particular, every single-beat ECG sample is decomposed into five subwaves and each subwave is parameterised by a Frequency Modulated Moebius. Those parameters have explicit meanings for ECG interpretation. In stead of solving the optimisation problem iteratively which is time-consuming, we make use of an Cascaded CNN network to estimate the parameters for each single-beat ECG signal. Our preliminary results show that with appropriate position regularisation strategy, our neural network is able to estimate the subwave for P, Q, R, S, T events and maintain a good reconstruction accuracy (with R2 score 0.94 on test dataset of PTB-XL) in a unsupervised manner. Using the estimated parameters, we achieve very good classification and generalisation performance on myocardial infarction detection on four different datasets. The features of high importance are in accordance with clinical interpretations. Our project is open-source (https://gitlab.inria.fr/epione/ecgdecomposition).

**Keywords:** ECG analysis · Reconstruction · Explainable ML · Myocardial infarction classification.

# 1 Introduction

Myocardial infarction (MI) is a kind of pathology where myocardial cells are dead due to the prolonged lack of oxygen (ischaemia). A patient is diagnosed as MI if he/she has elevated cardiac troponin values and falls into at least one of the following conditions: symptoms of myocardial ischaemia, new changes of ST-segment/T-wave in electrocardiogram (ECG), development of pathological Q waves in ECG, abnormal myocardium motion and presence of coronary thrombus [22]. Among all the diagnostic approaches, ECG is very easy and fast to perform on patients, even with non-experts. Whereas, to diagnose MI patients with ECG is a challenging task. For example, one study shows that experienced
cardiologists only identified 82% of the real ST-segment elevated MI patients [17]. Computer-assisted ECG analysis could help cardiologists, non-experts better interpret ECG recordings for MI detection.

There exist many research works on automatic MI detection using ECG signals and they can be categorised into feature-based methods and neural network based methods. The feature-based methods usually contains three stages: ECG delineation (segmentation), feature extraction and classification. Different kinds of features were explored: morphological features (such as ST-elevation value, QRS duration, T wave amplitude, Q wave amplitude etc.) [4, 10, 14], wavelet transform related features (coefficients) [5, 11, 19], empirical mode decomposition features [1] and so on. Compared with other features, morphological features are explainable but very sensitive to ECG delineation results. ECG delineation methods [9, 18], usually depend on annotations for all the events (P,Q,R,S,T) to train models. They are constrained by the size and type of pathology in the annotated dataset. The neural network based methods for MI detection have overwhelmed in recent years. For example, single-beat ECG signals are directly classified using a 1D convolutional neural network (CNN) [2] or are transformed into 12-lead 2D image for a 2D CNN [7]. For detailed review of MI detection methods, interested readers are invited to read reviews [3, 24].

In our work, we tackle this MI detection problem following the feature-based approach by ECG parameterisation. Actually, ECG parameterisation/modelling is not a new idea. For example, Liu et al. proposed to fit a 20th order polynomial function to a given ECG signal and used the fitted coefficients as ECG features [12]. Second-order ODEs were applied to model the 12-lead ECGs and the estimated time-varying coefficients were used as features [25]. They both achieved good accuracy for MI detection but the features do not have an explainable meaning for clinicians. In our case, we adapt the explainable Frequency Modulated Moebius model as our parameterisation model [20] for single-beat ECG.

The contribution of our work lies in two folds.

- We propose a time-efficient and automatic pipeline for ECG decomposition and reconstruction by passing through a deep learning model: Cascaded FMMnet, which is capable to reconstruct single beat signal with high quality. The training is unsupervised and make it accessible for all kinds of ECG datasets, with or without annotations. The estimated parameters have explainable meanings for each subwave, such as the amplitude, the position etc.

- We present our preliminary results of using the estimated parameters as features to classify normal and myocardial infarction patients. The important features identified are in accordance with the clinical interpretation indexes, such as T wave and Q wave change.
cardiologists only identified 82% of the real ST-segment elevated MI patients [17]. Computer-assisted ECG analysis could help cardiologists, non-experts better interpret ECG recordings for MI detection.

There exist many research works on automatic MI detection using ECG signals and they can be categorised into feature-based methods and neural network based methods. The feature-based methods usually contains three stages: ECG delineation (segmentation), feature extraction and classification. Different kinds of features were explored: morphological features (such as ST-elevation value, QRS duration, T wave amplitude, Q wave amplitude etc.) [4, 10, 14], wavelet transform related features (coefficients) [5, 11, 19], empirical mode decomposition features [1] and so on. Compared with other features, morphological features are explainable but very sensitive to ECG delineation results. ECG delineation methods [9, 18], usually depend on annotations for all the events (P,Q,R,S,T) to train models. They are constrained by the size and type of pathology in the annotated dataset. The neural network based methods for MI detection have overwhelmed in recent years. For example, single-beat ECG signals are directly classified using a 1D convolutional neural network (CNN) [2] or are transformed into 12-lead 2D image for a 2D CNN [7]. For detailed review of MI detection methods, interested readers are invited to read reviews [3, 24].

In our work, we tackle this MI detection problem following the feature-based approach by ECG parameterisation. Actually, ECG parameterisation/modelling is not a new idea. For example, Liu et al. proposed to fit a 20th order polynomial function to a given ECG signal and used the fitted coefficients as ECG features [12]. Second-order ODEs were applied to model the 12-lead ECGs and the estimated time-varying coefficients were used as features [25]. They both achieved good accuracy for MI detection but the features do not have an explainable meaning for clinicians. In our case, we adapt the explainable Frequency Modulated Moebius model as our parameterisation model [20] for single-beat ECG.

The contribution of our work lies in two folds.

- We propose a time-efficient and automatic pipeline for ECG decomposition and reconstruction by passing through a deep learning model: Cascaded FMMnet, which is capable to reconstruct single beat signal with high quality. The training is unsupervised and make it accessible for all kinds of ECG datasets, with or without annotations. The estimated parameters have explainable meanings for each subwave, such as the amplitude, the position etc.

- We present our preliminary results of using the estimated parameters as features to classify normal and myocardial infarction patients. The important features identified are in accordance with the clinical interpretation indexes, such as T wave and Q wave change.
## 2 Methods

The pipeline of our explainable ECG analysis consists of three stages (Fig.1(a)). First, the 12-lead ECG recordings are filtered and segmented to obtain single-beat median ECG signals. Second, each lead-wise median signal is passed through an encoder network (Cascaded FMMnet) for subwave decomposition. The encoder network outputs 21 estimated parameters that are crucial for signal reconstruction and interpretation. Third, for each sample (12-lead median ECG signal), myocardial infarction classification is conducted based on the 264(21x12+12) estimated parameters, where 12 additional parameters comes from estimated ST-segment voltage value. To explain the classification result, we use the additive weighted features for linear classification models and SHAP value [15] for nonlinear classification models. Decomposed waveform and feature importance from classifier together give visual and quantitative explainability of our prediction result.

### 2.1 Data Preprocessing

The preprocessing includes 5 steps: resampling, filtering, R-peak detection, ECG segmentation and median signal generation.

The original 12-lead ECG recording is resampled to 500Hz if its original sampling rate is not 500Hz. A butterworth high-pass filter with cutoff frequency at 0.5Hz is then applied to remove baseline wander. The R-peaks of Lead II are automatically detected and used as reference for all the other leads. For every lead ECG, each single beat segment is set from 35% heart beat duration (s) before the R-peak to 50% heart beat duration (s) after the R-peak. One 1.2-second median beat signal is calculated by aligning the R-peaks of all the single beats (at 0.5-second position) and padded by neighbouring values at the two ends if the medial signal is shorter than 1.2s. Neurokit2 package [16] is used for filtering, R-peak detection and single beat segment calculation.

### 2.2 Cascaded FMMnet

In order to reinforce explain-ability in automatic ECG analysis, we utilise the decomposition model proposed by [20]. The idea is to approximate the single-beat ECG signal by composition of five subwaves (P,Q,R,S,T), each of which is parameterised by a Frequency Modulated Moebius.

Assuming $X(t_i), t_i \in [0, 2\pi]$, the original signal of a single-beat ECG record, could be decomposed into five subwaves $W_s, s \in \{P, Q, R, S, T\}$. Each subwave is described by a four-dimensional parameter $p_s = \{A_s, \alpha_s, \beta_s, \omega_s\}$ respectively,

$$W_s(t, p_s) = A_s \cos(\beta_s + 2\arctan(\omega_s \tan(\frac{t - \alpha_s}{2}))) \quad (1)$$

where $A, \alpha, \beta, \omega$ control the absolute amplitude, the position, the skewness and the kurtosis of the waveform (see Fig.1 (c)(d)). The approximation of original
## 2 Methods

The pipeline of our explainable ECG analysis consists of three stages (Fig.1(a)). First, the 12-lead ECG recordings are filtered and segmented to obtain single-beat median ECG signals. Second, each lead-wise median signal is passed through an encoder network (Cascaded FMMnet) for subwave decomposition. The encoder network outputs 21 estimated parameters that are crucial for signal reconstruction and interpretation. Third, for each sample (12-lead median ECG signal), myocardial infarction classification is conducted based on the 264(21x12+12) estimated parameters, where 12 additional parameters comes from estimated ST-segment voltage value. To explain the classification result, we use the additive weighted features for linear classification models and SHAP value [15] for nonlinear classification models. Decomposed waveform and feature importance from classifier together give visual and quantitative explainability of our prediction result.

### 2.1 Data Preprocessing

The preprocessing includes 5 steps: resampling, filtering, R-peak detection, ECG segmentation and median signal generation.

The original 12-lead ECG recording is resampled to 500Hz if its original sampling rate is not 500Hz. A butterworth high-pass filter with cutoff frequency at 0.5Hz is then applied to remove baseline wander. The R-peaks of Lead II are automatically detected and used as reference for all the other leads. For every lead ECG, each single beat segment is set from 35% heart beat duration (s) before the R-peak to 50% heart beat duration (s) after the R-peak. One 1.2-second median beat signal is calculated by aligning the R-peaks of all the single beats (at 0.5-second position) and padded by neighbouring values at the two ends if the medial signal is shorter than 1.2s. Neurokit2 package [16] is used for filtering, R-peak detection and single beat segment calculation.

### 2.2 Cascaded FMMnet

In order to reinforce explain-ability in automatic ECG analysis, we utilise the decomposition model proposed by [20]. The idea is to approximate the single-beat ECG signal by composition of five subwaves (P,Q,R,S,T), each of which is parameterised by a Frequency Modulated Moebius.

Assuming $X(t_i), t_i \in [0, 2\pi]$, the original signal of a single-beat ECG record, could be decomposed into five subwaves $W_s, s \in \{P, Q, R, S, T\}$. Each subwave is described by a four-dimensional parameter $p_s = \{A_s, \alpha_s, \beta_s, \omega_s\}$ respectively,

$$W_s(t, p_s) = A_s \cos(\beta_s + 2 \arctan(\omega_s \tan(\frac{t - \alpha_s}{2}))) \quad (1)$$

where $A, \alpha, \beta, \omega$ control the absolute amplitude, the position, the skewness and the kurtosis of the waveform (see Fig.1 (c)(d)). The approximation of original
<figure><img src="image_2.png" /><figcaption>Fig. 1: (a) Pipeline of our proposed explainable ECG classification. (b) An example of ECG decomposition. (c) $\omega$ controls the kurtosis of the wave signal. (d) $\beta$ controls the skewness of the wave signal.</figcaption></figure>

signal $\hat{X}(t)$ is defined as the addition of the five subwaves $W_s$ and an additional baseline parameter $M$,

$$ \hat{X}(t, \theta, M) = M + \sum_{s \in \{P,Q,R,S,T\}} W_s(t, p_s) \quad (2) $$

where $\theta = (M, p_S, p_Q, p_R, p_S, p_T)$ and they verify the following ranges

- 1. $M \in \mathcal{R}$

- 2. $p_s \in \mathcal{R}^+ \times [0, 2\pi] \times [0, 2\pi] \times [0, 1], s \in \{P, Q, R, S, T\}$

- 3. $\alpha_P \le \alpha_Q \le \alpha_R \le \alpha_S \le \alpha_T$

The aim of decomposition is to estimate the optimal 21 parameters $\hat{\theta}$ that best fit $\hat{\theta} = \operatorname{argmin}_{\theta} \sum_{i=1}^{n} [X(t_i) - \hat{X}(t_i)]^2$.

Instead of using the computationally intensive iterative optimisation [20], we estimate the 21 parameters through a data-driven deep learning model: Cascaded FMMnet. The network consists of 5 identical cascaded sub-network, each of which is responsible for estimating 5 parameters ($M_i, A_i, \alpha_i, \beta_i, \omega_i$) of one sub-wave $S_i$, where $S_i(t) = M_i + A_i \cos(\beta_i + 2 \arctan(\omega_i \tan(\frac{t-\alpha_i}{2})))$. Assuming the original signal $X(t)$, the input of the $i$th subnet $X_i(t)$ is the residual of the original signal subtracting former subwaves, i.e. $X_i(t) = X_{i-1}(t) - S_{i-1}(t)$, where $i \in [1, 5]$, $X_0(t) = X(t)$, $S_0(t) = 0$.

The encoder block in our network comprises 2 stacks of causal convolution with down-sampled skip-connection, 1 max-pooling layer and 2 linear layers. It takes an input of 1x600 dimension and outputs a 21-dimension vector which is the estimation of the parameters. The input median ECG signal is resized to be within the range of $[-1, 1]$ and the last linear layer has a Sigmoid activation for ($A_i, \alpha_i, \beta_i, \omega_i$) and a Tanh activation for $M_i$ parameter. The final $M$ is the sum of all the $M_i, i \in [1, 5]$. The final estimation of $\theta$ are obtained by multiplying $M$, $A_i$ with the resize factor and by multiplying $\alpha_i, \beta_i$ with $2\pi$.
<figure><img src="image_2.png" /><figcaption>Fig. 1: (a) Pipeline of our proposed explainable ECG classification. (b) An example of ECG decomposition. (c)ω controls the kurtosis of the wave signal. (d) β controls the skewness of the wave signal.</figcaption></figure>

signal $\hat{X}(t)$ is defined as the addition of the five subwaves $W_s$ and an additional baseline parameter $M$,

$$ \hat{X}(t, \theta, M) = M + \sum_{s \in \{P,Q,R,S,T\}} W_s(t, p_s) \quad (2) $$

where $\theta = (M, p_S, p_Q, p_R, p_S, p_T)$ and they verify the following ranges

- 1. $M \in \mathcal{R}$

- 2. $p_s \in \mathcal{R}^+ \times [0, 2\pi] \times [0, 2\pi] \times [0, 1], s \in \{P, Q, R, S, T\}$

- 3. $\alpha_P \le \alpha_Q \le \alpha_R \le \alpha_S \le \alpha_T$

The aim of decomposition is to estimate the optimal 21 parameters $\hat{\theta}$ that best fit $\hat{\theta} = \operatorname{argmin}_{\theta} \sum_{i=1}^{n} [X(t_i) - \hat{X}(t_i)]^2$.

Instead of using the computationally intensive iterative optimisation [20], we estimate the 21 parameters through a data-driven deep learning model: Cascaded FMMnet. The network consists of 5 identical cascaded sub-network, each of which is responsible for estimating 5 parameters ($M_i, A_i, \alpha_i, \beta_i, \omega_i$) of one sub-wave $S_i$, where $S_i(t) = M_i + A_i \cos(\beta_i + 2 \arctan(\omega_i \tan(\frac{t-\alpha_i}{2})))$. Assuming the original signal $X(t)$, the input of the ith subnet $X_i(t)$ is the residual of the original signal subtracting former subwaves, i.e. $X_i(t) = X_{i-1}(t) - S_{i-1}(t)$, where $i \in [1, 5]$, $X_0(t) = X(t)$, $S_0(t) = 0$.

The encoder block in our network comprises 2 stacks of causal convolution with down-sampled skip-connection, 1 max-pooling layer and 2 linear layers. It takes an input of 1x600 dimension and outputs a 21-dimension vector which is the estimation of the parameters. The input median ECG signal is resized to be within the range of [-1, 1] and the last linear layer has a Sigmoid activation for ($A_i, \alpha_i, \beta_i, \omega_i$) and a Tanh activation for $M_i$ parameter. The final $M$ is the sum of all the $M_i, i \in [1, 5]$. The final estimation of $\theta$ are obtained by multiplying $M$, $A_i$ with the resize factor and by multiplying $\alpha_i, \beta_i$ with $2\pi$.
<figure><img src="image_3.png" /><figcaption>Fig. 2: The detailed architecture of Cascaded FMM net.</figcaption></figure>

We penalise the network by minimising the mean square error of reconstructed signal $S_i(t)$ and the input signal $X_i(t)$. In order to force each subnet to capture a fixed subwave, a regulariser called prior loss is added in the loss function. We randomly chose 100 median ECG samples and estimated the 21 hidden parameters (5 hidden waves) using the FMM R package [21]. The mean $\mu_\alpha$ and variance $\sigma_\alpha^2$ of parameter $\alpha$ are computed and are used to constrain the subwaves' position. We let the Cascaded FMMnet estimate the T,R,S,P,Q subwaves sequentially by regularising the position $\alpha$ to be close to its corresponding pre-calculated distribution. The total loss function is

$$loss = loss_{mse} + \gamma loss_{prior} \quad (3)$$

$$= \sum_{i=1}^{5} |X_{i}(t) - S_{i}(t)|^{2} + \gamma \sum_{i=1}^{5} \frac{(\alpha_{i} - \mu_{\alpha})^{2}}{\sigma_{\alpha}^{2}} \quad (4)$$

where $\gamma$ controls the balance of signal fitting and parameter distribution.

In order to ease the estimation for all leads, we assume that the P,Q,R,S,T are sequentially positioned in all single beat ECG, which may be different with the conventional names of ECG wave peaks in some leads. For example, in Fig.6(a), the decomposed Q wave represents the conventional R wave for lead V1.

# 3 Experiments and Results

## 3.1 Datasets

<table><caption>Table 1: The detailed information of the 4 datasets used in our study. AMI/IMI/LMI refer to anterior/inferior/lateral myocardial infarction.</caption><thead><tr><th>Dataset</th><th>NORM</th><th>MI</th><th>AMI</th><th>IMI</th><th>LMI</th><th>Frequency(Hz)</th><th>Folds</th></tr></thead><tbody><tr><td>PTB-XL [23]</td><td>7185</td><td>2955</td><td>1937</td><td>1447</td><td>70</td><td>500</td><td>10</td></tr><tr><td>PTB [6]</td><td>80</td><td>368</td><td>181</td><td>175</td><td>130</td><td>1000</td><td>5</td></tr><tr><td>CPSC(+Extra) [13]</td><td>922</td><td>370</td><td>-</td><td>-</td><td>-</td><td>500</td><td>5</td></tr><tr><td>CHU</td><td>9</td><td>12</td><td>-</td><td>-</td><td>-</td><td>Paper scan</td><td>-</td></tr></tbody></table>
<figure><img src="image_3.png" /><figcaption>Fig. 2: The detailed architecture of Cascaded FMM net.</figcaption></figure>

We penalise the network by minimising the mean square error of reconstructed signal $S_i(t)$ and the input signal $X_i(t)$. In order to force each subnet to capture a fixed subwave, a regulariser called prior loss is added in the loss function. We randomly chose 100 median ECG samples and estimated the 21 hidden parameters (5 hidden waves) using the FMM R package [21]. The mean $\mu_\alpha$ and variance $\sigma_\alpha^2$ of parameter $\alpha$ are computed and are used to constrain the subwaves' position. We let the Cascaded FMMnet estimate the T,R,S,P,Q subwaves sequentially by regularising the position $\alpha$ to be close to its corresponding pre-calculated distribution. The total loss function is

$$loss = loss_{mse} + \gamma loss_{prior} \quad (3)$$

$$= \sum_{i=1}^{5} |X_{i}(t) - S_{i}(t)|^{2} + \gamma \sum_{i=1}^{5} \frac{(\alpha_{i} - \mu_{\alpha})^{2}}{\sigma_{\alpha}^{2}} \quad (4)$$

where $\gamma$ controls the balance of signal fitting and parameter distribution.

In order to ease the estimation for all leads, we assume that the P,Q,R,S,T are sequentially positioned in all single beat ECG, which may be different with the conventional names of ECG wave peaks in some leads. For example, in Fig.6(a), the decomposed Q wave represents the conventional R wave for lead V1.

# 3 Experiments and Results

## 3.1 Datasets

<table><caption>Table 1: The detailed information of the 4 datasets used in our study. AMI/IMI/LMI refer to anterior/inferior/lateral myocardial infarction.</caption><thead><tr><th>Dataset</th><th>NORM</th><th>MI</th><th>AMI</th><th>IMI</th><th>LMI</th><th>Frequency(Hz)</th><th>Folds</th></tr></thead><tbody><tr><td>PTB-XL [23]</td><td>7185</td><td>2955</td><td>1937</td><td>1447</td><td>70</td><td>500</td><td>10</td></tr><tr><td>PTB [6]</td><td>80</td><td>368</td><td>181</td><td>175</td><td>130</td><td>1000</td><td>5</td></tr><tr><td>CPSC(+Extra) [13]</td><td>922</td><td>370</td><td>-</td><td>-</td><td>-</td><td>500</td><td>5</td></tr><tr><td>CHU</td><td>9</td><td>12</td><td>-</td><td>-</td><td>-</td><td>Paper scan</td><td>-</td></tr></tbody></table>
We included three public ECG datasets and one private dataset in our study. All the four datasets contain standard 12-lead ECG recordings and are (re)sampled to 500Hz. The PTB-XL dataset [23] contains 21837 12-lead ECG recordings and covers multiple ECG diagnostics and morphologies. Our Cascaded FMMnet is trained on this big dataset without considering specific pathology. For classification, as we are concerned about detecting myocardial infarction (MI) patients from normal (NORM) cases, we present the detailed information of MI and NORM across different datasets in Table 1. The private dataset (CHU) is collected from Nice University Hospital in scanned PDF format. Specific preprocessing is conducted to digitalize the ECG signals [8].

## 3.2 Reconstruction

**Experiment** The PTB-XL dataset is used to train the Cascaded FMMnet. As it is provided with 10 pre-defined folds, we randomly choose 8 folds as training set, 1 fold as validation set and the rest fold as test set. 100 random samples from training set are picked to compute the mean and variance used in regulariser (equation 4). The encoder network is implemented in Pytorch and is trained with batch size of 192, learning rate of 0.0001. $\gamma$ is initialised from 1 and it is updated to $\gamma = 0.1\gamma$ if $loss_{mse} \le \gamma loss_{prior}$.

**Results** We evaluated the reconstruction performance by mean absolute error ($MAE = \frac{1}{600} \sum_{i=1}^{600} |X(t_i) - \hat{X}(t_i)|$) and R2 score. The proposed Cascaded FMMnet demonstrated very good reconstruction results and generalised well on three unseen datasets from different centers. First, the FMMnet was trained on 80% of the whole PTB-XL dataset and it demonstrated similar reconstruction result on the train/validation/test set of PTB-XL: they all presented a mean MAE of 0.016mV and a mean R2 score of 0.94. Second, all the four datasets showed consistent reconstruction error on NORM/MI patients (Fig.3(a-b)) and lead-wisely (Fig.3(c-d)). Our Cascaded FMMnet takes 0.09s/12 leads on a Dell laptop (Intel® Core™ i7-8650U CPU @ 1.90GHz × 4) while the original FMM optimisation [21] takes more than 10s/1 lead on the same machine. We show an example of 12-lead ECG decomposition in Fig.6(a).

## 3.3 Classification

**Experiment** For each 12-lead ECG sample (median beat), we obtain a 252-dimension feature vector from the Cascaded FMMnet. In addition, we include ST-segment voltage feature for each lead to form a 264-dimension vector. The ST-segment is identified as the short flat platform between peak S and peak T from each lead with the help of positional parameter $\alpha_T$ and $\alpha_S$.

*Explainable classification:* we explored two approaches to provide explainable classification. The first method begins with a partial least squares regression
We included three public ECG datasets and one private dataset in our study. All the four datasets contain standard 12-lead ECG recordings and are (re)sampled to 500Hz. The PTB-XL dataset [23] contains 21837 12-lead ECG recordings and covers multiple ECG diagnostics and morphologies. Our Cascaded FMMnet is trained on this big dataset without considering specific pathology. For classification, as we are concerned about detecting myocardial infarction (MI) patients from normal (NORM) cases, we present the detailed information of MI and NORM across different datasets in Table 1. The private dataset (CHU) is collected from Nice University Hospital in scanned PDF format. Specific preprocessing is conducted to digitalize the ECG signals [8].

## 3.2 Reconstruction

**Experiment** The PTB-XL dataset is used to train the Cascaded FMMnet. As it is provided with 10 pre-defined folds, we randomly choose 8 folds as training set, 1 fold as validation set and the rest fold as test set. 100 random samples from training set are picked to compute the mean and variance used in regulariser (equation 4). The encoder network is implemented in Pytorch and is trained with batch size of 192, learning rate of 0.0001. $\gamma$ is initialised from 1 and it is updated to $\gamma = 0.1\gamma$ if $loss_{mse} \le \gamma loss_{prior}$.

**Results** We evaluated the reconstruction performance by mean absolute error ($MAE = \frac{1}{600} \sum_{i=1}^{600} |X(t_i) - \hat{X}(t_i)|$) and R2 score. The proposed Cascaded FMMnet demonstrated very good reconstruction results and generalised well on three unseen datasets from different centers. First, the FMMnet was trained on 80% of the whole PTB-XL dataset and it demonstrated similar reconstruction result on the train/validation/test set of PTB-XL: they all presented a mean MAE of 0.016mV and a mean R2 score of 0.94. Second, all the four datasets showed consistent reconstruction error on NORM/MI patients (Fig.3(a-b)) and lead-wisely (Fig.3(c-d)). Our Cascaded FMMnet takes 0.09s/12 leads on a Dell laptop (Intel® Core™ i7-8650U CPU @ 1.90GHz × 4) while the original FMM optimisation [21] takes more than 10s/1 lead on the same machine. We show an example of 12-lead ECG decomposition in Fig.6(a).

## 3.3 Classification

**Experiment** For each 12-lead ECG sample (median beat), we obtain a 252-dimension feature vector from the Cascaded FMMnet. In addition, we include ST-segment voltage feature for each lead to form a 264-dimension vector. The ST-segment is identified as the short flat platform between peak S and peak T from each lead with the help of positional parameter $\alpha_T$ and $\alpha_S$.

*Explainable classification:* we explored two approaches to provide explainable classification. The first method begins with a partial least squares regression
<figure><img src="image_4.png" /><figcaption>Fig. 3: (a-b) The reconstruction metrics of different evaluation datasets on HC/MI separately. (c-d) Lead-wise R2 score of signal reconstruction of NORM patients and MI patients.</figcaption></figure>

that projects the 264-dimension vector to 3-dimension. A support vector machine (SVM) with linear kernel is applied then to find the best hyperplane that separates the MI/NORM patients. The additive nature of weighted features help to explain the classification results. The second method is to use SHAP value to explain a Logistic regression (LR) model for MI/NORM classification. We trained separate classifiers on PTB-XL, PTB and CPSC(+extra) datasets using 10-fold, 5-fold, 5-fold cross-validation respectively. Two more specific classifiers for detecting AMI/IMI (vs. non AMI/IMI) were established on PTB-XL using 10-fold cross-validation.

*Generalisable classification:* we tested the classifiers trained on PTB-XL to other three datasets: PTB, CPSC(+extra) and our private dataset (CHU) to evaluate the generalisation of our proposed classification pipeline.

<table><caption>Table 2: Classification results on different datasets using Cascaded FMM net.</caption><thead><tr><th>Model</th><th>Dataset (evaluation)</th><th>Dataset (train)</th><th>Class</th><th>CV</th><th>AUROC</th><th>Accuracy</th><th>Sensitivity</th><th>Specificity</th></tr></thead><tbody><tr><td>VGG [7]</td><td>PTB-XL</td><td>PTB-XL</td><td>MI</td><td>10-fold</td><td>1.00</td><td>0.97</td><td>0.96</td><td>0.98</td></tr><tr><td>Ours (LR)</td><td>PTB-XL</td><td>PTB-XL</td><td>MI</td><td>10-fold</td><td>0.99</td><td>0.96</td><td>0.93</td><td>0.96</td></tr><tr><td>Ours (SVM)</td><td>PTB-XL</td><td>PTB-XL</td><td>MI</td><td>10-fold</td><td>0.98</td><td>0.94</td><td>0.92</td><td>0.95</td></tr><tr><td>Ours (LR)</td><td>PTB-XL</td><td>PTB-XL</td><td>AMI</td><td>10-fold</td><td>0.98</td><td>0.93</td><td>0.92</td><td>0.93</td></tr><tr><td>Ours (LR)</td><td>PTB-XL</td><td>PTB-XL</td><td>IMI</td><td>10-fold</td><td>0.97</td><td>0.91</td><td>0.92</td><td>0.91</td></tr><tr><td>VGG [7]</td><td>PTB</td><td>PTB</td><td>MI</td><td>5-fold</td><td>0.98</td><td>0.96</td><td>0.97</td><td>0.91</td></tr><tr><td>Ours (LR)</td><td>PTB</td><td>PTB</td><td>MI</td><td>5-fold</td><td>0.95</td><td>0.91</td><td>0.92</td><td>0.88</td></tr><tr><td>Ours (SVM)</td><td>PTB</td><td>PTB</td><td>MI</td><td>5-fold</td><td>0.95</td><td>0.90</td><td>0.92</td><td>0.81</td></tr><tr><td>Ours (LR)</td><td>PTB</td><td>PTB-XL</td><td>MI</td><td>-</td><td>0.95</td><td>0.84</td><td>0.83</td><td>0.99</td></tr><tr><td>Ours (SVM)</td><td>PTB</td><td>PTB-XL</td><td>MI</td><td>-</td><td>0.94</td><td>0.82</td><td>0.79</td><td>0.99</td></tr><tr><td>Ours (LR)</td><td>CPSC</td><td>CPSC</td><td>MI</td><td>5-fold</td><td>0.97</td><td>0.93</td><td>0.88</td><td>0.96</td></tr><tr><td>Ours (SVM)</td><td>CPSC</td><td>CPSC</td><td>MI</td><td>5-fold</td><td>0.97</td><td>0.92</td><td>0.88</td><td>0.93</td></tr><tr><td>Ours (LR)</td><td>CPSC</td><td>PTB-XL</td><td>MI</td><td>-</td><td>0.97</td><td>0.94</td><td>0.86</td><td>0.97</td></tr><tr><td>Ours (SVM)</td><td>CPSC</td><td>PTB-XL</td><td>MI</td><td>-</td><td>0.95</td><td>0.91</td><td>0.83</td><td>0.95</td></tr><tr><td>Ours (LR)</td><td>Private</td><td>PTB-XL</td><td>MI</td><td>-</td><td>0.80</td><td>0.76</td><td>0.92</td><td>0.56</td></tr><tr><td>Ours (SVM)</td><td>Private</td><td>PTB-XL</td><td>MI</td><td>-</td><td>0.77</td><td>0.71</td><td>0.83</td><td>0.56</td></tr></tbody></table>
<figure><img src="image_4.png" /><figcaption>Fig. 3: (a-b) The reconstruction metrics of different evaluation datasets on HC/MI separately. (c-d) Lead-wise R2 score of signal reconstruction of NORM patients and MI patients.</figcaption></figure>

that projects the 264-dimension vector to 3-dimension. A support vector machine (SVM) with linear kernel is applied then to find the best hyperplane that separates the MI/NORM patients. The additive nature of weighted features help to explain the classification results. The second method is to use SHAP value to explain a Logistic regression (LR) model for MI/NORM classification. We trained separate classifiers on PTB-XL, PTB and CPSC(+extra) datasets using 10-fold, 5-fold, 5-fold cross-validation respectively. Two more specific classifiers for detecting AMI/IMI (vs. non AMI/IMI) were established on PTB-XL using 10-fold cross-validation.

*Generalisable classification:* we tested the classifiers trained on PTB-XL to other three datasets: PTB, CPSC(+extra) and our private dataset (CHU) to evaluate the generalisation of our proposed classification pipeline.

<table><caption>Table 2: Classification results on different datasets using Cascaded FMM net.</caption><thead><tr><th>Model</th><th>Dataset (evaluation)</th><th>Dataset (train)</th><th>Class</th><th>CV</th><th>AUROC</th><th>Accuracy</th><th>Sensitivity</th><th>Specificity</th></tr></thead><tbody><tr><td>VGG [7]</td><td>PTB-XL</td><td>PTB-XL</td><td>MI</td><td>10-fold</td><td>1.00</td><td>0.97</td><td>0.96</td><td>0.98</td></tr><tr><td>Ours (LR)</td><td>PTB-XL</td><td>PTB-XL</td><td>MI</td><td>10-fold</td><td>0.99</td><td>0.96</td><td>0.93</td><td>0.96</td></tr><tr><td>Ours (SVM)</td><td>PTB-XL</td><td>PTB-XL</td><td>MI</td><td>10-fold</td><td>0.98</td><td>0.94</td><td>0.92</td><td>0.95</td></tr><tr><td>Ours (LR)</td><td>PTB-XL</td><td>PTB-XL</td><td>AMI</td><td>10-fold</td><td>0.98</td><td>0.93</td><td>0.92</td><td>0.93</td></tr><tr><td>Ours (LR)</td><td>PTB-XL</td><td>PTB-XL</td><td>IMI</td><td>10-fold</td><td>0.97</td><td>0.91</td><td>0.92</td><td>0.91</td></tr><tr><td>VGG [7]</td><td>PTB</td><td>PTB</td><td>MI</td><td>5-fold</td><td>0.98</td><td>0.96</td><td>0.97</td><td>0.91</td></tr><tr><td>Ours (LR)</td><td>PTB</td><td>PTB</td><td>MI</td><td>5-fold</td><td>0.95</td><td>0.91</td><td>0.92</td><td>0.88</td></tr><tr><td>Ours (SVM)</td><td>PTB</td><td>PTB</td><td>MI</td><td>5-fold</td><td>0.95</td><td>0.90</td><td>0.92</td><td>0.81</td></tr><tr><td>Ours (LR)</td><td>PTB</td><td>PTB-XL</td><td>MI</td><td>—</td><td>0.95</td><td>0.84</td><td>0.83</td><td>0.99</td></tr><tr><td>Ours (SVM)</td><td>PTB</td><td>PTB-XL</td><td>MI</td><td>—</td><td>0.94</td><td>0.82</td><td>0.79</td><td>0.99</td></tr><tr><td>Ours (LR)</td><td>CPSC</td><td>CPSC</td><td>MI</td><td>5-fold</td><td>0.97</td><td>0.93</td><td>0.88</td><td>0.96</td></tr><tr><td>Ours (SVM)</td><td>CPSC</td><td>CPSC</td><td>MI</td><td>5-fold</td><td>0.97</td><td>0.92</td><td>0.88</td><td>0.93</td></tr><tr><td>Ours (LR)</td><td>CPSC</td><td>PTB-XL</td><td>MI</td><td>—</td><td>0.97</td><td>0.94</td><td>0.86</td><td>0.97</td></tr><tr><td>Ours (SVM)</td><td>CPSC</td><td>PTB-XL</td><td>MI</td><td>—</td><td>0.95</td><td>0.91</td><td>0.83</td><td>0.95</td></tr><tr><td>Ours (LR)</td><td>Private</td><td>PTB-XL</td><td>MI</td><td>—</td><td>0.80</td><td>0.76</td><td>0.92</td><td>0.56</td></tr><tr><td>Ours (SVM)</td><td>Private</td><td>PTB-XL</td><td>MI</td><td>—</td><td>0.77</td><td>0.71</td><td>0.83</td><td>0.56</td></tr></tbody></table>
<figure><img src="image_5.png" /><figcaption>Fig. 4: The classification boundary (hyperplane) of trained linear SVM classifiers and data points (3-dim) projected on one of the 2D plane orthogonal to the corresponding hyperplane.</figcaption></figure>

<figure><img src="image_6.png" /><figcaption>Fig. 5: Explanations of feature importance for Myocardial Infarction (MI), Anterior Myocardial Infarction (AMI) and Inferior Myocardial Infarction (IMI) classification respectively using SHAP value on models trained on PTB-XL dataset. Higher shap value helps to augment the chances of detecting positive classes, in our cases, the MI/AMI/IMI classes.</figcaption></figure>

**Results** We present the detailed classification evaluation in Table.2. First, it can be observed that using our classification pipeline, we are able to obtain satisfactory classification performance on different datasets (PTB-XL/PTB/CPSC) compared with other methods. In Fig.4, we can observe that a linear classifier (SVM with linear kernel) is already capable to obtain good separation of MI/NORM patients on both training and test data for PTB-XL, PTB and CPSC datasets respectively. Using SHAP values, our models (Logistic regression classifiers) are capable to identify important infarction related features such as T wave amplitude change (T_A), T inversion (T_β) etc. They also distinguish the influenced leads for infarction. For example, as shown in Fig.5, it distinguishes the V1,V2,V3 for AMI (Fig.5b), the II,III,avF for IMI (Fig.5c). Since the MI label combines MI of different localisation, the important features for MI/NORM classification are spread widely across different leads (Fig.5a).
<figure><img src="image_5.png" /><figcaption>Fig. 4: The classification boundary (hyperplane) of trained linear SVM classifiers and data points (3-dim) projected on one of the 2D plane orthogonal to the corresponding hyperplane.</figcaption></figure>

<figure><img src="image_6.png" /><figcaption>Fig. 5: Explanations of feature importance for Myocardial Infarction (MI), Anterior Myocardial Infarction (AMI) and Inferior Myocardial Infarction (IMI) classification respectively using SHAP value on models trained on PTB-XL dataset. Higher shap value helps to augment the chances of detecting positive classes, in our cases, the MI/AMI/IMI classes.</figcaption></figure>

**Results** We present the detailed classification evaluation in Table.2. First, it can be observed that using our classification pipeline, we are able to obtain satisfactory classification performance on different datasets (PTB-XL/PTB/CPSC) compared with other methods. In Fig.4, we can observe that a linear classifier (SVM with linear kernel) is already capable to obtain good separation of MI/NORM patients on both training and test data for PTB-XL, PTB and CPSC datasets respectively. Using SHAP values, our models (Logistic regression classifiers) are capable to identify important infarction related features such as T wave amplitude change (T_A), T inversion (T_β) etc. They also distinguish the influenced leads for infarction. For example, as shown in Fig.5, it distinguishes the V1,V2,V3 for AMI (Fig.5b), the II,III,avF for IMI (Fig.5c). Since the MI label combines MI of different localisation, the important features for MI/NORM classification are spread widely across different leads (Fig.5a).
<figure><img src="image_7.png" /><figcaption>Fig. 6: An example from PTB-XL test dataset classified as MI by the linear SVM classifier/Logistic regression classifier. According to the PTB-XL description, the patient is diagnosed with old anteroseptal infarction (tiny R waves present in V2,V3), anterolateral ischaemia (inverted T waves and depressed ST-segments in I, avL, flat T waves in V5,V6) and inferior infarction (flat T wave in II). (a) Decomposed 12-lead median ECG. (b)(c) Explainability provided by linear SVM model. Red rectangles mark the T-ST change related leads (acute infarction/ischaemia related) and blue rectangles mark the R wave change related leads (old infarction related and are represented here by our parameters pre-fixed by Q). (d) Explainability provided by Logistic regression model by SHAP value.</figcaption></figure>
<figure><img src="image_7.png" /><figcaption>Fig. 6: An example from PTB-XL test dataset classified as MI by the linear SVM classifier/Logistic regression classifier. According to the PTB-XL description, the patient is diagnosed with old anteroseptal infarction (tiny R waves present in V2,V3), anterolateral ischaemia (inverted T waves and depressed ST-segments in I, avL, flat T waves in V5,V6) and inferior infarction (flat T wave in II). (a) Decomposed 12-lead median ECG. (b)(c) Explainability provided by linear SVM model. Red rectangles mark the T-ST change related leads (acute infarction/ischaemia related) and blue rectangles mark the R wave change related leads (old infarction related and are represented here by our parameters pre-fixed by Q). (d) Explainability provided by Logistic regression model by SHAP value.</figcaption></figure>
Second, models trained on PTB-XL generalise well on other datasets, without to much drop of accuracy. However, we observe a drop of specificity on our small private dataset. Since the signals are extracted from scanned ECG papers, the domain gap could be enlarged. In addition, the manner of annotation may be different. The label of NORM/MI in our private dataset is the final diagnosis decision. It's made by an experienced cardiologist after an overall examination of the patient, including echocardiography, ECG and sometimes coronary angiography. This may be different from the direct diagnosis based on ECG alone from PTB-XL dataset.

We show an example from PTB-XL test data that was correctly detected as MI (MI/NORM classifier) in Fig.6. The influenced ECG leads of this patient are I, II, avL, V2, V3, V5 and V6. First, our Cascaded FMMnet successfully identified the subwaves for most of the leads (Fig.6a). Second, we group the weighted features lead-wisely using the linear SVM model and observe that all leads helped to identify this MI patient (they are all positive as shown in Fig.6b). In addition, when examining the top-3 highest weighted features of every lead(Fig.6c), we find that most of the important features are in accordance with doctor's diagnosis (see red and blue rectangles in Fig.6c). We also observe a similar trend of important features explained by SHAP value from the Logistic regression classifier (Fig.6d).

# 4 Discussion and Conclusion

In this work, we propose an automatic decomposition model, Cascaded FMMnet for ECG analysis which facilitates the downstream tasks, such as classification and in our case, to classify normal and myocardial infarction patients. The Cascaded FMMnet is able to generalise reconstruction across datasets from different centers and the estimated parameters can be used for MI classification with good explainability. It should be noticed that the Cascaded FMMnet was trained on PTB-XL dataset, which contains not only healthy samples but also samples with different pathologies (myocardial infarction, conduction disturbance and hypertrrophy etc). We believe that proposed network is capable to play an important role in other pathology classification. In the future, we will explore to improve the decomposition of different ECG leads with more specification. Our current Cascaded FMMnet assumes P,Q,R,S,T present in all leads while in some cases, some subwaves can be absent. For example, in Fig.6a, we can observe the small S wave (in green) does not represent a meaningful peak and it's superposed with the large R wave in lead avF, V1-4. This phenomenon is supported by the superior reconstruction accuracy on leads close to lead II(I, II, V5, V6) than the other leads(Fig.3c-d). The original FMM paper [20] also presented their results on lead II only. Some specific care for leads like V1-V4 should be explored.

**Acknowledgements** This work has been supported by the French government through the National Research Agency (ANR) Investments in the Future with 3IA Côte d'Azur (ANR-19-P3IA-0002) and by Inria PhD funding.
Second, models trained on PTB-XL generalise well on other datasets, without much drop of accuracy. However, we observe a drop of specificity on our small private dataset. Since the signals are extracted from scanned ECG papers, the domain gap could be enlarged. In addition, the manner of annotation may be different. The label of NORM/MI in our private dataset is the final diagnosis decision. It's made by an experienced cardiologist after an overall examination of the patient, including echocardiography, ECG and sometimes coronary angiography. This may be different from the direct diagnosis based on ECG alone from PTB-XL dataset.

We show an example from PTB-XL test data that was correctly detected as MI (MI/NORM classifier) in Fig.6. The influenced ECG leads of this patient are I, II, avL, V2, V3, V5 and V6. First, our Cascaded FMMnet successfully identified the subwaves for most of the leads (Fig.6a). Second, we group the weighted features lead-wisely using the linear SVM model and observe that all leads helped to identify this MI patient (they are all positive as shown in Fig.6b). In addition, when examining the top-3 highest weighted features of every lead(Fig.6c), we find that most of the important features are in accordance with doctor's diagnosis (see red and blue rectangles in Fig.6c). We also observe a similar trend of important features explained by SHAP value from the Logistic regression classifier (Fig.6d).

# 4 Discussion and Conclusion

In this work, we propose an automatic decomposition model, Cascaded FMMnet for ECG analysis which facilitates the downstream tasks, such as classification and in our case, to classify normal and myocardial infarction patients. The Cascaded FMMnet is able to generalise reconstruction across datasets from different centers and the estimated parameters can be used for MI classification with good explainability. It should be noticed that the Cascaded FMMnet was trained on PTB-XL dataset, which contains not only healthy samples but also samples with different pathologies (myocardial infarction, conduction disturbance and hypertrophy etc). We believe that proposed network is capable to play an important role in other pathology classification. In the future, we will explore to improve the decomposition of different ECG leads with more specification. Our current Cascaded FMMnet assumes P,Q,R,S,T present in all leads while in some cases, some subwaves can be absent. For example, in Fig.6a, we can observe the small S wave (in green) does not represent a meaningful peak and it's superposed with the large R wave in lead avF, V1-4. This phenomenon is supported by the superior reconstruction accuracy on leads close to lead II(I, II, V5, V6) than the other leads(Fig.3c-d). The original FMM paper [20] also presented their results on lead II only. Some specific care for leads like V1-V4 should be explored.

**Acknowledgements** This work has been supported by the French government through the National Research Agency (ANR) Investments in the Future with 3IA Côte d'Azur (ANR-19-P3IA-0002) and by Inria PhD funding.
References

1. Acharya, U.R., Fujita, H., Adam, M., Lih, O.S., Sudarshan, V.K., Hong, T.J., Koh, J.E., Hagiwara, Y., Chua, C.K., Poo, C.K., et al.: Automated characterization and classification of coronary artery disease and myocardial infarction by decomposition of ecg signals: A comparative study. Information Sciences **377**, 17–29 (2017)

2. Acharya, U.R., Fujita, H., Oh, S.L., Hagiwara, Y., Tan, J.H., Adam, M.: Application of deep convolutional neural network for automated detection of myocardial infarction using ecg signals. Information Sciences **415**, 190–198 (2017)

3. Ansari, S., Farzaneh, N., Duda, M., Horan, K., Andersson, H.B., Goldberger, Z.D., Nallamothu, B.K., Najarian, K.: A review of automated methods for detection of myocardial ischemia and infarction using electrocardiogram and electronic health records. IEEE reviews in biomedical engineering **10**, 264–298 (2017)

4. Arif, M., Malagore, I.A., Afsar, F.A.: Detection and localization of myocardial infarction using k-nearest neighbor classifier. Journal of medical systems **36**(1), 279–289 (2012)

5. Bhaskar, N.A.: Performance analysis of support vector machine and neural networks in detection of myocardial infarction. Procedia Computer Science **46**, 20–30 (2015)

6. Bousseljot, R., Kreiseler, D., Schnabel, A.: Nutzung der ekg-signaldatenbank cardiodat der ptb über das internet (1995)

7. Fang, R., Lu, C.C., Chuang, C.T., Chang, W.H.: A visually interpretable detection method combines 3-d ecg with a multi-vgg neural network for myocardial infarction identification. Computer Methods and Programs in Biomedicine **219**, 106762 (2022)

8. Fortune, J.D., Coppa, N.E., Haq, K.T., Patel, H., Tereshchenko, L.G.: Digitizing ecg image: a new method and open-source software code. Computer Methods and Programs in Biomedicine p. 106890 (2022)

9. Graja, S., Boucher, J.M.: Hidden markov tree model applied to ecg delineation. IEEE Transactions on Instrumentation and Measurement **54**(6), 2163–2168 (2005)

10. Jaleel, A., Tafreshi, R., Tafreshi, L.: An expert system for differential diagnosis of myocardial infarction. Journal of Dynamic Systems, Measurement, and Control **138**(11) (2016)

11. Jayachandran, E., Joseph K, P., Acharya U, R., et al.: Analysis of myocardial infarction using discrete wavelet transform. Journal of medical systems **34**(6), 985–992 (2010)

12. Liu, B., Liu, J., Wang, G., Huang, K., Li, F., Zheng, Y., Luo, Y., Zhou, F.: A novel electrocardiogram parameterization algorithm and its application in myocardial infarction detection. Computers in biology and medicine **61**, 178–184 (2015)

13. Liu, F., Liu, C., Zhao, L., Zhang, X., Wu, X., Xu, X., Liu, Y., Ma, C., Wei, S., He, Z., et al.: An open access database for evaluating the algorithms of electrocardio- gram rhythm and morphology abnormality detection. Journal of Medical Imaging and Health Informatics **8**(7), 1368–1373 (2018)

14. Lu, H., Ong, K., Chia, P.: An automated ecg classification system based on a neuro-fuzzy system. In: Computers in Cardiology 2000. Vol. 27 (Cat. 00CH37163). pp. 387–390. IEEE (2000)

15. Lundberg, S.M., Lee, S.I.: A unified approach to interpreting model predictions. In: Guyon, I., Luxburg, U.V., Bengio, S., Wallach, H., Fergus, R., Vishwanathan, S., Garnett, R. (eds.) Advances in Neural Information Processing Systems. vol. 30. Curran Associates, Inc. (2017)
References

1. Acharya, U.R., Fujita, H., Adam, M., Lih, O.S., Sudarshan, V.K., Hong, T.J., Koh, J.E., Hagiwara, Y., Chua, C.K., Poo, C.K., et al.: Automated characterization and classification of coronary artery disease and myocardial infarction by decomposition of ecg signals: A comparative study. Information Sciences **377**, 17–29 (2017)

2. Acharya, U.R., Fujita, H., Oh, S.L., Hagiwara, Y., Tan, J.H., Adam, M.: Application of deep convolutional neural network for automated detection of myocardial infarction using ecg signals. Information Sciences **415**, 190–198 (2017)

3. Ansari, S., Farzaneh, N., Duda, M., Horan, K., Andersson, H.B., Goldberger, Z.D., Nallamothu, B.K., Najarian, K.: A review of automated methods for detection of myocardial ischemia and infarction using electrocardiogram and electronic health records. IEEE reviews in biomedical engineering **10**, 264–298 (2017)

4. Arif, M., Malagore, I.A., Afsar, F.A.: Detection and localization of myocardial infarction using k-nearest neighbor classifier. Journal of medical systems **36**(1), 279–289 (2012)

5. Bhaskar, N.A.: Performance analysis of support vector machine and neural networks in detection of myocardial infarction. Procedia Computer Science **46**, 20–30 (2015)

6. Bousseljot, R., Kreiseler, D., Schnabel, A.: Nutzung der ekg-signaldatenbank cardiodat der ptb über das internet (1995)

7. Fang, R., Lu, C.C., Chuang, C.T., Chang, W.H.: A visually interpretable detection method combines 3-d ecg with a multi-vgg neural network for myocardial infarction identification. Computer Methods and Programs in Biomedicine **219**, 106762 (2022)

8. Fortune, J.D., Coppa, N.E., Haq, K.T., Patel, H., Tereshchenko, L.G.: Digitizing ecg image: a new method and open-source software code. Computer Methods and Programs in Biomedicine p. 106890 (2022)

9. Graja, S., Boucher, J.M.: Hidden markov tree model applied to ecg delineation. IEEE Transactions on Instrumentation and Measurement **54**(6), 2163–2168 (2005)

10. Jaleel, A., Tafreshi, R., Tafreshi, L.: An expert system for differential diagnosis of myocardial infarction. Journal of Dynamic Systems, Measurement, and Control **138**(11) (2016)

11. Jayachandran, E., Joseph K, P., Acharya U, R., et al.: Analysis of myocardial infarction using discrete wavelet transform. Journal of medical systems **34**(6), 985–992 (2010)

12. Liu, B., Liu, J., Wang, G., Huang, K., Li, F., Zheng, Y., Luo, Y., Zhou, F.: A novel electrocardiogram parameterization algorithm and its application in myocardial infarction detection. Computers in biology and medicine **61**, 178–184 (2015)

13. Liu, F., Liu, C., Zhao, L., Zhang, X., Wu, X., Xu, X., Liu, Y., Ma, C., Wei, S., He, Z., et al.: An open access database for evaluating the algorithms of electrocardio- gram rhythm and morphology abnormality detection. Journal of Medical Imaging and Health Informatics **8**(7), 1368–1373 (2018)

14. Lu, H., Ong, K., Chia, P.: An automated ecg classification system based on a neuro-fuzzy system. In: Computers in Cardiology 2000. Vol. 27 (Cat. 00CH37163). pp. 387–390. IEEE (2000)

15. Lundberg, S.M., Lee, S.I.: A unified approach to interpreting model predictions. In: Guyon, I., Luxburg, U.V., Bengio, S., Wallach, H., Fergus, R., Vishwanathan, S., Garnett, R. (eds.) Advances in Neural Information Processing Systems. vol. 30. Curran Associates, Inc. (2017)
16. Makowski, D., Pham, T., Lau, Z.J., Brammer, J.C., Lespinasse, F., Pham, H., Schölzel, C., Chen, S.H.A.: NeuroKit2: A python toolbox for neurophysiological signal processing. *Behavior Research Methods* **53**(4), 1689–1696 (feb 2021)

17. Mixon, T.A., Suhr, E., Caldwell, G., Greenberg, R.D., Colato, F., Blackwell, J., Jo, C.H., Dehmer, G.J.: Retrospective description and analysis of consecutive catheterization laboratory st-segment elevation myocardial infarction activations with proposal, rationale, and use of a new classification scheme. *Circulation: Cardiovascular Quality and Outcomes* **5**(1), 62–69 (2012)

18. Peimankar, A., Puthusserypady, S.: Dens-ecg: A deep learning approach for ecg signal delineation. *Expert systems with applications* **165**, 113911 (2021)

19. Pereira, H., Daimiwal, N.: Analysis of features for myocardial infarction and healthy patients based on wavelet. In: 2016 Conference on Advances in Signal Processing (CASP). pp. 164–169. IEEE (2016)

20. Rueda, C., Larriba, Y., Lamela, A.: The hidden waves in the ecg uncovered revealing a sound automated interpretation method. *Scientific reports* **11**(1), 1–11 (2021)

21. Rueda, C., Larriba, Y., Peddada, S.D.: Frequency modulated möbius model accurately predicts rhythmic signals in biological and physical sciences. *Scientific Reports* **9**(1), 1–10 (2019)

22. Thygesen, K., Alpert, J.S., Jaffe, A.S., Chaitman, B.R., Bax, J.J., Morrow, D.A., White, H.D., Group, E.S.D.: Fourth universal definition of myocardial infarction (2018). *European Heart Journal* **40**(3), 237–269 (08 2018). https://doi.org/10.1093/eurheartj/ehy462

23. Wagner, P., Strodthoff, N., Bousseljot, R.D., Kreiseler, D., Lunze, F.I., Samek, W., Schaeffter, T.: Ptb-xl, a large publicly available electrocardiography dataset. *Scientific data* **7**(1), 1–15 (2020)

24. Xiong, P., Lee, S.M.Y., Chan, G.: Deep learning for detecting and locating myocardial infarction by electrocardiogram: A literature review. *Frontiers in Cardiovascular Medicine* **9** (2022)

25. Zewdie, G., Xiong, M.: Fully automated myocardial infarction classification using ordinary differential equations. *arXiv preprint arXiv:1410.6984* (2014)
16. Makowski, D., Pham, T., Lau, Z.J., Brammer, J.C., Lespinasse, F., Pham, H., Schölzel, C., Chen, S.H.A.: NeuroKit2: A python toolbox for neurophysiological signal processing. *Behavior Research Methods* **53**(4), 1689–1696 (feb 2021)

17. Mixon, T.A., Suhr, E., Caldwell, G., Greenberg, R.D., Colato, F., Blackwell, J., Jo, C.H., Dehmer, G.J.: Retrospective description and analysis of consecutive catheterization laboratory st-segment elevation myocardial infarction activations with proposal, rationale, and use of a new classification scheme. *Circulation: Cardiovascular Quality and Outcomes* **5**(1), 62–69 (2012)

18. Peimankar, A., Puthusserypady, S.: Dens-ecg: A deep learning approach for ecg signal delineation. *Expert systems with applications* **165**, 113911 (2021)

19. Pereira, H., Daimiwal, N.: Analysis of features for myocardial infarction and healthy patients based on wavelet. In: 2016 Conference on Advances in Signal Processing (CASP). pp. 164–169. IEEE (2016)

20. Rueda, C., Larriba, Y., Lamela, A.: The hidden waves in the ecg uncovered revealing a sound automated interpretation method. *Scientific reports* **11**(1), 1–11 (2021)

21. Rueda, C., Larriba, Y., Peddada, S.D.: Frequency modulated möbius model accurately predicts rhythmic signals in biological and physical sciences. *Scientific Reports* **9**(1), 1–10 (2019)

22. Thygesen, K., Alpert, J.S., Jaffe, A.S., Chaitman, B.R., Bax, J.J., Morrow, D.A., White, H.D., Group, E.S.D.: Fourth universal definition of myocardial infarction (2018). *European Heart Journal* **40**(3), 237–269 (08 2018). https://doi.org/10.1093/eurheartj/ehy462

23. Wagner, P., Strodthoff, N., Bousseljot, R.D., Kreiseler, D., Lunze, F.I., Samek, W., Schaeffter, T.: Ptb-xl, a large publicly available electrocardiography dataset. *Scientific data* **7**(1), 1–15 (2020)

24. Xiong, P., Lee, S.M.Y., Chan, G.: Deep learning for detecting and locating myocardial infarction by electrocardiogram: A literature review. *Frontiers in Cardiovascular Medicine* **9** (2022)

25. Zewdie, G., Xiong, M.: Fully automated myocardial infarction classification using ordinary differential equations. *arXiv preprint arXiv:1410.6984* (2014)