Spectral Slope and Lempel–Ziv Complexity as Robust Markers of Brain States during Sleep and Wakefulness

Nonoscillatory measures of brain activity such as the spectral slope and Lempel–Ziv complexity are affected by many neurological disorders and modulated by sleep. A multitude of frequency ranges, particularly a broadband (encompassing the full spectrum) and a narrowband approach, have been used especially for estimating the spectral slope. However, the effects of choosing different frequency ranges have not yet been explored in detail. Here, we evaluated the impact of sleep stage and task engagement (resting, attention, and memory) on slope and complexity in a narrowband (30–45 Hz) and broadband (1–45 Hz) frequency range in 28 healthy male human subjects (21.54 ± 1.90 years) using a within-subject design over 2 weeks with three recording nights and days per subject. We strived to determine how different brain states and frequency ranges affect slope and complexity and how the two measures perform in comparison. In the broadband range, the slope steepened, and complexity decreased continuously from wakefulness to N3 sleep. REM sleep, however, was best discriminated by the narrowband slope. Importantly, slope and complexity also differed between tasks during wakefulness. While narrowband complexity decreased with task engagement, the slope flattened in both frequency ranges. Interestingly, only the narrowband slope was positively correlated with task performance. Our results show that slope and complexity are sensitive indices of brain state variations during wakefulness and sleep. However, the spectral slope yields more information and could be used for a greater variety of research questions than Lempel–Ziv complexity, especially when a narrowband frequency range is used.


Introduction
Neural oscillations are a dominant electrophysiological signature of human brain activity.For instance, quiet wakefulness is characterized by pronounced alpha-band activity (Klimesch et al., 1993;Jensen and Mazaheri, 2010), and sleep stages are defined by oscillatory events like sleep spindles and slow oscillations (Terzano et al., 2002;Richard et al., 2012).However, recent evidence suggests that non-oscillatory, irregular brain activity, assessed by Lempel-Ziv complexity (Lempel and Ziv, 1976;Welch, 1984) or the spectral slope (He, 2014), also carries meaningful information about electrophysiological variations across brain states.
The spectral slope is obtained in the frequency domain and reflects the steepness of the power spectrum.In contrast, Lempel-Ziv complexity (Welch, 1984) is computed in the time domain and reflects the regularity of a signal (Lau et al., 2022).Thus, Lempel-Ziv complexity is still strongly influenced by oscillatory activity (Extended Data Fig. 1-4), whereas the spectral slope captures mainly aperiodic activity (Donoghue et al., 2020).
Computational modeling has demonstrated that the spectral slope constitutes a marker of the brain's excitation to inhibition (E/I) balance (Gao et al., 2017), which is impaired in a variety of clinical conditions (Rubenstein and Merzenich, 2003;Gao and Penzes, 2015;Robertson et al., 2019;Karalunas et al., 2022).Interestingly, some disorders, for instance, epilepsy, have been associated not only with alterations in the spectral slope but also in complexity (Wong, 2010;Aarabi and He, 2012;Zhu et al., 2017).Overall, previous studies suggest that both, spectral slope and Lempel-Ziv complexity, capture brain state changes in similar ways.The slope steepens (i.e., decreases) under anesthesia (Gao et al., 2017;Colombo et al., 2019;Lendner et al., 2020;Waschke et al., 2021) and during sleep (Ma et al., 2018;Miskovic et al., 2019;Lendner et al., 2020).Similarly, Lempel-Ziv complexity is reduced under anesthesia (Zhang et al., 2001;Ferenets et al., 2007) and with increasing sleep depth (Andrillon et al., 2016;Schartner et al., 2017).Evidence from Waschke et al. (2021) suggests that the spectral slope further tracks the level of attention, whereby faster response times are indexed by flatter slopes.This is in line with work demonstrating that the slope is indicative of cognitive processing speed (Ouyang et al., 2020;Pathania et al., 2022) and modulated by cognitive decline (Voytek et al., 2015;Voytek and Knight, 2015;Dave et al., 2018).Relatedly, higher task-related Lempel-Ziv complexity has also been suggested to track higher processing speed (Mediano et al., 2021).
A big issue, however, that has hampered the assessment of and comparability between slope and complexity is the huge heterogeneity in frequency ranges used to calculate these measures.While there will be no frequency range without potential confounds, it is important to compare different frequency ranges and calculation settings to gain a better understanding of how the choice of a certain frequency range affects the data.Particularly for the spectral slope, researchers have argued either in favor of broadband (Podvalny et al., 2015;Waschke et al., 2021;Karalunas et al., 2022) or more narrowband (Gao et al., 2017;Lendner et al., 2020) frequency ranges, commonly within 1-45/50 Hz.While broadband ranges (e.g., 1-45 Hz) encompass more of the total signal and result in better overall fits (Donoghue et al., 2020;Gerster et al., 2022), narrowband ranges (e.g., 30-45 Hz) are less affected by slower oscillatory activity and reflect mostly aperiodic activity (Gao et al., 2017;Lendner et al., 2020).But also regarding complexity, recent evidence demonstrated that this metric is strongly affected by different frequency contents and might be mainly driven by lower frequencies (González et al., 2022).
Taken together, a functional overlap between the spectral slope and Lempel-Ziv complexity is suggested in the literature.However, direct comparisons between the two measures are rare and limited to quiet wakefulness and anesthesia (Medel et al., 2023).Thus, even though slope and complexity are both biomarkers of arousal that are similarly modulated by changes in brain states, it is yet unclear how they behave in comparison.Moreover, it remains unclear how the selection of different frequency ranges affects the information captured by them.
Here, we leverage a within-subject design with multiple sleep and wake recordings over 14 days (1) to investigate whether spectral slope and Lempel-Ziv complexity are modulated by sleep stages and tasks during wakefulness and (2) to assess their significance for cognition in different frequency ranges.Additionally, we aim (3) to evaluate which parameter might be better suited under different circumstances and for different research questions.Finally, by using multiple recordings per subject, we assess the stability of these measures as indices of underlying brain states.

