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
+6 -1
View File
@@ -55,7 +55,12 @@ class Preprocessing:
import mne
p = PreprocessPlan.from_dict(plan)
raw = mne.io.read_raw_edf(edf_path, preload=True, verbose="error")
try:
raw = mne.io.read_raw_edf(edf_path, preload=True, verbose="error")
except Exception as e: # annotation texts in a Windows code page
if "latin1" not in str(e):
raise
raw = mne.io.read_raw_edf(edf_path, preload=True, verbose="error", encoding="latin1")
ren, seen, drop = {}, set(), []
for c in raw.ch_names: # edf_convert: unknown dropped, first duplicate kept
n = _channels.normalize(c)