This commit is contained in:
GABRIEL Sebastian 2026-11-12 10:43:11 +01:00
commit 35a380b808
8 changed files with 954 additions and 46 deletions

View file

@ -1,4 +1,4 @@
# Patient Monitor Simulation (PaMSim) — v0.3.0
# Patient Monitor Simulation (PaMSim) — v0.3.2
A two-window, Rust/GTK4 patient-monitor simulator for teaching on Fedora Linux.
@ -20,14 +20,17 @@ 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.
**Admin:** Controls patient name; ECG rhythm and rate; mechanical capture;
SpO₂, signal quality and sensor connection; 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
light grey. The patient name entered in Admin replaces **PATIENT MONITOR** in
the header immediately; leaving the name blank restores the generic title.
Long names are automatically resized or clipped to fit the header.
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
@ -37,6 +40,41 @@ 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.
## Patient name and pulse oximeter signal state (new in v0.3.2)
The new **Patient name** text field at the top of Admin immediately replaces the
monitor headline. It is optional; an empty or whitespace-only name displays
**PATIENT MONITOR**. This is a local teaching label, not a patient record.
Admin → **Pulse oximetry** has two additional controls:
- **Sensor not attached** (checkbox): immediately removes the pleth waveform,
suppresses SpO₂ and pulse-rate readings, and displays **NO SENSOR** instead
of the numeric saturation. This takes precedence over signal quality.
- **Signal quality** (dropdown), which changes the visible pleth waveform and
quality indicator, independently of the instructor-set SpO₂ percentage:
| Setting | Pleth waveform | Monitor display |
| --- | --- | --- |
| **0 — None** | No waveform | SpO₂ `--`, PR `--`, **NO SIGNAL**; no stars |
| **1 — Poor** | Small, irregularly amplitude-distorted pulse | 1 star (★) |
| **2 — Adequate** | Medium, smoothly damped pulse | 2 stars (★★) |
| **3 — Good** | Full nominal, smoothly damped pulse | 3 stars (★★★) |
Default: sensor attached; signal quality **3 — Good**. At levels 1–3, the
instructor-set SpO₂ number is shown only when mechanical pulses are detected.
The signal quality does **not** randomly alter that number: it affects the
pleth morphology and the quality indicator only. The simulated pulse rate
remains derived from mechanically captured QRS complexes.
The degraded waveform uses deterministic, smoothly interpolated pseudo-noise
that scales only existing pleth pulses: it cannot manufacture pulses during
PEA, ventricular fibrillation or asystole. Unplugging a sensor or selecting
quality 0 hides even previously buffered pleth samples immediately. ECG and
ART continue unaffected. The **Show on monitor** checkbox still hides the
entire SpO₂ row; sensor/quality controls leave the row visible so the status
can be taught.
## ECG and mechanical coupling
- ECG rhythms: sinus, atrial fibrillation, monomorphic ventricular tachycardia,
@ -102,9 +140,31 @@ The five **Show on monitor** checkboxes affect the presentation only:
Remaining visible waveforms keep their relative order and receive an equal
share of the available area; zero waveform channels is supported.
## ECG morphology correction (v0.3.1)
At high heart rates, the previous ECG generator expressed QRS width as a fixed
fraction of the R–R interval and sampled at 100 Hz. Narrow R waves could fall
between samples, making successive QRS complexes appear to vary dramatically
in amplitude despite a regular sinus rhythm.
- Synthetic P/QRS/T components now have widths specified in milliseconds,
not fixed fractions of the cardiac cycle. P/T positioning and widths adapt
to the R–R interval, while the QRS width remains essentially constant.
- Sampling increased to **250 Hz** (4 ms intervals) to capture QRS peaks
more consistently, including at **189–240 bpm**.
- The ECG morphology remains independent of the respiratory arterial PPV
setting. The arterial and pleth delays and mechanical capture options are
unchanged.
- Regression tests compare peak heights at 60, 75, 120, 189 and 240 bpm,
and verify that changing PPV does not affect the ECG signal.
The ECG remains a schematic educational signal; no voltage calibration,
lead placement model, diagnostic criteria, or patient-specific physiology
are simulated.
## Signal implementation
- 100 Hz synthetic signal samples, 10 s retained history, 8 s scrolling trace.
- 250 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.
@ -139,3 +199,17 @@ src/
**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.
## Changes in v0.3.2
1. Added live patient-name header in Admin/Monitor with blank-name fallback.
2. Added four levels of SpO₂ signal quality, quality stars and an irregular,
low-amplitude pleth waveform for Poor quality.
3. Added **Sensor not attached** with `NO SENSOR` status and suppression of
saturation, pulse rate and pleth waveform.
4. Added tests for signal-quality scaling, displayed readings and disconnected
sensor behavior.
**Build verification:** ZIP integrity and patch application were checked.
The GTK4 application and Rust tests were not compiled in the packaging
environment; run `cargo test` and `cargo run --release` on Fedora.