Fully-automated sleep staging for Parkinson's disease and isolated REM sleep behavior disorder.
4 blocks of code here have a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.
The 4 matches · 2 of them tie a paragraph to a whole file without given lines: weak matches, whose lines are not tinted
- [1] § Methods › Sleep staging ↔ csdp_training/lightning_models/base.py, the whole file · a weak match · score 0.69 · cross entropy loss, Adam, hyperparameters, Optimizer, training, batch · block
oscr:b:CEJTKRMWQ1YT7-Z· Report a mismatch - [2] § Methods › Sleep staging ↔ csdp_training/lightning_models/factories/lightning_model_factory.py, lines 21 to 87 · score 0.62 · EOG channel, Sleep model, depth, loss, class, batch · block
oscr:b:WNJ8WJSA1DSAJ-6· Report a mismatch - [3] § Methods › Sleep staging ↔ csdp_training/experiments/cv.py, lines 20 to 87 · score 0.57 · mini batches, validation subjects, fold, split, epoch, models · block
oscr:b:XZ48WK2WEZ1R8-C· Report a mismatch - [4] § Methods › Sleep staging ↔ csdp_pipeline/pipeline_elements/bids_predictor.py, the whole file · a weak match · score 0.56 · majority vote, sleep stage prediction, batches, epoch, models · block
oscr:b:NWXM333108ZMJ-E· Report a mismatch
Paper
Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Python · 145 lines · 5 KB · no license · 1 match
- # -*- coding: utf-8 -*-
- """
- Created on Thu Feb 2 13:40:59 2023
- @author: repse
- """
- import torch
- import torch.nn as nn
- import pytorch_lightning as pl
- from csdp_training.utility import kappa, acc, f1
- class Base_Lightning(pl.LightningModule):
- def __init__(
- self,
- model,
- lr,
- batch_size,
- lr_patience,
- lr_factor,
- lr_minimum,
- loss_weights
- ):
- super().__init__()
- self.model = model
- self.lr = lr
- self.batch_size = batch_size
- self.lr_patience = lr_patience
- self.lr_factor = lr_factor
- self.lr_minimum = lr_minimum
- self.loss_weights = loss_weights
- self.training_step_outputs = []
- self.validation_step_loss = []
- self.validation_step_acc = []
- self.validation_step_kap = []
- self.validation_step_f1 = []
- self.validation_preds = []
- self.validation_labels = []
- weights = torch.tensor(loss_weights) if loss_weights != None else None
- self.loss = nn.CrossEntropyLoss(weight=weights,
- ignore_index=5)
- self.save_hyperparameters(ignore=['model'])
- self.log_to_progress_bar=False
- def forward(self, x):
- return self.model(x.float())
- def configure_optimizers(self):
- optimizer = torch.optim.Adam(self.parameters(), lr=self.lr)
- scheduler=torch.optim.lr_scheduler.ReduceLROnPlateau(optimizer,
- mode='max',
- factor=self.lr_factor,
- patience=self.lr_patience,
- threshold=1e-4,
- threshold_mode='rel',
- cooldown=0,
- min_lr=self.lr_minimum,
- eps=1e-8,
- verbose=True)
- return {
- 'optimizer': optimizer,
- 'monitor': 'valKap',
- 'lr_scheduler': scheduler
- }
- def compute_train_metrics(self, y_pred, y_true):
- y_pred = torch.swapdims(y_pred, 1, 2)
- y_pred = torch.reshape(y_pred, (-1, 5))
- y_true = torch.flatten(y_true)
- loss = self.loss(y_pred, y_true.long())
- y_pred = torch.argmax(y_pred, dim=1)
- try:
- accu = acc(y_pred, y_true)
- kap = kappa(y_pred, y_true, 5)
- f1_score = f1(y_pred, y_true, average=False)
- except:
- accu = None
- kap = None
- f1_score = None
- return loss, accu, kap, f1_score
- def compute_test_metrics(self, y_pred, y_true):
- y_true = torch.flatten(y_true)
- accu = acc(y_pred, y_true)
- kap = kappa(y_pred, y_true, 5)
- f1_score = f1(y_pred, y_true, average=False)
- return accu, kap, f1_score
- def on_train_epoch_end(self):
- all_outputs = self.training_step_outputs
- mean_loss = torch.mean(torch.stack(all_outputs, dim=0))
- self.log('trainLoss', mean_loss, batch_size=self.batch_size, rank_zero_only=True)
- self.training_step_outputs.clear()
- def on_validation_epoch_end(self):
- all_losses = self.validation_step_loss
- all_acc = self.validation_step_acc
- all_kap = self.validation_step_kap
- all_f1 = self.validation_step_f1
- mean_loss = torch.mean(torch.stack(all_losses, dim=0))
- mean_acc = torch.mean(torch.stack(all_acc, dim=0))
- mean_kap = torch.mean(torch.stack(all_kap, dim=0))
- mean_f1c0 = torch.mean(torch.stack(all_f1, dim=1)[0])
- mean_f1c1 = torch.mean(torch.stack(all_f1, dim=1)[1])
- mean_f1c2 = torch.mean(torch.stack(all_f1, dim=1)[2])
- mean_f1c3 = torch.mean(torch.stack(all_f1, dim=1)[3])
- mean_f1c4 = torch.mean(torch.stack(all_f1, dim=1)[4])
- batch_size=1
- self.log('valLoss', mean_loss, batch_size=batch_size, rank_zero_only=True)
- self.log('valAcc', mean_acc, batch_size=batch_size, rank_zero_only=True)
- self.log('valKap', mean_kap, batch_size=batch_size, rank_zero_only=True, prog_bar=self.log_to_progress_bar)
- self.log('val_f1_c0', mean_f1c0, batch_size=batch_size, rank_zero_only=True)
- self.log('val_f1_c1', mean_f1c1, batch_size=batch_size, rank_zero_only=True)
- self.log('val_f1_c2', mean_f1c2, batch_size=batch_size, rank_zero_only=True)
- self.log('val_f1_c3', mean_f1c3, batch_size=batch_size, rank_zero_only=True)
- self.log('val_f1_c4', mean_f1c4, batch_size=batch_size, rank_zero_only=True)
- self.validation_step_loss.clear()
- self.validation_step_acc.clear()
- self.validation_step_kap.clear()
- self.validation_step_f1.clear()
- self.validation_labels.clear()
- self.validation_preds.clear()
base.py at commit 19e72b6, no license · at the source
Overview
13 affiliations
- Department of Electrical and Computer Engineering, Aarhus University, Aarhus, Denmark
- Department of Nuclear Medicine, Aarhus University Hospital, Aarhus, Denmark
- Lundbeck Foundation Parkinson’s Disease Research Center (PACE), Aarhus University, Aarhus, Denmark
- Department of Neurology, Aarhus University Hospital, Aarhus, Denmark
- Department of Clinical Medicine, Aarhus University, Aarhus, Denmark
- Faculty of Mathematics and Natural Sciences, University of Cologne, Cologne, Germany
- Institute for Biomedical Informatics, Faculty of Medicine and University Hospital Cologne, Cologne, Germany
- Center for Molecular Medicine Cologne (CMMC), Faculty of Medicine and University Hospital Cologne, Cologne, Germany
- Cognitive Neuroscience, Institute for Neuroscience and Medicine, INM-3, Research Center Juelich, Juelich, Germany
- Department of Neurology, Faculty of Medicine and University Hospital Cologne, University of Cologne, Cologne, Germany
- Center of Neurology, Department of Parkinson, Sleep and Movement Disorders, University Hospital Bonn, University of Bonn, Bonn, Germany
- German Center for Neurodegenerative Diseases (DZNE), Bonn, Germany
- Danish Center for Sleep Medicine, Rigshospitalet, Glostrup, Denmark
Abstract
Isolated REM sleep behavior disorder (iRBD) is a key prodromal marker of Parkinson’s disease (PD). Video-polysomnography (vPSG) remains the diagnostic gold standard, but manual sleep staging is particularly time-consuming and challenging in neurodegenerative disease. We adapted U-Sleep, a deep neural network, for automated sleep staging in PD and iRBD. A pretrained model (PUB, 19,236 PSGs), was finetuned on multicenter datasets (PACE, CBC: 112 PD, 138 iRBD, 89 controls) and evaluated on a clinical hold-out (DCSM: 81 PD, 36 iRBD, 87 controls). Predictors of staging agreement were analyzed, and low-agreement recordings were blindly rescored. Confidence-based thresholds were applied to enhance REM detection. The pretrained model achieved κ = 0.66 in PACE/
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 4 matches between paragraphs and lines of code.
jesperstroem/U-Sleep-for-RBD-PD
19e72b632b1bd87650f7d560f42aa32d47bd9a9b, 4 June 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
48 files
- csdp_pipeline/
__init__.py , Python, 1 line - csdp_pipeline/
factories/ , Python, 1 line__init__.py - csdp_pipeline/
factories/ , Python, 231 linesdataloader_factory.py - csdp_pipeline/
pipeline_elements/ , Python, 1 line__init__.py - csdp_pipeline/
pipeline_elements/ , Python, 163 linesaugmenters.py - csdp_pipeline/
pipeline_elements/ , Python, 115 lines, 1 matchbids_predictor.py - csdp_pipeline/
pipeline_elements/ , Python, 218 linesfull_data_samplers.py - csdp_pipeline/
pipeline_elements/ , Python, 194 linesmne_sleep_dataset.py - csdp_pipeline/
pipeline_elements/ , Python, 256 linesmodels.py - csdp_pipeline/
pipeline_elements/ , Python, 80 linespipeline.py - csdp_pipeline/
pipeline_elements/ , Python, 47 linesresampler.py - csdp_pipeline/
pipeline_elements/ , Python, 394 linessamplers.py - csdp_pipeline/
pipeline_elements/ , Python, 54 linesspectrogram.py - csdp_pipeline/
plot_hypnogram.py , Python, 32 lines - csdp_pipeline/
preprocessing/ , Python, 1 line__init__.py - csdp_pipeline/
preprocessing/ , Python, 116 linesspectrogram.py - csdp_pipeline/
preprocessing/ , Python, 100 linesusleep_prep_steps.py - csdp_training/
__init__.py , Python, 3 lines - csdp_training/
experiments/ , Python, 1 line__init__.py - csdp_training/
experiments/ , Python, 280 lines, 1 matchcv.py - csdp_training/
lightning_models/ , Python, 1 line__init__.py - csdp_training/
lightning_models/ , Python, 145 lines, 1 matchbase.py - csdp_training/
lightning_models/ , Python, 1 linefactories/ __init__.py - csdp_training/
lightning_models/ , Python, 134 lines, 1 matchfactories/ lightning_model_factory. py - csdp_training/
lightning_models/ , Python, 204 lineslseqsleepnet.py - csdp_training/
lightning_models/ , Python, 260 linesusleep.py - csdp_training/
utility.py , Python, 134 lines - demos/
demo.ipynb , Jupyter, 50 lines - ml_architectures/
__init__.py , Python, 1 line - ml_architectures/
common/ , Python, 1 line__init__.py - ml_architectures/
common/ , Python, 27 linesbasic_layers.py - ml_architectures/
common/ , Python, 145 linesbn_blstm.py - ml_architectures/
common/ , Python, 131 linesepoch_encoder.py - ml_architectures/
common/ , Python, 36 linesfilterbank_utils.py - ml_architectures/
lseqsleepnet/ , Python, 2 lines__init__.py - ml_architectures/
lseqsleepnet/ , Python, 37 linesclassifier.py - ml_architectures/
lseqsleepnet/ , Python, 137 lineslong_sequence_model.py - ml_architectures/
lseqsleepnet/ , Python, 39 lineslseqsleepnet.py - ml_architectures/
lseqsleepnet/ , Python, 93 linesutils.py - ml_architectures/
seqsleepnet/ , Python, 2 lines__init__.py - ml_architectures/
seqsleepnet/ , Python, 31 linesclassifier.py - ml_architectures/
seqsleepnet/ , Python, 38 linesseqsleepnet.py - ml_architectures/
seqsleepnet/ , Python, 28 linesshort_sequence_model.py - ml_architectures/
seqsleepnet/ , Python, 79 linesutils.py - ml_architectures/
usleep/ , Python, 1 line__init__.py - ml_architectures/
usleep/ , Python, 291 linesusleep.py - setup.py, Python, 35 lines
- README.md, Text, 110 lines
Code availability
The underlying code for the U-Sleep model is available at https://
Reproduced under the paper's license (CC BY), from the paper cited above.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 47 scripts, each with its path and the digest of its content;
- 4 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Data availability
The datasets used in the current study are not publicly available because they contain personal health data protected by local ethics and data-protection regulations. Access requires specific approvals, including data sharing agreements. Fully anonymized, processed data may be shared on reasonable requests, subject to necessary regulatory and contractual agreements.
Reproduced under the paper's license (CC BY), from the paper cited above.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 3, 28 September 2026
- Funding: added Michael J. Fox Foundation for Parkinson's Research: MJFF‐022856; Innovationsfonden; Lundbeckfonden: R359-2020-2533; H. Lundbeck A/S; HORIZON EUROPE Framework Programme: 101095426; European Research Council
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 14 authors, 4 keywords, 41 references.
Cite
This paper
Strøm, J., Skjærbæk, C., Bertelsen, N. B., Simonsen, S. T., Okkels, N., Bertram, D., Röttgen, S., Kufer, K., Mikkelsen, K. B., Otto, M., Jennum, P. J., Borghammer, P., Sommerauer, M., & Kidmose, P. (2026). Fully-automated sleep staging for Parkinson's disease and isolated REM sleep behavior disorder. NPJ digital medicine, 9(1), 629. https://
BibTeX
@article{strm2026fully,
author = {Strøm, Jesper and Skjærbæk, Casper and Bertelsen, Natasha Becker and Simonsen, Steffen Torpe and Okkels, Niels and Bertram, David and Röttgen, Sinah and Kufer, Konstantin and Mikkelsen, Kaare B and Otto, Marit and Jennum, Poul Jørgen and Borghammer, Per and Sommerauer, Michael and Kidmose, Preben},
title = {{Fully-automated sleep staging for Parkinson's disease and isolated REM sleep behavior disorder}},
journal = {NPJ digital medicine},
year = {2026},
month = aug,
volume = {9},
number = {1},
pages = {629},
publisher = {Nature Publishing Group},
issn = {2398-6352},
doi = {10.1038/
url = {https://
pmid = {42601395},
pmcid = {PMC13476445}
}
RIS
TY - JOUR
AU - Strøm, Jesper
AU - Skjærbæk, Casper
AU - Bertelsen, Natasha Becker
AU - Simonsen, Steffen Torpe
AU - Okkels, Niels
AU - Bertram, David
AU - Röttgen, Sinah
AU - Kufer, Konstantin
AU - Mikkelsen, Kaare B
AU - Otto, Marit
AU - Jennum, Poul Jørgen
AU - Borghammer, Per
AU - Sommerauer, Michael
AU - Kidmose, Preben
TI - Fully-automated sleep staging for Parkinson's disease and isolated REM sleep behavior disorder
T2 - NPJ digital medicine
J2 - NPJ Digit Med
PY - 2026
DA - 2026/
VL - 9
IS - 1
SP - 629
SN - 2398-6352
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Fully-automated sleep staging for Parkinson's disease and isolated REM sleep behavior disorder",
"container-title": "NPJ digital medicine",
"author": [
{
"family": "Strøm",
"given": "Jesper"
},
{
"family": "Skjærbæk",
"given": "Casper"
},
{
"family": "Bertelsen",
"given": "Natasha Becker"
},
{
"family": "Simonsen",
"given": "Steffen Torpe"
},
{
"family": "Okkels",
"given": "Niels"
},
{
"family": "Bertram",
"given": "David"
},
{
"family": "Röttgen",
"given": "Sinah"
},
{
"family": "Kufer",
"given": "Konstantin"
},
{
"family": "Mikkelsen",
"given": "Kaare B"
},
{
"family": "Otto",
"given": "Marit"
},
{
"family": "Jennum",
"given": "Poul Jørgen"
},
{
"family": "Borghammer",
"given": "Per"
},
{
"family": "Sommerauer",
"given": "Michael"
},
{
"family": "Kidmose",
"given": "Preben"
}
],
"container-title-short":
"volume": "9",
"issue": "1",
"page": "629",
"DOI": "10.1038/
"PMID": "42601395",
"PMCID": "PMC13476445",
"ISSN": "2398-6352",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
8,
11
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1038/s41593-025-01910-9 [code]
- Sympathetic and parasympathetic subtypes of body-first Lewy body disease observed in postmortem tissue from prediagnostic individuals.Journal: Nature neuroscienceIn common: scikit-learn, pandas, SciPy, 2 other tools, Parkinson's, 2 references, 2 authors
- [2] doi:10.1002/mds.70265 [code]
- Differential Progression of Neuroinflammation in Patients with Isolated Rapid-Eye-Movement Sleep Behavior Disorder.Journal: Movement disorders : official journal of the Movement Disorder SocietyIn common: sleep disorders, Parkinson's, 2 references, 2 authors
- [3] doi:10.1038/s41746-025-02237-2 [code]
- SLEEPYLAND: trust begins with fair evaluation of automatic sleep staging models.Journal: NPJ digital medicineIn common: WFDB Python, MNE-Python, h5py, 5 other tools, 4 references
- [4] doi:10.1038/s41746-026-03406-7 [code]
- AnySleep: a channel-agnostic deep learning system for high-resolution sleep staging in multi-center cohorts.Journal: NPJ digital medicineIn common: MNE-Python, h5py, PyTorch, 5 other tools, sleep disorders, 4 references
- [5] doi:10.1038/s41597-025-04579-8
- Ear-EEG sleep monitoring data sets.Journal: Scientific dataIn common: 2 references, 2 authors
- [6] doi:10.1038/s41746-024-01115-7 [code]
- Generalized sleep decoding with basal ganglia signals in multiple movement disorders.Journal: NPJ digital medicineIn common: MNE-Python, h5py, scikit-learn, 4 other tools, sleep disorders, 4 references
- [7] doi:10.1038/s41467-024-54273-3 [code]
- Multi-regional control of amygdalar dynamics reliably reflects fear memory age.Journal: Nature communicationsIn common: WFDB Python, PyTorch Lightning, MNE-Python, 7 other tools
- [8] doi:10.7554/elife.100605 [code]
- Age-related changes in ‘cortical’ 1/
f dynamics are linked to cardiac activity Journal: n/aIn common: WFDB Python, MNE-BIDS, MNE-Python, 6 other tools - [9] doi:10.1007/s12021-026-09803-3 [code]
- NeuroFusion: A Unified Framework for Generalized Visual Stimulus Decoding from fMRI Across Datasets and Subjects.Journal: NeuroinformaticsIn common: MNE-BIDS, PyTorch Lightning, MNE-Python, 7 other tools
- [10] doi:10.3389/fnhum.2023.1134599 [code]
- The potential of convolutional neural networks for identifying neural states based on electrophysiological signals: experiments on synthetic and real patient data.Journal: Frontiers in human neuroscienceIn common: MNE-BIDS, PyTorch Lightning, MNE-Python, 7 other tools
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 47 scripts, and 4 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:c0b443f653dcc5ad…
Add the badge to the code's README
If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.
Markdown
<!-- oscr-badge:start -->
[](https://openscicode.org/badge/doi/10.1038/s41746-026-02946-2)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.1038/s41746-026-02946-2.svg
:target: https://openscicode.org/badge/doi/10.1038/s41746-026-02946-2
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1038/s41746-026-02946-2"><img src="https://openscicode.org/badge/doi/10.1038/s41746-026-02946-2.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".
If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.
Report a mismatch between the code and the paper · Report a code error (signed in)
Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.
Report a reproduction failure (signed in)
Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
