EDF annotation texts not in UTF-8 (ISSSTELEÓN): legacy reads them as edf_convert does, modern retries latin1

This commit is contained in:
AlbertoPMDM
2026-11-19 04:09:48 -06:00
parent 6d0a99e6e5
commit fe36d5d859
5 changed files with 54 additions and 6 deletions
+17
View File
@@ -93,6 +93,23 @@ def test_no_posterior_channels_is_not_an_error(tmp_path):
assert not np.isfinite(t.posterior_rhythm_hz.iloc[0]), impl
def test_annotation_text_not_utf8_is_not_an_error(tmp_path):
"""ISSSTELEÓN: annotation texts written in a Windows code page (bytes invalid in UTF-8).
Legacy reads them as the director's edf_convert does (UTF-8 with replacement)."""
p = make_edf(tmp_path / "cp1252.edf", minutes=6, annotations=[(30.0, None, "ojos cerrXdos")])
b = Path(p).read_bytes()
assert b.count(b"cerrXdos") == 1
Path(p).write_bytes(b.replace(b"cerrXdos", b"cerr\x8cdos"))
for impl in ("legacy", "modern"):
t = Pipeline.default(impl=impl).map([p], plan=DIRECTOR_CLUSTER, ages_months=[24],
biomarkers=("posterior_rhythm",),
**({"cluster": "sync"} if impl == "modern" else {}))
assert t.error.iloc[0] == "", (impl, t.error.iloc[0])
from tea_modulo.legacy.preprocessing.api import _annotations
a = _annotations(p)
assert any(d.startswith("ojos cerr") for d in a.description)
def _inverse(x):
return 1 / x