Participants and inclusion criteria
We recorded data from 28 biologically male participants (18-25 years; mean age, 21.54 ± 1.90 years) to avoid previously reported sex effects on sleep, attributed to hormonal variations (Alonso et al., 2021;Plamberger et al., 2021).Final sample sizes varied for each analysis between N = 26-28 as some participants had missing data for specific tasks or timepoints (the exact sample size for each analysis is provided in the corresponding figure caption).All participants were free of medication and did not suffer from a mental or physiological illness or reported sleep problems.They adhered to a regular sleep-wake rhythm (i.e., regular bedtimes with ∼8 h of sleep per night) and refrained from drug use and above-average caffeine consumption (more than three cups of coffee per day) during participation.For screening purposes, all subjects filled in an entrance questionnaire in which we checked for sleep quality, mood, anxiety, perceived stress level, and chronotype to exclude individuals with clinical symptoms in advance (compare Extended Data Fig. 1-1).Written informed consent was obtained from every participant, and they were remunerated with either 100€ and 16 h course credit or 50€ and 24 h course credit.The study was approved by the local ethics committee and conducted in agreement with the Declaration of Helsinki.

Experimental protocol
Study design.Each subject participated over a time span of 14 days (for an outline of the protocol, see Fig. 1).From that day on, participants wore an actigraph (MotionWatch 8; CamNtech; Table 1) and filled in daily online sleep protocols (LimeSurvey), which were checked for compliance with a regular sleep-wake rhythm.An overview of all key resources is given in Table 1.
The first recording was scheduled on day 4 for adaptation purposes to avoid potential first night effects (Browman and Cartwright, 1980;Curcio et al., 2004).After electrode placement, participants were familiarized with the resting session and Go/Nogo (GNG) task.Bedtime was scheduled for ∼11:00 P.M., and participants were woken up 8 h after lights out, thereby adhering to general sleep hygiene recommendations (Watson et al., 2015;Chaput et al., 2018).The experimental recordings were scheduled on days 7, 10, and 13.Participants arrived at 6:00 P.M. and electrodes were mounted again.Recordings started with an initial resting session (3 min eyes closed and 3 min eyes open) and the GNG task (10 min), which was followed by the encoding sessions (two times 14 min) of a declarative memory task.Before the first cued recall, another resting and GNG session was conducted.Afterward, participants had a break of 1.5 h in which they read standardized stories under different light conditions.These conditions consisted of either reading from a smartphone with or without a blue light filter or from a printed book, leading to varying levels of short-wavelength light exposure with dim background room lighting (Höhn et al., 2021;Schmid et al., 2021).Before going to bed at ∼11:00 P.M., participants completed the last resting and GNG session of the day.After awakening, a morning session of resting and the GNG task as well as another cued recall session were performed.During all wake recordings, daylight mimicking room lights (provided by Emilum) were dimmed to 4.5 photopic lux, and room temperature was adjusted via air conditioning based on participant's preferences.Go/Nogo task.To assess objective levels of attention and inhibitory control, we implemented an auditory version of the Go/Nogo paradigm (Donders, 1969) via the Psychophysics Toolbox (PTB-3; Kleiner et al., 2007) in MATLAB (Release 2018b, The MathWorks).Due to the plentitude of tasks already included in the study design, we opted for an attention task that measures various aspects of attention and inhibitory control and therefore chose the Go/Nogo paradigm over a classical psychomotor vigilance task.Thus, participants were asked to react as quickly as possible on a response time box (RTBox v5/6; Ohio State University) whenever they heard a "Go" sound and needed to inhibit their reaction when a "Nogo" sound was played.The task comprised 400 trials with Go sounds being presented in 80% of the trials (the order of Go and Nogo sounds was randomized each time).The two stimuli used for the Go and Nogo sounds were low-(1,000 Hz) and high-pitched (1,500 Hz) tones, which were presented for 50 ms with a varying interstimulus interval (1,480-1,880 ms).Whether the low-or high-pitched sound represented the Go-signal was determined by chance at the beginning of each session.Participants had to react within 500 ms for the response to be considered valid, and reaction times longer than 500 ms were regarded as attentional lapses.From each session, the performance score was computed by dividing the percentage of correct trials by the median reaction time of all valid responses (≤500 ms, no errors) in milliseconds (Figueiro et al., 2016).
Declarative memory task.Participants encoded a set of 80 word pairs on days 7, 10, and 13.To avoid learning effects over time, we presented a different but similarly difficult set of 80 word pairs on each of the 3 days.The order of the sets was randomized across subjects.Each set was presented twice for 14 min during encoding, and the data from both encoding sessions was pooled.Each word pair was presented for 1,500 ms, followed by a fixation-cross for 8,500 ms.Participants were instructed to encode the word pair as vividly as possible during the presentation of the fixation-cross by imagining a semantic connection between the two words.During the cued recall sessions, only the first word of a pair was presented, and participants were asked to press a button on the response time box as soon as they remembered the second word.Whenever a button was pressed, the participant was instructed to name the missing word and a fixationcross appeared for 3,500 ms while the experimenter noted the answer.When no button was pressed, the fixation-cross appeared automatically after 6,500 ms.Recall performance was measured as the percentage of correctly recalled word pairs during each retrieval session.To assess the overnight change in performance, we computed the increase in percentage from the evening performance to the following morning.

