Work

PySpiro: A Python Library for Lung Function Reference Equations and Severity Classification

Year: 2026
Type: preprint
Abstract: Background and Objective Lung function reference equations are essential for interpreting spirometry and related modalities, yet existing tools are fragmented, modality- and language-specific (predominantly R), and lack integrated severity classifiers. We present PySpiro, an open-source Python library unifying 23 spirometry, 1 multiple breath washout, 2 diffusing capacity, 1 static lung volume, and 2 oscillometry reference equations under a single API, with 10 clinical severity classifiers. Methods PySpiro was implemented in Python 3 using NumPy and pandas, with all equations coded directly from literature. The unified API exposes predicted medians, z-scores, limits of normal (LLN/ULN), and raw Lambda-Mu-Sigma (LMS) triplets per parameter, plus a vectorised compute() method for batch processing at the DataFrame level. Unit-tests covering every equation and classifier verify agreement with published values and confirm correct boundary, out-of-range, and missing-input handling. Results PySpiro covers spirometry equations from 1971 to 2022 across Caucasian, Asian, Indian, and race-neutral global populations, plus non-spirometry modalities (multiple breath washout, diffusing capacity, static lung volumes, oscillometry). Classifiers span COPD, interstitial lung disease, pattern and severity grading, bronchodilator reversibility, and primary ciliary dyskinesia. Compared with rspiro (5 equations, 4 spirometry) and the only prior Python package (spiref, 2 equations, no z-scores or % predicted), PySpiro offers substantially broader coverage, multi-modality support, a richer output API, and 10 classifiers absent from both. Conclusions PySpiro is freely available (PyPI: pyspiro; doi:10.5281/zenodo.15519193) and provides a comprehensive, validated, and extensible platform for lung function data analysis in research pipelines.
Source: medRxiv
Language: English
Field: Medicine
Open Access status: green
OpenAlex ID: W7220937684
Cites: 31
Cited by:
Related to: 10