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-patient-simulator

v1.0.0

Published

Real-time physiological signal simulation of pneumonia patient using a transformer-based surrogate model

Downloads

13

Readme

Patient Simulator

Real-time physiological signal simulation using a transformer-based surrogate model with ONNX Runtime Web.

Installation

npm install pneumonia-patient-simulator onnxruntime-web

Usage

import { PatientSimulator } from 'pneumonia-patient-simulator';

// Create simulator instance
const simulator = new PatientSimulator({
  fps: 30,           // Simulation frequency (default: 30)
  initialState: 0,   // Initial patient state (default: 0)
});

// Initialize with model and scalers
await simulator.initialize(
  './surrogate_model_v3.onnx',
  './scalers_v3.json'
);

// Subscribe to data events
simulator.on('data', (data) => {
  // Plot variables (fast waveforms)
  console.log('ECG:', data.plot['Ecg.ecg']);
  console.log('Pressure:', data.plot['EithaPressure.pressure']);
  
  // Monitor variables (clinical metrics)
  console.log('Heart Rate:', data.monitor['currentHeartReat.y']);
  console.log('SpO2:', data.monitor['arterial.sO2']);
});

// Subscribe to state changes
simulator.on('stateChange', ({ from, to }) => {
  console.log(`State changed from ${from} to ${to}`);
});

// Start simulation
simulator.start();

// Change patient state
simulator.setState(1); // Pneumonia

// Stop simulation
simulator.stop();

// Clean up
simulator.dispose();

Patient States

| ID | Name | Description | |----|------|-------------| | 0 | Normal | Healthy patient | | 1 | Pneumonia | Patient with pneumonia | | 2 | Ventilated | Patient on mechanical ventilation | | 3 | Stabilized | Stabilized patient |

Output Variables

Plot Variables (Fast Waveforms)

  • lungs.q_in[1].p - Lung pressure
  • lungs.q_in[1].m_flow - Lung flow
  • Ecg.ecg - ECG signal
  • EithaPressure.pressure - Arterial pressure waveform

Monitor Variables (Clinical Metrics)

  • filter.y - Filtered signal
  • currentHeartReat.y - Heart rate
  • HRAdd.y - HR additive component
  • arterialPressure.systolic - Systolic BP
  • arterialPressure.diastolic - Diastolic BP
  • arterial.sO2 - Arterial oxygen saturation
  • arterial.pO2 - Arterial partial pressure O2
  • arterial.pCO2 - Arterial partial pressure CO2
  • arterial.pH - Arterial pH
  • tissueUnit[1].pH - Tissue pH
  • venous.pH - Venous pH

API Reference

PatientSimulator

Constructor

new PatientSimulator(config?: SimulatorConfig)

Methods

| Method | Description | |--------|-------------| | initialize(modelPath, scalersPath) | Load ONNX model and scalers | | start() | Start simulation loop | | stop() | Stop simulation loop | | setState(state: 0-3) | Set patient state | | getState() | Get current state | | getStateInfo() | Get state name and ID | | isActive() | Check if running | | getTimestep() | Get current timestep | | reset() | Reset to initial state | | on(event, callback) | Subscribe to events | | off(event, callback) | Unsubscribe from events | | dispose() | Clean up resources |

Events

| Event | Payload | Description | |-------|---------|-------------| | data | SimulationData | Emitted at each simulation step | | stateChange | { from, to } | Emitted when state changes | | start | { timestep } | Emitted when simulation starts | | stop | { timestep } | Emitted when simulation stops | | error | Error | Emitted on error |

Model Files

The package requires two model files:

  • surrogate_model_v3.onnx - ONNX model file
  • scalers_v3.json - Normalization parameters

These should be served from your application and their paths provided to initialize().

Browser Compatibility

Requires browsers with WebAssembly support (all modern browsers).

License

MIT