SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2308.15291 · 2023

Towards quantitative precision for ECG analysis: Leveraging state space models, self-supervision and patient metadata

arXiv · PDF · Open in the Atlas

Code that ran

5 of 7 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; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 2 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/2308.15291.json · badge: /api/ran/2308.15291.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
tmehari/ssm_ecg canonical (classifier label)
classifier basis: classifier_2025
5 ran · 2 no recorded run
FunctionStatusWhere it lives
cat Ran
ran, honoured the contract we drafted
tmehari/ssm_ecg/code/train_ecg_model.py
code served (permissive licence) · get_code("f49db14836b035d6")
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 ndarray, ndim 2, dtype family float, shape (6, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 numpy as np

torch.manual_seed(0)

# The function expects:
# - res: a list/iterable of items where some are dicts containing a key
# - key: a string key to extract from dicts in res

# Construct valid arguments
res = [
    {"output": torch.randn(2, 4)},
    {"output": torch.randn(2, 4)},
    "not_a_dict",  # will be skipped by type check
    {"other_key": torch.randn(2, 4)},  # has different key, will be skipped
    {"output": torch.randn(2, 4)},
]

key = "output"

ARGS = {
    "res": res,
    "key": key,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (6, 4) — shape (6, 4) as a later run recorded it
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
configure_optimizer Ran
ran; our contract draft was wrong, not the code
tmehari/ssm_ecg/code/finetuning.py
code served (permissive licence) · get_code("7dcebcf902c5c695")
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) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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
import torch.nn.functional as F

torch.manual_seed(0)

# Mock auc_loss class
class auc_loss(nn.Module):
    def __init__(self, priors):
        super().__init__()
        self.priors = priors
    
    def forward(self, x, y):
        return F.binary_cross_entropy_with_logits(x, y)

# Mock PESG_AUC optimizer
class PESG_AUC(torch.optim.Optimizer):
    def __init__(self, params, lr=0.001, weight_decay=0.0):
        defaults = dict(lr=lr, weight_decay=weight_decay)
        super().__init__(params, defaults)
    
    def step(self, closure=None):
        pass

# Build a mock ResNet1D model
class MockResNet1D(nn.Module):
    def __init__(self):
        super().__init__()
        self.features_0 = nn.Linear(4, 8)
        self.features_1 = nn.Linear(8, 16)
        self.features_2 = nn.Linear(16, 32)
        self.l1 = nn.Linear(32, 71)
    
    def forward(self, x):
        x = self.features_0(x)
        x = self.features_1(x)
        x = self.features_2(x)
        x = self.l1(x)
        return x

# Build a mock CPC/S4 model
class MockCPCModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.encoder = nn.Linear(4, 8)
        self.rnn = nn.LSTM(8, 16, batch_first=True)
        self.head = nn.Linear(16, 71)
        self.meta_head = nn.Linear(16, 10)
    
    def forward(self, x):
        x = self.encoder(x)
        x, _ = self.rnn(x)
        x = self.head(x)
        return x

# Build a mock LeNet model
class MockLeNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.layers = nn.Sequential(
            nn.Linear(4, 8),
            nn.ReLU(),
            nn.Linear(8, 16),
            nn.ReLU(),
            nn.Linear(16, 71)
        )
    
    def __getitem__(self, idx):
        return self.layers[idx]
    
    def parameters(self):
        return self.layers.parameters()
    
    def forward(self, x):
        return self.layers(x)

# Create model instances
resnet_model = MockResNet1D()
cpc_model = MockCPCModel()
lenet_model = MockLeNet()

ARGS = {
    'model': resnet_model,
    'batch_size': 256,
    'head_only': False,
    'lr': None,
    'discriminative_lr': False,
    'base_model': 'xresnet1d',
    'optimizer': 'adamw',
    'discriminative_lr_factor': 1,
    'auc_maximization': False,
    'num_classes': 71,
    'use_meta_information_in_head': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 float — 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
get_loss_from_output Ran
ran, honoured the contract we drafted
tmehari/ssm_ecg/code/train_ecg_model.py
code served (permissive licence) · get_code("af782b24118dedfb")
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 Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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)

# The function recursively unwraps nested structures until it finds a dict with the key
# Then returns out[key]

# Case 1: out is a dict with 'minimize' key
dict_output = {
    'minimize': torch.tensor(0.5),
    'other_loss': torch.tensor(0.3)
}

# Case 2: out is a nested tuple/list that eventually contains a dict
nested_output = (
    (
        {
            'minimize': torch.tensor(0.7),
            'auxiliary': torch.tensor(0.2)
        },
    ),
)

# Use the simple dict case for ARGS
ARGS = {
    'out': dict_output,
    'key': 'minimize'
}
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 Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
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
get_new_state_dict Ran
ran; our contract draft was wrong, not the code
tmehari/ssm_ecg/code/finetuning.py
code served (permissive licence) · get_code("482685ef2356a018")
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 OrderedDict. 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 torch
from collections import OrderedDict

torch.manual_seed(0)

# Create init_state_dict - simulates a model's initial state
init_state_dict = OrderedDict([
    ('features.0.weight', torch.randn(4, 3)),
    ('features.0.bias', torch.randn(4)),
    ('features.1.weight', torch.randn(5, 4)),
    ('features.1.bias', torch.randn(5)),
    ('l1.weight', torch.randn(6, 5)),
    ('l1.bias', torch.randn(6)),
    ('l2.weight', torch.randn(2, 6)),
    ('l2.bias', torch.randn(2)),
])

# Create lightning_state_dict for simclr method
lightning_state_dict_simclr = OrderedDict([
    ('encoder.features.0.weight', torch.randn(4, 3)),
    ('encoder.features.0.bias', torch.randn(4)),
    ('encoder.features.1.weight', torch.randn(5, 4)),
    ('encoder.features.1.bias', torch.randn(5)),
])

# Create lightning_state_dict for moco method
lightning_state_dict_moco = OrderedDict([
    ('encoder_q.features.0.weight', torch.randn(4, 3)),
    ('encoder_q.features.0.bias', torch.randn(4)),
    ('encoder_q.features.1.weight', torch.randn(5, 4)),
    ('encoder_q.features.1.bias', torch.randn(5)),
])

# Create lightning_state_dict for byol method
lightning_state_dict_byol = OrderedDict([
    ('online_network.encoder.features.0.weight', torch.randn(4, 3)),
    ('online_network.encoder.features.0.bias', torch.randn(4)),
    ('online_network.encoder.features.1.weight', torch.randn(5, 4)),
    ('online_network.encoder.features.1.bias', torch.randn(5)),
])

# Create lightning_state_dict for swav method
lightning_state_dict_swav = OrderedDict([
    ('model.features.0.weight', torch.randn(4, 3)),
    ('model.features.0.bias', torch.randn(4)),
    ('model.features.1.weight', torch.randn(5, 4)),
    ('model.features.1.bias', torch.randn(5)),
])

# Create lightning_state_dict for cpc/s4 method
lightning_state_dict_cpc = OrderedDict([
    ('model_cpc.features.0.weight', torch.randn(4, 3)),
    ('model_cpc.features.0.bias', torch.randn(4)),
    ('model_cpc.head.weight', torch.randn(2, 4)),
    ('model_cpc.head.bias', torch.randn(2)),
])

# Define ARGS for the simclr case
ARGS = {
    'init_state_dict': init_state_dict,
    'lightning_state_dict': lightning_state_dict_simclr,
    'method': 'simclr',
    'model': 'resnet'
}
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 OrderedDict — a OrderedDict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a OrderedDict 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
mean Ran
ran, honoured the contract we drafted
tmehari/ssm_ecg/code/train_ecg_model.py
code served (permissive licence) · get_code("76ec45b4b876760c")
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 Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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

torch.manual_seed(0)

# The function expects:
# - res: a list of dicts, where each dict can have key1 (and optionally key2)
# - key1: a string key to access in each dict
# - key2: optional string key to access nested dict values

# Create sample data: list of dicts with nested structure
res = [
    {
        "loss": torch.tensor(1.5),
        "metrics": {
            "accuracy": torch.tensor(0.85)
        }
    },
    {
        "loss": torch.tensor(2.1),
        "metrics": {
            "accuracy": torch.tensor(0.92)
        }
    }
]

key1 = "metrics"
key2 = "accuracy"

ARGS = {
    "res": res,
    "key1": key1,
    "key2": key2
}
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 Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
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
add_model_specific_args Not yet run
unverified (harvested, no recorded run)
tmehari/ssm_ecg/code/pretraining.py
code served (permissive licence) · get_code("38759ed71f26ef44")
How it ran

no invocation recorded.

adjust Not yet run
unverified (harvested, no recorded run)
tmehari/ssm_ecg/code/finetuning.py
code served (permissive licence) · get_code("a610f4fbc9fdf111")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 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 7 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

Deep learning has emerged as the preferred modeling approach for automatic ECG analysis. In this study, we investigate three elements aimed at improving the quantitative accuracy of such systems. These components consistently enhance performance beyond the existing state-of-the-art, which is predominantly based on convolutional models. Firstly, we explore more expressive architectures by exploiting structured state space models (SSMs). These models have shown promise in capturing long-term dependencies in time series data. By incorporating SSMs into our approach, we not only achieve better performance, but also gain insights into long-standing questions in the field. Specifically, for standard diagnostic tasks, we find no advantage in using higher sampling rates such as 500Hz compared to 100Hz. Similarly, extending the input size of the model beyond 3 seconds does not lead to significant improvements. Secondly, we demonstrate that self-supervised learning using contrastive predictive coding can further improve the performance of SSMs. By leveraging self-supervision, we enable the model to learn more robust and representative features, leading to improved analysis accuracy. Lastly, we depart from synthetic benchmarking scenarios and incorporate basic demographic metadata alongside the ECG signal as input. This inclusion of patient metadata departs from the conventional practice of relying solely on the signal itself. Remarkably, this addition consistently yields positive effects on predictive performance. We firmly believe that all three components should be considered when developing next-generation ECG analysis algorithms.

For agents

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

get_harvested_code_for_paper("2308.15291")
get_code_for_paper("2308.15291")
have("2308.15291")

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

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

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

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

Connect an agent — have() is free.