Reproducing the paper#
Every paper asset maps to an entry-point module run as python -m protosleepnet.<module>. Pass --help for options; full experiment settings
(M value, seeds, datasets) are documented per script and mirrored in the
protosleepnet. Modules under clinical_probing/ run in the
order listed.
Note
Raw recordings are not redistributed here — obtain them from their sources
and preprocess with physioex (this repo
ships none of its own preprocessing). Large artifacts (predictions, embeddings,
reconstruction arrays, checkpoints) are not in git; only small figure-source
JSON is committed under data/ (data/reconstructions/M12/, the per-prototype
records behind Fig 3–4 and Tab 1–2, and data/probing_staging_summary/, the
staging tables of Supplementary Note 1). Paths are read from the environment:
see Installation.
Figure / table → experiment → command#
Paper asset |
Experiment |
Command |
|---|---|---|
Fig 2a; Supp Note 1 |
In-domain + OOD staging, per-class, confusion, stats |
|
Supp Note 2 |
Component ablation (4 variants) + occlusion robustness |
|
Fig 2b; Supp Note 3 |
M-sweep, VQ methods, residual baselines |
|
Supp Note 3 (§5) |
Continuous-vs-quantized disagreement; paired per-subject κ |
|
Fig 4; Supp Notes 5, 6 |
Prototype reconstruction (data/model/hybrid) + cross-dataset |
|
Fig 3; Tab 1, 2; Supp Notes 4, 6 |
Codebook summaries, band-ablation rules, coherence checklist, local IG |
|
Tab 2; Supp Note 6 (§5) |
Checklist threshold sweeps + joint margins; stage-permutation control |
|
Supp Note 6 (§10) |
Automatically detected spindles / slow waves vs band relevance (MASS SS2; needs |
|
Supp Note 8 |
Prototype randomization |
|
Supp Note 9 |
Seed stability (training seeds, reconstruction, MMD) |
|
Supp Note 9 (§4) |
Coarse-to-fine codebook refinement across adjacent M |
|
Fig 5; Tab 3; Supp Note 7 |
Clinical probing (ASD, KPD): frozen embeddings → training atlas → per-subject records → 20 features → 34-descriptor comparator → nested LOSO → DeLong inference → deficit structure |
|
Live demo |
Subject selection, anonymized subset, PaCMAP atlas, per-epoch IG, prototype cards |
|
CPU-only analyses have ready-made launchers under examples/slurm/analysis/.
Manuscript figure/table assembly (LaTeX-coupled emitters) is kept out of this
repo, with the paper sources.
Repository layout#
src/protosleepnet/ # installable package (run as python -m protosleepnet.<mod>)
train.py test_pretrained.py extract_embeddings.py # staging training / evaluation
learn_prototypes_vq.py test_prototypes.py # VQ codebook learning + quantized inference
test_occlusion.py test_prototype_randomization.py # occlusion robustness, prototype randomization
seed_*.py convert_and_predict_seeds.py # seed-stability pipeline
build_protosleepnet.py # shared model factory
ablation/ baselines/ # component ablation; residual / mixer / dropout variants
posthoc_prototypes/ # k-means codebooks, quantization disagreement, codebook refinement
proto_reconstruction/ # data-driven / model-driven / hybrid reconstruction
figure_reconstruction/ # rules, spectral & relevance signatures, local IG,
# threshold sweeps, stage permutation, detected events
clinical_probing/ # atlas, per-subject records, 20 features, nested LOSO,
# hypnogram comparator, DeLong inference, deficit structure
plot/ # portable figure scripts (from predictions)
demo/ # interactive-demo precompute pipeline + static app
examples/slurm/ # cluster launchers; copy env.sh.example -> env.sh (analysis/ = CPU-only analyses)
data/ # small committed figure-source JSON only
scripts/ # HuggingFace upload of the released weights + model cards
tests/ # smoke tests (import graph + optional pretrained forward pass)
Smoke test#
bash reproduce.sh # load weights → forward pass → regenerate one figure
pip install -e . pytest
pytest # import-graph smoke test (no network)
pytest --runslow # also pull weights from HuggingFace and run a forward pass
The interactive demo#
The protosleepnet.demo subpackage builds the static bundle behind the
Live demo: subject selection, subsetting/anonymization, the PaCMAP atlas,
per-epoch IG, and the clinical-plausibility audit. It ships only anonymized
derived artifacts — never the source signals. See its module reference in the
protosleepnet.