# An Efficient Method to Learn Overcomplete Multi-Scale Dictionaries of ECG Signals
## 4 Numerical Results
### Dictionary Construction  
As mentioned earlier, to construct the dictionary, we used channel 10 (lead V4) from the first register of the \(Q=51\) healthy patients in the PTB database: Patients 104, 105, 116, 117, 121, 122, 131, 150, 155, 156, 166, 169, 170, 172-174, 180, 182, 184, 185, 198, 214, 229, 233-248, 251, 252, 255, 260, 263, 264, 266, 267, 276, 277, 279, and 284. From this whole set of patients, we were able to obtain reliable average QRS complexes for \(Q^{\prime}=44\) Patients: 104, 105, 117, 121, 122, 131, 150, 155, 156, 169, 170, 174, 180, 182, 184, 185, 198, 214, 229, 234-248, 251, 252, 260, 263, 264, 267, 276, 277, 279, and 284. The remaining \(Q-Q^{\prime}=7\) patients (116, 166, 172, 173, 233, 255, and 266), where the extraction of the QRS complexes fails, were used as the test set. The average waveforms for the \(Q^{\prime}=44\) patients, after resampling to \(L=124\) samples (i.e., 124 ms), windowing and normalization, can be seen in Figure 5. Note that, as expected, there is a large degree of similarity among all the waveforms, since they all correspond to regular heartbeats from healthy patients. This similarity is illustrated also by the color plot of the absolute value of the correlation coefficient in Figure 6. Note the large correlation (corresponding to dark red points) among most waveforms. For this reason, in [22], we decided to extract a single waveform in order to construct the multi-scale and overcomplete dictionary. However, in Figure 6, we also notice that some waveforms exhibit low correlation values (as shown by blue points). This motivates us to explore here the performance as more than one waveform is extracted from the pool of average QRS complexes shown in Figure 5 in order to construct the dictionary.  
To build dictionaries composed of different waveforms, we tested several threshold levels: \(\gamma=0.1,0.2,\ldots,0.9\). Note that the larger is the value of \(\gamma\) the less restrictive is the condition to incorporate a new atom to the dictionary, and thus the larger is the number of final atoms (\(K\)) used: for \(\gamma=0\), we would always obtain \(K=1\) atoms (since no new atoms can be incorporated after the first one), whereas, for \(\gamma=1\), we would obtain \(K=Q^{\prime}\) (as all waveforms would be considered valid). Following this approach, we obtained \(K=1\) atoms for \(\gamma\leq 0.2\), \(K=2\) atoms for \(0.3\leq\gamma\leq 0.6\), \(K=3\) atoms when \(\gamma=0.7\), \(K=4\) atoms when \(\gamma=0.8\), and \(K=6\) atoms when \(\gamma=0.9\). Figure 7 shows the six atoms selected for \(\gamma=0.9\). Note that, since we followed a deterministic procedure, the first atom was the one obtained for \(K=1\) (i.e., when \(\gamma\leq 0.2\)), the first and second ones were those obtained for \(K=2\) (i.e., for \(0.3\leq\gamma\leq 0.6\)), and so on.  
Figure 5: \(Q^{\prime}=44\) reliable average QRS complexes extracted from the \(Q=51\) healthy patients in the PTB database [29] after resampling, windowing and normalization.  
Figure 6: Color map showing the absolute value of the correlation coefficient, \(|\rho_{ij}|\), for the \(Q^{\prime}=44\) average QRS waveforms. Dark red colors indicate values close to 1, whereas dark blue colors indicate values closer to 0.  
Finally, the selected waveforms for \(K=1,\ldots,6\) were resampled in such a way that their duration ranged from 60 ms to 160 ms (with a time step of 10 ms). The resulting base dictionary, composed of \(P=11\times K=11,22,\ldots,66\) atoms, is shown in Figure 8 for \(K=6\). The final multi-scale and overcomplete dictionary consists of these \(P\) waveforms time shifted to the \(N-M\) locations of the sampled ECGs, implying that its size is \(N\times P(N-M)\). For instance, for \(N=115,200\) samples (a typical signal size in the PTB database) and \(M=160\) samples (the maximum support of the selected waveforms), the size of the matrix dictionary ranges from \(N\times 11(N-M)=115,200\times 1,265,440\) for \(K=1\) up to \(N\times 66(N-M)=115,200\times 7,592,640\) for \(K=6\).