OSCR

REST-a deep learning tool for automated mouse sleep stage classification.

Code ↔ Paper

5 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

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 5 matches
  1. [1] § Materials and methods › REST model design and training ↔ Training.py, lines 106 to 145 · score 0.83 · AdamW, weight decay, Focal loss, class weights, optimizer, Training · block oscr:b:XJDRS34K943ZT-I · Report a mismatch
  2. [2] § Materials and methods › REST model design and training ↔ RESTCORE.py, lines 27 to 84 · score 0.76 · ReLU, Transformer encoder, positional encoding, layer normalization, logits, linearly · block oscr:b:6GGR4WCJT31DN-L · Report a mismatch
  3. [3] § Materials and methods › REST model design and training ↔ RESTutils.py, lines 219 to 271 · score 0.76 · bandpass filter, EEG STFT, EMG epoch, EEG epoch, spectrum, memory · block oscr:b:8WEC2H8YAXF3X-2 · Report a mismatch
  4. [4] § Materials and methods › REST model design and training ↔ RESTCORE.py, lines 27 to 84 · score 0.75 · ReLU, Transformer encoder, positional encoding, dropout, Linear, layers · block oscr:b:6GGR4WCJT31DN-L · Report a mismatch
  5. [5] § Materials and methods › REST model design and training ↔ RESTutils.py, lines 164 to 204 · score 0.64 · notch filter, bandpass filtered, EMG signals, 250 Hz, 30 Hz, 0.1 Hz · block oscr:b:NEXS20GXAXRYF-C · 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 · 84 lines · 3.1 KB · MIT · 2 matches

  1. import torch
  2. import torch.nn as nn
  3. import math
  4. # -- Positional encoding ------------------------------------------------------
  5. class PositionalEncoding(nn.Module):
  6. def __init__(self, d_model, max_len=500):
  7. super().__init__()
  8. pe = torch.zeros(max_len, d_model)
  9. pos = torch.arange(0, max_len).unsqueeze(1)
  10. div = torch.exp(torch.arange(0, d_model, 2) * (-math.log(10000.0) / d_model))
  11. pe[:, 0::2] = torch.sin(pos * div)
  12. pe[:, 1::2] = torch.cos(pos * div)
  13. self.register_buffer("pe", pe.unsqueeze(0)) # [1, max_len, d_model]
  14. def forward(self, x): # x:[B, L, D]
  15. return x + self.pe[:, :x.size(1)]
  16. # -- Attention pooling --------------------------------------------------------
  17. class AttnPool(nn.Module):
  18. def __init__(self, d_model):
  19. super().__init__()
  20. self.q = nn.Linear(d_model, 1)
  21. def forward(self, x): # x:[B, L, D]
  22. w = torch.softmax(self.q(x).squeeze(-1), dim=1) # [B, L]
  23. return torch.sum(w.unsqueeze(-1) * x, dim=1) # [B, D]
  24. class REST(nn.Module):
  25. def __init__(self, in_feat, n_classes, win_len,
  26. d_model=256, nhead=8, nlayers_epoch=4, nlayers_seq=4,
  27. ff=512, fc_hidden1=128,fc_hidden2=64, dropout=0.1, use_layernorm=True):
  28. super().__init__()
  29. self.use_layernorm = use_layernorm
  30. if self.use_layernorm:
  31. self.input_norm = nn.LayerNorm(in_feat)
  32. # Epoch-level encoding
  33. self.epoch_in_proj = nn.Linear(in_feat, d_model)
  34. self.epoch_pos_enc = PositionalEncoding(d_model, max_len=10)
  35. epoch_layer = nn.TransformerEncoderLayer(d_model, nhead, ff, dropout, batch_first=True)
  36. self.epoch_transformer = nn.TransformerEncoder(epoch_layer, nlayers_epoch)
  37. self.epoch_pool = AttnPool(d_model)
  38. # Sequence-level encoding
  39. self.seq_pos_enc = PositionalEncoding(d_model, max_len=win_len)
  40. seq_layer = nn.TransformerEncoderLayer(d_model, nhead, ff, dropout, batch_first=True)
  41. self.seq_transformer = nn.TransformerEncoder(seq_layer, nlayers_seq)
  42. # Final classifier
  43. self.fc = nn.Sequential(
  44. nn.Linear(d_model, fc_hidden1),
  45. nn.ReLU(),
  46. nn.Dropout(dropout),
  47. nn.Linear(fc_hidden1, fc_hidden2),
  48. nn.ReLU(),
  49. nn.Dropout(dropout),
  50. nn.Linear(fc_hidden2, n_classes)
  51. )
  52. def forward(self, x): # x: [B, win_len, frames, feat]
  53. B, W, F, C = x.shape
  54. # Flatten batch and window
  55. x = x.view(B * W, F, C)
  56. if self.use_layernorm:
  57. x = self.input_norm(x) # [B*W, F, C] — LayerNorm over last dim (C)
  58. # Epoch-level transformer
  59. x = self.epoch_in_proj(x)
  60. x = self.epoch_pos_enc(x)
  61. x = self.epoch_transformer(x)
  62. x = self.epoch_pool(x) # [B*W, d_model]
  63. # Reshape back to sequence form
  64. x = x.view(B, W, -1)
  65. # Sequence-level transformer
  66. x = self.seq_pos_enc(x)
  67. x = self.seq_transformer(x)
  68. # Classification
  69. logits = self.fc(x) # [B, W, n_classes]
  70. return logits