EEG recording and analyses
All electrophysiological data were recorded with a sampling rate of 500 Hz via the BrainVision Recorder software (Version 2.11) using a 32-channel BrainAmp system (Brain Products).We placed 11 gold-cup electrodes (Grass Technologies, Astro-Med) according to the international 10-20 system on the positions: F3, Fz, F4, C3, Cz, C4, P3, Pz, P4, O1, and O2.Linked mastoids were used for offline re-referencing as the data were online referenced against Cz.The position Fpz was used as ground electrode.Additionally, two EMG electrodes were placed on the musculus mentalis for measuring muscle activity during sleep and four EOG electrodes around the eyes to record horizontal and vertical eye movements.Impedances were always kept below 10 kΩ.
Polysomnography.Time in bed was standardized for all polysomnography recordings to 8 h.For sleep staging, the data were first low-pass filtered at 30 Hz and re-referenced to contralateral mastoids with the BrainVision Analyzer software (Version 2.2.0.7383, Brain Products GmbH, 2019).EOG and EMG channels were referenced bipolarly and the data were down-sampled to 128 Hz for further staging.Sleep stages were classified for each 30 s epoch with the Somnolyzer 24 × 7 algorithm (Koninklijke Philips N.V.) in accordance with the criteria of the American Academy of Sleep Medicine (Richard et al., 2012).The results were finally verified by a human expert scorer.The general sleep architecture of each night is presented descriptively in Extended Data Figure 1-2.
EEG preprocessing.In a first step, the raw data were processed with the BrainVision Analyzer software, and we applied a 0.3 Hz high-pass as well as a 50 Hz notch filter.EEG channels were re-referenced to linked mastoids and the online reference Cz was restored.We corrected for eye movements with the Gratton and Coles method (Gratton et al., 1983; only implemented for data during wakefulness) and ran an automatic artifact detection procedure on all scalp EEG channels, which was manually checked afterward.Events with a voltage jump exceeding 50 μV/ms, an absolute voltage difference of >400 μV within 200 ms or activity <0.5 μV for at least 100 ms were marked as bad intervals.If severe muscle or movement artifacts were missed, they were additionally marked manually.The data were then down-sampled to 250 Hz and exported for further analyses in MATLAB.The continuous data were subsequently segmented into epochs of 4 s for each task and sleep stage using the FieldTrip toolbox (Oostenveld et al., 2011).To be able to compare all task and sleep data, we decided to set the epoch length to 4 s as this enabled the best tradeoff between sufficient epochs even for the shortest tasks (3 min resting sessions) and an adequate frequency resolution.All artifact-containing epochs (defined as >1% being detected as artifact) were removed.Since the remaining number of clean epochs from the tasks (resting, Go/Nogo, encoding, and retrieval) and sleep stages (WAKE, N1, N2, N3, and REM) varied due to different recording lengths, we balanced the number of epochs across tasks and sleep stages for the multivariate pattern (MVPA) analyses.We set the maximum number of epochs for the MVPA analyses to the highest possible number of epochs from the shortest task (i.e., 45 epochs as the resting sessions only comprised 3 min).To do so, we drew a random subset of 45 epochs from all data that contained >45 clean epochs.For all other analyses, we used all available data to maximize the signal-to-noise ratio wherever possible (compare Extended Data Fig. 1-3).
Spectral slope.To obtain the spectral slope, we first calculated power spectra between 0.5 and 45 Hz from the preprocessed, 4 s segmented data via the mtmfft method in FieldTrip (Oostenveld et al., 2011) using a multitaper approach (1 Hz frequency smoothing).To extract the slope, we applied robust linear fits (using the robust fit MATLAB function) in log-log space between 30 and 45 Hz.We decided to use robust linear fits instead of using the FOOOF algorithm (Donoghue et al., 2020) for the narrowband frequency range since this approach has already been established to yield a sensitive aperiodic marker of arousal by Lendner et al. (2020) and because in this frequency range also the FOOOF would approximate a linear fit, thus leading to highly comparable results.However, for the broadband frequency range (1-45 Hz), we applied the FOOOF algorithm to extract the slope since linear fits would have been skewed by oscillatory bumps in the power spectrum.
Lempel-Ziv Complexity.We followed previous approaches (Schartner et al., 2015;Mediano et al., 2021;Medel et al., 2023) and calculated the Lempel-Ziv-Welch complexity (Lempel and Ziv, 1976;Welch, 1984) per channel and epoch.To obtain the complexity in the same frequency ranges in which we calculated the spectral slope, we applied additional 1 or 30 Hz high-pass and 45 Hz low-pass filters.As Rivolta et al. (2014) demonstrated that 1,000 datapoints are sufficient for reliable Lempel-Ziv complexity analyses during sleep, we used the same 4 s segmented data (corresponding to 1,000 sampling points per epoch in our down-sampled data) as for the spectral slope.We then applied a Hilbert transformation on each epoch to obtain the instantaneous amplitude.Afterward, we binarized the resulting single epoch data around its median amplitude and transformed it into a binary sequence.Values of 1 were given for amplitude samples above the median and values of 0 for amplitudes below (or equal with) the median.This binary sequence of ones and zeros was subjected to the Lempel-Ziv-Welch complexity algorithm (Comsa, 2019) in MATLAB.In general, higher complexity values (normalized between 0 and 1) reflect more random and unpredictable signals (compare Extended Data Fig. 1-4).

Statistical analyses
Statistics were calculated in RStudio (Version 4.1.2.).MATLAB functions from the FieldTrip toolbox and the ggplotframework (Wickham, 2016) in R were adapted for data visualization.
ANOVA-type analyses and correlations.All analyses involved three repeated measurements (days 7, 10, and 13; compare Fig. 1) and therefore at least two factors (lab-session and task or sleep stage).Since in most cases at least one assumption for parametrical testing was violated, we decided to compute more conservative semiparametrical analyses with the MANOVA.RM package (Friedrich et al., 2019).For these factorial analyses, data were averaged over all EEG electrodes to facilitate interpretation of the results.In the statistical results, we always refer to the Wald-type statistics (WTS) with empirical p values obtained from permutation resampling procedures and 10,000 iterations.Whenever multiple comparisons were conducted, p values were corrected with the Benjamini-Hochberg procedure (Benjamini and Hochberg, 1995).
For correlational analyses, we computed the Spearman rho coefficients instead of Pearson's correlations whenever the normality assumption was significantly violated (indicated by Shapiro-Wilk tests) and for all cluster correlations on the whole scalp level.For the cluster corrected correlation approach, we used the Monte Carlo method with 10,000 iterations to assess the relationship between EEG parameters per channel and behavioral measures.
Multivariate pattern analyses.Since it is difficult to take topographical patterns into account in classical factorial designs, we additionally computed MVPA analyses using the MVPA-Light toolbox (Treder, 2020) to exploit the information present in the complexity and slope data as patterns across electrodes.For each task and sleep stage, the complexity and slope from every epoch and electrode was fed into the classifier.Thus, the single epochs per subject were used for training and testing while the complexity and slope patterns over electrodes represented the multivariate information.For comparisons between more than two tasks or sleep stages, multiclass linear discriminant analyses (LDAs) were used and regular LDA for two-condition comparisons.We calculated classification accuracies per subject via leave-one-out crossvalidation (LOO-CV) to account for the restricted amount of data available for training and testing.Since no effects regarding the different lab-sessions emerged, we pooled the data from the different lab-sessions for each participant to improve the reliability of the MVPA analyses.

