## 3 Materials and Methods
### Clustering and Descriptors  
In the clustering and descriptors step, three major procedures were performed according to the assumptions previously stated. Firstly, the signals were clustered in groups. This work proposes that the clustering algorithm, self-organizing maps (SOM), is able to distinguish between SVBo and VBo, then the problem is reduced to classifying the clusters in SVBo or VBo using a set of descriptors. The SOM is an arrangement of neurons connected in a single-layer network, with most of the cases presented in a two-dimensional network. It is characterized by soft competition between neurons in the output layer, where a winner neuron and its neighbors are updated at every iteration in the training. The SOM learns the distribution and topology of the input vectors, generally mapping data \(R^{n}\) onto a regular bidimensional grid. A parametric reference vector \(m_{i}\in R^{n}\) is associated with every node \(i\) in the map. Every input \(x\) is compared with every node, and the closest match is selected, and then the input is mapped onto that location \(c=argmin_{i}\|x-m_{i}\|\). Nodes topographically close to others in the array will learn from the same input with the following formula:  
\[m_{i}(t+1)=m_{i}(t)+\infty*h_{c,i}(t)[x(t)-m_{i}(t)] \tag{6}\]  
The heartbeats extracted are sliced from the 60 th to 170 th sample and clustered, using the self-organizing map (SOM) algorithm. The time frame extracted from the heartbeats ensures that the heartbeat QRS complex is used for clustering, which is an important differentiator between the SVBo and VBo. Figure 4: Illustration of denoising an ECG signal. Figure 3: Expanded version of the stage “clustering and descriptors” of Figure 2.  
Secondly, this work stated that if we computed the trend of the heart rate in a window time, most of the heartbeats above the trend are SVBo, and most of the VBo will be located below the trend. The heart rate is computed taking the distance in samples from the heartbeats that the R peak selected and the previous one. All databases identify a heartbeat with its R peak location; thus, every R peak is already identified in the data. The trend \(t[N]\) is computed using a moving average filter as follows:  
\[y[n]=\sum_{k=0}^{K}w[k]x[n-k] \tag{7}\]  
where \(k\) represents the index terms of the signal, \(w[k]\) represents the window signal, \(x[n-k]\) is the signal value that is being filtered shifting \(k\) terms, and \(y[n]\) is the filtered output signal. RR features such as mean, kurtosis, and SD were not part of the inputs for final clustering. RR intervals as features were used as an initial reference to preclassify the clusters as \"normal\" if they were above the red trend line, as can be seen in Figure 5 and explained in Section 3.4. The beats above the trend level are labeled as above-the-trend beats (ATBs), and they are used in the third step as SVBo, and all those below are labeled as below-the-trend beats (BTBs). These labels become descriptors for each cluster. In Figure 5, a patient's R-R interval, its trend, and the labeling of ATB and BTB in the heart rate are shown. The third assumption is that, in the feature space, most of SVBo are grouped and VBo are scattered. With the help of the second assumption, most heartbeats identified above the trend are labeled as SVBo and with this one class, the one-class SVM (OC-SVM) classifier algorithm is trained to create a nonlinear discriminant function to include more SVBo, and the rest of the heartbeats are classified as VBo. The OC-SVM separates the data using a subset of the class identified as reference for outliers by some prior value specified \(v\in(0,1)\). The solution is to estimate a function \(f\), which is a discriminant between the points marked as outliers and the insiders. The function \(f\) can be seen as  
\[f(x)= \begin{cases}SVM_{o}&\text{if }x\in S\\ VB_{o}&\text{if }x\in S\end{cases}  \tag{8}\]  
Figure 5: Comparison of real label and label above and below the trend.