Skip to content

Commit 53ea68e

Browse files
committed
another comment
1 parent 45bb253 commit 53ea68e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

neo/rawio/blackrockrawio.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ def _read_nev_data(self, spec, filename):
12631263
)
12641264

12651265
# Get packet identifiers and types directly from spec-based dictionaries
1266-
packet_identifiers = NEV_PACKET_IDENTIFIERS[spec]
1266+
packet_identifiers = NEV_PACKET_IDENTIFIERS_BY_SPEC[spec]
12671267
data_types = NEV_PACKET_DATA_TYPES_BY_SPEC[spec]
12681268

12691269
# Apply masks and create type definitions
@@ -1282,11 +1282,15 @@ def _read_nev_data(self, spec, filename):
12821282

12831283
event_segment_ids = self._get_event_segment_ids(raw_data, masks, spec)
12841284

1285+
# Extract data for each packet type using view-then-mask pattern
1286+
# Strategy: reinterpret entire raw_data array with each packet type's structure, then filter
1287+
# All NEV data packets are fixed-width, so temporarily viewing "Spikes" data as "Comments"
1288+
# structure is safe - we immediately filter to keep only packets that actually match.
1289+
# This avoids creating copies of large data arrays during the parsing process.
12851290
data = {}
12861291
for data_type in packet_identifiers:
1287-
if data_type in masks:
1288-
mask = masks[data_type]
1289-
data[data_type] = (raw_data.view(types[data_type])[mask], event_segment_ids[mask])
1292+
mask = masks[data_type]
1293+
data[data_type] = (raw_data.view(types[data_type])[mask], event_segment_ids[mask])
12901294

12911295
return data
12921296

@@ -2116,7 +2120,7 @@ def _is_set(self, flag, pos):
21162120
# Used to create masks that filter raw data packets by their packet ID field.
21172121
# Single values indicate equality check, tuples (min, max) indicate range check.
21182122
# According to NEV spec: packet IDs < 32768 identify channels, IDs >= 32768 are system events.
2119-
NEV_PACKET_IDENTIFIERS = {
2123+
NEV_PACKET_IDENTIFIERS_BY_SPEC = {
21202124
"2.1": {
21212125
"NonNeural": 0,
21222126
"Spikes": (1, 255), # Packet IDs in this range identify spike events on electrodes

0 commit comments

Comments
 (0)