Data and code accessibility
The data and code necessary to reproduce the main results and figures is freely available online at https://doi.org/10.17605/OSF.IO/QGPW4.

Results
We calculated the spectral slope and Lempel-Ziv complexity for all sleep stages and tasks in a narrowband (30-45 Hz) and broadband (1-45 Hz) frequency range (compare Fig. 1B,C; Colombo et al., 2019;Lendner et al., 2020Lendner et al., , 2022;;Jacob et al., 2021;Kozhemiako et al., 2022;Ameen et al., 2023;Helson et al., 2023).We set the upper frequency limit to 45 Hz to avoid line-noise influences ∼50 Hz and the need for fitting a knee in higher frequencies.Likewise, we decided to set the lower frequency boundary for the broadband range at 1 Hz since the area below often exhibits a plateau that would require fitting an additional knee or would otherwise also distort the data (He et al., 2010;Gerster et al., 2022).The 30 Hz lower limit for the narrowband range was selected based on original modeling work for the spectral slope, demonstrating that the 30-45 Hz range is capable of tracking changes in the brain's excitation/inhibition balance (Gao et al., 2017).Furthermore, a large replication study with >10,000 polysomnography recordings confirmed that the 30-45 Hz range tracks the hypnogram accurately (Kozhemiako et al., 2022), a finding that has also been supported by others who used a data-driven fitting algorithm to compare different frequency ranges for slope estimation (Lendner et al., 2020(Lendner et al., , 2022)).

Spectral slope and Lempel-Ziv complexity delineate brain states during sleep
The narrowband slope and complexity were significantly modulated by sleep stage (N1, N2, N3, and REM sleep: WTS (4) = 133.57,p < 0.001 and WTS (4) = 21.64,p = 0.004, respectively).The narrowband slope was significantly steeper in all sleep stages compared with wakefulness with the steepest slope during REM sleep.In contrast, the narrowband complexity slightly increased from wakefulness to all sleep stages (Fig. 2).To control for muscular activity in the 40-70 Hz range, we also computed the slope and complexity of the EMG channels (Extended Data Figs.2-1, 2-2).When partialling out the First, the raw signal, filtered within a certain frequency range, is Hilbert transformed.Second, the resulting data is binarized around its median amplitude and stored as a vector of zeros and ones.Lastly, the Lempel-Ziv-Welch algorithm (Welch, 1984) is applied on this binary sequence in order to obtain a complexity value, which is driven by the number of unique repetitions of ones and zeros.The effect of signal regularity on Lempel-Ziv complexity and the spectral slope is further demonstrated in Extended Data Figure 1-4.For an overview of the number of epochs that were used for all analyses, see Extended Data Figure 1-3.
EMG from the EEG data, the modulation of the EEG slope and complexity remained largely unaffected, indicating that EMG activity did not significantly confound the results.
When the broadband frequency range was used for estimation, the effect of sleep stage was even more pronounced in both parameters (spectral slope: WTS (4) = 1,088.28,p < 0.001; Lempel-Ziv complexity: WTS (4) = 857.60,p < 0.001).Both, broadband slope and complexity, significantly decreased from shallow (N1) to deep NREM sleep (N3).For REM sleep, however, both markers increased again (Fig. 3), arguably reflecting more wake-like brain activity.While REM sleep was significantly different from wakefulness in both frequency ranges for both parameters (all p < 0.025), it was best discernable with the narrowband slope.We found no significant effects of the repeated measurements (all p adj. ≥ 0.419), revealing that the effect of sleep stage robustly emerged in all individual recordings per subject.

Spectral slope and Lempel-Ziv complexity vary across tasks
Next, we investigated whether spectral slope and Lempel-Ziv complexity can differentiate between resting and task engagement as well as between the different active tasks.We calculated both markers from resting sessions with eyes closed (REC) and eyes open (REO), an auditory Go/Nogo (GNG) task, an encoding session (ENC) from a declarative memory task, as well as its retrieval session (RET).For this, we focused on the task data from the evening recordings (see dashed dark-green rectangle in Fig. 1A).Theoretically, a task engagement effect, representing a shift toward excitation (i.e., flatter slopes and higher complexity), should be visible between the resting sessions and the GNG or learning task.Since the GNG task was mainly auditory and should rely on different cognitive resources compared with the visual/verbal memory task, we also expected differences between the GNG, ENC, and RET sessions.In the narrowband range, we observed a significant flattening of the slope (WTS (4) = 56.64,p < 0.001) along with a decrease in complexity (WTS (4) = 199.55,p < 0.001) from resting sessions to active tasks, including GNG, ENC, and RET (Fig. 4).As expected, the slope was flatter during the GNG, ENC, and RET tasks than during resting.However, there was an additional flattening of the narrowband slope during RET compared with that during GNG and ENC, potentially reflecting higher cognitive engagement.Narrowband Lempel-Ziv complexity did not differ between the resting and GNG sessions (all p adj. > 0.110) but decreased from the GNG to the ENC session and was lowest during retrieval.
When investigating the broadband frequency range, we found that the diverging pattern between spectral slope and Lempel-Ziv complexity disappeared and both parameters were increasing from rest to active task engagement (slope: WTS (4) = 40.46,p < 0.001; complexity: WTS (4) = 46.24,p < 0.001; Fig. 5).In addition, Lempel-Ziv complexity differed  4-1 for an analysis averaged over all timepoints per lab-session and Extended Data Fig. 4-2 for an analysis demonstrating similar results when using a different task order).Center figures show the data averaged over all channels and topographical maps are provided below (colorcoding refers to z values of slope or complexity computed from the grand average across all tasks).In A, the log-log power spectra for each task are provided to illustrate narrowband slope differences across tasks.Classification accuracies are shown on the right side.A, The spectral slope flattens when engaging in cognitive tasks (Go/Nogo and learning) and is flattest during the retrieval session of the learning task.B, Lempel-Ziv complexity decreases with task engagement and reaches its minimum during the retrieval session.***p < 0.001, **p ≤ 0.010, *p ≤ 0.050, n.s.p > 0.050; p values adjusted for multiple comparisons; error bars show 95% confidence intervals (N = 28).
between the two resting sessions (eyes closed and eyes open), likely reflecting a difference in alpha power (8-12 Hz).This further supports the notion that oscillatory components exert a greater influence on Lempel-Ziv complexity than those on the spectral slope.Again, we did not observe any effects of the repeated measurements (all p adj. ≥ 0.222).
To control for task order and potential influences of exhaustion, we repeated the analyses with the task data averaged over all timepoints (compare Fig. 1A; i.e., the resting and GNG data were averaged over four timepoints, the RET data were over two timepoints, and the ENC was only completed once) and with a different order of tasks.Both control analyses showed the same pattern as the original analysis (compare Extended Data Figs.4-1, 4-2 as well as Extended Data Figs.5-1, 5-2).Further, we tested in the GNG task whether it would have made a difference if we focused only on epochs with or without stimulus presentation and did not detect strong differences between different epoch types (compare Extended Data Fig. 5-3).To evaluate the topographical distribution of the spectral slope and Lempel-Ziv complexity, we also ran MVPA analyses with multiclass LDAs.Thus, we quantified how well sleep stages and tasks could be decoded by taking the topographical distribution of the slope and complexity into account.In both frequency ranges and for both parameters, classification accuracies were significantly above chance level (20%; p < 0.001).In the narrowband range, the slope was significantly more informative about the underlying brain state (i.e., yielded higher classification accuracies) than complexity (sleep: WTS (1) = 166.15,p < 0.001; wake: WTS (1) = 82.28,p < 0.001; compare Fig. 6A).Within the broadband range, this was only true for the sleep stage classification (WTS (1) = 19.84,p < 0.001).As for the classification of tasks during wakefulness, the Lempel-Ziv complexity was more informative (WTS (1) = 22.38, p < 0.001; compare Fig. 6B).An overview of the pairwise classification accuracies for all sleep stages and task pairings is presented in Extended Data Figures 6-1 and 6-2.Correlations between slope and complexity as well as analyses of the robustness across repeated measurements are presented in Extended Data Figures 6-3, 6-4, and 6-5.

