# A Novel 1-D CCANet for ECG Classification
## 3 Proposed Method
### Neural Feature Extraction
#### 3.2.1 First Convolutional Layer  
We denote \(x_{h,cat}^{(i)}\) the \(i\)-th element (\(i\in\{1,\dots,m\}\)) of an input vector \(x_{h,cat}\). We selected a series of segments of size \(k\) centered on each value \(x_{h,cat}^{(i)}\), to obtain the \(m\) following segments, \(b_{h,1},\dots,b_{h,m}\in\mathbb{R}^{k}\). The latter are then zero-centered and concatenated to build a matrix of the segments \([\overline{b}_{h,1},\dots,\overline{b}_{h,m}]\in\mathbb{R}^{k\times m}\). This procedure is performed on each of the \(N\) training heartbeats and the resulting matrices of segments are finally concatenated to obtain \(\mathbf{X}_{h}\in\mathbb{R}^{k\times Nm}\), \(h=1,2\). Note that our network is simultaneously fed with all the training heartbeats in order to build the two matrices \(\mathbf{X}_{1}\) and \(\mathbf{X}_{2}\).  
Let us address the filter extraction stage. In [20], the filters are found with a CCA, thus by maximizing the correlation between pairs of projected variables. The first projection direction can be obtained by optimizing Equation (4):  
\[\max\rho(a_{1},b_{1})=a_{1}^{\top}S_{12}b_{1} \tag{4}\]  
Figure 3: Proposed 1-D CCANet-SVD.  
with the constraints \(a_{1}^{T}S_{11}a_{1}=1,b_{1}^{T}S_{22}b_{1}=1\), where \(S_{hh^{\prime}}=(\mathbf{X}_{h})(\mathbf{X}_{h^{\prime}})^{T}\), and \(a_{1}\) and \(b_{1}\) are the first canonical vectors for each of the two leads. The Lagrange multiplier technique shows that \(a_{1}\) and \(b_{1}\) are eigenvectors of \(M_{1}=S_{11}^{-1}S_{12}S_{22}^{-1}S_{21}\) and \(M_{2}=S_{22}^{-1}S_{21}S_{11}^{-1}S_{12}\), respectively. Given the first \(l-1\) directions, the \(l\)-th projection direction can be calculated by solving problem (4) with the additional constraints \(a_{i}^{T}S_{11}a_{l}=b_{i}^{T}S_{22}b_{l}=0\), \((i<l)\). In the end, the \(L_{1}\) filters for the first lead are built by taking the \(L_{1}\) primary eigenvectors of \(M_{1}\) (i.e., associated with the \(L_{1}\) biggest eigenvalues), whereas the \(L_{1}\) filters for the second lead are built by considering the \(L_{1}\) primary eigenvectors of \(M_{2}\).  
In this paper, we use a slightly different approach, referred to as the CCA-SVD filter extraction technique. We perform an SVD of both \(M_{1}\), and \(M_{2}\), as per \(M_{1}=U_{1}D_{1}V_{1}^{T}\) and \(M_{2}=U_{2}D_{2}V_{2}^{T}\), where the \(U\) and \(V\) matrices are unitary, and the \(D\) matrices are diagonal with singular values on the diagonals. Using an SVD allows to retrieve the directions, which explain the most the variance of \(M_{1}\) and \(M_{2}\). Since these two matrices derive from the CCA, they capture the correlations between the two leads. Therefore, we use the directions found by performing an SVD on them to have the best explanation of the correlation between the two leads. Consequently, the \(L_{1}\) filters for the first lead are built by taking the columns of \(U_{1}\) that are associated with the \(L_{1}\) biggest singular values of \(D_{1}\), whereas the \(L_{1}\) filters for the second lead are built by considering the columns of \(U_{2}\) that are associated with the \(L_{1}\) biggest singular values of \(D_{2}\). Such an approach yields better results than the traditional CCA filter extraction technique (see _Experiments_). We denote as \(W_{1,l}\) and \(W_{2,l}\), \(l=1,\dots,L_{1}\), the \(L_{1}\) filters of size \(k\) corresponding to the first and second lead, respectively.  
As for the convolutions, for each lead \(h\), each input signal \(x_{h,cat}\) yields \(L_{1}\) outputs \(x_{h,cat,l}=x_{h,cat}*W_{h,l}\), \(l=1,\dots,L_{1}\). The length of the input and output signal were kept identical, thanks to a zero-padding of the input.