RESTCORE.py at commit 1b267c4, under MIT · at the source

Overview

Authors: Jun Wang1, Sue Osting1, Anna Goforth1, Mathew V Jones2, Rama Maganti1
  1. Department of Neurology, University of Wisconsin-Madison School of Medicine and Public Health, Madison, Wisconsin, United States
  2. Department of Neuroscience, University of Wisconsin-Madison School of Medicine and Public Health, Madison, Wisconsin, United States
Institutions: University of Wisconsin–Madison (United States)
Journal: Sleep advances : a journal of the Sleep Research Society, volume 7, issue 2, article zpag044
Dates: received 8 January 2026; accepted 12 April 2026; published online 15 April 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1093/sleepadvances/zpag044 · PMID 42169976 · PMCID PMC13189165 · OpenAlex W7154513878
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: EEG (modality), mouse (organism)
Methods: Spectral & time-frequency, Preprocessing, Connectivity, Statistics, Physiology & signal measures, Machine learning
Keywords: mouse, neural network, deep learning, sleep stages, sleep classification, EEG
Topic: Sleep and Wakefulness Research (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: Department of Defense (DOD PR221869)
Citations: not cited yet (Europe PMC); 34 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repository

Its files are read in the Code ↔ Paper reader above, with 5 matches between paragraphs and lines of code.

SukiyakiP/REST

License: MIT
State: the link answers, verified on 29 September 2026
Evidence: files inventoried
Commit: 1b267c4c47023e797f0a28c45afdd56e12785a91, 26 May 2026
Languages: Python (13)
Size: 25 files, 13 scripts
Software Heritage: not archived
Found in: “Data availability”
Holds: README, license file, environment (environment.yml)
Not found: CITATION.cff, tests, continuous integration, documentation
Tools: NumPy (11 files), PyTorch (9 files), MNE-Python (6 files), SciPy (6 files), pandas (4 files), Matplotlib (3 files), Pillow (2 files), scikit-learn (2 files)
Availability: 1 check, the latest on 29 September 2026: the link answers
  • 29 September 2026: the link answers
15 files

The paper's code and data availability statement is in the Data section.

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;
  • 13 scripts, each with its path and the digest of its content;
  • 5 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.

Code and data availability statement

The paper has a code and data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

  • it points to the authors' code: SukiyakiP/REST
  • it says that the data are available on request

Read it in the paper: doi.org/10.1093/sleepadvances/zpag044.

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 1, 29 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 5 authors, 6 keywords, 1 funder, 31 references.

Cite

This paper

Wang, J., Osting, S., Goforth, A., Jones, M. V., & Maganti, R. (2026). REST-a deep learning tool for automated mouse sleep stage classification. Sleep advances : a journal of the Sleep Research Society, 7(2), zpag044. https://doi.org/10.1093/sleepadvances/zpag044

BibTeX

@article{wang2026rest,
author = {Wang, Jun and Osting, Sue and Goforth, Anna and Jones, Mathew V and Maganti, Rama},
title = {{REST-a deep learning tool for automated mouse sleep stage classification}},
journal = {Sleep advances : a journal of the Sleep Research Society},
year = {2026},
month = apr,
volume = {7},
number = {2},
pages = {zpag044},
publisher = {Oxford University Press},
issn = {2632-5012},
doi = {10.1093/sleepadvances/zpag044},
url = {https://doi.org/10.1093/sleepadvances/zpag044},
pmid = {42169976},
pmcid = {PMC13189165}
}

RIS

TY - JOUR
AU - Wang, Jun
AU - Osting, Sue
AU - Goforth, Anna
AU - Jones, Mathew V
AU - Maganti, Rama
TI - REST-a deep learning tool for automated mouse sleep stage classification
T2 - Sleep advances : a journal of the Sleep Research Society
J2 - Sleep Adv
PY - 2026
DA - 2026/04/15
VL - 7
IS - 2
SP - zpag044
SN - 2632-5012
PB - Oxford University Press
DO - 10.1093/sleepadvances/zpag044
UR - https://doi.org/10.1093/sleepadvances/zpag044
LA - en
ER -

CSL-JSON

{
"id": "10.1093/sleepadvances/zpag044",
"type": "article-journal",
"title": "REST-a deep learning tool for automated mouse sleep stage classification",
"container-title": "Sleep advances : a journal of the Sleep Research Society",
"author": [
{
"family": "Wang",
"given": "Jun"
},
{
"family": "Osting",
"given": "Sue"
},
{
"family": "Goforth",
"given": "Anna"
},
{
"family": "Jones",
"given": "Mathew V"
},
{
"family": "Maganti",
"given": "Rama"
}
],
"container-title-short": "Sleep Adv",
"volume": "7",
"issue": "2",
"page": "zpag044",
"DOI": "10.1093/sleepadvances/zpag044",
"PMID": "42169976",
"PMCID": "PMC13189165",
"ISSN": "2632-5012",
"publisher": "Oxford University Press",
"URL": "https://doi.org/10.1093/sleepadvances/zpag044",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
15
]
]
}
}

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.1371/journal.pcbi.1011793 [code]
Somnotate: A probabilistic sleep stage classifier for studying vigilance state transitions.
Journal: PLoS computational biology
In common: scikit-learn, pandas, SciPy, 2 other tools, EEG, mouse, 5 references
[2] doi:10.1093/sleepadvances/zpaf025 [code]
Probability estimation of narcolepsy type 1 in DTA mice using unlabeled EEG and EMG data.
Journal: Sleep advances : a journal of the Sleep Research Society
In common: scikit-learn, pandas, SciPy, 2 other tools, EEG, mouse, 4 references
[3] doi:10.1523/eneuro.0226-25.2025 [code]
Automated Classification of Sleep-Wake States and Seizures in Mice.
Journal: eNeuro
In common: scikit-learn, pandas, SciPy, 2 other tools, EEG, mouse, 4 references
[4] doi:10.3390/s23020899 [code]
Influence of Channel Selection and Subject's Age on the Performance of the Single Channel EEG-Based Automatic Sleep Staging Algorithms.
Journal: Sensors (Basel, Switzerland)
In common: MNE-Python, Pillow, PyTorch, 5 other tools, EEG, 2 references
[5] doi:10.3390/bios14080406 [code]
MLS-Net: An Automatic Sleep Stage Classifier Utilizing Multimodal Physiological Signals in Mice.
Journal: Biosensors
In common: EEG, mouse, 6 references
[6] doi:10.1038/s41746-025-02237-2 [code]
SLEEPYLAND: trust begins with fair evaluation of automatic sleep staging models.
Journal: NPJ digital medicine
In common: MNE-Python, scikit-learn, pandas, 3 other tools, 3 references
[7] doi:10.1371/journal.pone.0346294
Neural network architectures and normalization techniques for automated sleep stage classification using rodent EEG and EMG signals.
Journal: PloS one
In common: EEG, 6 references
[8] 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 medicine
In common: MNE-Python, PyTorch, scikit-learn, 4 other tools, EEG, 2 references
[9] doi:10.1038/s41598-024-54727-0 [code]
SlumberNet: deep learning classification of sleep stages using residual neural networks.
Journal: Scientific reports
In common: scikit-learn, pandas, SciPy, 2 other tools, EEG, mouse, 3 references
[10] doi:10.3390/s25030921 [code]
Open-Source Algorithm for Automated Vigilance State Classification Using Single-Channel Electroencephalogram in Rodents.
Journal: Sensors (Basel, Switzerland)
In common: MNE-Python, scikit-learn, pandas, 3 other tools, EEG, mouse, 2 references

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.

Add the badge to the code's README

OSCR: the badge of this paper

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 -->
[![OSCR](https://openscicode.org/badge/doi/10.1093/sleepadvances/zpag044.svg)](https://openscicode.org/badge/doi/10.1093/sleepadvances/zpag044)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.1093/sleepadvances/zpag044.svg
   :target: https://openscicode.org/badge/doi/10.1093/sleepadvances/zpag044
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1093/sleepadvances/zpag044"><img src="https://openscicode.org/badge/doi/10.1093/sleepadvances/zpag044.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.