npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pneumonia-surrogate

v1.0.6

Published

Web Component running an ONNX surrogate model of a respiratory physiology simulator at ~30 Hz in the browser.

Readme

pneumonia-surrogate

A self-contained Web Component that runs an ONNX surrogate model of a respiratory physiology simulator at ~30 Hz entirely in the browser.

Installation

npm install pneumonia-surrogate

Or load directly from a CDN with no build step:

<script src="https://cdn.jsdelivr.net/npm/pneumonia-surrogate/dist/pneumonia-surrogate.js"></script>

<pneumonia-surrogate id="sim"></pneumonia-surrogate>

Model assets

The three model files are included in the npm package and are also available on jsDelivr CDN. By default the component fetches them from CDN automatically, so no local setup is required. Override the URLs via attributes only if you want to self-host the files.

| File | Description | |------|-------------| | surrogate_model.onnx | Exported ONNX graph (all weights inlined) | | scalers.json | StandardScaler + MinMaxScaler parameters | | golden_seed.json | 90-step warm-start physiological history |

Usage

The URL attributes (model-url, scalers-url, seed-url) default to the published CDN location and can be omitted.

<!-- If installed via npm, import from dist/ -->
<script src="node_modules/pneumonia-surrogate/dist/pneumonia-surrogate.js"></script>

<pneumonia-surrogate id="sim"></pneumonia-surrogate>

<script>
  const sim = document.getElementById('sim');

  // optional Start the inference loop
  sim.start();

  // optional Listen for predictions (~30 events per second)
  sim.addEventListener('surrogate-data', (event) => {
    const { plot_vars, monitor_vars, step } = event.detail;
    console.log('Step', step, plot_vars, monitor_vars);
  });

  // optional Change control variables at any time while the simulation is running
  sim.totalCompliance = 80;
  sim.dv = 200;
  sim.cShuntFrac = 10;
</script>

Integrate with bodylight.js

Attributes

| Attribute | Type | Default | Description | |-----------|------|---------|-------------| | model-url | string | CDN | URL to surrogate_model.onnx | | scalers-url | string | CDN | URL to scalers.json | | seed-url | string | CDN | URL to golden_seed.json | | total-compliance | number | 60 | Lung compliance [10 – 200] | | dv | number | 150 | Dead volume [150 – 400] | | cshunt-frac | number | 5 | Shunt fraction [2 – 70] | | autostart | Boolean | false | starts the surrogate model after loading |

All three control attributes are also exposed as JS properties (totalCompliance, dv, cShuntFrac) and can be set at any time while the simulation is running.

Public methods

| Method | Description | |--------|-------------| | start() | Load the ONNX session (if not already cached) and begin the ~30 Hz inference loop | | stop() | Pause the inference loop; session remains loaded | | reset() | Stop execution, restore control defaults, reload the warm-start seed |

surrogate-data event detail

{
  plot_vars: {
    "lungs.q_in[1].p":    number,  // Airway pressure
    "lungs.q_in[1].m_flow": number, // Airflow
    "Ecg.ecg":            number,  // ECG signal
    "EithaPressure.pressure": number // Arterial pressure waveform
  },
  monitor_vars: {
    "filter.y":                   number,  // Respiratory rate
    "currentHeartReat.y":         number,  // Heart rate
    "arterialPressure.systolic":  number,  // Systolic ABP (mmHg)
    "arterialPressure.diastolic": number,  // Diastolic ABP (mmHg)
    "arterial.sO2":               number,  // SpO2 (%)
    "arterial.pO2":               number,  // PaO2 (mmHg)
    "arterial.pCO2":              number,  // PaCO2 (mmHg)
    "arterial.pH":                number,  // Arterial pH
    "tissueUnit[1].pH":           number,  // Tissue pH
    "venous.pH":                  number   // Venous pH
  },
  step: number  // Monotonic step counter since last start()
}

The event bubbles and is composed: true, so it crosses Shadow DOM boundaries.

fmidata event detail, compatible with bodylight.js

{ time: number, //time of surrogate simulation
  data: {[number, ..., number ]}} //array of just values in order of plot_vars and monitor_vars