Documentation·GitHub·neuroresp
phrenic
Mechanistic model of human breathing across physiological sensors
Anatomy
Flow against volume
Chest against abdomen
Statistics
How it works
This browser port of phrenic runs the same physics engine as simulate_respiration in Python, so you can see how different sensors read the same breaths. Its sister package, neuroresp, works in the other direction, recovering breathing from recorded fMRI, MEG, ECG, belts, and airflow.
One lung model, every sensor
- Shared physiology: Breathing muscles generate pressure across airway resistance and lung stiffness (with an optional narrowed second lung region), splitting each breath between ribcage and abdomen while driving a breath-coupled heartbeat clock.
- Realistic sensor distortions: Every trace comes from that single ground truth: square-law nasal pressure, thermistor thermal lag, AC belt drift and rail clipping, airway gas transport for capnography, and head movement for MEG and MRI. Unlike waveform generators such as NeuroKit2, signals stay physically linked.
Three views
- Live: Runs continuously; parameter changes and events apply from the next breath.
- Snapshot: Fixed window matching Python’s
simulate_respiration(use Copy Python call to reproduce it). - Reconstruct: Runs in reverse from one or two observed channels (open-access real recordings or a live synthetic person), projecting unobserved sensors with 90% credible bands, rescuing clipped belts with ECG or MRI B0, and toggling between blind adult priors and lifespan demographic priors (age, sex, height, and BMI).
Live and Snapshot defaults use textbook resting-adult values; Reconstruct demographic priors come from multi-cohort resting lifespan curves. Full equations and real-data comparisons are in the phrenic model and calibration notes and tutorial.
© 2026 Shane Lindsay. Text and figures licensed under CC BY 4.0. Simulator code from phrenic under the MIT licence. 3D anatomical meshes adapted from BodyParts3D (© DBCLS, CC BY 4.0) via open-anatomy-3d. Real sample snippets in Reconstruct come from open-access recordings in PhysioNet CPAP (CC BY 4.0) and Schumann et al. (2025).