The narrowband spectral slope as an electrophysiological marker of task performance
Having established that slope and complexity are not only modulated by sleep but also differ between tasks in a frequency range-specific manner, we next investigated their relationship with task performance.We correlated the slope and complexity from the narrow-and broadband frequency range during the GNG task with the according performance scores (percentage of correct trials divided by median reaction time) over multiple sessions.
Within the narrowband range, the slope was more consistently related to higher task performance than the complexity, reaching statistical significance at 3 out of 4 timepoints (compare Fig. 7).In the broadband range, the relationship with task performance was also consistently positive for both parameters but did not reach statistical significance (compare Extended Data Fig. 7-1).Thus, only the narrowband slope reliably predicted GNG task performance.
Next, we determined whether the narrowband slope would also track memory performance.Thus, we correlated slope and complexity during the RET sessions of the declarative memory task with recall performance (i.e., percentage of correctly recalled word pairs).Even though the slope was again consistently positively correlated with recall performance, only few correlations (C4 and P4 at the delayed retrieval) reached statistical significance (Fig. 8).Despite the lack of  6-1 for all pairwise classification accuracies) for the spectral slope and Lempel-Ziv complexity regarding sleep stages (WAKE, N1, N2, N3, REM) and tasks during wakefulness (resting eyes closed, resting eyes open, auditory Go/Nogo, encoding, retrieval).Sleep stages and tasks could be decoded more precisely with the spectral slope.Overall classification accuracy was significantly higher for tasks than for sleep stages.B, Comparison of the classification accuracies across tasks and sleep stages for slope and complexity within 1-45 Hz (see Extended Data Fig. 6-2 for the pairwise classifications).The slope only yielded better decoding performance during sleep, whereas task classification worked better when using Lempel-Ziv complexity, which is arguably due to the difference in complexity between the two resting conditions that is not present in the slope.The dotted red lines represent chance level (20%).The correlation between slope and complexity within 30-45 Hz and 1-45 Hz is presented in Extended Data Figure 6 statistical significance, the positive trend of tracking recall performance was only observed for the narrowband spectral slope.In the broadband frequency range, both parameters did not show a consistent relationship with recall performance (Extended Data Fig. 8-1).
Finally, we assessed whether the performance in the GNG and RET task were related, resulting from better overall attention and higher task engagement.However, there was no significant relationship between the performance scores in the two tasks (evening: rho = 0.10, p = 0.611; morning: rho = 0.06, p = 0.766).Thus, subjects that performed well in the GNG task did not necessarily achieve high recall performance scores.

Discussion
In this study comprising three experimental recordings with multiple measurements per subject, we demonstrated that the spectral slope and Lempel-Ziv complexity (1) reliably delineate sleep stages and (2) are modulated by different cognitive tasks.Critically, we provided evidence that (3) the modulation of the slope and complexity strongly depends on the frequency content.While the broadband (1-45 Hz) slope and complexity were more strongly modulated by sleep stages in general, the narrowband (30-45 Hz) slope best differentiated REM sleep from wakefulness and reflects mainly  7-1 for the 1-45 Hz range).For the large scatterplots, data were averaged across all lab-sessions (small scatterplots show the relationship per lab-session).The topoplots depict the correlation strength for each electrode.Electrodes forming a significant cluster are highlighted with asterisks.Those showing a significant correlation after false discovery rate correction but did not from a cluster are marked with a cross.Only the narrowband spectral slope showed a consistent positive relationship with task performance (N = 26).aperiodic activity.Moreover, we found that (4) active task engagement (i.e., switching from resting to an attention or learning task) was associated with flatter slopes in the narrow-and broadband range, but only with higher complexity in the broadband range.The broadband range was also better suited to capture differences between tasks in the classification analyses.However, (5) only the narrowband slope tracked task performance in an auditory attention task and trended toward significance regarding memory performance.

