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. 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.93.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.93-py3-none-any.whl (81.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: psgscoring-0.2.93.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.93.tar.gz
Algorithm Hash digest
SHA256 9ffc16cbf0f13d299ad09ca0251e8ab4dfb4669aff31173b81b4f233c7955649
MD5 3280321d0ece213e31230642a3376bb5
BLAKE2b-256 66d259510438293a3777ff1e0b3210d805a4622b87773a3ec1ba25d57d02fdf3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: psgscoring-0.2.93-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.93-py3-none-any.whl
Algorithm Hash digest
SHA256 a836b84991563f9cac477a06598e55b2ed98b03b58e530638632d5a8f35ab0f1
MD5 02589a9e9d54d9e3ca47ccc8ea15f26c
BLAKE2b-256 8a6fe291e67568007d8bb763dd566f4c81d8d79a62c9411327c5ff1bc86cb8df

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