## 2 Methods
### OSA Detection Based on Deep Learning Techniques  
In the DL context, convolutional neural networks (CNNs) are the most extensively employed algorithms for a wide variety of applications, being especially relevant in fields like computer vision [54], medicine [55], and speech recognition, among others [56]. They are generally constituted by an \(M\times M\times L\) input layer followed by one or more convolutional layers, a fully connected layer, and eventually an output layer [57]. Unlike the conventional multi-layer perceptron networks, convolutional layers are typically oriented to make use of full 2-dimensional input data [58]. These layers use a series of filters or _kernels_ that generate abstract representations denominated feature maps, i.e., matrix representations that capture patterns within the input image. These feature maps are obtained as the convolution of an input image with a kernel matrix containing the weights for every corresponding pixel [58]. Kernels can have similar dimensions but different sizes compared to the input layer. These particular filters slide along the input image to generate feature maps employing a determined and quantified displacement measure, usually referred to as _stride_, which specifies the number of pixels that the kernel has to move along to perform the convolutional operations [58]. Furthermore, for more complex and long-concatenated networks, a pooling layer may also be included at the end of each convolutional layer to downsample the feature maps by aggregating features from local spatial regions [59]. In addition, the process involves mapping both RP and DM representations with specific color codes suitable for input into generic DL-based classifiers. DMs utilize MATLAB's  
Figure 4: Generation of DM and RP images from HRV series: (**a**) illustrates an apneic episode, while (**b**) presents a normal episode. Both show how HRV data are transformed into corresponding DM and RP images for further analysis. jet colormap for mapping the distances (Figure 5). On the other side, traditional RPs also employ the same colormap, resulting in red and blue images similar to those depicted in Figure 6. It should be noted that the graphs in Figures 5 and 6 come from the same phase spaces. These representations allow for a distinct visualization of the data, facilitating their use in the CNN models applied in this study. Notice that colorbars follow the same criteria stated in the previous section. All the proposed CNN-based architectures were supplied with identical color images of DMs and RPs. Nevertheless, these images were rescaled to fit the corresponding dimensions of the input layers. In the current study, in order to discern between normal and apneic episodes, two distinct CNN architectures were employed. Firstly, a customized CNN model (referred to as cuCNN) was designed, as illustrated in Table 2. This architecture incorporated a limited number of layers, starting with three convolutional layers featuring 32, 64, and 128 filters (kernels), each with dimensions of \(3\times 3\) and a stride of \(1\times 1\). Subsequently, the outputs from each convolutional layer underwent max pooling and batch normalization, employing the rectified linear unit (ReLU) activation function [60; 61]. Following the last convolutional layer, two fully connected layers were introduced to facilitate the extraction of higher-level features [62]. These high-level features were then processed by an output layer, which determined the classification outcome based on cross-entropy loss and the input weights computed in the preceding layer [63]. To prevent overfitting and enhance the network's generalization capabilities, a dropout layer with a 50% probability was placed just before the final fully connected layer [64]. Notably, this proposed CNN architecture comprised 25.7 million learnable parameters. Figure 5: Visual comparison of DMs for apneic and normal episodes: (**a,b**) represent apneic episodes, whereas (**c,d**) represent normal episodes.