Skip to main content

Open-source Python library for AASM 2.6-compliant automated polysomnography scoring

Project description

psgscoring

PyPI License: BSD-3 Python Validated

Open-source Python library for AASM 2.6-compliant automated polysomnography scoring.

psgscoring extracts the core respiratory scoring algorithms from YASAFlaskified into a standalone, pip-installable library for the research community.

Validation (v0.2.92)

External validation on two public datasets:

PSG-IPA (PhysioNet, 5 recordings, 60 scorer sessions from 12 RPSGT/ESRS)

Metric Result Target
AHI bias +1.6/h <±5/h ✓
MAE 2.5/h
Pearson r 0.990 ≥0.85 ✓
Severity concordance 75% ≥70% ✓
Event-level F1 (SN3) 0.890

For 3/5 recordings, the algorithm's deviation from the scorer mean was smaller than the inter-scorer variability.

iSLEEPS (39 ischemic stroke patients, SOMNOmedics)

Severity Bias MAE
Normal/Mild (n=13) −0.1/h 3.3/h
Moderate/Severe (n=26) −16.6/h 16.6/h

Excellent for standard populations; systematic under-scoring in stroke patients (central apnea predominance).

Features

  • AASM 2.6 respiratory scoring: apnea/hypopnea detection with dual-sensor support
  • 12 systematic bias corrections: 6 over-counting + 6 under-counting
  • Breath-amplitude stability filter: rejects false-positive hypopneas during normal breathing
  • AHI confidence interval: strict/standard/sensitive profiles with robustness grade (A/B/C)
  • Hypoxic burden (v0.2.92): total SpO₂ desaturation area per event, normalised per hour (Azarbarzin et al., AJRCCM 2019)
  • Post-processing (v0.2.92): CSR-aware central reclassification, mixed apnea decomposition, central instability index
  • ECG-derived effort classification: spectral + TECG for central apnea detection
  • Configurable scoring profiles: strict (research), standard (AASM 2.6), sensitive (UARS)
  • PLM, SpO₂, RERA/RDI, signal quality assessment

Installation

pip install psgscoring

Quick start

from psgscoring import run_pneumo_analysis
import mne

raw = mne.io.read_raw_edf("recording.edf", preload=True)
hypno = ["W", "N1", "N2", "N3", "R", ...]  # 30-s epochs

results = run_pneumo_analysis(raw, hypno, scoring_profile="standard")

# AHI with confidence interval
iv = results["ahi_interval"]
print(f"AHI: {iv['standard']['ahi']} [{iv['strict']['ahi']}{iv['sensitive']['ahi']}]")
print(f"Grade: {iv['robustness_grade']}")

# Hypoxic burden (v0.2.92)
hb = results["hypoxic_burden"]
print(f"Hypoxic burden: {hb['hypoxic_burden']} {hb['unit']}")

# Post-processing results (v0.2.92)
pp = results["postprocess"]
print(f"CSR reclassified: {pp['n_csr_reclassified']}")
print(f"Mixed decomposed: {pp['n_mixed_decomposed']}")

What's new in v0.2.92

  • Hypoxic burden: per-event SpO₂ desaturation area, normalised %·min/h
    • Clinical thresholds: <20 low, 20–73 moderate, >73 high CV risk
  • CSR-aware reclassification: flagged obstructive/mixed events in CSR troughs → central
  • Mixed apnea decomposition: central portion ≥10s → reclassified as central
  • Central instability index: profile-dependent O/C uncertainty (0–1 scale)
  • iSLEEPS validation: 39 stroke patients, MAE 3.3/h at normal/mild
  • Event-level validation: F1=0.890, Δt=2.3s on severe-OSA recording

Documentation

📖 Online Supplement (Wiki) 📖 Technical Handbook

Live platform

slaapkliniek.be — upload EDF, receive complete PSG report.

Citation

Rombaut B, Rombaut B, Rombaut C, Vallat R. psgscoring: An Open-Source Python Library for AASM 2.6-Compliant Automated Polysomnography Scoring. 2026. https://github.com/bartromb/psgscoring

This library builds on YASA:

Vallat R, Walker MP. An open-source, high-performance tool for automated sleep staging. eLife. 2021;10:e70092.

License

BSD-3-Clause. See LICENSE.

Disclaimer: Research use only. Not CE-marked or FDA-cleared. See DISCLAIMER.md.

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

psgscoring-0.2.92.tar.gz (78.2 kB view details)

Uploaded Source

Built Distribution

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

psgscoring-0.2.92-py3-none-any.whl (81.7 kB view details)

Uploaded Python 3

File details

Details for the file psgscoring-0.2.92.tar.gz.

File metadata

  • Download URL: psgscoring-0.2.92.tar.gz
  • Upload date:
  • Size: 78.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for psgscoring-0.2.92.tar.gz
Algorithm Hash digest
SHA256 9ae858a95fabaca51dc642bfaad98f627090d0ad8300beac114f3c3ad97ed7fd
MD5 820feb2c862f08d9958db27732faddba
BLAKE2b-256 73caa48ab851253bf0ac99d32b6a2d399b84861eb409688242d0d39fc1b86735

See more details on using hashes here.

File details

Details for the file psgscoring-0.2.92-py3-none-any.whl.

File metadata

  • Download URL: psgscoring-0.2.92-py3-none-any.whl
  • Upload date:
  • Size: 81.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for psgscoring-0.2.92-py3-none-any.whl
Algorithm Hash digest
SHA256 fb4a2235c00dafa181d5cd2bb53924f8d80f1f792292717230ca08d209275eea
MD5 3d323f3593fcb2fefa8f5950bec04728
BLAKE2b-256 4934bde46b369cdc225ddc46119b0f1f5a67edae529ad986e0947937e5184ff0

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