Spaces:
Sleeping
Sleeping
| 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 | |
| } | |