Skip to content

BlackRock: shape parameter for memap #1705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion neo/rawio/blackrockrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,21 @@ def __read_nev_data(self, nev_data_masks, nev_data_types):
# read all raw data packets and markers
dt0 = [("timestamp", ts_format), ("packet_id", "uint16"), ("value", f"S{data_size - header_skip}")]

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

raw_data = np.memmap(
filename,
offset=header_size,
dtype=dt0,
shape=(n_packets,),
mode="r",
)

masks = self.__nev_data_masks(raw_data["packet_id"])
types = self.__nev_data_types(data_size)
Expand Down
Loading