# Towards an Automatic Recognition of Artifacts and Features in Plethysmographic Traces
## 5 Feature Identification
### Model Description  
The model chosen to address the challenge of locating and identifying the peaks was a convolutional neural network (CNN) [42]. A CNN consists of a set of convolutional filters designed to detect characteristic waveform patterns, including peak shapes, slopes, and amplitude variations. This architecture is particularly well-suited for peak identification, as it remains robust with variations in the timing and amplitude of peaks within the signal. The CNN convolutional filters consisted of one-dimensional (1D) segments containing 15 timesteps of the plethysmographic trace. The network model consisted of three 1D convolutional layers, followed by a flattening layer that converted the output of the convolutional layers into a 1D vector. This vector was fed to a dense fully connected layer, which produced another 1D vector for each input sample. The final dense layer output a vector three times the size of the input segment, assigning the probability of each timestep belonging to one of these three categories: a \(c\) peak, a \(y\) peak, or neither. Figure 5: An example of artifact detection. The black dots represent the points where there is a significant difference between the data and the model prediction (50 th quantile), and the data deviate from the interval between the 10 th–90 th quantiles. The region under the hatched area represents the region excluded from further analysis. The kernel size [43] for the convolutional layers was set to eight timesteps, which was optimal to capturing local patterns in the signal. No additional padding [44] was applied to the input, resulting in reduced spatial dimensions after each convolution operation. A unitary stride [44] ensured that the filter moved one element at a time, thoroughly exploring the input space without omitting any region. The number of filters in the convolutional layers, the kernel sizes, the dropout rates, and the number of units in the fully connected layer were selected based on model's performance on the validation set, ensuring that the chosen hyperparameters provided the best balance between efficiency and purity. The model was implemented in Keras [38], based on TensorFlow [39], and is summarized in Table 2.  
The model was trained, validated, and tested on a homogeneous sample of supine patients that did not produce experimental noise or artifacts during recording the data. In total, seven patients fulfilled these requirements. The seven samples were split into the training group (six patients, corresponding to approximately 85% of the available dataset), while the one remaining patient (accounting for 15% of the dataset) was considered a validation sample to evaluate the performance of the model. During the training of the model, it was verified that shuffling the training and validation datasets did not change in a significant way the performance of the model. Because of the limited amount of data available for training, the performance of the model was enhanced using the following technique. Since almost every data point was fed to the model multiple times following the creation of 1D segments, the predictions for each time step were repeated \(N\) times. The final classification was obtained by averaging these multiple predictions and applying a threshold of \(1/N\), which classified as peaks the timesteps with at least one \(c\) or \(y\) peak classification. This procedure followed the \"map-reduce\" principle [45; 46], which consists of processing datasets by dividing tasks into parallel \"map\" functions, which process and transform data, and a \"reduce\" function, which aggregates the results to produce the final output. This computing paradigm inherits various desirable properties, such as scalability, which is crucial for real-life applications where the model has to deal with long time series signals.