@@ -129,7 +129,7 @@ def _parse_header(self):
129129 # if header-attached there is one giant memory-map
130130 if self .file_format == "header-attached" :
131131 self ._raw_data = np .memmap (self .filename , dtype = data_dtype , mode = "r" , offset = header_size )
132-
132+
133133 # for 'one-file-per-signal' we have one memory map / neo stream
134134 elif self .file_format == "one-file-per-signal" :
135135 self ._raw_data = {}
@@ -139,7 +139,9 @@ def _parse_header(self):
139139 size_in_bytes = file_path .stat ().st_size
140140 dtype_size = np .dtype (stream_datatype ).itemsize
141141 n_samples = size_in_bytes // (dtype_size * num_channels )
142- signal_stream_memmap = np .memmap (file_path , dtype = stream_datatype , mode = "r" , shape = (num_channels , n_samples )).T
142+ signal_stream_memmap = np .memmap (
143+ file_path , dtype = stream_datatype , mode = "r" , shape = (num_channels , n_samples )
144+ ).T
143145 self ._raw_data [stream_index ] = signal_stream_memmap
144146
145147 # for one-file-per-channel we have one memory map / channel stored as a list / neo stream
@@ -153,7 +155,6 @@ def _parse_header(self):
153155 channel_memmap = np .memmap (file_path , dtype = stream_datatype , mode = "r" )
154156 self ._raw_data [stream_index ].append (channel_memmap )
155157
156-
157158 # check timestamp continuity
158159 if self .file_format == "header-attached" :
159160 timestamp = self ._raw_data ["timestamp" ].flatten ()
@@ -174,7 +175,7 @@ def _parse_header(self):
174175 for c , chan_info in enumerate (self ._ordered_channels ):
175176 name = chan_info ["custom_channel_name" ]
176177 channel_id = chan_info ["native_channel_name" ]
177- sig_dtype = chan_info [' dtype' ]
178+ sig_dtype = chan_info [" dtype" ]
178179 stream_id = str (chan_info ["signal_type" ])
179180 signal_channels .append (
180181 (
@@ -236,7 +237,7 @@ def _segment_t_stop(self, block_index, seg_index):
236237 return t_stop
237238
238239 def _get_signal_size (self , block_index , seg_index , stream_index ):
239-
240+
240241 if self .file_format == "header-attached" :
241242 stream_id = self .header ["signal_streams" ][stream_index ]["id" ]
242243 mask = self .header ["signal_channels" ]["stream_id" ] == stream_id
@@ -302,19 +303,18 @@ def _get_analogsignal_chunk_header_attached(self, i_start, i_stop, stream_index,
302303 dtype = self ._raw_data [channel_id_0 ].dtype
303304 sigs_chunk = np .zeros ((i_stop - i_start , len (channel_ids )), dtype = dtype )
304305
305-
306306 # This is False for Temperature and timestamps
307307 multiple_samples_per_block = len (shape ) == 2
308308
309309 # In the header attached case the data for each channel comes interleaved in blocks
310- # To avoid unecessary memory access we can calculate the blocks we need to access beforehand:
310+ # To avoid unecessary memory access we can calculate the blocks we need to access beforehand:
311311 if multiple_samples_per_block :
312312 block_size = shape [1 ]
313313 block_start = i_start // block_size
314314 block_stop = i_stop // block_size + 1
315315 sl0 = i_start % block_size
316316 sl1 = sl0 + (i_stop - i_start )
317-
317+
318318 # raw_data is a structured memmap with a field for each channel_id
319319 for chunk_index , channel_id in enumerate (channel_ids ):
320320 data_chan = self ._raw_data [channel_id ]
@@ -325,7 +325,6 @@ def _get_analogsignal_chunk_header_attached(self, i_start, i_stop, stream_index,
325325
326326 return sigs_chunk
327327
328-
329328 def _get_analogsignal_chunk_one_file_per_channel (self , i_start , i_stop , stream_index , channel_indexes ):
330329
331330 signal_data_memmap_list = self ._raw_data [stream_index ]
@@ -336,7 +335,7 @@ def _get_analogsignal_chunk_one_file_per_channel(self, i_start, i_stop, stream_i
336335 stop = channel_indexes .stop or num_channels
337336 step = channel_indexes .step or 1
338337 channel_indexes = range (start , stop , step )
339-
338+
340339 # We get the dtype from the first channel
341340 first_channel_index = channel_indexes [0 ]
342341 dtype = signal_data_memmap_list [first_channel_index ].dtype
@@ -348,7 +347,6 @@ def _get_analogsignal_chunk_one_file_per_channel(self, i_start, i_stop, stream_i
348347
349348 return sigs_chunk
350349
351-
352350 def _get_analogsignal_chunk_one_file_per_signal (self , i_start , i_stop , stream_index , channel_indexes ):
353351
354352 # One memmap per stream case
@@ -704,12 +702,11 @@ def read_rhd(filename, file_format: str):
704702 chan_info ["offset" ] = 0.0
705703 chan_info ["dtype" ] = "int16"
706704 ordered_channels .append (chan_info )
707-
705+
708706 if file_format == "header-attached" :
709707 data_dtype += [(name , "uint16" , BLOCK_SIZE )]
710708 else :
711709 data_dtype [0 ] = "int16"
712-
713710
714711 # 1: RHD2000 auxiliary input channel
715712 for chan_info in channels_by_type [1 ]:
@@ -725,7 +722,6 @@ def read_rhd(filename, file_format: str):
725722 else :
726723 data_dtype [1 ] = "uint16"
727724
728-
729725 # 2: RHD2000 supply voltage channel
730726 for chan_info in channels_by_type [2 ]:
731727 name = chan_info ["native_channel_name" ]
@@ -737,7 +733,7 @@ def read_rhd(filename, file_format: str):
737733 ordered_channels .append (chan_info )
738734 if file_format == "header-attached" :
739735 data_dtype += [(name , "uint16" )]
740- else :
736+ else :
741737 data_dtype [2 ] = "uint16"
742738
743739 # temperature is not an official channel in the header
@@ -797,7 +793,6 @@ def read_rhd(filename, file_format: str):
797793 else :
798794 data_dtype [sig_type ] = "uint16"
799795
800-
801796 if global_info ["notch_filter_mode" ] == 2 and version >= V ("3.0" ):
802797 global_info ["notch_filter" ] = "60Hz"
803798 elif global_info ["notch_filter_mode" ] == 1 and version >= V ("3.0" ):
0 commit comments