v0.5.5: try to fix tests
This commit is contained in:
parent
483a3c3d61
commit
8225ac8e70
7 changed files with 140 additions and 13 deletions
65
patient-monitor-simulation-v0.5.4-to-v0.5.5.patch
Normal file
65
patient-monitor-simulation-v0.5.4-to-v0.5.5.patch
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
--- a/Cargo.toml
|
||||
+++ b/Cargo.toml
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "patient-monitor-simulation"
|
||||
-version = "0.5.4"
|
||||
+version = "0.5.5"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
description = "Synthetic patient-monitor simulation for teaching (not for clinical use)"
|
||||
--- a/README.md
|
||||
+++ b/README.md
|
||||
@@ -490,3 +490,8 @@
|
||||
- Distinct critical-rhythm and standard/technical patterns; critical priority.
|
||||
- Audio keeps running independently of the monitor's drawing callback.
|
||||
- Visual alarms and existing physiological simulation remain unchanged.
|
||||
+
|
||||
+
|
||||
+### v0.5.5 — CPR plethysmography correction
|
||||
+
|
||||
+The delayed CPR pleth waveform no longer wraps its trailing portion into the next compression. The regression test now reports the maximum valid waveform amplitude when failing. No other simulation controls were changed.
|
||||
--- a/README.de.md
|
||||
+++ b/README.de.md
|
||||
@@ -469,3 +469,8 @@
|
||||
technische Alarme; kritische Alarme haben Vorrang.
|
||||
- Die Audioausgabe ist von der Kurvendarstellung entkoppelt.
|
||||
- Bisherige optische Alarme und Simulationsfunktionen bleiben unverändert.
|
||||
+
|
||||
+
|
||||
+### v0.5.5 – Korrektur der CPR-Plethysmographie
|
||||
+
|
||||
+Die verzögerte Plethysmographiekurve bei Thoraxkompressionen überlappt nicht mehr mit der nächsten Kompression. Der Regressionstest gibt bei einem Fehlschlag die maximale gültige Kurvenamplitude aus. Sonstige Simulationseinstellungen bleiben unverändert.
|
||||
--- a/src/simulation.rs
|
||||
+++ b/src/simulation.rs
|
||||
@@ -154,9 +154,12 @@
|
||||
}
|
||||
|
||||
fn pleth_wave(&self) -> f64 {
|
||||
- // A delayed, deliberately weak mechanical pleth pulse.
|
||||
- let phase = (self.phase - 0.26).rem_euclid(1.0);
|
||||
- smooth_step(phase / 0.27) * (1.0 - smooth_step((phase - 0.27) / 0.62))
|
||||
+ // A delayed, low-amplitude pulse for effective CPR. Using a bounded
|
||||
+ // within-compression phase instead of wrapping the delay prevents
|
||||
+ // a pulse's trailing portion leaking into the *next* compression.
|
||||
+ let phase = self.phase - 0.25;
|
||||
+ if phase <= 0.0 { return 0.0; }
|
||||
+ smooth_step(phase / 0.22) * (1.0 - smooth_step((phase - 0.35) / 0.35))
|
||||
}
|
||||
|
||||
fn ecg_artifact(&self, time: f64) -> f64 {
|
||||
@@ -751,8 +754,12 @@
|
||||
assert_eq!(sim.spo2_quality(&p), Spo2Quality::Poor);
|
||||
assert_eq!(sim.spo2_status(&p), Spo2Status::Available);
|
||||
assert!(sim.spo2_pulse_rate(&p).is_some_and(|v| (90..=110).contains(&v)));
|
||||
- assert!(sim.samples.iter().rev().take(400).any(|s| s.pleth > 0.05 && s.pleth_valid));
|
||||
- assert!(sim.samples.iter().rev().take(400).all(|s| s.pleth_quality == Spo2Quality::Poor));
|
||||
+ let recent: Vec<_> = sim.samples.iter().rev().take(400).collect();
|
||||
+ let max_valid_pleth = recent.iter().filter(|s| s.pleth_valid)
|
||||
+ .map(|s| s.pleth).fold(0.0_f64, f64::max);
|
||||
+ assert!(max_valid_pleth > 0.05,
|
||||
+ "good CPR in VF must generate valid pleth pulses; max valid amplitude={max_valid_pleth:.4}");
|
||||
+ assert!(recent.iter().all(|s| s.pleth_quality == Spo2Quality::Poor));
|
||||
}
|
||||
|
||||
#[test]
|
||||
2
patient-monitor-simulation/Cargo.lock
generated
2
patient-monitor-simulation/Cargo.lock
generated
|
|
@ -438,7 +438,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "patient-monitor-simulation"
|
||||
version = "0.5.4"
|
||||
version = "0.5.5"
|
||||
dependencies = [
|
||||
"gtk4",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "patient-monitor-simulation"
|
||||
version = "0.5.4"
|
||||
version = "0.5.5"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
description = "Synthetic patient-monitor simulation for teaching (not for clinical use)"
|
||||
|
|
|
|||
|
|
@ -6,6 +6,53 @@ Ein mit Rust und GTK4 entwickelter Patient*innenmonitor-Simulator mit zwei Fenst
|
|||
> EKG, invasive arterielle Druckkurve, Plethysmogramm und Kapnogramm sind schematische mathematische Annäherungen.
|
||||
> Die Simulation wurde nicht klinisch validiert und ist kein Medizinprodukt.
|
||||
|
||||
## Thoraxkompressionen (v0.5.4)
|
||||
|
||||
Im Admin-Bereich **Chest compressions** startet die grüne Schaltfläche
|
||||
**Start Chest Compressions** die Simulation. Während aktiver Kompressionen
|
||||
wechselt sie zu **Stop Chest Compressions** mit rotem Hintergrund.
|
||||
Die **Compression quality** kann jederzeit auf **Good**, **Adequate**
|
||||
(Standard), **Poor** oder **Bad** gestellt werden.
|
||||
|
||||
- Die Kompressionsfrequenz schwankt zufällig im Bereich **90–110/min**;
|
||||
für jeden Druckstoß werden Frequenz und Druckhöhe neu festgelegt.
|
||||
Der eingestellte EKG-Rhythmus und die elektrische Herzfrequenz bleiben
|
||||
unverändert.
|
||||
- Das EKG wird durch kompressionssynchrone Bewegungsartefakte überlagert.
|
||||
Besteht ein **eigener arterieller Kreislauf**, bleibt die ursprüngliche
|
||||
Druckkurve bestehen, wird jedoch durch Kompressionen verzerrt.
|
||||
- **Ohne eigenständige arterielle Pulsation** (beispielsweise bei KF, PVT,
|
||||
Asystolie oder PEA) erzeugen wirksame Kompressionen breite, stumpfe
|
||||
arterielle Druckwellen:
|
||||
|
||||
| Kompressionsqualität | Systolischer ART-Spitzendruck |
|
||||
| --- | --- |
|
||||
| Good | 90 mmHg ±10 % (81–99 mmHg) |
|
||||
| Adequate (Standard) | 70 mmHg ±10 % (63–77 mmHg) |
|
||||
| Poor | 50 mmHg, +10 % / −50 % (25–55 mmHg) |
|
||||
| Bad | Kein durch Kompressionen erzeugter Druck; Grundschwankung von 0–5 mmHg |
|
||||
|
||||
Bei fehlender Eigenpulsation zeigt **ART SYS** den Spitzendruck der
|
||||
aktuellen Kompression; **DIA/MAP** bleiben `--`, da sie aus der synthetischen
|
||||
Kurve nicht verlässlich bestimmt werden.
|
||||
- Ein SpO₂-Messwert und ein Plethysmogramm werden während laufender
|
||||
Kompressionen **nur bei Qualität Good** angezeigt, vorausgesetzt, der Sensor
|
||||
ist angeschlossen und nicht durch eine NIBP-Manschette okkludiert.
|
||||
Die angezeigte Signalqualität beträgt unabhängig von der Grundeinstellung
|
||||
**Poor (★)**. Die angezeigte **PR folgt der Kompressionsfrequenz (90–110/min)**,
|
||||
nicht der EKG-Frequenz. Bei Adequate, Poor oder Bad erscheint **NO READING**,
|
||||
bei abgezogenem Sensor **NO SENSOR**. Die durch Kompressionen erzwungene
|
||||
Signalqualität Poor führt nicht zu den sonst üblichen periodischen
|
||||
Aussetzern; bei regulärer Grundeinstellung Poor gelten diese nach Ende
|
||||
der Kompressionen wieder.
|
||||
- Die bestehenden Rhythmus- und Grenzwertalarme bleiben aktiv. ART-SYS-Grenzen
|
||||
beziehen sich dabei auf die Kompressionsspitzen. Die NIBP-Messintervalle bleiben unverändert; die Dauer eines Messzyklus
|
||||
richtet sich weiterhin nach der wirksamen SpO₂-Signalqualität beim Start.
|
||||
|
||||
**Hinweis:** Druckwerte und Signalformen sind didaktisch gewählt und nicht
|
||||
klinisch validiert. Aus dieser Simulation darf keine reale Wirksamkeit von
|
||||
Reanimationsmaßnahmen abgeleitet werden.
|
||||
|
||||
## Installation, Kompilierung und Start unter Fedora
|
||||
|
||||
```bash
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
--- README.de.md
|
||||
+++ README.de.md
|
||||
@@ -1,4 +1,4 @@
|
||||
-# Patient Monitor Simulation (PaMSim) — v0.5.3
|
||||
+# Patient Monitor Simulation (PaMSim) — v0.5.4
|
||||
|
||||
Ein mit Rust und GTK4 entwickelter Patient*innenmonitor-Simulator mit zwei Fenstern für die Lehre unter Fedora Linux.
|
||||
|
||||
@@ -469,3 +469,8 @@
|
||||
technische Alarme; kritische Alarme haben Vorrang.
|
||||
- Die Audioausgabe ist von der Kurvendarstellung entkoppelt.
|
||||
- Bisherige optische Alarme und Simulationsfunktionen bleiben unverändert.
|
||||
+
|
||||
+
|
||||
+### v0.5.5 – Korrektur der CPR-Plethysmographie
|
||||
+
|
||||
+Die verzögerte Plethysmographiekurve bei Thoraxkompressionen überlappt nicht mehr mit der nächsten Kompression. Der Regressionstest gibt bei einem Fehlschlag die maximale gültige Kurvenamplitude aus. Sonstige Simulationseinstellungen bleiben unverändert.
|
||||
|
|
|
|||
|
|
@ -490,3 +490,8 @@ No NIBP measurement logic or alarm behavior was changed.
|
|||
- Distinct critical-rhythm and standard/technical patterns; critical priority.
|
||||
- Audio keeps running independently of the monitor's drawing callback.
|
||||
- Visual alarms and existing physiological simulation remain unchanged.
|
||||
|
||||
|
||||
### v0.5.5 — CPR plethysmography correction
|
||||
|
||||
The delayed CPR pleth waveform no longer wraps its trailing portion into the next compression. The regression test now reports the maximum valid waveform amplitude when failing. No other simulation controls were changed.
|
||||
|
|
|
|||
|
|
@ -154,9 +154,12 @@ impl ChestCompressions {
|
|||
}
|
||||
|
||||
fn pleth_wave(&self) -> f64 {
|
||||
// A delayed, deliberately weak mechanical pleth pulse.
|
||||
let phase = (self.phase - 0.26).rem_euclid(1.0);
|
||||
smooth_step(phase / 0.27) * (1.0 - smooth_step((phase - 0.27) / 0.62))
|
||||
// A delayed, low-amplitude pulse for effective CPR. Using a bounded
|
||||
// within-compression phase instead of wrapping the delay prevents
|
||||
// a pulse's trailing portion leaking into the *next* compression.
|
||||
let phase = self.phase - 0.25;
|
||||
if phase <= 0.0 { return 0.0; }
|
||||
smooth_step(phase / 0.22) * (1.0 - smooth_step((phase - 0.35) / 0.35))
|
||||
}
|
||||
|
||||
fn ecg_artifact(&self, time: f64) -> f64 {
|
||||
|
|
@ -751,8 +754,12 @@ mod tests {
|
|||
assert_eq!(sim.spo2_quality(&p), Spo2Quality::Poor);
|
||||
assert_eq!(sim.spo2_status(&p), Spo2Status::Available);
|
||||
assert!(sim.spo2_pulse_rate(&p).is_some_and(|v| (90..=110).contains(&v)));
|
||||
assert!(sim.samples.iter().rev().take(400).any(|s| s.pleth > 0.05 && s.pleth_valid));
|
||||
assert!(sim.samples.iter().rev().take(400).all(|s| s.pleth_quality == Spo2Quality::Poor));
|
||||
let recent: Vec<_> = sim.samples.iter().rev().take(400).collect();
|
||||
let max_valid_pleth = recent.iter().filter(|s| s.pleth_valid)
|
||||
.map(|s| s.pleth).fold(0.0_f64, f64::max);
|
||||
assert!(max_valid_pleth > 0.05,
|
||||
"good CPR in VF must generate valid pleth pulses; max valid amplitude={max_valid_pleth:.4}");
|
||||
assert!(recent.iter().all(|s| s.pleth_quality == Spo2Quality::Poor));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue