@@ -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
286286def _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
0 commit comments