@@ -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 )
@@ -1797,7 +1811,7 @@ def __nev_params(self, param_name):
17971811 hour = self .__nev_basic_header ["hour" ],
17981812 minute = self .__nev_basic_header ["minute" ],
17991813 second = self .__nev_basic_header ["second" ],
1800- microsecond = self .__nev_basic_header ["millisecond" ],
1814+ microsecond = int ( self .__nev_basic_header ["millisecond" ]) * 1000 ,
18011815 ),
18021816 "max_res" : self .__nev_basic_header ["timestamp_resolution" ],
18031817 "channel_ids" : self .__nev_ext_header [b"NEUEVWAV" ]["electrode_id" ],
0 commit comments