Spaces:
Sleeping
Sleeping
File size: 1,226 Bytes
5d0ad1b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import numpy as np
import random
def run_inference(ecg_signal: np.ndarray) -> dict:
"""
Simuliert eine DeepECG-Inferenz für ein EKG-Signal (Dummy-Implementierung).
Parameter:
- ecg_signal: numpy array der Form (12, N)
Gibt zurück:
- dict mit Top-Diagnosen, Risiko-Score und Interpretation
"""
diagnoses = [
"Normaler Sinusrhythmus",
"Vorhofflimmern",
"Rechtsschenkelblock",
"Linksschenkelblock",
"ST-Hebung"
]
random.shuffle(diagnoses)
top_diagnoses = [
{"label": diagnoses[0], "probability": random.randint(65, 90)},
{"label": diagnoses[1], "probability": random.randint(30, 60)},
{"label": diagnoses[2], "probability": random.randint(10, 30)}
]
risk_score = top_diagnoses[0]["probability"]
if risk_score < 40:
interpretation = "Unauffälliger Befund"
elif risk_score < 70:
interpretation = "Auffälliger Befund – weitere Abklärung empfohlen"
else:
interpretation = "Hochgradig auffälliger Befund – dringende Abklärung"
return {
"top_diagnoses": top_diagnoses,
"risk_score": risk_score,
"interpretation": interpretation
}
|