@@ -36,9 +36,10 @@ class BiocamRawIO(BaseRawIO):
3636 fill_gaps_strategy: "zeros" | "synthetic_noise" | None, default: None
3737 The strategy to fill the gaps in the data when using event-based
3838 compression. If None and the file is event-based compressed,
39- you need to specify a fill gaps strategy.
40- If "zeros", the gaps are filled with 0s.
41- If "synthetic_noise", the gaps are filled with synthetic noise.
39+ you need to specify a fill gaps strategy:
40+
41+ * "zeros": the gaps are filled with 0s.
42+ * "synthetic_noise": the gaps are filled with synthetic noise.
4243
4344 Examples
4445 --------
@@ -352,12 +353,12 @@ def readHDF5t_brw4_sparse(rf, t0, t1, nch, use_synthetic_noise=False):
352353 if well_ID .startswith ("Well_" ):
353354 break
354355 # initialize an empty (fill with zeros) data collection
355- data = np .zeros ((nch , num_frames ), dtype = np .int16 )
356+ data = np .zeros ((nch , num_frames ), dtype = np .uint16 )
356357 if not use_synthetic_noise :
357358 # Will read as 0s after 12 bits signed conversion
358359 data .fill (2048 )
359- # fill the data collection with Gaussian noise if requested
360360 else :
361+ # fill the data collection with Gaussian noise if requested
361362 data = generate_synthetic_noise (rf , data , well_ID , start_frame , num_frames ) #, std=noise_std)
362363 # fill the data collection with the decoded event based sparse raw data
363364 data = decode_event_based_raw_data (rf , data , well_ID , start_frame , num_frames )
@@ -384,23 +385,23 @@ def decode_event_based_raw_data(rf, data, well_ID, start_frame, num_frames):
384385 binary_data_length = len (binary_data )
385386 pos = 0
386387 while pos < binary_data_length :
387- ch_idx = int .from_bytes (binary_data [pos :pos + 4 ], byteorder = "little" , signed = True )
388+ ch_idx = int .from_bytes (binary_data [pos :pos + 4 ], byteorder = "little" )
388389 pos += 4
389- ch_data_length = int .from_bytes (binary_data [pos :pos + 4 ], byteorder = "little" , signed = True )
390+ ch_data_length = int .from_bytes (binary_data [pos :pos + 4 ], byteorder = "little" )
390391 pos += 4
391392 ch_data_pos = pos
392393 while pos < ch_data_pos + ch_data_length :
393- from_inclusive = int .from_bytes (binary_data [pos :pos + 8 ], byteorder = "little" , signed = True )
394+ from_inclusive = int .from_bytes (binary_data [pos :pos + 8 ], byteorder = "little" )
394395 pos += 8
395- to_exclusive = int .from_bytes (binary_data [pos :pos + 8 ], byteorder = "little" , signed = True )
396+ to_exclusive = int .from_bytes (binary_data [pos :pos + 8 ], byteorder = "little" )
396397 pos += 8
397398 range_data_pos = pos
398399 for j in range (from_inclusive , to_exclusive ):
399400 if j >= start_frame + num_frames :
400401 break
401402 if j >= start_frame :
402403 data [ch_idx ][j - start_frame ] = int .from_bytes (
403- binary_data [range_data_pos :range_data_pos + 2 ], byteorder = "little" , signed = True )
404+ binary_data [range_data_pos :range_data_pos + 2 ], byteorder = "little" )
404405 range_data_pos += 2
405406 pos += (to_exclusive - from_inclusive ) * 2
406407
@@ -450,9 +451,9 @@ def generate_synthetic_noise(rf, data, well_ID, start_frame, num_frames):
450451 for ch_idx in range (len (data )):
451452 if ch_idx in noise_info :
452453 data [ch_idx ] = np .array (np .random .normal (noise_info [ch_idx ][0 ], noise_info [ch_idx ][1 ],
453- num_frames ), dtype = np .int16 )
454+ num_frames ), dtype = np .uint16 )
454455 else :
455456 data [ch_idx ] = np .array (np .random .normal (median_mean , median_std , num_frames ),
456- dtype = np .int16 )
457+ dtype = np .uint16 )
457458
458459 return data
0 commit comments