Skip to main content

Open-source AASM 2.6-compliant respiratory scoring for polysomnography

Project description

psgscoring

Open-source AASM 2.6-compliant respiratory scoring for polysomnography.

psgscoring is a standalone Python library that implements the full AASM 2.6 respiratory scoring algorithm for polysomnographic (PSG) recordings. It is the scoring engine behind YASAFlaskified and is designed to work with YASA and MNE-Python.

Features

  • Apnea detection: ≥90% flow reduction on oronasal thermistor, ≥10 s
  • Hypopnea detection: ≥30% flow reduction on nasal pressure, ≥10 s, with ≥3% desaturation or arousal
  • Apnea type classification: 7-rule obstructive/central/mixed classification with Hilbert phase-angle analysis
  • ECG-derived effort (v0.2.4): Transformed ECG (TECG) method (Berry et al., JCSM 2019) + spectral classifier for improved central vs. obstructive differentiation
  • Six over-counting corrections: post-apnea baseline inflation, SpO₂ cross-contamination, Cheyne-Stokes flagging, borderline classification, artefact-flank exclusion, local baseline validation
  • Six under-counting corrections: peak-based hypopnea detection, SpO₂ de-blocking, extended nadir window, flow smoothing, position auto-mapping, configurable scoring profiles
  • SpO₂ analysis: ODI at 3% and 4% thresholds, baseline (P90), T90
  • PLM scoring: AASM 2.6 + WASM criteria
  • RERA and RDI: flow limitation (flattening index) and FRI-RERA detection

Installation

pip install psgscoring

With optional dependencies (LightGBM confidence calibration):

pip install psgscoring[full]

Quick start

import mne
from psgscoring import run_pneumo_analysis

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

results = run_pneumo_analysis(raw, hypno)

ahi = results["respiratory"]["summary"]["ahi_total"]
print(f"AHI: {ahi}")

Scoring profiles

Three configurable profiles balance sensitivity vs. specificity:

Profile Use case Hypopnea threshold
strict Minimise false positives 40% flow reduction
standard AASM 2.6 default 30% flow reduction
sensitive Maximise detection 25% flow reduction

References

  • Berry RB et al. The AASM Manual for the Scoring of Sleep and Associated Events, Version 2.6. AASM, 2020.
  • Berry RB et al. Use of a Transformed ECG Signal to Detect Respiratory Effort During Apnea. J Clin Sleep Med. 2019;15(11):1653–1660.
  • Vallat R, Walker MP. An open-source, high-performance tool for automated sleep staging. eLife. 2021;10:e70092.

Disclaimer

psgscoring is research software, not a cleared medical device. All computed indices are research-grade estimates that must be reviewed by a qualified clinician. See DISCLAIMER.md.

License

BSD-3-Clause. See LICENSE.

Citation

If you use psgscoring in your research, please cite:

Rombaut B, Rombaut B, Rombaut C, Vallat R. YASAFlaskified: an open-source platform for automated PSG analysis with systematic over-counting and under-counting corrections. In preparation, 2026.

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.4.tar.gz (59.5 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.4-py3-none-any.whl (64.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: psgscoring-0.2.4.tar.gz
  • Upload date:
  • Size: 59.5 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.4.tar.gz
Algorithm Hash digest
SHA256 85633b575c2f540807dd5b7215a873b38ec8c00bc7882c70976d32d3f964ae8f
MD5 2524278c4d15d2acb16a22af874a19ef
BLAKE2b-256 f83b9ec3f204c54f5e243050c7819f2dfc422445c2f2eae44ed58c7c85762e48

See more details on using hashes here.

File details

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

File metadata

  • Download URL: psgscoring-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 64.5 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 311a1c2b84d9dea8f577a3afee92d9e887a1ad509589f437560ba25f79846e40
MD5 5ce7cf0ad12f0abdf07ff10657fa8b34
BLAKE2b-256 0d3fc64617c20ca38847e0022be622ace849925a41191793106d61437153f078

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