Skip to content

Commit b87b8f2

Browse files
authored
BlackrockRawIO: Fix int overflow (#1669)
* fix another overflow * fix my own typos... * more overflow fun
1 parent 060d73a commit b87b8f2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

neo/rawio/blackrockrawio.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,19 @@ def _parse_header(self):
276276
self.internal_unit_ids = [] # pair of chan['packet_id'], spikes['unit_class_nb']
277277
for i in range(len(self.__nev_ext_header[b"NEUEVWAV"])):
278278

279-
channel_id = self.__nev_ext_header[b"NEUEVWAV"]["electrode_id"][i]
279+
# electrode_id values are stored at uint16 which can overflow when
280+
# multiplying by 1000 below. We convert to a regular python int which
281+
# won't overflow
282+
channel_id = int(self.__nev_ext_header[b"NEUEVWAV"]["electrode_id"][i])
280283

281284
chan_mask = spikes["packet_id"] == channel_id
282285
chan_spikes = spikes[chan_mask]
286+
287+
# all `unit_class_nb` is uint8. Also will have issues with overflow
288+
# cast this to python int
283289
all_unit_id = np.unique(chan_spikes["unit_class_nb"])
284290
for u, unit_id in enumerate(all_unit_id):
291+
unit_id = int(unit_id)
285292
self.internal_unit_ids.append((channel_id, unit_id))
286293
name = f"ch{channel_id}#{unit_id}"
287294
_id = f"Unit {1000 * channel_id + unit_id}"

0 commit comments

Comments
 (0)