Skip to main content

Artifact detection for physiological signals (ABP and ECG)

Project description

OkekeClean

PyPI Python 3.12+ License: AGPL v3

OkekeClean is a Python package for detecting artifact in physiological waveforms. It ships released inference code for arterial blood pressure (ABP) and electrocardiogram (ECG) models, and downloads the corresponding model weights from Hugging Face on first use.

Installation

pip install okekeclean

Or with uv:

uv add okekeclean

Quick Start

ABP

import pandas as pd
import torch

from okekeclean import ABPParams, detect_artifacts, load_model

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = load_model("okekeclean-abp-ensemble", device=device)

waveform = pd.Series(
    [80.0, 83.2, 90.5, 102.1, 110.4, 105.0, 96.3, 88.7] * 500,
    index=pd.Timestamp("2025-01-01")
    + pd.to_timedelta(range(4000), unit="s") / 125,
)

artifact_flags = detect_artifacts(
    waveform=waveform,
    modality="ABP",
    model=model,
    params=ABPParams(),
    device=device,
)

ECG

import numpy as np
import pandas as pd
import torch

from okekeclean import ECGParams, detect_artifacts, load_model

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = load_model("okekeclean-ecg-efficientnet_b0", device=device)

samples = 5000
time = np.arange(samples) / 500.0
waveform = pd.Series(
    0.9 * np.sin(2 * np.pi * 1.2 * time) + 0.05 * np.random.randn(samples),
    index=pd.Timestamp("2025-01-01") + pd.to_timedelta(time, unit="s"),
)

artifact_probs = detect_artifacts(
    waveform=waveform,
    modality="ECG",
    model=model,
    params=ECGParams(),
    device=device,
    return_type="probability",
)

Runnable examples:

Released Models

Model Signal Architecture Threshold Test performance
okekeclean-abp-ensemble ABP ResNet-18 (full FT) + EfficientNet-B0 (shallow FT) 0.184 AU-ROC 0.958, sensitivity 0.952, specificity 0.730, accuracy 0.795
okekeclean-abp-resnet18 ABP ResNet-18 (full FT) 0.17785164713859558 AU-ROC 0.951, sensitivity 0.915, specificity 0.824, accuracy 0.851
okekeclean-abp-efficientnet_b0 ABP EfficientNet-B0 (shallow FT) 0.04994076117873192 AU-ROC 0.945, sensitivity 0.799, specificity 0.939, accuracy 0.898
okekeclean-ecg-efficientnet_b0 ECG EfficientNet-B0 (full FT) 0.20802117884159088 AU-ROC 0.970, sensitivity 0.858, specificity 0.950, accuracy 0.922

Input Requirements

  • ABP: pd.Series with a DatetimeIndex, sampled at 125 Hz, units in mmHg.
  • ECG: pd.Series with a DatetimeIndex, sampled at 500 Hz, units in mV. ECG segments are resampled to 500 Hz internally if needed.

Model Weights

License

GNU Affero General Public License v3. See LICENSE.

Citation

@misc{okekeclean,
  title = {OkekeClean},
  author = {Tony Kabilan Okeke},
  year = {2026},
  howpublished = {\url{https://github.com/moberg-analytics/oss-models}}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

okekeclean-1.1.0.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

okekeclean-1.1.0-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file okekeclean-1.1.0.tar.gz.

File metadata

  • Download URL: okekeclean-1.1.0.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for okekeclean-1.1.0.tar.gz
Algorithm Hash digest
SHA256 467ec5374a09e1e7752ad4af7f315425042ff28bc7d6a264287b7ed390b60b89
MD5 1cf0f6f8ac9b2cba41eb2cdc385f031b
BLAKE2b-256 4e811e671ed9f74fca56a49b89109c30a1b8893886b14e82694f8dad8ed000c3

See more details on using hashes here.

File details

Details for the file okekeclean-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: okekeclean-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for okekeclean-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2517881a8e8266c90f1099eb2a9f56a7ab57955d3b017a9e1d3adbb5537d11f8
MD5 14f7f7bde782c57088e9ebd7e7262ca9
BLAKE2b-256 574a3820707a070ebc8c4bc9f36893009853be3d1b80f309119a98728f34e6b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page