SimPaM/patient-monitor-simulation/README.md
2026-11-12 09:36:13 +01:00

6.5 KiB
Raw Blame History

Patient Monitor Simulation (PaMSim) — v0.3.0

A two-window, Rust/GTK4 patient-monitor simulator for teaching on Fedora Linux.

Synthetic training signals only — not for clinical use. ECG, arterial pressure, plethysmography and capnography are schematic mathematical approximations. The simulation has no clinical validation and is not a medical device.

Build and run on Fedora

sudo dnf install rust cargo gcc pkgconf-pkg-config gtk4-devel
cargo test
cargo run --release

Run these commands from the extracted patient-monitor-simulation folder. Window titles show the application version. GTK4 requires a functional graphical session (e.g., Fedora KDE/Wayland).

Windows

Admin: Controls ECG rhythm and rate; mechanical capture; SpO₂; invasive arterial pressure, waveform shape and pulse-pressure variation; NIBP; and capnography. Numeric inputs have bidirectionally linked sliders and text fields. Each of the five monitor parameters (ECG, SpO₂/pleth, ART, CO₂, NIBP) has its own Show on monitor checkbox.

Monitor: Black background; ECG green, pleth yellow, ART red and capnogram light grey. Waveforms and vital signs disappear together when their respective visibility checkbox is cleared. Remaining waveform rows expand to use the space. Hiding a display channel does not stop signal generation or physiological coupling: for example, hiding ECG does not stop ART or pleth pulses. NIBP can be hidden independently; this also removes its footer.

The monitor can be resized and toggled fullscreen with F11; Esc exits fullscreen. On Wayland, move the monitor to the presentation screen before activating fullscreen. Fullscreen does not lock down the computer.

ECG and mechanical coupling

  • ECG rhythms: sinus, atrial fibrillation, monomorphic ventricular tachycardia, ventricular fibrillation and asystole.
  • Mechanical capture: 1:1, 2:1, 3:1, None (PEA), or deterministic pseudo-random capture (~65%). PR is derived from conducted QRS events, never controlled by a pulse-rate slider.
  • A captured QRS leads to an ART upstroke after a schematic 120 ms, and a peripheral pleth pulse after 300 ms. Pleth is strongly damped/filtered.
  • VF, asystole and PEA suppress mechanical pulses; old samples scroll out of view. NIBP is a static, separately entered cuff reading.

Invasive arterial pressure and PPV (new in v0.3)

The arterial waveform has a fixed 0–200 mmHg display axis, with tick marks at 0, 50, 100, 150 and 200 mmHg. Nominal ART systolic and diastolic inputs are limited to 0–200 mmHg.

Pulse pressure variation (PPV) is adjustable from 0% to 60%, in 1% increments, via synchronized slider and text field (Admin → Invasive arterial blood pressure). Its default is 0% (no respiratory modulation). The respiratory cycle comes from the same respiratory-rate parameter as the capnogram. RR = 0 disables the respiratory modulation (apnea).

The synthetic PPV definition is:

PPV (%) = 100 × (PPmax − PPmin) / ((PPmax + PPmin) / 2)

The model applies a sinusoidal variation to pulse pressure, sampled for each mechanically conducted beat. The diastolic baseline remains nominally fixed, so this is primarily a beat-to-beat systolic swing, not an arbitrary vertical translation of the entire arterial trace. It does not affect ECG, mechanical capture or pleth amplitude. This is a visual teaching model, not a validated predictor of fluid responsiveness.

Example: ART 120/75 mmHg has nominal pulse pressure 45 mmHg. At PPV 20%, the ideal pulse-pressure extrema are 40.5 and 49.5 mmHg, corresponding to systolic peaks of approximately 115.5 and 124.5 mmHg (assuming the diastolic baseline stays at 75 mmHg). The rendered waveform shape and finite number of beats per respiratory cycle mean the visible maxima may not reach the ideal extrema exactly.

The ART sidebar displays the nominal systolic/diastolic pressures and MAP, plus the configured PPV percentage when PPV is greater than 0. It does not measure PPV from sampled arterial data. At very high nominal systolic pressure, the highest modulated pulses can exceed the 200 mmHg scale; the displayed curve is then clipped at the top, without rescaling the axis.

Display options (new in v0.3)

The five Show on monitor checkboxes affect the presentation only:

Checkbox Hidden monitor content
ECG ECG waveform, HR and rhythm label
Pulse oximetry Pleth waveform, SpO₂ and PR
Invasive arterial blood pressure ART waveform, pressure values, MAP and PPV label
Capnography CO₂ waveform, EtCO₂ and RR
NIBP Static cuff pressure values and NIBP footer

Remaining visible waveforms keep their relative order and receive an equal share of the available area; zero waveform channels is supported.

Signal implementation

  • 100 Hz synthetic signal samples, 10 s retained history, 8 s scrolling trace.
  • Cairo draws into the GTK4 DrawingArea and scales with the window.
  • A conducted QRS records its own respiratory PPV multiplier at event time. The arterial pulse thus retains the same amplitude throughout the beat.
  • Varying PPV does not alter the peripheral pleth pulse or the number of mechanical pulses.
  • Clinical accuracy, dynamic NIBP measurements, alarms, artifacts, calibration, precise waveform timing, and patient physiology are outside this prototype.

Project layout

src/
  main.rs        GTK application entry point
  model.rs       Parameters, rhythm/capture settings, display flags
  simulation.rs  QRS-timed mechanical signals, PPV and respiratory synthesis
  render.rs      Cairo monitor layout, dynamic visibility, fixed ART axis
  ui.rs          Admin controls and monitor window

Changes since v0.2.2

  1. Respiratory PPV with a 0–60% instructor setting, coupled to the simulated respiratory cycle and applied per arterial beat.
  2. Five independent display visibility toggles, dynamic waveform row layout, and independent NIBP-footer hiding.
  3. ART axis reduced from 0–250 to 0–200 mmHg, with inputs adjusted to the new range.
  4. Added regression tests for PPV arithmetic and its effects on ART, for hiding ECG while retaining mechanical pulses, for active channel selection, and for arterial-axis normalization.

Verification: The archive is generated from these sources. Run cargo test locally to verify the Rust/GTK build; Rust and GTK4 development components were not available in the environment where this ZIP was prepared.