Skip to content

Commit 4645a70

Browse files
committed
Fix unit tests
1 parent 9b15b42 commit 4645a70

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

mne/io/nihon/nihon.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def _read_nihon_header(fname):
280280
"Cannot read NK file with different sfreq in each datablock"
281281
)
282282

283-
return header
283+
return header, _chan_labels
284284

285285

286286
def _read_event_log_block(fid, t_block, version):
@@ -380,13 +380,13 @@ def _map_ch_to_type(ch_name):
380380
return "eeg"
381381

382382

383-
def _map_ch_to_specs(ch_name, ch_names_upper):
383+
def _map_ch_to_specs(ch_name, chan_labels_upper):
384384
unit_mult = 1e-3
385385
phys_min = -12002.9
386386
phys_max = 12002.56
387387
dig_min = -32768
388-
if ch_name.upper() in ch_names_upper:
389-
idx = ch_names_upper.index(ch_name.upper())
388+
if ch_name.upper() in chan_labels_upper:
389+
idx = chan_labels_upper.index(ch_name.upper())
390390
if (idx < 42 or idx > 73) and idx not in [76, 77]:
391391
unit_mult = 1e-6
392392
phys_min = -3200
@@ -432,7 +432,9 @@ def __init__(self, fname, preload=False, *, encoding="utf-8", verbose=None):
432432
data_name = fname.name
433433
logger.info(f"Loading {data_name}")
434434

435-
header = _read_nihon_header(fname)
435+
# chan_labels contains the electrode codes defined
436+
# in the .21E file. It is not the same as header["ch_names"].
437+
header, chan_labels = _read_nihon_header(fname)
436438
metadata = _read_nihon_metadata(fname)
437439

438440
# n_chan = len(header['ch_names']) + 1
@@ -448,8 +450,8 @@ def __init__(self, fname, preload=False, *, encoding="utf-8", verbose=None):
448450
with info._unlock():
449451
info["meas_date"] = metadata["meas_date"]
450452

451-
ch_names_upper = [x.upper() for x in info["ch_names"]]
452-
chs = {x: _map_ch_to_specs(x, ch_names_upper) for x in info["ch_names"]}
453+
chan_labels_upper = [x.upper() for x in chan_labels]
454+
chs = {x: _map_ch_to_specs(x, chan_labels_upper) for x in info["ch_names"]}
453455
cal = np.array([chs[x]["cal"] for x in info["ch_names"]], float)[:, np.newaxis]
454456
offsets = np.array([chs[x]["offset"] for x in info["ch_names"]], float)[
455457
:, np.newaxis

mne/io/nihon/tests/test_nihon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_nihon_eeg():
4848
raw = read_raw_nihon(fname_edf, preload=True)
4949

5050
with pytest.raises(ValueError, match="Not a valid Nihon Kohden EEG file"):
51-
raw = _read_nihon_header(fname_edf)
51+
header, _ = _read_nihon_header(fname_edf)
5252

5353
bad_fname = data_path / "eximia" / "text_eximia.nxe"
5454

0 commit comments

Comments
 (0)