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.

The 5 matches
  1. [1] § Materials and methods › REST model design and training ↔ Training.py, lines 106–145 · score 0.83 · AdamW, weight decay, Focal loss, class weights, optimizer, Training
  2. [2] § Materials and methods › REST model design and training ↔ RESTCORE.py, lines 27–84 · score 0.76 · ReLU, Transformer encoder, positional encoding, layer normalization, logits, linearly
  3. [3] § Materials and methods › REST model design and training ↔ RESTutils.py, lines 219–271 · score 0.76 · bandpass filter, EEG STFT, EMG epoch, EEG epoch, spectrum, memory
  4. [4] § Materials and methods › REST model design and training ↔ RESTCORE.py, lines 27–84 · score 0.75 · ReLU, Transformer encoder, positional encoding, dropout, Linear, layers
  5. [5] § Materials and methods › REST model design and training ↔ RESTutils.py, lines 164–204 · score 0.64 · notch filter, bandpass filtered, EMG signals, 250 Hz, 30 Hz, 0.1 Hz

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: 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
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: DOD (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.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
[2] doi:10.1371/journal.pone.0351872 [code]
Decoding visual object recognition from EEG signals.
Journal: PloS one
In common: MNE-Python, Pillow, PyTorch, 5 other tools, EEG
[3] doi:10.1162/imag.a.1207 [code]
Investigating the temporal dynamics and modeling of mid-level feature representations in humans.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: MNE-Python, Pillow, PyTorch, 5 other tools, EEG
[4] doi:10.1002/hbm.70528 [code]
Explainable AI Insights Into EEG Classification and Its Alignment to Neural Correlates.
Journal: Human brain mapping
In common: MNE-Python, Pillow, PyTorch, 5 other tools, EEG
[5] doi:10.1038/s41597-025-05174-7 [code]
A large-scale MEG and EEG dataset for object recognition in naturalistic scenes
Journal: n/a
In common: MNE-Python, Pillow, PyTorch, 5 other tools, EEG
[6] doi:10.1098/rstb.2024.0461 [code]
Shallow recurrent decoders for neural and behavioural dynamics.
Journal: Philosophical transactions of the Royal Society of London. Series B, Biological sciences
In common: MNE-Python, Pillow, PyTorch, 5 other tools, mouse
[7] doi:10.1007/s12021-026-09803-3 [code]
NeuroFusion: A Unified Framework for Generalized Visual Stimulus Decoding from fMRI Across Datasets and Subjects.
Journal: Neuroinformatics
In common: MNE-Python, Pillow, PyTorch, 5 other tools
[8] doi:10.1038/s41593-026-02285-1 [code]
Fixation duration on natural scenes is explained by memory encoding not processing demand.
Journal: Nature neuroscience
In common: MNE-Python, Pillow, PyTorch, 5 other tools
[9] doi:10.1038/s41598-026-50475-5 [code]
Segmentation and classification of hippocampal subregions using multi-task generative adversarial networks.
Journal: Scientific reports
In common: Pillow, PyTorch, scikit-learn, 3 other tools, mouse, 1 reference
[10] doi:10.3389/fncom.2026.1786996 [code]
Schumann-anchored golden ratio organization of human neural oscillations.
Journal: Frontiers in computational neuroscience
In common: MNE-Python, Pillow, scikit-learn, 4 other tools, EEG

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.

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: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.