# An Efficient Method to Learn Overcomplete Multi-Scale Dictionaries of ECG Signals
## 4 Numerical Results
### Sparse ECG Representation  
We next tested the constructed dictionary on 21 recordings corresponding to 17 healthy patients from the PTB database. Our main goal was determining whether the constructed dictionary (which is not patient-specific) can be effectively used to perform a sparse representation of ECG signals from multiple patients. To solve Equation (5), we used the CoSA algorithm recently proposed in [21],  
Figure 8: Multi-scale dictionary constructed using the \(K=6\) most representative waveforms shown in Figure 7.  
Figure 7: \(K=6\) atoms selected from the \(Q^{\prime}=44\) reliable average QRS complexes obtained from the \(Q=51\) healthy patients in the PTB database, using a threshold \(\gamma=0.9\). which allows us to process the \(N\approx 115\),200 samples (almost 2 min of recorded time) of the whole signal at once (i.e., without having to partition it into several segments that have to be processed separately) in a reasonable amount of time. Since several signals showed a significant degree of baseline wander, before applying CoSA all signals were filtered using a third-order high-pass IIR (infinite impulse response) Butterworth filter designed using Matlab's filterDesigner tool: stop-band frequency \(f_{stop}=0.1\) Hz; pass-band frequency \(f_{pass}=1\) Hz; minimum stop-band attenuation \(A_{stop}=40\) dB; and maximum pass-band attenuation \(A_{pass}=1\) dB. Forward-backward filtering was applied again to avoid phase distortion. An example of the reconstructed signal using \(K=1\) and \(\lambda=20\) is shown in Figure 9. Note that all the QRS complexes (our main goal here) are properly represented by the sparse model. By increasing the number of signals (\(K\)), and especially by decreasing the sparsity factor (\(\lambda\)), a better model that also includes the P and T waveforms can be obtained. However, let us remark that this is not our main goal. Indeed, a better option to model the P and T waveforms would be constructing specific dictionaries of P and T waveforms: either using synthetic waveforms (e.g., Gaussians) or applying the proposed approach to construct real-world dictionaries of P and T waveforms. We intend to explore this issue in future works, constructing mega-dictionaries of P-QRS-T waveforms which are able to model all the relevant activations in the ECGs. To measure the effectiveness of the proposed approach, we used several performance metrics that measure both the model's sparsity and its accuracy in representing the original signal. On the one hand, the sparsity was gauged by the coefficient sparsity (C-Sp),  
\[\text{C-Sp (\%)}=\frac{\|\boldsymbol{\beta}\|_{0}}{(N-M)P}\times 100 \tag{17}\]  
which measures how many non-null coefficients (out of the total ones) are required to represent the signal, and the signal sparsity (S-Sp),  
\[\text{S-Sp (\%)}=\frac{\|\boldsymbol{x}\|_{0}}{N}\times 100 \tag{18}\]  
which measures how many samples of the signal's approximation (out of the total number of samples) are not equal to zero. Note that \(\|\cdot\|_{0}\) indicates the \(L_{0}\) \"norm\" of a vector, i.e., its number of non-null elements. On the other hand, the reconstruction error was measured by the normalized mean squared error (NMSE) and its logarithmic counterpart, the reconstruction signal to noise ratio (R-SNR):  
Figure 9: Example of sparse ECG representation with the derived dictionary for a segment of signal 121 from the PTB database. Real signal in blue; sparse representation (QRS complexes) in red. \[\text{NMSE (\%)} =\frac{\|\mathbf{x}-\mathbf{A}\boldsymbol{\beta}\|_{2}^{2}}{\| \mathbf{x}\|_{2}^{2}}\times 100 \tag{19}\] \[\text{R-SNR (dB)} =10\cdot\log_{10}(\text{NMSE}), \tag{20}\]  
where \(\|\cdot\|_{2}^{2}\) denotes the squared \(L_{2}\) norm of a vector. The results, for the four performance measured previously described, are displayed in Figure 10. On the left hand side, we show the results (mean value and standard deviation) for the first 10 patients in the training set: Patients 104, 105, 117, 121, 122, 131, 150, 155, 156, and 169.