@@ -81,14 +81,18 @@ def _source_name(self):
8181 return self .filename
8282
8383 def _produce_ephys_channel_ids (self , n_total_channels , n_channels_per_chip ):
84- """Compute the channel ID labels
84+ """Compute the channel ID labels for subset of spikegadgets recordings
8585 The ephys channels in the .rec file are stored in the following order:
8686 hwChan ID of channel 0 of first chip, hwChan ID of channel 0 of second chip, ..., hwChan ID of channel 0 of Nth chip,
8787 hwChan ID of channel 1 of first chip, hwChan ID of channel 1 of second chip, ..., hwChan ID of channel 1 of Nth chip,
8888 ...
8989 So if there are 32 channels per chip and 128 channels (4 chips), then the channel IDs are:
9090 0, 32, 64, 96, 1, 33, 65, 97, ..., 128
9191 See also: https://github.com/NeuralEnsemble/python-neo/issues/1215
92+
93+ This doesn't work for all types of spikegadgets
94+ see: https://github.com/NeuralEnsemble/python-neo/issues/1517
95+
9296 """
9397 ephys_channel_ids_list = []
9498 for hw_channel in range (n_channels_per_chip ):
@@ -120,6 +124,8 @@ def _parse_header(self):
120124 hconf = root .find ("HardwareConfiguration" )
121125 sconf = root .find ("SpikeConfiguration" )
122126
127+ # store trode version in case there are version changes in the future
128+ self ._trode_version = gconf ["trodesVersion" ]
123129 self ._sampling_rate = float (hconf .attrib ["samplingRate" ])
124130 num_ephy_channels = int (hconf .attrib ["numChannels" ])
125131
@@ -129,9 +135,11 @@ def _parse_header(self):
129135 num_ephy_channels = sconf_channels
130136 if sconf_channels > num_ephy_channels :
131137 raise NeoReadWriteError (
132- "SpikeGadgets: the number of channels in the spike configuration is larger than the number of channels in the hardware configuration"
138+ "SpikeGadgets: the number of channels in the spike configuration is larger "
139+ "than the number of channels in the hardware configuration"
133140 )
134141
142+ # as spikegadgets change we should follow this
135143 try :
136144 num_chan_per_chip = int (sconf .attrib ["chanPerChip" ])
137145 except KeyError :
@@ -207,9 +215,9 @@ def _parse_header(self):
207215 signal_streams .append ((stream_name , stream_id ))
208216 self ._mask_channels_bytes [stream_id ] = []
209217
210- # we can only produce these channels for a subset of spikegadgets setup. If this criteria isn't
218+ # we can only produce these channels for a subset of spikegadgets setup. If this criteria isn't
211219 # true then we should just use the raw_channel_ids and let the end user sort everything out
212- if num_ephy_channels % num_chan_per_chip == 0 :
220+ if num_ephy_channels % num_chan_per_chip == 0 :
213221 channel_ids = self ._produce_ephys_channel_ids (num_ephy_channels , num_chan_per_chip )
214222 raw_channel_ids = False
215223 else :
@@ -231,6 +239,8 @@ def _parse_header(self):
231239 units = ""
232240
233241 for schan in trode :
242+ # Here we use raw ids if necessary for parsing (for some neuropixel recordings)
243+ # otherwise we default back to the raw hwChan IDs
234244 if raw_channel_ids :
235245 name = "trode" + trode .attrib ["id" ] + "chan" + schan .attrib ["hwChan" ]
236246 chan_id = schan .attrib ["hwChan" ]
@@ -261,7 +271,7 @@ def _parse_header(self):
261271 signal_streams = np .array (signal_streams , dtype = _signal_stream_dtype )
262272 signal_channels = np .array (signal_channels , dtype = _signal_channel_dtype )
263273
264- # remove some stream if no wanted
274+ # remove some stream if not wanted
265275 if self .selected_streams is not None :
266276 if isinstance (self .selected_streams , str ):
267277 self .selected_streams = [self .selected_streams ]
0 commit comments