SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2405.17766 · 2024

SleepFM: Multi-modal Representation Learning for Sleep Across Brain Activity, ECG and Respiratory Signals

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 6 failures of our instrument; 2 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2405.17766.json · badge: /api/ran/2405.17766.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
rthapa84/sleepfm-codebase canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
FunctionStatusWhere it lives
cache_pkl Ran
ran; our contract draft was wrong, not the code
rthapa84/sleepfm-codebase/sleepfm/model/dataset.py
code served (permissive licence) · get_code("be38301cc4c45a97")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pickle
import tempfile
import os

# Create a temporary pickle file for testing
temp_dir = tempfile.mkdtemp()
temp_pickle_path = os.path.join(temp_dir, "test.pkl")

# Write some test data to the pickle file
test_data = {"key": "value", "numbers": [1, 2, 3, 4, 5]}
with open(temp_pickle_path, 'wb') as f:
    pickle.dump(test_data, f)

# Define ARGS with the path parameter
ARGS = {
    "path": temp_pickle_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
count_parameters Ran
ran, honoured the contract we drafted
rthapa84/sleepfm-codebase/sleepfm/2_pretrain.py
code served (permissive licence) · get_code("649ce0bf7b6ccf7e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 8)
        self.linear2 = nn.Linear(8, 3)
        self.embedding = nn.Embedding(10, 5)
    
    def forward(self, x):
        return self.linear2(self.linear1(x))

model = SimpleModel()

ARGS = {
    "model": model
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_labels Ran
ran; our contract draft was wrong, not the code
rthapa84/sleepfm-codebase/sleepfm/0_extract_pretraining_data.py
code served (permissive licence) · get_code("42245dbd78d632cc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import h5py
import tempfile
import os

# Create a temporary HDF5 file with the expected structure
temp_dir = tempfile.mkdtemp()
temp_path = os.path.join(temp_dir, "test_data.h5")

with h5py.File(temp_path, 'w') as f:
    # Create the nested group structure that extract_labels expects
    sleep_stages_group = f.create_group('data/sleep_stages')
    
    # Create datasets for each sleep stage label
    length = 10
    wake_data = np.random.rand(1, length)
    rem_data = np.random.rand(1, length)
    n1_data = np.random.rand(1, length)
    n2_data = np.random.rand(1, length)
    n3_data = np.random.rand(1, length)
    unknown_data = np.random.rand(1, length)
    
    sleep_stages_group.create_dataset('wake', data=wake_data)
    sleep_stages_group.create_dataset('rem', data=rem_data)
    sleep_stages_group.create_dataset('n1', data=n1_data)
    sleep_stages_group.create_dataset('n2', data=n2_data)
    sleep_stages_group.create_dataset('n3', data=n3_data)
    sleep_stages_group.create_dataset('unknown', data=unknown_data)

ARGS = {
    'path': temp_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
h5py, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
getEDFFilenames Ran
ran; our contract draft was wrong, not the code
rthapa84/sleepfm-codebase/sleepfm/utils.py
code served (permissive licence) · get_code("6135b0afef6f2ae2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
import os
from pathlib import Path

# Create a temporary directory with some test EDF files
temp_dir = tempfile.mkdtemp()

# Create some dummy EDF files
Path(temp_dir, "test_file.edf").touch()
Path(temp_dir, "another_file.EDF").touch()
Path(temp_dir, "data_file.Edf").touch()
Path(temp_dir, "mslt_study.edf").touch()  # This should be filtered out

# Create a subdirectory with more EDF files
subdir = Path(temp_dir, "subdir")
subdir.mkdir()
Path(subdir, "nested_file.edf").touch()
Path(subdir, "mslt_nested.edf").touch()  # This should be filtered out

ARGS = {
    "path2check": temp_dir
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
getEDFFiles Ran
ran; our contract draft was wrong, not the code
rthapa84/sleepfm-codebase/sleepfm/utils.py
code served (permissive licence) · get_code("01dfb4f45e1655db")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
from pathlib import Path

# Create a temporary directory with some test files
temp_dir = tempfile.mkdtemp()

# Create some EDF files
edf_file_1 = Path(temp_dir) / "test_study_1.edf"
edf_file_1.touch()

edf_file_2 = Path(temp_dir) / "test_study_2.EDF"
edf_file_2.touch()

# Create an MSLT file that should be filtered out
mslt_file = Path(temp_dir) / "mslt_study.edf"
mslt_file.touch()

# Create a subdirectory with an EDF file
subdir = Path(temp_dir) / "subdir"
subdir.mkdir()
edf_file_3 = subdir / "nested_study.REC"
edf_file_3.touch()

ARGS = {
    "path2check": temp_dir
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_data Ran
ran; our contract draft was wrong, not the code
rthapa84/sleepfm-codebase/sleepfm/utils.py
code served (permissive licence) · get_code("198787f0addf9d90")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import pickle
import tempfile
import os

# Create temporary files for testing
temp_dir = tempfile.mkdtemp()

# Create a pickle file with sample data
pickle_file = os.path.join(temp_dir, "test_data.pkl")
sample_pickle_data = {"key": "value", "numbers": [1, 2, 3]}
with open(pickle_file, 'wb') as f:
    pickle.dump(sample_pickle_data, f)

# Create a JSON file with sample data
json_file = os.path.join(temp_dir, "test_data.json")
sample_json_data = {"name": "test", "values": [10, 20, 30]}
with open(json_file, 'w') as f:
    json.dump(sample_json_data, f)

# Define ARGS - we'll use the pickle file as the primary test case
ARGS = {
    "filename": pickle_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
resample_signal Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
rthapa84/sleepfm-codebase/sleepfm/0_extract_pretraining_data.py
code served (permissive licence) · get_code("e9351282d196962e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import scipy.signal

# Create small test data
# data should be 2D array with shape (num_samples, num_features)
# labels should be 2D array with shape (num_samples, num_columns) where column 4 exists
data = np.random.randint(-100, 100, size=(100, 8)).astype(np.float32)
labels = np.random.randint(0, 10, size=(100, 5)).astype(np.float32)

# Ensure there's at least one transition in column 4 of labels
# so that cutoff has at least one element
labels[50:, 4] = 5  # Change value at index 50

old_fs = 200  # Old sampling frequency

ARGS = {
    "data": data,
    "labels": labels,
    "old_fs": old_fs
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
cache_csv Not yet run
unverified (harvested, no recorded run)
rthapa84/sleepfm-codebase/sleepfm/model/dataset.py
code served (permissive licence) · get_code("aad95e0e0f173703")
How it ran

no invocation recorded.

import_signal_names Not yet run
unverified (harvested, no recorded run)
rthapa84/sleepfm-codebase/sleepfm/0_extract_pretraining_data.py
code served (permissive licence) · get_code("7e08abd687492a60")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 9 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Sleep is a complex physiological process evaluated through various modalities recording electrical brain, cardiac, and respiratory activities. We curate a large polysomnography dataset from over 14,000 participants comprising over 100,000 hours of multi-modal sleep recordings. Leveraging this extensive dataset, we developed SleepFM, the first multi-modal foundation model for sleep analysis. We show that a novel leave-one-out approach for contrastive learning significantly improves downstream task performance compared to representations from standard pairwise contrastive learning. A logistic regression model trained on SleepFM's learned embeddings outperforms an end-to-end trained convolutional neural network (CNN) on sleep stage classification (macro AUROC 0.88 vs 0.72 and macro AUPRC 0.72 vs 0.48) and sleep disordered breathing detection (AUROC 0.85 vs 0.69 and AUPRC 0.77 vs 0.61). Notably, the learned embeddings achieve 48% top-1 average accuracy in retrieving the corresponding recording clips of other modalities from 90,000 candidates. This work demonstrates the value of holistic multi-modal sleep modeling to fully capture the richness of sleep recordings. SleepFM is open source and available at https://github.com/rthapa84/sleepfm-codebase.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2405.17766")
get_code_for_paper("2405.17766")
have("2405.17766")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2405.17766.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2405.17766.svg)](https://syntology.ai/paper/2405.17766)

Connect an agent — have() is free.