Skip to content

Commit 0023e51

Browse files
authored
Merge pull request #1447 from catalystneuro/fix_missing_channel_group_keys_in_tdtrawio
Fix reading TDT files where Tbk header contains incomplete channel group info
2 parents 883b29a + dee9e12 commit 0023e51

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"The tbk file contains incomplete channel group info for group {list(info.items())}. "
567+
"This channel group will be skipped."
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)