The narrowband slope uniquely tracks aperiodic brain activity in REM
Our findings corroborate previous research demonstrating that the spectral slope and Lempel-Ziv complexity are sensitive markers of sleep stage (Abásolo et al., 2015;Schartner et al., 2017;Lendner et al., 2020;Bódizs et al., 2021;Kozhemiako et al., 2022;Pascovich et al., 2022).We extended these findings by leveraging repeated EEG recordings per subject and confirmed that the two parameters can robustly differentiate between all sleep stages and wakefulness across multiple recording days.In contrast to complexity, the calculation of the slope was ∼3.5 times more computationally efficient with our implementations, highlighting its practical applicability for closed loop and clinical settings.
Overall, sleep stages could be better delineated within a broadband frequency range.This is probably because the broadband range encompasses the frequencies typically used for traditional sleep scoring, such as slow wave activity (0.5-4 Hz) and sleep spindles (11-15 Hz;Dijk, 1995), thereby increasing the sleep stage-specific information in the underlying signal.Interestingly, REM sleep was only clearly distinguished from all other sleep stages by the narrowband slope, in line with findings from Lendner et al. (2020).In the broadband range, both parameters showed a relative, more wake-like, increase during REM sleep.Since REM sleep (sometimes called "paradoxical sleep"; Peigneux et al., 2001or Siegel, 2011) is characterized by a more desynchronized EEG pattern that lacks prominent oscillations (Peever and Fuller, 2017;  For the large scatterplots, data was averaged across all lab-sessions (small scatterplots show the relationship per session).The topoplots represent the strength of the correlations on each electrode.Even though the spectral slope was consistently positively correlated with recall performance, no electrodes formed a significant cluster.Significant single electrodes that survived false discovery rate correction are highlighted with a cross (N = 28).Blumberg et al., 2020), these disparate results between the two frequency ranges support the notion that the narrowband slope mainly measured aperiodic activity.The relative increase in broadband complexity during REM has been attributed to higher levels of conscious content that accompany vivid dreaming and thus require more complex brain activity than deeper, mostly dreamless sleep stages (Mateos et al., 2018;Lau et al., 2022).
Previous modeling work has linked the narrowband slope with the E/I balance in the brain (Gao et al., 2017).Within this framework, steeper slopes during REM sleep potentially reflect stronger inhibitory brain activity.This might allow the brain to decouple from its environment and, by maintaining muscle atonia, to enable the consolidation of emotional memories and the experience of vivid dreams (Aime et al., 2022) without acting them out.The narrowband complexity, however, does not appear to yield informative results and stayed almost constant across sleep stages.Thus, for complexity it might not be sensible to select a narrowband frequency range.Other research also provided evidence that complexity changes are mainly driven by frequencies at the lower end of the frequency spectrum (González et al., 2022).

Aperiodic brain activity tracks task engagement and performance
We demonstrated that the spectral slope and Lempel-Ziv complexity can also track different tasks and are affected by task engagement.That slope and complexity are modulated during wakefulness is in line with other research (Sheehan et al., 2018;Jacob et al., 2021;Mediano et al., 2021;Waschke et al., 2021).However, to our best knowledge this is the first study comparing multiple tasks and different rest conditions as well as the effect of different frequency ranges.Like for sleep, we observed a homogenous modulation of the broadband slope and complexity, where flatter slopes and higher complexity values were associated with active task engagement.
In the E/I balance framework, flatter slopes are the result of higher excitation in the brain (Gao et al., 2017;Chini et al., 2022).Thus, our observed pattern of a flattening of the slope with task engagement and between cognitive tasks might be attributed to differences in the amount of required cognitive resources, leading to stronger excitatory brain activity (Harris and Thiele, 2011;He, 2011;Kanashiro et al., 2017).Unlike Waschke et al. (2021), who reported a stronger occipital flattening of the slope in a visual compared with an auditory task, we did not observe clear topographical differences between the auditory Go/Nogo task and the declarative memory task that relied on visual content.However, this lack of topographical distinctiveness might be due to a partial overlap of involved brain areas since both, auditory discrimination and learning, involve frontotemporal brain regions (Ackerman, 1992;Halsband, 1998).
When relating slope and complexity to behavior, we observed that only the narrowband slope was consistently correlated with attentional task performance across almost all recordings per subject (with the exception of the third session, compare Fig. 7).This association between flatter narrowband slopes and better task performance might even translate to cognitive tasks that do not solely rely on attention since we also observed a consistent but weaker and not statistically significant relationship with memory performance.However, in larger-scale studies which offer more reliable effect sizes and confidence intervals, the broadband slope and complexity were also significantly correlated with task performance (Mediano et al., 2021;Waschke et al., 2021).Taken together, our findings suggest that the narrowband slope serves as a particularly sensitive marker for task-dependent fluctuations in brain states relevant for behavioral performance.

Narrow-and broadband frequency ranges track different facets of brain activity
Based on the results from the broadband range, it is tempting to assume that the spectral slope and Lempel-Ziv complexity are indexing similar features of brain activity.Indeed, according to Medel et al. (2023), both parameters might be driven by the transition entropy of the underlying cortical system (i.e., the predictive capacity of the current signal for the upcoming signal).Thus, flatter slopes and higher complexity values could be characteristic of the same cortical states.However, the divergence between the slope and complexity in the narrowband range clearly demonstrates that the two parameters are not redundant and indeed track different facets of the underlying signal.Different contributions of oscillatory and aperiodic brain activity might account for the diverging patterns.At first, it appears paradoxical that flatter slopes, representing an increase in aperiodic activity, should be accompanied by a decrease in complexity as complexity should also increase with higher irregularity.However, others have also reported this type of counterintuitive behavior.For instance, Mediano et al. (2021) showed that in MEG within 0.5-30 Hz, active tasks exhibited lower complexity values than quiet wakefulness.Additionally, a recent review from Lau et al. (2022) discussed several studies that reported contradicting modulations of signal complexity in different clinical conditions, where some report lower and others higher levels of complexity.So far, these contradictory findings seem to be best explained by the notion that higher complexity values can represent both, either more complex or more random systems (de la Torre-Luque et al., 2016), which makes it difficult to argue whether higher complexity always represents a healthier brain.

