Merge parity/F2b-web
This commit is contained in:
+32
-20
@@ -70,14 +70,14 @@ def _filtered(x, fs, mains_hz, lo, hi):
|
|||||||
def _temporal(v: np.ndarray) -> list[tuple[str, str]]:
|
def _temporal(v: np.ndarray) -> list[tuple[str, str]]:
|
||||||
finite = v[np.isfinite(v)]
|
finite = v[np.isfinite(v)]
|
||||||
if len(finite) < 10 or np.std(finite) < 0.5:
|
if len(finite) < 10 or np.std(finite) < 0.5:
|
||||||
return [("dead-channel", "dead channel")]
|
return [("dead-channel", "Canal muerto")]
|
||||||
out = []
|
out = []
|
||||||
if np.mean(np.abs(np.diff(finite)) < 1e-9) > 0.5:
|
if np.mean(np.abs(np.diff(finite)) < 1e-9) > 0.5:
|
||||||
out.append(("frozen", "frozen"))
|
out.append(("frozen", "Señal congelada"))
|
||||||
if np.mean(np.abs(finite) > 0.98 * np.max(np.abs(finite))) > 0.001:
|
if np.mean(np.abs(finite) > 0.98 * np.max(np.abs(finite))) > 0.001:
|
||||||
out.append(("saturated", "saturated"))
|
out.append(("saturated", "Señal saturada"))
|
||||||
if np.isinf(v).any():
|
if np.isinf(v).any():
|
||||||
out.append(("inf-values", "Inf values"))
|
out.append(("inf-values", "Valores infinitos"))
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
@@ -140,9 +140,7 @@ def _ears(y: np.ndarray, fs: float, names: list[str]) -> dict[str, tuple[float,
|
|||||||
def bad_channels(rec: Recording, mains_hz: float) -> dict[str, list[tuple[str, str]]]:
|
def bad_channels(rec: Recording, mains_hz: float) -> dict[str, list[tuple[str, str]]]:
|
||||||
x, fs, names, kinds = rec.x, rec.fs, list(rec.names), rec.kinds()
|
x, fs, names, kinds = rec.x, rec.fs, list(rec.names), rec.kinds()
|
||||||
reasons = {name: _temporal(x[:, i]) for i, name in enumerate(names)}
|
reasons = {name: _temporal(x[:, i]) for i, name in enumerate(names)}
|
||||||
dead = {
|
dead = {name for name, found in reasons.items() if found and found[0][0] == "dead-channel"}
|
||||||
name for name, found in reasons.items() if found[:1] == [("dead-channel", "dead channel")]
|
|
||||||
}
|
|
||||||
notched = signals.notch(x, fs, mains_hz)
|
notched = signals.notch(x, fs, mains_hz)
|
||||||
y45 = signals.bandpass(notched, fs, 0.5, min(45.0, fs / 2 * 0.9))
|
y45 = signals.bandpass(notched, fs, 0.5, min(45.0, fs / 2 * 0.9))
|
||||||
y40 = signals.bandpass(notched, fs, 1.0, 40.0)
|
y40 = signals.bandpass(notched, fs, 1.0, 40.0)
|
||||||
@@ -158,34 +156,38 @@ def bad_channels(rec: Recording, mains_hz: float) -> dict[str, list[tuple[str, s
|
|||||||
found, k = reasons[name], kinds[name]
|
found, k = reasons[name], kinds[name]
|
||||||
if missing[i] > missing.min() + 0.02:
|
if missing[i] > missing.min() + 0.02:
|
||||||
excess = 100 * (missing[i] - missing.min())
|
excess = 100 * (missing[i] - missing.min())
|
||||||
found.append(("own-gaps", f"own gaps ({excess:.1f}% more than the rest)"))
|
found.append(
|
||||||
|
("own-gaps", f"Interrupciones del canal ({excess:.1f} % más que el resto)")
|
||||||
|
)
|
||||||
if name in dead:
|
if name in dead:
|
||||||
continue
|
continue
|
||||||
if k == "eeg" and name in bridges:
|
if k == "eeg" and name in bridges:
|
||||||
found.append(("bridge", f"bridge with {bridges[name]}"))
|
found.append(("bridge", f"Puente con {bridges[name]}"))
|
||||||
if k in ("eeg", "ear") and np.isfinite(ratio[i]) and ratio[i] > 4.0:
|
if k in ("eeg", "ear") and np.isfinite(ratio[i]) and ratio[i] > 4.0:
|
||||||
found.append(("amplitude", f"amplitude {ratio[i]:.1f} x the scalp median"))
|
found.append(
|
||||||
|
("amplitude", f"Amplitud {ratio[i]:.1f} veces la mediana del cuero cabelludo")
|
||||||
|
)
|
||||||
if name in ears and ears[name][1] > 0.2 and ears[name][0] < 0.5 * ears[name][1]:
|
if name in ears and ears[name][1] > 0.2 and ears[name][0] < 0.5 * ears[name][1]:
|
||||||
c, e = ears[name]
|
c, e = ears[name]
|
||||||
found.append(
|
found.append(
|
||||||
(
|
(
|
||||||
"does-not-correlate",
|
"does-not-correlate",
|
||||||
f"does not correlate with its neighbours ({c:.2f} vs {e:.2f})",
|
f"Sin correlación con los vecinos ({c:.2f} frente a {e:.2f})",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if np.isfinite(low[i]) and low[i] > 0.10:
|
if np.isfinite(low[i]) and low[i] > 0.10:
|
||||||
found.append(
|
found.append(
|
||||||
(
|
(
|
||||||
"intermittent-contact",
|
"intermittent-contact",
|
||||||
f"intermittent contact ({100 * low[i]:.0f}% of blocks silent)",
|
f"Contacto intermitente ({100 * low[i]:.0f} % de bloques sin señal)",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if k in ("eeg", "ear") and np.isfinite(burst[i]) and burst[i] > 0.05:
|
if k in ("eeg", "ear") and np.isfinite(burst[i]) and burst[i] > 0.05:
|
||||||
found.append(
|
found.append(
|
||||||
(
|
(
|
||||||
"intermittent-bursts",
|
"intermittent-bursts",
|
||||||
f"intermittent contact by bursts "
|
f"Contacto intermitente por ráfagas "
|
||||||
f"({100 * burst[i]:.0f}% of blocks above 4 x the montage)",
|
f"({100 * burst[i]:.0f} % de bloques por encima de 4 veces el montaje)",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if k in ("eog", "ecg"):
|
if k in ("eog", "ecg"):
|
||||||
@@ -194,8 +196,8 @@ def bad_channels(rec: Recording, mains_hz: float) -> dict[str, list[tuple[str, s
|
|||||||
found.append(
|
found.append(
|
||||||
(
|
(
|
||||||
"aux-amplitude",
|
"aux-amplitude",
|
||||||
f"amplitude {np.sqrt(np.mean(v**2)):.0f} uV, "
|
f"Amplitud {np.sqrt(np.mean(v**2)):.0f} µV, "
|
||||||
f"out of range even for {k.upper()}",
|
f"fuera de rango incluso para {k.upper()}",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return {name: found for name, found in reasons.items() if found}
|
return {name: found for name, found in reasons.items() if found}
|
||||||
@@ -286,7 +288,7 @@ def validate(rec: Recording, mains_hz: float) -> Validation:
|
|||||||
check(
|
check(
|
||||||
"internal-coverage",
|
"internal-coverage",
|
||||||
value=coverage,
|
value=coverage,
|
||||||
unit="fraction",
|
unit="fracción",
|
||||||
low=MIN_COVERAGE,
|
low=MIN_COVERAGE,
|
||||||
abnormal=coverage < MIN_COVERAGE,
|
abnormal=coverage < MIN_COVERAGE,
|
||||||
decisive=True,
|
decisive=True,
|
||||||
@@ -294,7 +296,7 @@ def validate(rec: Recording, mains_hz: float) -> Validation:
|
|||||||
check(
|
check(
|
||||||
"bad-scalp-triage",
|
"bad-scalp-triage",
|
||||||
value=float(len(triaged)),
|
value=float(len(triaged)),
|
||||||
unit="electrodes",
|
unit="electrodos",
|
||||||
high=float(MAX_BAD_SCALP),
|
high=float(MAX_BAD_SCALP),
|
||||||
abnormal=len(triaged) > MAX_BAD_SCALP,
|
abnormal=len(triaged) > MAX_BAD_SCALP,
|
||||||
decisive=True,
|
decisive=True,
|
||||||
@@ -302,12 +304,22 @@ def validate(rec: Recording, mains_hz: float) -> Validation:
|
|||||||
check(
|
check(
|
||||||
"usable-scalp",
|
"usable-scalp",
|
||||||
value=float(len(usable)),
|
value=float(len(usable)),
|
||||||
unit="electrodes",
|
unit="electrodos",
|
||||||
low=float(MIN_SCALP),
|
low=float(MIN_SCALP),
|
||||||
abnormal=len(usable) < MIN_SCALP,
|
abnormal=len(usable) < MIN_SCALP,
|
||||||
decisive=True,
|
decisive=True,
|
||||||
),
|
),
|
||||||
check("triage-level", text=level, abnormal=level == NOT_ANALYZABLE, decisive=True),
|
check(
|
||||||
|
"triage-level",
|
||||||
|
text={
|
||||||
|
NOT_ANALYZABLE: "No analizable",
|
||||||
|
"partial": "Parcial",
|
||||||
|
"no_ear_reference": "Sin referencia auricular",
|
||||||
|
"complete": "Completo",
|
||||||
|
}[level],
|
||||||
|
abnormal=level == NOT_ANALYZABLE,
|
||||||
|
decisive=True,
|
||||||
|
),
|
||||||
]
|
]
|
||||||
if np.isfinite(line):
|
if np.isfinite(line):
|
||||||
rows.append(
|
rows.append(
|
||||||
|
|||||||
Reference in New Issue
Block a user