Skip to content

Commit 5df3403

Browse files
luiztaufferzm711
andauthored
BlackRock: shape parameter for memap (#1705)
* shape parameter for memap * Update neo/rawio/blackrockrawio.py Co-authored-by: Zach McKenzie <[email protected]> * Update neo/rawio/blackrockrawio.py --------- Co-authored-by: Zach McKenzie <[email protected]>
1 parent f747abd commit 5df3403

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

neo/rawio/blackrockrawio.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,21 @@ def __read_nev_data(self, nev_data_masks, nev_data_types):
12541254
# read all raw data packets and markers
12551255
dt0 = [("timestamp", ts_format), ("packet_id", "uint16"), ("value", f"S{data_size - header_skip}")]
12561256

1257-
raw_data = np.memmap(filename, offset=header_size, dtype=dt0, mode="r")
1257+
# expected number of data packets. We are not sure why, but it seems we can get partial data packets
1258+
# based on blackrock's own code this is okay so applying an int to round down is necessary to obtain the
1259+
# memory map of full packets and toss the partial packet.
1260+
# See reference: https://github.com/BlackrockNeurotech/Python-Utilities/blob/fa75aa671680306788e10d3d8dd625f9da4ea4f6/brpylib/brpylib.py#L580-L587
1261+
n_packets = int(
1262+
(self.__get_file_size(filename) - header_size) / data_size
1263+
)
1264+
1265+
raw_data = np.memmap(
1266+
filename,
1267+
offset=header_size,
1268+
dtype=dt0,
1269+
shape=(n_packets,),
1270+
mode="r",
1271+
)
12581272

12591273
masks = self.__nev_data_masks(raw_data["packet_id"])
12601274
types = self.__nev_data_types(data_size)

0 commit comments

Comments
 (0)