Unsupervised domain transfer: Overcoming signal degradation in sleep monitoring by increasing scoring realism Mohammad Ahangarkiasari * , Andreas Tind Damgaard , Casper Haurum , and Kaare B. Mikkelsen*
arXiv:2604.13988v1 [cs.LG] 15 Apr 2026
Department of Electrical and Computer Engineering, Aarhus University, Denmark * Corresponding authors: {ahangar100,mikkelsen.kaare}@ece.au.dk April 16, 2026 Abstract Objective: Investigate whether hypnogram ’realism’ can be used to guide an unsupervised method for handling arbitrary types of signal degradation in mobile sleep monitoring. Approach: Combining a pretrained, state-of-the-art ‘u-sleep’ model with a ‘discriminator’ network, we align features from a target domain with a feature space learned during pretraining. To test the approach, we distort the source domain with realistic signal degradations, to see how well the method can adapt to different types of degradation. We compare the performance of the resulting model with best-case models designed in a supervised manner for each type of transfer. Main Results: Depending on the type of distortion, we find that the unsupervised approach can increase Cohen’s kappa with as little as 0.03 and up to 0.29, and that for all transfers, the method does not decrease performance. However, the approach never quite reaches the estimated theoretical optimal performance, and when tested on a real-life domain mismatch between two sleep studies, the benefit was insignificant. Significance: ‘Discriminator-guided fine tuning’ is an interesting approach to handling signal degradation for ’in the wild’ sleep monitoring, with some promise. In particular, what it says about sleep data in general is interesting. However, more development will be necessary before using it ‘in production’. Index Terms: Transfer learning, sleep scoring, deep learning
1
Introduction
Sleep is a fundamental aspect of human health, and accurate monitoring of sleep patterns and physiological phenomena is essential for diagnosing a wide range of medical conditions [1, 2]. Sleep scoring, the process of identifying and classifying distinct sleep stages, plays a central role in the screening, evaluation, and diagnosis of sleep-related disorders [3]. The gold standard for sleep scoring is to perform it manually by trained sleep technicians, following standardized protocols. These guidelines are outlined in the “Manual for the Scoring of Sleep and Associated Events,” published by the American Academy of Sleep Medicine (AASM) [4]. However, due to the time consuming nature of manual sleep scoring (a single recording may take two hours to score [5]), it is an on-going effort to develop good, automatic sleep scoring models [3]. This endeavor has led to several good sleep scoring models [6, 7], which never the less can still struggle when there is a mismatch between training and application domains [8, 9, 10]. This is a general problem in the machine learning literature, and many different approaches for ’transfer learning’ have been proposed [11, 12]. In one of our previous studies, Lorenzen et al 2024[13], we investigated the benefit of different methods to deal with the domain mismatch, for the specific problem of fine tuning sleep scoring models to personal domains. There, we found very limited benefit from so-called ’unsupervised’ methods, which do not rely on ground truth labels from the target domain. This was unfortunate, since the reliance on ground truth (manual) labels is an obstacle to greater adoption of automated sleep scoring. In this study, we return to the topic of applying unsupervised domain transfer to sleep scoring, but apply it instead to the problem of adapting to various realistic signal degradations (’distortions’) that may occur when recording biomedical signals ’out in the wild’. This is a very real problem, particularly for dry-contact EEG sleep monitoring, where signal quality may be highly variable [14, 15, 16, 17]. 1
As shown below, we find that unsupervised methods, specifically ’adversarial domain transfer’ [18] show great potential in dealing with different forms of signal degradation. Additionally, we find that by simply searching for the most ’realistic’ hypnogram that can be made to fit the data, we also find hypnograms that are closer to the actual, correct sleep scoring. This highlights the possible use of the ’sparsity’ in the hypnogram space for intelligent sleep scoring algorithms, and is the main contribution of this paper.
2
Hypothesis
Most manually generated hypnograms (sleep scorings), generated by scoring polysomnography data, follow a characteristic pattern; patients usually start and end the night awake, the sleep stages are usually of a certain duration, and they tend to come in a certain order. Taken together, these restrictions define a much smaller space of ’realistic’ hypnograms than the total space of ’possible’ hypnograms. However, when a sleep recording is severely contaminated by recording noise, or some other issue is creating a significant domain mismatch, the result is often a less realistic hypnogram, drawing from a much larger portion of the full hypnogram space. We now hypothesize that by improving the ’realism’ of a hypnogram, we may also increase the accuracy, relative to a non-polluted version of the same recording. In other words, can we disentangle the signal from noise by requiring that the resulting hypnogram should look ’convincing’ ? To which extent can the ’sparsity’ of correct hypnograms in the full space of possible hypnograms be leveraged for model updating?
Figure 1: Example hypnogram illustrating the progression of sleep stages across a single night. The x-axis represents time in hours, and the y-axis denotes sleep stages based on the AASM categories: W (Wake), R (REM), N1, N2, N3, and U (Unknown/non-scorable). To explore this question, we formalize the problem of overcoming signal degradation in terms of domain adaptation. Assume clean sleep recordings as a source domain Ds = s1 , . . . , sn , where each si ∈ RC×T represents a sleep recording with C channels and T time samples. Similarly, assume a target domain Dt = t1 , . . . , tm , where ti ∈ RC×T consists of recordings whose distribution is shifted relative to the source domain, due to factors such as noise, device variability, or clinical conditions. The goal is to adapt a model trained on Ds to generalize sleep-stage classification on Dt , despite the absence of annotations in Dt . To achieve this, we adopt an adversarial learning [18] framework designed to minimize the apparent discrepancy between the two domains. Specifically, data are processed through two networks: a sleep scorer and a discriminator. The discriminator is trained to distinguish between hypnograms derived from source and target domains Ds and Dt . The sleep scorer aims to fool the discriminator on the target domain while remaining accurate on the source domain. If the approach is successful, the sleep scoring network can achieve notable performance improvement on data from the target domain, without having access to any ground truth labels on which to base its adjustments. Note that this approach does not attempt to reconstruct the original signal, or determine what the issue may have been.
3
Related Works
Considering specifically the topic of handling signal degradation, we can compare our work with the recent review by Raj et al [19], who looked at 29 different Deep Learning based approaches to EEG denoising, or the equally relevant works by Kalite et al [20] and Gorjan et al [21]. What sets our approach
2
apart from these works is that instead of trying to recreate the clean data ’underneath’ the artifacts, we focus on performance on a specific task (sleep scoring), and teach a model to either ignore the artifacts or work around them. As will be seen below, this recipe allows us to deal with signal degradation using a generic solution. As to the other aspect of our work, ’domain adaptation’ aims to address the distributional mismatch between source and target data. Existing approaches, both in biomedical data and outside, typically incorporate specific objectives into the training process, such as moment matching[22], Kullback–Leibler divergence [12, 23], or adversarial learning [18]. Particularly relevant for this work, Heremans et al [10] focused on evaluating a ’supervised’ adversarial domain adaptation framework in real-world sleep staging scenarios. Borrowing the model structure originally proposed by Ganin et al. [18], their study explored adaptation across diverse EEG datasets, focusing on how to transfer performance from PSG models to ’wearable’ models, and obtaining improvements in Cohens kappa of 0.11 to 0.22. In contrast to this approach, our model operates in a fully unsupervised setting, requiring no access to labeled data or recordings from the target domain. This design makes it particularly interesting for practical deployment scenarios where annotated data is unavailable. Equally relevant, Yoo et al. [24] investigated unsupervised domain adaptation for automatic sleep staging to address distribution shifts between labeled source datasets and unlabeled target datasets. Within an adversarial framework, they introduced local discriminators to reduce structural misalignment in sleep data. Their work differs from ours in the design of the sleep scoring model, the discriminator, the amount of data used (Yoo et al investigate transfer between two different datasets, where we aim for more mixed domains), and the fact that they transfer between non-distorted domains. This last point may partly explain why the improvements they find are generally smaller than what is found here. Finally, Fan et al. [25] proposed an unsupervised domain adaptation approach for automatic sleep staging based on domain statistics alignment in batch normalization layers. By aligning batch-normalization statistics between source and target domains, their method reduces distribution mismatch and improves target-domain performance without requiring labeled target data. Compared to the present study, their method is not adversarial, the transfer is from a single, homogeneous source domain, and the target domains are all ’clean’ datasets. In combination, our work here both relates to existing studies in this field, but also adds a new approach, and we are not aware of any studies investigating the ’realism’ aspect.
4
Methods
4.1
Data
In this study, we primarily use open data sets from the National Sleep Research Resource[26], similar to what was used in Perslev et al [6] and Strøm et al [27]. Specifically, the datasets used for training and testing are given in Table 1. This means that we are only using multichannel datasets with both EEG and EOG channels available. For these, we prioritized picking either the C4-LPA derivation or the C3-RPA as the EEG channel, and the EL-RPA or the ER-LPA as the EOG channel [28]. For recordings that were missing either both EEG or both EOG derivations, a random derivation of the same type was used instead. To reduce the confounding effects of human error in our analysis, specifically that stemming from incorrect manual scorings being used as ground truth, we used the output from a pretrained U-sleep model as the ground truth labels (prior to adding noise or distortions to the data). As mentioned, we treat data cleaning as a form of domain transfer, between ’clean’ (source) and ’distorted’ (target) domains. Therefore, we start from a diverse selection of ’clean’ source datasets, and then artificially add various types of ’distortions’ to create target domains over which we have full control: Source Domain: The datasets used in this study are summarized in Table 1. They comprise a diverse collection of publicly available sleep datasets, each differing in recording conditions, subject demographics, and data quality. As can be seen from the table, we have focused on getting a diverse selection of datasets. Target domains: For training and evaluation, we constructed artificially distorted datasets by introducing various types of ’distortions’ to the source domain. The selected distortions were designed to challenge the sleep scoring model without rendering the task infeasible, thereby necessitating adaptation of the model to maintain performance. Briefly, the investigated distortion types were: 3
Dataset ABC CFS DOD-H EESM19 ISRUC-SG1 ISRUC-SG3 MASS-C3 SEDF-SC SOF
Subjects
Records
Dataset
Subjects
Records
49 25 20 100 10 62 78 453
132 730 25 200 91 10 61 145 453
CCSHS DCSM DOD-O HOMEPAP ISRUC-SG2 MASS-C1 PHYS SEDF-ST SVUH
515 255 55 8 53 994 22 -
515 255 55 233 6 40 919 36 25
Table 1: Datasets used in this study. Further details of each data set are found in the following references: ABC: [29] CCSHS: [26], CFS:[30], DOD:[31], EESM19: [17], HOMEPAP: [32], DCSM:[26], ISRUC:[33], MASS:[34], PHYS:[35], SEDF :[36], SVUH:[37], SOF:[38]. Where possible, data was obtained through the ’National Sleep Research Resource’[26]. White noise Intended to simulate one of the input channels being broken, rendering the resulting channel useless. We do this by changing that channel to white noise. Since the U-Sleep model distinguishes between EEG and EOG derivations, we test distorting these separately. The standard deviation of the white noise distortion is set to 5. Amplifier overload Problems with bad electrode connections and bad ground connection may result in large spikes interrupting the signal. We simulate this by adding a bi-exponential transient to sleep signals, producing a rapid overshoot followed by an equally rapid undershoot spike. In this case, the amplitude was set as twice the amplitude of the clean signal. An example is shown in the appendix. To simulate its occurrence more realistically in experimental settings, white noise with standard deviation 1 is superimposed onto this pulse. As shown in the results section, we test different frequencies of occurrence for this distortion. Spectral deformation Both hardware and physiology may result in altered distributions of power in the frequency domain. We simulate this by running both signals through a 4th-order digital IIR band-pass filter, implemented in a numerically stable SOS form, to keep frequencies between lowcut and highcut and reduce everything else. We fix highcut at 20 Hz, and test different values of lowcut. See the appendix for visualizations.
4.2
Model implementation
We focus on a specific implementation of our framework, illustrated in Figure 2: The full model consists of a sleep scoring network and discriminator. In our design, we use the Usleep model by Perslev et al [6] as the basis for the sleep scoring network. To enforce the hypothesis being tested, namely that the model should learn to ’work around’ the distortion to still generate plausible sleep scorings, we split Usleep in its encoder and decoder portions, and will treat these slightly differently: 4.2.1
Encoder
Copying the original U-sleep implementation, the encoder comprises 12 sequential encoder blocks. Each block includes a convolutional layer followed by an exponential linear unit (ELU) activation function, batch normalization, and max-pooling. The number of filters increases progressively with each block, starting from five filters in the initial layer and growing by a fixed factor in subsequent layers. The encoder’s main role is to extract increasingly abstract feature maps from the input signals while simultaneously reducing their temporal resolution, enabling the model to capture essential patterns for accurate sleep stage classification. In our training framework, two encoders are employed: one for the source domain Es , which is frozen and provides clean features, and another for the target domain, Et which extracts distorted features from the target domain. Both encoders are initialized with weights from a pretrained Usleep. 4
Figure 2: The overall structure of the proposed model. Es denotes the frozen, pretrained encoder used for the source domain, while Et is initialized with the same pretrained U-Sleep weights but is fine-tuned during training to adapt to the target domain. Dec is the pretrained U-Sleep Decoder and D is the discriminator. fs and ft denote the decoder output features of the U-Sleep model for the source and target domains, respectively (refer to section 4.3). 4.2.2
Decoder
The decoder module also consists of 12 decoder blocks, each performing upsampling using nearest neighbor interpolation followed by a convolutional layer, ELU activation, and batch normalization. After upsampling, the output is merged through skip connections with the corresponding encoder block outputs taken before max-pooling. These skip connections link layers that share the same temporal resolution; for example, the last decoder block aligns with the first encoder block. Unlike the encoder, the decoder reduces the number of learned filters by a factor of two at each successive layer to mirror the encoder’s temporal resolution changes. Once processed through the decoder, the output represents a high-frequency, detailed sleep stage signal that aligns with the input sampling rate of 128 Hz. Our encoder also incorporates the ’segment classifier’, which in the original U-Sleep architecture is implemented as a separate block. The segment classifier aggregates the high-frequency feature representations generated by the decoder over longer time segments to produce sleep stage predictions. Since the goal is to generate one prediction per 30-second epoch, the segment size is set accordingly. Unlike the encoder, the decoder is ’frozen’, meaning the weights are not updated. 4.2.3
Discriminator
The discriminator is implemented as a lightweight Transformer-based binary classifier. Initially, the input is fed into a linear projection layer that maps each channel to a fixed embedding dimension, to which is added a learnable positional embedding to preserve temporal order. The result is processed through a stack of 2 Transformer encoders composed of multi-head self-attention (4 heads) and feedforward sub-modules. After the encoders, the sequence is flattened and passed through a fully connected layer to produce a scalar output. A sigmoid activation function is applied to indicate whether the input originated from the source or target domain. Note that the discriminator receives the predicted class probability distributions across all five sleep stages. In this way, the discriminator learns to distinguish between the probabilistic output patterns of the source and target domains. Thus, it can be interpreted as learning the distributional pattern of predicted sleep-stage probabilities, rather than making decisions based on hard class assignments. In our implementation, we instantiate three such discriminators in parallel to form the final domain prediction. This is found to provide more reliable adversarial supervision in our experiments. The structure of the model is fixed throughout all experiments.
5
4.3
Model training
The overall training process is formulated through two components: an anchor loss and an adversarial loss. These objectives jointly guide the model to learn domain-invariant and semantically consistent representations during adaptation. To support these objectives, the source and target encoders Es and Et , and the decoder Dec are initialized from a pretrained U-Sleep, while the discriminator D is randomly initialized. Let fs = Dec(Es (rs )) and ft = Dec(Et (rt )) denote the source and target features that are fed to D, where rs ∼ Ds and rt ∼ Dt (denote samples drawn from the empirical source and target data distributions induced by the datasets Ds and Dt , respectively). The expectations Ers ∼Ds [·] and Ert ∼Dt [·] are approximated by mini-batch averages during training. The discriminator is trained with a binary cross-entropy objective to output 0 for target features and 1 for source features: LD + Ert ∼Dt log D(ft ) , (1) adv = Ers ∼Ds log 1 − D(fs ) so minimizing LD adv pushes D(fs ) → 1 and D(ft ) → 0. In contrast, the target encoder is optimized to fool the discriminator, i.e., to make target features appear source-like. To train Et , we therefore maximize the discriminator outputs on target features, which is implemented by Eq. 2, driving D(ft ) → 1. t LE adv = Ert ∼Dt [log(1 − D(ft ))] ,
(2)
To stabilize adaptation and preserve the pretrained geometry on source data, we further introduce an anchor loss that penalizes deviations between the target and source encoders on the same source inputs: h i 2 Lanchor = Ers ∼Ds ∥Et (rs ) − Es (rs )∥2 . (3) At each iteration, we update D by minimizing LD adv and update Et (and any shared parameters with Dec if applicable) by minimizing t α LE adv + β Lanchor ,
with α = 1 and β = 0.1.
This min–max interplay aligns the target feature distribution with the source while the anchor term enforces cross-domain consistency. The values of α and β were set apriori based on experience from previous projects, and were not tuned during these experiments. It may be worth noting that the implementation of the anchor loss forces the model to assume ’covariate shift’, meaning that if the target domain is a mixture of distorted and clean data (which is a likely scenario), the non-distorted data will still be correctly scored. See the appendix for plots of model losses and performance measures as a function of training epochs. 4.3.1
Technical implementation
The model was trained with a batch size of 1 (full recording). This rather small batch size was chosen to allow stable training on a laptop, even while experimenting with different model implementations. We have since determined that the present implementation does not appreciably benefit from increasing the batch size up to 8. A benefit of using single recordings is that we have not needed to adjust the data loading to accommodate varying recording lengths (by padding short recordings, for instance). The learning rate was set to 1 × 10−5 , for the encoder and 1 × 10−6 for the discriminator. Keeping the encoder’s learning rate one order of magnitude higher than that of the discriminator allows the generator to continuously adapt to the discriminator’s feedback, thereby stabilizing the adversarial training process. All parameters were optimized using the Adam optimizer, and the model was trained for 50 epochs. A single run took between 6 and 8 hours on a laptop with dedicated GPU.
4.4
Performance Evaluation
We evaluated the performance of the pretrained and fine-tuned U-Sleep models using some complementary analyzes designed to capture both predictive accuracy and model behavior under signal distortions.
6
4.4.1
Cohen’s kappa
To quantify the agreement between predicted and true hypnograms, we use Cohen’s kappa score [39], hereafter denoted simply as kappa. This metric provides a standard measure of reliability across sleep stages, accounting for the level of agreement that could be expected by chance. In addition, we perform a chance kappa analysis to verify that improvements in agreement are not attributable to generic or signal-independent predictions. 4.4.2
Chance kappa analysis
To ensure that the observed improvements in kappa are not merely due to producing generic hypnograms that resemble typical sleep stage distributions without basing it on the input signal, we perform a Chance kappa analysis. This involves estimating the distribution of kappa scores obtained under random hypnogram sampling, providing a baseline against which to assess whether the fine-tuned model generates outputs that more closely follow the true temporal structure of sleep stages than the pretrained model, particularly on noisy or distorted target-domain data. We estimate the chance kappa distribution by randomly selecting two sleep recordings from the source domain and processing them with the pretrained U-Sleep model to generate two hypnograms. The agreement between these hypnograms is quantified using Cohen’s kappa score [39]. This procedure is repeated to obtain the Chance Kappa distribution for the source domain using the pretrained model. A similar process is applied to the target domain using the fine-tuned U-Sleep model. The resulting distributions are analyzed to ensure that the fine-tuned model’s outputs reflect the inherent variability of the input signals, rather than showing artificially high agreement or converging to repetitive patterns. See the appendices for a pseudo-code description of the algorithm. 4.4.3
’Benchmark performance’
To have a point of reference for each type of distortion, we compare with a benchmark model that is likely to be the best possible performance achievable (a ’native’ model). For the white noise distortion, this is simply a model that ignores the white noise channel (by setting the input weights to zero, mimicing the empty channels used in pretraining), while for the ’amplifier overload’ and ’spectral deformation’ distortions we compare with a model trained in a conventional, supervised fashion using target labels together with distorted data. 4.4.4
Permutation tests
Statistical significance was assessed using a paired permutation test on per-record performance differences. f ine For each record i, we calculated the difference di = mfi ine − mpre and mpre denote the i , where mi i metric of interest (F1 scores, Accuracy, Cohen’s kappa scores) based on fine-tuned and pre-trained models, PN respectively. The observed mean difference ∆obs = N1 i=1 di was compared to a null distribution generated by randomly flipping the sign of each di with probability of 0.5 by multiplying it with an (b) (b) (b) (b) (b) independent random sign si ∈ {+1, −1}, where Pr(si = +1) = Pr(si = −1) = 0.5. Thus, di = si di . P (b) (b) N The permuted mean difference is then calculated as ∆perm = N1 i=1 di , repeating this procedure over P = 10, 000 permutations. We then estimate the p-value as the following equation; PP (b) 1 + b=1 I ∆perm ≥ ∆obs , (4) p= 1+P PP (b) (b) where b=1 I ∆perm ≥ ∆obs count the number of times that the ∆perm is equal or bigger that than ∆obs .
5
Results
5.1
Chance Kappa Evaluation of Fine-Tuned U-Sleep Model
Figure 3 presents the histograms obtained from the Chance Kappa analysis for both the source and the target domains. For each domain, 300 samples were randomly selected to compute the Chance Kappa distribution. The Chance Kappa distributions are centered around low kappa values, reflecting the variability in hypnogram predictions when PSG recordings are randomly paired (unrelated PSG 7
recordings). The shape and location of the two distributions are similar, suggesting that fine-tuning the U-Sleep model on the target domain has not led to output collapse or artificially high agreement across predictions. This indicates that the model continues to generate distinct hypnograms for different PSG samples, preserving the diversity of its predictions. The low mean kappa values ( ≈ 0 ) in both distributions confirm that agreement due to distribution bias remains low. We see that kappa values above 0.35 can safely be considered ’significant’ agreement.
Figure 3: Histogram of Chance Kappa scores. Kappa scores are computed from random EEG-EOG sample pairs drawn from the target and source datasets. Blue: Pretrained U-Sleep on the source dataset. Red: Fine-tuned U-Sleep on the target dataset.
5.2
Distortion Analysis
As described above, we test how the approach handles different types of distortions: A total of 3,931 recordings compiled from all available datasets are utilized for this analysis. A stratified random split is performed, allocating 80% of the data for training and the remaining 20% for testing. 5.2.1
White Noise
Figure 4 presents a comparison of kappa scores between the pretrained, the fine-tuned and benchmark models, while Table 2 reports the corresponding average values for Cohen’s kappa scores, Accuracy and F1-score. Across the board, finetuning gives a marked improvement over pretraining, but is still beaten by the benchmark model. We see slightly different behavior depending on which channel is distorted, reflecting differences in the model’s reliance on the EEG and EOG inputs. 5.2.2
Amplifier Overload
Table 3 reports the model performance across amplifier-overload distortion frequencies, comparing kappa scores for pre-trained and fine-tuned models with distortion applied equally to both EEG and EOG channels. The amplifier overload frequencies are set to 20, 25, and 30 Hz. Across amplifier-overload frequencies, the fine-tuned model improves performance in terms of Cohen’s kappa, accuracy, and F1 score compared to the pre-trained baseline; however, the performance of both models degrades as the distortion frequency increases. As with the white noise distortion, our unsupervised fine tuning does not compete with the benchmark model, finetuned with labels.
8
(a) Finetuned vs. pre- (b) Finetuned vs. bench- (c) Finetuned vs. pre- (d) Finetuned vs. benchtrained, distorting EEG mark model, distorting trained, distorting EOG mark model, distorting channel. EEG channel. channel. EOG channel.
Figure 4: Comparison of Cohen’s kappa (κ) before and after fine-tuning with white noise distortion. Results are compared to both pretrained model and benchmark model.
Metric κ
Accuracy
F1-score
Model Pretrained model Finetuned model ∆ (Fine–Pre) p-value Pretrained model Finetuned model ∆ (Fine–Pre) p-value Pretrained model Finetuned model ∆ (Fine–Pre) p-value
EEG 0.23 0.42 0.29 < 1 × 10−4 0.46 0.60 0.14 < 1 × 10−4 0.47 0.59 0.12 < 1 × 10−4
EOG 0.02 0.18 0.16 < 1 × 10−4 0.31 0.42 0.11 < 1 × 10−4 0.32 0.41 0.09 < 1 × 10−4
Table 2: Effect of finetuning to ignore a noisy input channel. The column header indicates which U-Sleep input was replaced with white noise. Results are reported for Cohen’s κ, accuracy, and F1-score. P-values test whether pretrained and fine-tuned performance might be the same.
9
Frequency (Hz) Metric Model 20 25 30 Pretrained 0.30 0.29 0.28 κ Fine-tuned 0.41 0.38 0.36 ∆ (Fine–Pre) 0.11 0.09 0.08 p-value < 1 × 10−4 < 1 × 10−4 < 1 × 10−4 Pretrained 0.49 0.48 0.48 Accuracy Fine-tuned 0.58 0.55 0.53 ∆ (Fine–Pre) 0.09 0.06 0.05 p-value < 1 × 10−4 < 1 × 10−4 < 1 × 10−4 Pretrained 0.50 0.50 0.50 F1-score Fine-tuned 0.54 0.54 0.53 ∆ (Fine–Pre) 0.04 0.05 0.03 p-value < 1 × 10−4 < 1 × 10−4 < 1 × 10−4
Table 3: Effect of amplifier-overload distortion frequency on performance. Results are reported for Cohen’s κ, Accuracy, and F1-score. The fine-tuned model exceeds the pretrained baseline across all frequencies.
(a) Low-cut: 1 Hz
(b) Low-cut: 5 Hz
(c) Low-cut: 7 Hz
(d) Low-cut: 10 Hz
Figure 5: Cohen’s kappa (κ) between fine-tuned and pretrained U-Sleep models under different low-cut thresholds (1, 5, 7, and 10 Hz) in a mid-pass filter with a fixed high-cut frequency of 20 Hz. 5.2.3
Spectral deformation
Table 4 provides average kappa scores, accuracy, and F1-scores for different low-cut frequencies. As expected, more aggressive high-pass filtering (>5 Hz) disproportionately harms the baseline model. Across all cutoffs, the fine-tuned model improves the baseline with absolute gains ∆κ =0.03,0.16,0.15,0.15 at 1,5,7,10 Hz. A more detailed picture for kappa scores is shown in Figure 5, where scatterplots comparing pretrained and finetuned performance are shown. Finally, just like with the other two distortion types, we find that even though the fine tuning siginificantly improves upon the baseline performance, it is still beaten by the benchmark, ’supervisedly’ trained model. We have included a scatter plot comparison in the appendix.
5.3
Stage-wise performance
For all distortion types, we see that the approach improves performance for all stages. As an example, in Table 5 stage-wise performance metrics are shown for the ‘spectral deformation’ case.
5.4
Performance under data scaling
To assess the influence of training data quantity on model performance, we conducted a series of experiments using different proportions of the available training records. By progressively increasing the dataset size, we aim to evaluate how the model’s learning capacity and generalization ability evolve with the amount of training data. This analysis provides insight into the model’s data efficiency and highlights whether additional data could further enhance performance or if the model has reached a saturation point. Figure 6 illustrates the effect of training set size on the fine-tuned model’s performance, for each distortion type. The total number of available training nights is 3980, and the x-axis represents the 10
Metric κ
Accuracy
F1-score
Model Pretrained Fine-tuned ∆κ (Fine–Pre) p-value Pretrained Fine-tuned ∆Acc (Fine–Pre) p-value Pretrained Fine-tuned ∆F1 (Fine–Pre) p-value
Low-cut frequency (Hz) 5 7 0.36 0.33 0.52 0.47 0.16 0.15 < 1 × 10−4 < 1 × 10−4 0.55 0.53 0.67 0.63 0.12 0.10 < 1 × 10−4 < 1 × 10−4 0.57 0.55 0.66 0.62 0.09 0.07 < 1 × 10−4 < 1 × 10−4
1 0.68 0.71 0.03 < 1 × 10−4 0.77 0.79 0.02 < 1 × 10−4 0.76 0.79 0.03 < 1 × 10−4
10 0.27 0.42 0.15 < 1 × 10−4 0.45 0.51 0.06 < 1 × 10−4 0.45 0.51 0.06 < 1 × 10−4
Table 4: Effect of increasing high-pass (low-cut) frequency on performance for different metrics. The fine-tuned model outperforms the pretrained baseline across all settings. P-values test whether pretrained and fine-tuned performance might be the same. Table 5: Per-class performance comparison against GT labels (support = number of ground-truth samples(epochs) per class). Class
Support
W N1 N2 N3 REM
27467 6664 45262 16756 14221
Pretrained Model Precision Recall F1-score 0.5593 0.5485 0.5538 0.2412 0.2758 0.2574 0.5674 0.6449 0.6037 0.6886 0.2730 0.3910 0.3508 0.4371 0.3892
pre-trained Model Precision Recall F1-score 0.5940 0.6161 0.6048 0.2420 0.2938 0.2654 0.6203 0.6547 0.6370 0.7630 0.4530 0.5685 0.4245 0.4796 0.4504
number of samples used during training. As the training set size increases, the model’s performance consistently improves across all conditions, albeit with diminishing returns.
6
Discussion
’Discriminator-guided fine tuning’, as we call this approach, was originally inspired by discussions with experienced, human sleep scorers. They mentioned that sometimes, when dealing with very problematic recordings, they would ignore certain channels or phenomena, because the resulting hypnograms would otherwise be nonsense. As researchers who are always trying to get models to better deal with new issues and domain mismatches, it was an interesting idea to design a machine learning approach mimicking the human approach. Especially since the human scorers seem to find that the approach has merit. We find that discriminator guided fine tuning improves sleep scoring performance for almost all recordings, across distortion types. We also see that the obtained kappa values are almost always outside the ’chance’ range, and the improvements are significantly better than what can be explained by chance. However, in the present version, the fine-tuned kappa values are usually worse than what is obtained with supervised methods, and most average values are below values reported for clinical populations [40]. We also find that the performance depends both on which type of noise the model has to remove, but also on the specific recording - some recordings are just harder to salvage than others. We hypothesize that the distortion dependency is related to what type of changes have to be made to the model weights. In the case where one of two input channels has to be ignored, it is a simpler change of weights compared to, for instance, reshaping the power spectrum. It is possible that a different model architecture, for instance one using the spectrum as input, like SleepTransformer [7] would perform better for this type of distortion. Future work will have to experiment with different model designs. Along the same lines, it appears necessary to find ways to reduce the amount of data required. Either through reducing the model size, introducing data augmentation, or perhaps some way to better estimate the data distribution using fewer samples. As is seen in Figure 6, several thousand recordings are right now required to obtain good improvement. We should strive to bring this number down by at least an 11
Figure 6: Effect of the training set size on the fine-tuned model’s Kappa under different noise conditions. The plot compares Kappa values obtained with white noise and spectral deformation and amplifier overloaded distortions as the proportion of training samples increases from 10% to 90%. order of magnitude, preferably two.
6.1
Ablation study
To determine the impact of the different design choices in our algorithm, we have performed an ’ablation’ study in which each choice is reversed, to see what impact it has on performance. Specifically, we have removed the ’anchor loss’ term from the loss function, unfrozen the decoder, varied the number of discriminators and the batch size, changed the discriminator architecture as well as removed the positional encoding in the discriminator. We find that 2 and 3 discriminators perform the same, increasing the batch size from 1 to 2 increases performance slightly, and that all other changes decrease performance.
6.2
Additional findings
We also performed various other experiments, the results of which were not interesting enough to warrant their own figures in the ’results’ section, but which never the less are important to report: (1) In the standard approach to using U-Sleep [27], multiple steps of preprocessing are carried out. In our study, the ’clean’ dataset has been preproccessed according to the standard recipe (DC-removal, band-pass filtering, robust scaling and clipping), but no preprocessing is done after distortion (so, in the target domain). However, to ensure that this does not markedly impact the findings here, we carried out additional experiments where all calculations were repeated, but with preprocessing repeated after distorting the data. The only change in the results was that the ’white noise’ distortion becomes a null-result; the impact on the pretrained model is decreased, and fine tuning has no effect. We assume that this is because the primary problem for the model in this case is the increased amplitude. We decided to stick with the current approach where preprocessing is not performed after data distortion, because we believe that the object under scrutiny here is the approach itself and not the performance of U-Sleep. (2) We tested one completely realistic and challenging domain transfer: from the current source domain to the dataset described in Tabar et al 2023 [41]. Our findings were that the fine tuning had no significant effect on performance. In investigating this negative result, we have considered multiple different explanations: inadequacy of the loss function (perhaps the anchor loss term was a mistake), differences in the type of domain mismatches observed, or simply limitations in the present version of the algorithm. While we cannot rule out that the ’distortion’ equivalent to moving to the Tabar et al dataset is significantly more complex than what we have tested here, we think the most likely explanation is related to what we see in Figure 6 - data scaling. The Tabar data set only has 120 recordings, thus
12
making it significantly smaller than what we are working with here. This could explain the lack of a significant improvement, and we will investigate remedies for this in future work.
7
Conclusion
In conclusion, we think the approach is promising, and that the results highlight interesting properties of sleep data in general. However, it is worthwhile to investigate other implementations. In particular, it seems necessary to reduce the required amount of data before this can become a viable tool in most clinical or engineering settings.
8
Code
9
Contributions and acknowledgments
KBM came up with the original idea and obtained funding for the project. AT and CH carried out preliminary investigations of the concept and best approaches. MA designed and implemented the final approach, and carried out all experiments and analysis. All authors read and accepted the manuscript. Compute resources for the project were donated by the Danish e-Infrastructure Consortium, under grant DeiC-AU-N5-2024046, ’Advanced EEG Analysis’.
References [1] Sleep Disorders and Sleep Deprivation: An Unmet Public Health Problem. The National Academies Collection: Reports funded by National Institutes of Health. Washington (DC), 2006. isbn: 978-0309-10111-0. url: http://www.ncbi.nlm.nih.gov/books/NBK19960/ (visited on 04/06/2026). [2] Michael J. Sateia. “International classification of sleep disorders-third edition: highlights and modifications”. In: Chest 146.5 (Nov. 2014), pp. 1387–1394. issn: 1931-3543. doi: 10.1378/chest.140970. [3] Huy Phan and Kaare Mikkelsen. “Automatic sleep staging of EEG signals: recent development, challenges, and future directions”. In: Physiological Measurement 43.4 (2022), 04TR01. [4] American Academy of Sleep Medicine et al. “The AASM manual for the scoring of sleep and associated events: rules, terminology and technical specifications”. In: Westchester, IL: American Academy of Sleep Medicine 23 (2007). [5] Luigi Fiorillo, Alessandro Puiatti, Michela Papandrea, Pietro-Luca Ratti, Paolo Favaro, Corinne Roth, Panagiotis Bargiotas, Claudio L Bassetti, and Francesca D Faraci. “Automated sleep scoring: A review of the latest approaches”. In: Sleep medicine reviews 48 (2019), p. 101204. [6] Mathias Perslev, Sune Darkner, Lykke Kempfner, Miki Nikolic, Poul Jørgen Jennum, and Christian Igel. “U-Sleep: resilient high-frequency sleep staging”. In: NPJ digital medicine 4.1 (2021), p. 72. [7] Huy Phan, Kaare Mikkelsen, Oliver Y Chén, Philipp Koch, Alfred Mertins, and Maarten De Vos. “Sleeptransformer: Automatic sleep staging with interpretability and uncertainty quantification”. In: IEEE Transactions on Biomedical Engineering 69.8 (2022), pp. 2456–2467. [8] Luigi Fiorillo, Giuliana Monachino, Julia van der Meer, Marco Pesce, Jan D. Warncke, Markus H. Schmidt, Claudio L. A. Bassetti, Athina Tzovara, Paolo Favaro, and Francesca D. Faraci. “U-Sleep’s resilience to AASM guidelines”. en. In: npj Digital Medicine 6.1 (Mar. 2023). Number: 1 Publisher: Nature Publishing Group, pp. 1–9. issn: 2398-6352. doi: 10.1038/s41746-023-00784-0. url: https://www.nature.com/articles/s41746-023-00784-0 (visited on 08/01/2023). [9] Patrycja Lebiecka-Johansen, Jesper Strøm, Kaare B. Mikkelsen, Alvaro F. Cabrera, Rasmus E. Madsen, Julie A. E. Christensen, Martin C. Hemmsen, and Preben Kidmose. “Benefits of Different Strategies to Adapt Sleep Scoring Models from Scalp- to Ear-EEG”. In: 2025 47th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC). ISSN: 2694-0604. July 2025, pp. 1–7. doi: 10.1109/EMBC58623.2025.11252780. url: https: //ieeexplore.ieee.org/document/11252780 (visited on 01/08/2026).
13
[10] Elisabeth RM Heremans, Huy Phan, Pascal Borzée, Bertien Buyse, Dries Testelmans, and Maarten De Vos. “From unsupervised to semi-supervised adversarial domain adaptation in electroencephalographybased sleep staging”. In: Journal of Neural Engineering 19.3 (2022), p. 036044. [11] Emilio Soria Olivas, Jos David Mart Guerrero, Marcelino Martinez-Sober, Jose Rafael MagdalenaBenedito, L Serrano, et al. Handbook of research on machine learning applications and trends: Algorithms, methods, and techniques: Algorithms, methods, and techniques. IGI global, 2009. [12] Huy Phan, Kaare Mikkelsen, Oliver Y Chén, Philipp Koch, Alfred Mertins, Preben Kidmose, and Maarten De Vos. “Personalized automatic sleep staging with single-night data: a pilot study with Kullback–Leibler divergence regularization”. In: Physiological measurement 41.6 (2020), p. 064004. [13]
Kristian P Lorenzen, Elisabeth RM Heremans, Maarten de Vos, and Kaare B Mikkelsen. “Personalization of automatic sleep scoring: How best to adapt models to personal domains in wearable EEG”. In: IEEE Journal of Biomedical and Health Informatics (2024).
[14] Kaare B Mikkelsen, Yousef R Tabar, Simon L Kappel, Christian B Christensen, Hans O Toft, Martin C Hemmsen, Mike L Rank, Marit Otto, and Preben Kidmose. “Accurate whole-night sleep monitoring with dry-contact ear-EEG”. In: Scientific reports 9.1 (2019), p. 16824. [15] Sven Leach, Ku-Young Chung, Laura Tüshaus, Reto Huber, and Walter Karlen. “A Protocol for Comparing Dry and Wet EEG Electrodes During Sleep”. In: Frontiers in Neuroscience 14 (2020), p. 586. issn: 1662-4548. doi: 10.3389/fnins.2020.00586. [16] Daria Kleeva, Ivan Ninenko, and Mikhail A. Lebedev. “Resting-state EEG recorded with gel-based vs. consumer dry electrodes: spectral characteristics and across-device correlations”. In: Frontiers in Neuroscience 18 (Feb. 2, 2024). Publisher: Frontiers. issn: 1662-453X. doi: 10.3389/fnins.2024. 1326139. url: https://www.frontiersin.org/journals/neuroscience/articles/10.3389/ fnins.2024.1326139/full (visited on 01/14/2026). [17] Kaare Bjarke Mikkelsen, Yousef Rezai Tabar, Laura Rævsbæk Birch, Simon Lind Kappel, Christian Bech Christensen, Lars Dalskov Mosgaard, Marit Otto, Martin Christian Hemmsen, Mike Lind Rank, and Preben Kidmose. “Ear-EEG sleep monitoring data sets”. In: Scientific Data 12.1 (Feb. 2025), p. 301. issn: 2052-4463. doi: 10.1038/s41597-025-04579-8. url: https://doi.org/10.1038/ s41597-025-04579-8. [18] Yaroslav Ganin, Evgeniya Ustinova, Hana Ajakan, Pascal Germain, Hugo Larochelle, François Laviolette, Mario March, and Victor Lempitsky. “Domain-adversarial training of neural networks”. In: Journal of machine learning research 17.59 (2016), pp. 1–35. [19] Vandana Akshath Raj, Tejasvi Parupudi, Ananthakrishna Thalengala, and Subramanya G. Nayak. “A comprehensive review of deep learning models for denoising EEG signals: challenges, advances, and future directions”. In: Discover Applied Sciences 7.11 (Oct. 22, 2025), p. 1268. issn: 3004-9261. doi: 10.1007/s42452-025- 07808-2. url: https://doi.org/10.1007/s42452-025- 07808-2 (visited on 01/15/2026). [20] Bhabesh Kalita, Nabamita Deb, and Daisy Das. “AnEEG: leveraging deep learning for effective artifact removal in EEG data”. In: Scientific Reports 14.1 (Oct. 16, 2024). Publisher: Nature Publishing Group, p. 24234. issn: 2045-2322. doi: 10.1038/s41598-024-75091-z. url: https: //www.nature.com/articles/s41598-024-75091-z (visited on 01/15/2026). [21] Dasa Gorjan, Klaus Gramann, Kevin De Pauw, and Uros Marusic. “Removal of movement-induced EEG artifacts: current state of the art and guidelines”. en. In: Journal of Neural Engineering 19.1 (Feb. 2022). Publisher: IOP Publishing, p. 011004. issn: 1741-2552. doi: 10.1088/1741-2552/ac542c. url: https://doi.org/10.1088/1741-2552/ac542c (visited on 01/15/2026). [22] Mohammad Ahangar Kiasari, Dennis Singh Moirangthem, and Minho Lee. “Joint moment-matching autoencoders”. In: Neural Networks 106 (2018), pp. 185–193. [23] Wei-Ning Hsu, Yu Zhang, and James Glass. “Unsupervised domain adaptation for robust speech recognition via variational autoencoder-based data augmentation”. In: 2017 IEEE automatic speech recognition and understanding workshop (ASRU). IEEE. 2017, pp. 16–23. [24] Chaehwa Yoo, Hyang Woon Lee, and Je-Won Kang. “Transferring structured knowledge in unsupervised domain adaptation of a sleep staging network”. In: IEEE journal of biomedical and health informatics 26.3 (2021), pp. 1273–1284.
14
[25] Jiahao Fan, Hangyu Zhu, Xinyu Jiang, Long Meng, Chen Chen, Cong Fu, Huan Yu, Chenyun Dai, and Wei Chen. “Unsupervised domain adaptation by statistics alignment for deep sleep staging networks”. In: IEEE Transactions on Neural Systems and Rehabilitation Engineering 30 (2022), pp. 205–216. [26] Guo-Qiang Zhang, Licong Cui, Remo Mueller, Shiqiang Tao, Matthew Kim, Michael Rueschman, Sara Mariani, Daniel Mobley, and Susan Redline. “The National Sleep Research Resource: towards a sleep data commons”. eng. In: Journal of the American Medical Informatics Association: JAMIA 25.10 (Oct. 2018), pp. 1351–1358. issn: 1527-974X. doi: 10.1093/jamia/ocy064. [27] Jesper Strøm, Andreas Larsen Engholm, Kristian Peter Lorenzen, and Kaare B Mikkelsen. “Common sleep data pipeline for combined data sets”. In: Plos one 19.8 (2024), e0307202. [28] Marc R. Nuwer. “10-10 electrode system for EEG recording”. In: Clinical Neurophysiology 129.5 (May 1, 2018), p. 1103. issn: 1388-2457. doi: 10.1016/j.clinph.2018.01.065. url: https: //www.sciencedirect.com/science/article/pii/S1388245718300907 (visited on 02/27/2024). [29] Jessie P. Bakker, Ali Tavakkoli, Michael Rueschman, Wei Wang, Robert Andrews, Atul Malhotra, Robert L. Owens, Amit Anand, Katherine A. Dudley, and Sanjay R. Patel. “Gastric Banding Surgery versus Continuous Positive Airway Pressure for Obstructive Sleep Apnea: A Randomized Controlled Trial”. eng. In: American Journal of Respiratory and Critical Care Medicine 197.8 (Apr. 2018), pp. 1080–1083. issn: 1535-4970. doi: 10.1164/rccm.201708-1637LE. [30] Susan Redline, Peter V Tishler, Tor D Tosteson, John Williamson, Kenneth Kump, Ilene Browner, Veronica Ferrette, and Patrick Krejci. “The familial aggregation of obstructive sleep apnea.” In: American journal of respiratory and critical care medicine 151.3 (1995), pp. 682–687. [31] Antoine Guillot, Fabien Sauvet, Emmanuel H During, and Valentin Thorey. “Dreem open datasets: Multi-scored sleep datasets to compare human and automated sleep staging”. In: IEEE transactions on neural systems and rehabilitation engineering 28.9 (2020), pp. 1955–1965. [32] Carol L. Rosen, Dennis Auckley, Ruth Benca, Nancy Foldvary-Schaefer, Conrad Iber, Vishesh Kapur, Michael Rueschman, Phyllis Zee, and Susan Redline. “A multisite randomized trial of portable sleep studies and positive airway pressure autotitration versus laboratory-based polysomnography for the diagnosis and treatment of obstructive sleep apnea: the HomePAP study”. eng. In: Sleep 35.6 (June 2012), pp. 757–767. issn: 1550-9109. doi: 10.5665/sleep.1870. [33] Sirvan Khalighi, Teresa Sousa, José Moutinho Santos, and Urbano Nunes. “ISRUC-Sleep: A comprehensive public dataset for sleep researchers”. In: Computer methods and programs in biomedicine 124 (2016), pp. 180–192. [34] Christian O’Reilly, Nadia Gosselin, Julie Carrier, and Tore Nielsen. “Montreal Archive of Sleep Studies: an open-access resource for instrument benchmarking and exploratory research”. en. In: Journal of Sleep Research 23.6 (2014). _eprint: https://onlinelibrary.wiley.com/doi/pdf/10.1111/jsr.12169, pp. 628–635. issn: 1365-2869. doi: https : / / doi . org / 10 . 1111 / jsr . 12169. url: https : / / onlinelibrary.wiley.com/doi/abs/10.1111/jsr.12169 (visited on 03/02/2021). [35] Mohammad M Ghassemi, Benjamin E Moody, Li-Wei H Lehman, Christopher Song, Qiao Li, Haoqi Sun, Roger G Mark, M Brandon Westover, and Gari D Clifford. “You snooze, you win: the physionet/computing in cardiology challenge 2018”. In: 2018 Computing in Cardiology Conference (CinC). Vol. 45. IEEE. 2018, pp. 1–4. [36] Bob Kemp, Aeilko H Zwinderman, Bert Tuk, Hilbert AC Kamphuisen, and Josefien JL Oberye. “Analysis of a sleep-dependent neuronal feedback loop: the slow-wave microcontinuity of the EEG”. In: IEEE Transactions on Biomedical Engineering 47.9 (2000), pp. 1185–1194. [37] Ary L Goldberger, Luis AN Amaral, Leon Glass, Jeffrey M Hausdorff, Plamen Ch Ivanov, Roger G Mark, Joseph E Mietus, George B Moody, Chung-Kang Peng, and H Eugene Stanley. “PhysioBank, PhysioToolkit, and PhysioNet: components of a new research resource for complex physiologic signals”. In: circulation 101.23 (2000), e215–e220. [38] Adam P Spira, Terri Blackwell, Katie L Stone, Susan Redline, Jane A Cauley, Sonia Ancoli-Israel, and Kristine Yaffe. “Sleep-disordered breathing and cognition in older women”. In: Journal of the American Geriatrics Society 56.1 (2008), pp. 45–50. [39] Jacob Cohen. “A coefficient of agreement for nominal scales”. In: Educational and psychological measurement 20.1 (1960), pp. 37–46.
15
[40] Heidi Danker-Hopfe, D. Kunz, G. Gruber, G. Klösch, J. L. Lorenzo, S. L. Himanen, B. Kemp, T. Penzel, J. Röschke, H. Dorn, et al. “Interrater reliability between scorers from eight European sleep laboratories in subjects with different sleep disorders”. en. In: Journal of Sleep Research 13.1 (2004). _eprint: https://onlinelibrary.wiley.com/doi/pdf/10.1046/j.1365-2869.2003.00375.x, pp. 63–69. issn: 1365-2869. doi: 10.1046/j.1365- 2869.2003.00375.x. url: https://onlinelibrary.wiley. com/doi/abs/10.1046/j.1365-2869.2003.00375.x (visited on 03/21/2024). [41] Yousef R Tabar, Kaare B Mikkelsen, Nelly Shenton, Simon L Kappel, Astrid R Bertelsen, Reza Nikbakht, Hans O Toft, Chris H Henriksen, Martin C Hemmsen, Mike L Rank, et al. “At-home sleep monitoring using generic ear-EEG”. In: Frontiers in neuroscience 17 (2023), p. 987578.
16
A
Appendix
A.1
Distortion details
Fig 7 compares the original waveform with the three distortion types; spectral deformation, amplifier overload, and additive white noise, highlighting how each distortion alters the temporal structure in a distinct manner. Additionally, in Figure 8 is shown the amplitude characteristic of the type of bandpass filter used to create ’spectral deformation’.
17
(a) White noise deformation
(b) Amplifier overload
(c) Spectral distortion.
Figure 7: (a)–(c) Visualizations of three representative distortions: bad filtering, amplifier overload, and additive white noise. The blue curve denotes the clean signal, and the red (dotted) curve denotes the distorted signal.
18
Figure 8: An example of band-pass filter applied to the signal with a low cut-off of 5.00 Hz and a high cut-off of 20.0 Hz, suppressing low-frequency drift and high-frequency noise while retaining features in the 5–20 Hz band.
19
A.2
Algorithm for calculating chance kappa distribution
Require: Fine-tuned U-Sleep model Uf , target domain consisting of distorted sleep recording Dt . Let N be number of experiments, and K the Chance Kappa distribution. K ← [] 1: for each i in N do 2: Randomly sample xi and yi from Dt 3: Predict the hypnogram: hxi ← Uf (xi ) , hyi ← Uf (yi ) 4: Compute kappa score between hypnograms hyi , hxi : ki ← κ(hyi , hxi ) 5: Appending : K ← {ki } 6: end for Analysis distribution of K
A.3
Training curves
In Figure 9 is shown both the losses for the generator and the discriminators, as well as a performance scores (F1, accuracy, kappa), for a single training run, using ’spectral deformation’ as the distortion type. We see that, as expected, the discriminator and generator losses are negatively correlated, but also that, interestingly, the performance measures do not decrease as soon as the generator loss. This is positive because it means that we are not quite as sensitive to the precise stopping time as we might otherwise have been.
(a)
(b)
Figure 9: (a) Training curves of the generator and discriminator. (b) Curves of F1-score, accuracy, and Cohen’s kappa on the test set during training, for the ’spectral deformation’ distortion.
A.4
Performance scatterplot
In Figure 10 upward deviations from the red line show that the benchmark model generally achieves higher agreement.
20
(a)
(b)
Figure 10: Comparison of pairwise kappa scores among the pre-trained, fine-tuned, and supervisedly trained U-Sleep models. The diagonal red line represents the line of equality (y = x). (a) illustrates the comparison between the pre-trained and fine-tuned U-Sleep models, and (b) shows the comparison between the fine-tuned and supervisedly trained U-Sleep models.
21