2121import os
2222from pathlib import Path
2323import platform
24+ import warnings
2425from urllib .request import urlopen
2526
2627import numpy as np
@@ -121,7 +122,8 @@ def _parse_header(self):
121122 max_sig_length = 0
122123 self ._signals = {}
123124 sig_channels = []
124- for stream_id in signal_streams ["id" ]:
125+ well_indices_to_remove = []
126+ for stream_index , stream_id in enumerate (signal_streams ["id" ]):
125127 if int (version ) == 20160704 :
126128 sr = 20000.0
127129 settings = h5file ["settings" ]
@@ -152,7 +154,13 @@ def _parse_header(self):
152154 gain = settings ["gain" ][0 ]
153155 gain_uV = 3.3 / (1024 * gain ) * 1e6
154156 mapping = settings ["mapping" ]
155- sigs = h5file ["wells" ][stream_id ][self .rec_name ]["groups" ]["routed" ]["raw" ]
157+ if "routed" in h5file ["wells" ][stream_id ][self .rec_name ]["groups" ]:
158+ sigs = h5file ["wells" ][stream_id ][self .rec_name ]["groups" ]["routed" ]["raw" ]
159+ else :
160+ warnings .warn (f"No 'routed' group found for well { stream_id } " )
161+ well_indices_to_remove .append (stream_index )
162+ continue
163+
156164
157165 channel_ids = np .array (mapping ["channel" ])
158166 electrode_ids = np .array (mapping ["electrode" ])
@@ -172,6 +180,9 @@ def _parse_header(self):
172180
173181 self ._t_stop = max_sig_length / sr
174182
183+ if len (well_indices_to_remove ) > 0 :
184+ signal_streams = np .delete (signal_streams , np .array (well_indices_to_remove ))
185+
175186 sig_channels = np .array (sig_channels , dtype = _signal_channel_dtype )
176187
177188 spike_channels = []
0 commit comments