2121import os
2222from pathlib import Path
2323import platform
24+ import warnings
2425from urllib .request import urlopen
2526
2627import numpy as np
@@ -114,7 +115,8 @@ def _parse_header(self):
114115 max_sig_length = 0
115116 self ._signals = {}
116117 sig_channels = []
117- for stream_id in signal_streams ["id" ]:
118+ well_indices_to_remove = []
119+ for stream_index , stream_id in enumerate (signal_streams ["id" ]):
118120 if int (version ) == 20160704 :
119121 sr = 20000.0
120122 settings = h5file ["settings" ]
@@ -145,7 +147,13 @@ def _parse_header(self):
145147 gain = settings ["gain" ][0 ]
146148 gain_uV = 3.3 / (1024 * gain ) * 1e6
147149 mapping = settings ["mapping" ]
148- sigs = h5file ["wells" ][stream_id ][self .rec_name ]["groups" ]["routed" ]["raw" ]
150+ if "routed" in h5file ["wells" ][stream_id ][self .rec_name ]["groups" ]:
151+ sigs = h5file ["wells" ][stream_id ][self .rec_name ]["groups" ]["routed" ]["raw" ]
152+ else :
153+ warnings .warn (f"No 'routed' group found for well { stream_id } " )
154+ well_indices_to_remove .append (stream_index )
155+ continue
156+
149157
150158 channel_ids = np .array (mapping ["channel" ])
151159 electrode_ids = np .array (mapping ["electrode" ])
@@ -164,6 +172,9 @@ def _parse_header(self):
164172
165173 self ._t_stop = max_sig_length / sr
166174
175+ if len (well_indices_to_remove ) > 0 :
176+ signal_streams = np .delete (signal_streams , np .array (well_indices_to_remove ))
177+
167178 sig_channels = np .array (sig_channels , dtype = _signal_channel_dtype )
168179
169180 spike_channels = []
0 commit comments