## 1 Introduction
### Cyclic Alternating Pattern  
The object of this study is the cyclic alternating pattern (CAP), defined by an alternating sequence of two characteristic EEG patterns, each lasting between 2 and 60 seconds [3]. These patterns are the **A-phase**, which is composed of lumps of sleep phasic events, and the **B-phase**, which is simply the return to the background EEG.  
The sequence of **A-B** phases is also called a _CAP cycle_. Yet, there is another sequence composed of the same EEG patterns. This is the _CAP sequence_, which contains at least two complete CAP cycles in succession. The minimum content of a CAP sequence is, therefore, **A-B-A-B**. Examples of CAP cycles and sequences are shown in Figure 1.  
Furthermore, A-phase activities are classified referring to the proportion of EEG synchrony (high-voltage slow waves) and EEG desynchrony (low-voltage fast rhythms) presented throughout the A-phase. The three A-phase types are:  
* **A1:** EEG activity is dominated by EEG synchrony and, if present, EEG desynchrony occupies less than 20% of the complete A-phase duration;
* **A2**: EEG activity is a combination of slow and fast rhythms, with EEG desynchrony occupying between 20% and 50% of the entire A-phase;
* **A3**: Fast, low-amplitude rhythms dominate EEG activity, and strictly more than 50% of the A-phase is occupied by EEG desynchrony.  
Figure 1: Cyclic alternating pattern, with its A-phases (red, blue, and green) and B-phases (gray). Note the difference between a CAP Cycle (phases A-B) and a CAP sequence (consisting of a minimum of phases A-B-A-B).  
[PERSON] et al. (2001) [4] described the detailed rules to score the CAP since it is considered a valuable EEG marker of unstable sleep. CAP rate is an interesting CAP-related parameter that can be computed by following these rules.  
The CAP rate measures the brain's effort to maintain sleep [5] and is proven to increase under conditions that cause vigilance instability, including noise [6], insomnia [7], periodic leg movements [8], nocturnal seizures [9], and certain severe diseases such as s-stage coma [10], and Creutzfeldt-Jakob disease (CJD) [11].  
In the same direction, manifestations of CAP phases have been linked to some specific phenomena. For example, the A-phase represents a favorable condition for the onset of nocturnal motor seizures in generalized and local (frontotemporal) epilepsy [9], bruxism [12], and periodic leg movements [13].  
On the other hand, the B-phase appears to be chronologically related to inhibitory events in nocturnal myoclonus in epileptic patients [5; 9].  
Additionally, CAP is a valuable parameter in the research of sleep disorders across all live stages since it can be detected both in child and adult sleep [14]. Thus, the detection and classification of CAPs are meaningful to understanding some physiological and pathological sleep processes.  
However, CAP detection and classification are commonly not carried out routinely due to the time and attention this problem requires. An automatic tool to solve this task would be helpful to massively analyze CAPs and possibly unravel new interesting relations between CAPs and different health conditions.