Limitations
In this study, we focused exclusively on two specific EEG derivatives: spectral slope and Lempel-Ziv complexity.Consequently, we did not compare these measures against other established analytical techniques such as spectral power, entropy, or network analyses (e.g., coherence).However, regarding spectral power, previous research demonstrated that the spectral slope is superior in discriminating REM sleep from wakefulness compared with slow oscillation or gamma power and performs similarly to beta power (Lendner et al., 2020;Kozhemiako et al., 2022).Additionally, Biggs et al. (2022) showed that Lempel-Ziv complexity also performed similarly well in comparison with alpha power and outperformed permutation entropy in capturing age-related changes in brain activity induced by anesthesia.Nevertheless, comparisons with other biomarkers, such as heart rate variability or blood pressure (Radha et al., 2019;Mitsukura et al., 2020;Kuula and Pesonen, 2021), as well as specific benchmark tests involving both spectral slope and Lempel-Ziv complexity, are still lacking and merit exploration in future large datasets.
It should also be noted that the tasks in this study were not specifically designed for the analysis of varying levels of task demand or difficulty as the dataset was originally designed for other purposes.Even though the participants reported differences in task difficulty, other significant factors that could potentially influence the results include differences in task modality.While there is evidence that attentional and learning tasks do differ regarding their level of cognitive demand (Sweller, 2011;Bambrah et al., 2019), it also seems to be dependent on the specific task instructions and modalities.In the future, it might be promising to contrast tasks that exclusively rely on different cognitive resources and sensory modalities.
Despite using only 11 scalp electrodes and no high-density EEG caps due to the need for long-term EEG data collection (14-16 h), we still robustly detected modulations by sleep stage and task engagement, thereby providing evidence for the practical usability of the slope and complexity as indices of different brain states.Nevertheless, research with high-density or intracranial EEG might further contribute to the understanding of which topographical areas are most influential in driving changes in slope or complexity across brain states.
Finally, we only recruited healthy biologically male adults in a restricted age range (18-25 years) to avoid potential sex differences and hormonal effects (Plamberger et al., 2021;Kozhemiako et al., 2022) and because controlling for hormonal variations by exclusively recording female participants in the follicular phase would have been extremely challenging with our study design.Therefore, it is unclear to what extent our results generalize to other populations.

Conclusions
Our results demonstrate that EEG spectral slope and Lempel-Ziv complexity are powerful indices of brain states during sleep and wakefulness.We present robust evidence from multiple recordings of three within-subject measurements, revealing that sleep stages and various cognitive tasks are reliably indexed by both spectral slope and Lempel-Ziv complexity.When derived from the full spectrum, slope and complexity capture redundant information and are influenced by oscillatory activity, particularly during sleep.In contrast, the narrowband slope (30-45 Hz) mainly indexes aperiodic brain activity, offering additional insights into underlying brain states.It provides a means to infer potential changes in the excitation/inhibition balance using only scalp electrodes, thus characterizing the spectral slope as a unique electrophysiological marker and distinguishing it from other measures such as spectral power.Moreover, recent evidence has shown that aperiodic activity on the scalp level can even offer insights into excitability changes on a cellular basis and reflects variations in pyramidal cell calcium activity (Lendner et al., 2023).
In the present study, the narrowband slope also proved to be the most powerful index of behavioral performance and was best suited to differentiate REM sleep from wakefulness and all other sleep stages without the additional use of EOG or EMG.Computing complexity in the narrowband range, however, did not yield any particularly meaningful results and should be undertaken with caution.Therefore, considering the faster computation time and the more diverse range of applications when using different frequency ranges as well as its correlation with task performance, the slope might be more practical and useful in most circumstances compared with complexity.Taken together, our study emphasizes the importance of considering the parametrization of brain activity into full, oscillatory, and aperiodic components to comprehensively understand the dynamics underlying passive and active brain states during sleep and wakefulness.

Figure 1 .
Figure 1.A, Overview of the experimental protocol.EEG was recorded throughout all tasks and during sleep (with full-night polysomnography) on the experimental days 7, 10, and 13 (see Extended Data Fig. 1-2 for the general sleep architecture on the different nights).The tasks, which are highlighted by a dashed, dark-green rectangle were primarily used to analyze the effects of engagement in different cognitive tasks during wakefulness.The adaptation night only served familiarization purposes and was not included in any of the analyses.An overview of the results from the screening entrance questionnaire is presented in Extended Data Figure 1-1.B, Example of the spectral slope estimation during N1 sleep.For illustration purposes, data are shown for the electrode Pz averaged over all subjects and sleep recordings.The spectral slope was fitted within 1-45 Hz (broadband, dashed green line) and 30-45 Hz (narrowband, dashed pink line).C, Schematic overview of the Lempel-Ziv complexity calculation based on a random 4 s epoch from electrode Pz of a subject during resting with closed eyes.First, the raw signal, filtered within a certain frequency range, is Hilbert transformed.Second, the resulting data is binarized around its median amplitude and stored as a vector of zeros and ones.Lastly, the Lempel-Ziv-Welch algorithm(Welch, 1984) is applied on this binary sequence in order to obtain a complexity value, which is driven by the number of unique repetitions of ones and zeros.The effect of signal regularity on Lempel-Ziv complexity and the spectral slope is further demonstrated in Extended Data Figure1-4.For an overview of the number of epochs that were used for all analyses, see Extended Data Figure1-3.

Figure 2 .
Figure 2. Spectral slope (green, A) and Lempel-Ziv (LZ) complexity (purple, B) from 30 to 45 Hz across sleep, averaged over all lab-sessions per subject.Center figures show the data averaged over all electrodes and topographical maps are provided below (color-coding refers to z values of slope or complexity computed from the grand average across all sleep stages).In A, the log-log power spectra are provided for each sleep stage to illustrate the slope changes across different sleep stages.Classification accuracies are shown on the right side.A, The spectral slope decreases from wakefulness across all sleep stages to REM sleep with a small temporary increase during N3 sleep.B, Lempel-Ziv complexity increases from shallow N1 to light N2 sleep and is in general less modulated by sleep stage than the spectral slope.EMG activity did not confound the modulation of the spectral slope and Lempel-Ziv complexity during sleep (Extended Data Fig. 2-1) or wakefulness (Extended Data Fig. 2-2).***p < 0.001, **p ≤ 0.010, *p ≤ 0.050, n.s., p > 0.050; all p values are adjusted for multiple comparisons; error bars represent 95% confidence intervals (N = 27).

Figure 3 .
Figure 3. Spectral slope (green, A) and Lempel-Ziv (LZ) complexity (purple, B) from 1 to 45 Hz across sleep, averaged over all lab-sessions per subject.Center figures show the data averaged over all electrodes and topographical maps are provided below (color-coding refers to z values of slope or complexity computed from the grand average across all sleep stages).In A, the log-log power spectra for each sleep stage are provided to illustrate the broadband slope differences across sleep stages.Classification accuracies are shown on the right side.A, Spectral slope steepens from wakefulness to N3 sleep but flattens to some extent in REM sleep.B, Lempel-Ziv complexity shows the same pattern as the spectral slope and likewise decreases from wakefulness to N3 with a subsequent increase in REM sleep.***p < 0.001, **p ≤ 0.010, *p ≤ 0.050, n.s.p > 0.050; p values are adjusted for multiple comparisons; error bars represent 95% confidence intervals (N = 27).

