## 3 Materials and Methods
### Data Extraction and Cleaning  
The preprocessing of the signals is an important task to allow the extraction of useful information from them and for further analysis. The following four preprocessing procedures were performed:  
1. Baseline wander removal;
2. Beat extraction;
3. Normalization;
4. Resample of signals.  
Figure 2: A high-level illustration of the processing pipeline.  
The baseline wander is generated by a low-frequency signal. Removing this noise benefits the extraction of time-domain features. For this task, the Discrete wavelet transform (DWT) is employed. Via the DWT coefficients, the ECG signal can be described in both time and frequency. The values of the coefficients are the results of passing the ECG signal through a series of high pass filters (HPFs) and low pass filters (LPFs). Depending on the wavelet applied, the LPF has specific coefficient values. The HPF is derived from the LPF as follows:  
\[HPF[L-1-k]=[-1]^{k}LPF[k] \tag{1}\]  
where \(L\) is the length of the filter in the number of samples, and \(k\) are the coefficients of the filter. Each pair of filters can be represented as follows:  
\[A[n]=\sum_{k=0}^{K}LPF[k]x[n-k] \tag{2}\]  
\[D[n]=\sum_{k=0}^{K}HPF[k]x[n-k] \tag{3}\]  
The filter has a half downsample after it to make the DWT efficient, represented as follows:  
\[A_{o}[n]=A[2n] \tag{4}\]  
\[D_{o}[n]=D[2n] \tag{5}\]  
where \(n\) is the length of the signal produced. The DWT sends the signal through a cascade of HPF and LPF, resulting in an average signal detailed and differentiated for classification.  
Following the recommendations in [32], the signal was decomposed into the ninth level using Daubechies wavelet family and the wavelet Daubechies 6 (db6), where the frequency in this level was about 0-0.351 Hz [32] levels of resolution. The signal proceeds through all the necessary levels to isolate the energy of the noise. To eliminate the baseline wander from the ECG, the signal was constructed from the eighth coefficient to the first, replacing the coefficients of the ninth with zeros. Figure 4 shows the denoising process of the ECG signal.  
The heartbeats were extracted from the denoised signal. Every record had a file indicating the heartbeat location in the sample and its type. After analyzing the research and results of [PERSON] et al. [32], which uses a window of approximately 552 ms and the research and results of [PERSON] et al. [33] that uses a window of 700 ms, in our case, we considered a slightly wider window, i.e., 730 ms-330 ms before the R peak and 400 ms after it--which were enough to cover the heartbeats of our test signals, making sure the whole beat and its characteristic waveform are totally covered. Every beat has a length of 0.73 s but because the sampling frequency varies among the databases, the length in samples varies depending on the database employed:  
1. MITBIH ECG signals consisted of 263 samples;
2. INCART consisted of 188 samples;
3. SUPRA had 93 samples.  
Finally, the signal values were normalized between 0 and 1 and resampled at 360 Hz, the sampling frequency of the MITBIH database signals. This was carried out following the recommendations of [PERSON] et al. [26].