modern modules: no channels left to pick gives NaN / no events, not a ValueError (HK1K K7535V)

spindle_detection's wake rhythm called raw.get_data(picks=[]) when none of
O1 O2 P3 P4 survived preprocessing; MNE raises on an empty pick. Same guard
in spindle_detection, gradient, coupling and spindle_topography.
This commit is contained in:
AlbertoPMDM
2026-11-19 00:29:58 -06:00
parent 4e224a03cb
commit 624774bfd9
5 changed files with 22 additions and 5 deletions
+15
View File
@@ -5,6 +5,7 @@ from __future__ import annotations
import os
from pathlib import Path
import numpy as np
import pandas as pd
import pytest
@@ -78,6 +79,20 @@ def test_dask_sync_and_local_equal_legacy_loop(edfs):
cluster="local", n_workers=2, memory_per_worker="2GiB"), ref)
def test_no_posterior_channels_is_not_an_error(tmp_path):
"""HK1K K7535V: no O1 O2 P3 P4 left. Every module must give NaN / no events, not raise."""
from synth_edf import AUX, EARS
keep = [c for c in SCALP if c not in ("O1", "O2", "P3", "P4")] + list(EARS) + list(AUX)
p = make_edf(tmp_path / "noposterior.edf", minutes=6, channels=keep)
bios = tuple(Pipeline.default(impl="legacy").biomarker_names())
for impl in ("legacy", "modern"):
t = Pipeline.default(impl=impl).map([p], plan=DIRECTOR_CLUSTER, ages_months=[24], biomarkers=bios,
**({"cluster": "sync"} if impl == "modern" else {}))
assert t.error.iloc[0] == "", (impl, t.error.iloc[0])
assert t.valid.iloc[0] == 1, (impl, t.reasons.iloc[0])
assert not np.isfinite(t.posterior_rhythm_hz.iloc[0]), impl
def test_positive_priority_refused():
with pytest.raises(ValueError, match="positive priorities"):
dask_runner.run(lambda: 1, [()], cluster="sync", priority=1)