## 2 Literature Review
### Time Series Data Mining  
Data mining (DM) is a set of methodologies that analyze large datasets, aiming to identify patterns and relationships that can help solve different types of problems. This is achieved by four main processes: data gathering, data preparation, data mining/processing,and a final analysis and interpretation of the results [17]. Time-series data mining (TSDM) applies these processes to sequential data, i.e., data recorded over time [18].  
However, when analyzing some specific time series (such as biomedical signals), TSDM focuses on particular areas of interest, known as events, instead of evaluating the entire time series [19]. Hence, this subsection describes some of the research works on TSDM that are interesting for the present proposal.  
[PERSON] et al. (2012) developed a methodology to visualize variable-length time-series motifs by implementing the symbolic aggregate approximation (SAX) [20]. A grammar-based compression algorithm (greedy and heuristic) was implemented for motif detection. This methodology was performed on ECG signals, and the results demonstrated that recurrent patterns can be effectively identified with grammar induction in time series, even without prior knowledge of their lengths.  
Wave2 Vec is a tool for vectorizing EEG signals to predict a brain disease (alcoholic vs. non-alcoholic patients) proposed by [PERSON] et al. (2018) [21]. This prediction was achieved by quantizing fixed-length EEG segments to one of the hexadecimal symbols of a fixed \"bag-of-symbols\". Subsequently, vectorization was performed with a similar model to Word2 Vec. Finally, three classification models based on deep neural networks (DNN), convolutional neural networks (CNN), and recurrent neural networks (RNN) were compared.  
Grammar induction for detecting anomalies in time series was implemented by [PERSON] et al. in 2020 [22]. This research was carried out on ECG signals transformed into symbols with SAX. The resulting symbolic sequences were analyzed through another NLP technique named grammar induction, where a set of rules that best describes the analyzed phenomena is found. Numerosity reduction was performed to simplify the rules found by the algorithm and to finally implement a \"Rule Density Function\" for anomaly detection.  
It is essential to mention that the previous research had objectives substantially different from those of the current research. [PERSON] et al. (2012) [20] and [PERSON] et al. (2020) [22] used ECG signals, which are significantly more periodic than EEG. Although [PERSON] et al. (2018) [21] implemented their tool on EEG signals, they were searching for another type of information within them (to predict alcoholism). None of the previous examples use sleep EEG or search for CAPs.  
In recent years, sleep analysis, especially the sleep staging task, has also been explored [23; 24]. Nevertheless, the methodologies proposed to solve this task are only indirectly related to the current research, which inquires into the symbolic transformation and/or vectorization of the signals.  
Sleep stage classification labels 30-second-long PSG segments, known as sleep epochs. The labels are usually visually scored and divided into deep-sleep, light-sleep, and awake or, more precisely, S1 or N1, S2 or N2, S3 or N3, and R or REM, which are used to analyze sleep macro-structure.  
In this direction, [PERSON] et al. (2022) [23] analyzed EEG and EOG images in terms of their time and frequency domains by using a CNN on the Sleep-EDEx dataset [25]. They achieved results of 94% both in accuracy and F1 scores. Alternatively, [PERSON] et al. (2023) [24] analyzed a single channel (ECG) to analyze the sleep structure of three different datasets, obtaining accuracy values of 0.849, 0.827, and 0.868.