Figure 4 .
Figure4.Spectral slope (green, A) and Lempel-Ziv (LZ) complexity (purple, B) from 30 to 45 Hz across tasks, averaged over all lab-sessions per subject (see Extended Data Fig.4-1 for an analysis averaged over all timepoints per lab-session and Extended Data Fig.4-2 for an analysis demonstrating similar results when using a different task order).Center figures show the data averaged over all channels and topographical maps are provided below (colorcoding refers to z values of slope or complexity computed from the grand average across all tasks).In A, the log-log power spectra for each task are provided to illustrate narrowband slope differences across tasks.Classification accuracies are shown on the right side.A, The spectral slope flattens when engaging in cognitive tasks (Go/Nogo and learning) and is flattest during the retrieval session of the learning task.B, Lempel-Ziv complexity decreases with task engagement and reaches its minimum during the retrieval session.***p < 0.001, **p ≤ 0.010, *p ≤ 0.050, n.s.p > 0.050; p values adjusted for multiple comparisons; error bars show 95% confidence intervals (N = 28).

Figure 5 .
Figure 5. Spectral slope (green, A) and Lempel-Ziv (LZ) complexity (purple, B) from 1 to 45 Hz across tasks, averaged over all lab-sessions per subject (see Extended Data Figs.5-1 and 5-2 for analyses averaged over all timepoints per session and for a different task order).Center figures show the data over all channels and topographical maps are provided below (color-coding refers to z values of slope or complexity computed from the grand average over all tasks).In A, the log-log power spectra for each sleep stage are provided to illustrate broadband slope differences across tasks.Classification accuracies are shown on the right side.A, The slope flattens from resting to the Go/Nogo task (see Extended Data Fig. 5-3 for an analysis of the effect of different epoch types and lengths for this task) and is flattest during retrieval.B, Complexity increases from resting with closed to open eyes and is further elevated in all active tasks, peaking during retrieval.***p < 0.001, **p ≤ 0.010, *p ≤ 0.050, n.s.p > 0.050; p values adjusted for multiple comparisons; error bars show 95% confidence intervals (N = 28).

Figure 6 .
Figure 6.A, Comparison of the multiclass classification accuracies within 30-45 Hz (see Extended Data Fig. 6-1 for all pairwise classification accuracies) for the spectral slope and Lempel-Ziv complexity regarding sleep stages (WAKE, N1, N2, N3, REM) and tasks during wakefulness (resting eyes closed, resting eyes open, auditory Go/Nogo, encoding, retrieval).Sleep stages and tasks could be decoded more precisely with the spectral slope.Overall classification accuracy was significantly higher for tasks than for sleep stages.B, Comparison of the classification accuracies across tasks and sleep stages for slope and complexity within 1-45 Hz (see Extended Data Fig. 6-2 for the pairwise classifications).The slope only yielded better decoding performance during sleep, whereas task classification worked better when using Lempel-Ziv complexity, which is arguably due to the difference in complexity between the two resting conditions that is not present in the slope.The dotted red lines represent chance level (20%).The correlation between slope and complexity within 30-45 Hz and 1-45 Hz is presented in Extended Data Figure 6-3.Extended Data Figures 6-4 and 6-5 demonstrate the robustness of the slope and complexity values across lab-visits and the correlation across frequency ranges.***p < 0.001, n.s.p > 0.050 (N = 28).
Figure 6.A, Comparison of the multiclass classification accuracies within 30-45 Hz (see Extended Data Fig. 6-1 for all pairwise classification accuracies) for the spectral slope and Lempel-Ziv complexity regarding sleep stages (WAKE, N1, N2, N3, REM) and tasks during wakefulness (resting eyes closed, resting eyes open, auditory Go/Nogo, encoding, retrieval).Sleep stages and tasks could be decoded more precisely with the spectral slope.Overall classification accuracy was significantly higher for tasks than for sleep stages.B, Comparison of the classification accuracies across tasks and sleep stages for slope and complexity within 1-45 Hz (see Extended Data Fig. 6-2 for the pairwise classifications).The slope only yielded better decoding performance during sleep, whereas task classification worked better when using Lempel-Ziv complexity, which is arguably due to the difference in complexity between the two resting conditions that is not present in the slope.The dotted red lines represent chance level (20%).The correlation between slope and complexity within 30-45 Hz and 1-45 Hz is presented in Extended Data Figure 6-3.Extended Data Figures 6-4 and 6-5 demonstrate the robustness of the slope and complexity values across lab-visits and the correlation across frequency ranges.***p < 0.001, n.s.p > 0.050 (N = 28).

Figure 7 .
Figure 7. Relationship between Go/Nogo task performance and spectral slope (A) or Lempel-Ziv (LZ) complexity (B) within 30-45 Hz across different assessment times (see Extended Data Fig. 7-1 for the 1-45 Hz range).For the large scatterplots, data were averaged across all lab-sessions (small scatterplots show the relationship per lab-session).The topoplots depict the correlation strength for each electrode.Electrodes forming a significant cluster are highlighted with asterisks.Those showing a significant correlation after false discovery rate correction but did not from a cluster are marked with a cross.Only the narrowband spectral slope showed a consistent positive relationship with task performance (N = 26).

Figure 8 .
Figure 8. Relationship between declarative memory recall performance and spectral slope (A) or Lempel-Ziv (LZ) complexity (B) within 30-45 Hz (see Extended Data Fig. 8-1 for the 1-45 Hz range).Results are shown for immediate recall in the evening and delayed recall on the next morning as well as for overnight change.For the large scatterplots, data was averaged across all lab-sessions (small scatterplots show the relationship per session).The topoplots represent the strength of the correlations on each electrode.Even though the spectral slope was consistently positively correlated with recall performance, no electrodes formed a significant cluster.Significant single electrodes that survived false discovery rate correction are highlighted with a cross (N = 28).

Table 1 .
Key resources