Skip to content

Commit f1a32bc

Browse files
committed
fix missing keys when parsing channel group info in read_tbk
1 parent f401627 commit f1a32bc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

neo/rawio/tdtrawio.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,16 @@ def read_tbk(tbk_filename):
557557
infos.append(info)
558558

559559
# and put into numpy
560+
tbk_field_names = [tbk_field_type[0] for tbk_field_type in tbk_field_types]
560561
info_channel_groups = np.zeros(len(infos), dtype=tbk_field_types)
561562
for i, info in enumerate(infos):
563+
missing_keys = set(tbk_field_names) - set(info.keys())
564+
if missing_keys:
565+
warnings.warn(
566+
f"Could not find all channel group info in tbk file, the missing keys are {missing_keys}.\n"
567+
"The reader will continue with channel groups that could be parsed."
568+
)
569+
continue
562570
for k, dt in tbk_field_types:
563571
v = np.dtype(dt).type(info[k])
564572
info_channel_groups[i][k] = v

0 commit comments

Comments
 (0)