window_selection and spikes, legacy and modern
- legacy: seleccion.seleccionar and candidatos_punta.de_estudio + indicadores vendored unchanged, run on the contract adapter with the sleep_state labels as the vigilancia table. - modern: the director's detector functions copied by name into _detector.py with three substitutions (MNE band-pass, channel lists from the study, a private port of the seleccion gate); a modern window_selection on the same port. - synthetic builder: optional focal spike-and-wave (the director's own _punta shape) with a field on the neighbours. Modern equals legacy exactly on window verdicts and spike indicators; the C3 focus is found; contract suites pass.
This commit is contained in:
@@ -154,6 +154,18 @@ def make_signals(*, fs=250.0, minutes=6.0, states=None, rhythm_hz=7.0, line_hz=6
|
||||
|
||||
def _apply_faults(data, bad, rng, fs):
|
||||
n = len(next(iter(data.values())))
|
||||
for ch in bad.get("spikes", []): # focal spike-and-wave every ~3 s with a field
|
||||
# the director's own synthetic spike (candidatos_punta._punta): 50 ms, then a slow wave
|
||||
m = int(0.05 * fs)
|
||||
t = np.linspace(-1, 1, max(m, 3))
|
||||
shape = np.concatenate([250 * (1 - t ** 2) ** 2,
|
||||
-100 * np.sin(np.pi * np.linspace(0, 1, int(0.3 * fs)))])
|
||||
nb = {"C3": ("F3", "T3", "Cz", "P3"), "C4": ("F4", "T4", "Cz", "P4")}.get(ch, ())
|
||||
for c in np.arange(3.0, n / fs - 2, 3.1):
|
||||
i0 = int(c * fs)
|
||||
data[ch][i0:i0 + len(shape)] += shape
|
||||
for v in nb:
|
||||
data[v][i0:i0 + len(shape)] += 0.6 * shape
|
||||
for ch in bad.get("flat", []):
|
||||
data[ch] = np.zeros(n) + rng.normal(0, 0.05, n)
|
||||
for ch in bad.get("frozen", []):
|
||||
|
||||
Reference in New Issue
Block a user