Fig. 1
From: Mapping nocturnal arousal across sleep and pain disorders

Automated CAP A-phase detection and A-phase index (API) pipeline9,21. Overnight EEG and accompanying PSG signals are recorded using standard clinical montages. (a) Central EEG derivations (C3 and C4) are fed to the validated automated CAP A-phase detector of Mendonça et al. (2023), which assigns per-sample labels A1, A2 or A32. The outputs from the subtype models were combined through an ensemble forecast. This forecast, at each second, determined the class with the highest probabilistic output from the three subtype models. To align with the CAP scoring rules, a correction procedure was applied. It involved discarding estimations lower than 2 s and converting annotations to the most prevalent subtype during sequences of alternating subtypes. For illustration, schematic waveforms on the top show stylised examples of A1 (slow, high-amplitude), A2 (mixed), and A3 (faster, lower-amplitude) events; these are idealised motifs based on CAP atlas descriptions rather than individual patient traces. (b) Detector outputs are restricted to NREM sleep and aggregated within non-overlapping 60-s windows. For each window and subtype k (A1, A2, A3), the A-phase index APIk is defined as time-in-Ak divided by time-in-NREM within that window, yielding a stage-aware, channel-averaged measure of A-phase burden across the night. (c) Windowed API values are then analysed at the level of sleep stages (N1, N2, N3) and as trajectories over normalised time-of-night, and summarised as early–late differences (ΔAPI). The API does not model B-phases or full A–B CAP cycles and is therefore not a CAP index; it provides a time-resolved read-out of A-phase subtype burden within NREM sleep. CAP, cyclic alternating pattern; API, A‑phase index; AASM, American Academy of Sleep Medicine; NREM, non‑rapid eye movement; C3/C4, central EEG derivations.