@@ -211,7 +211,7 @@ def _parse_header(self):
211211 else :
212212 self ._max_sigs_length = max (
213213 [
214- len (raw_data ) * raw_data [ 0 ] .size
214+ len (raw_data ) * raw_data .size
215215 for raw_data in self ._raw_data .values ()
216216 ]
217217 )
@@ -252,7 +252,7 @@ def _get_signal_size(self, block_index, seg_index, stream_index):
252252 elif self .file_format == 'one-file-per-signal' :
253253 size = self ._raw_data [stream_index ][:,0 ].size
254254 else :
255- size = self ._raw_data [stream_index ][0 ][ chan_id_0 ] .size
255+ size = self ._raw_data [stream_index ][0 ].size
256256
257257 size = self ._raw_data [channel_id_0 ].size
258258
@@ -285,9 +285,9 @@ def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, strea
285285 shape = self ._raw_data [stream_index ][:, 0 ].shape
286286 else :
287287 if channel_indexes_are_none :
288- shape = self ._raw_data [stream_index ][0 ][ channel_ids [ 0 ]] .shape
288+ shape = self ._raw_data [stream_index ][0 ].shape
289289 else :
290- shape = self ._raw_data [stream_index ][channel_indexes [0 ]][ channel_ids [ 0 ]] .shape
290+ shape = self ._raw_data [stream_index ][channel_indexes [0 ]].shape
291291
292292
293293 # some channel (temperature) have 1D field so shape 1D
@@ -301,21 +301,24 @@ def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, strea
301301 sl0 = i_start % block_size
302302 sl1 = sl0 + (i_stop - i_start )
303303
304- sigs_chunk = np .zeros ((i_stop - i_start , len (channel_ids )), dtype = "uint16" )
304+ if self .file_format == 'header-attached' and stream_id == 'RHD2000 amplifier channel' :
305+ sigs_chunk = np .zeros ((i_stop - i_start , len (channel_ids )), dtype = "int16" )
306+ else :
307+ sigs_chunk = np .zeros ((i_stop - i_start , len (channel_ids )), dtype = "uint16" )
305308 for channel_index , channel_id in enumerate (channel_ids ):
306309 if self .file_format == 'header-attached' :
307310 # Memmap fields are the channel_ids for unique channels
308311 data_chan = self ._raw_data [channel_id ]
309312 elif self .file_format == 'one-file-per-signal' :
310313 if channel_indexes_are_none :
311- data_chan = self ._raw_data [stream_index ][:, i ]
314+ data_chan = self ._raw_data [stream_index ][:, channel_index ]
312315 else :
313- data_chan = self ._raw_data [stream_index ][:, channel_indexes [i ]]
316+ data_chan = self ._raw_data [stream_index ][:, channel_indexes [channel_index ]]
314317 else :
315318 if channel_indexes_are_none :
316- data_chan = self ._raw_data [stream_index ][i ][ channel_id ]
319+ data_chan = self ._raw_data [stream_index ][channel_index ]
317320 else :
318- data_chan = self ._raw_data [stream_index ][channel_indexes [i ]][ channel_id ]
321+ data_chan = self ._raw_data [stream_index ][channel_indexes [channel_index ] ]
319322
320323
321324 if len (shape ) == 1 :
@@ -669,10 +672,8 @@ def read_rhd(filename, file_format: str):
669672 ordered_channels .append (chan_info )
670673 if file_format == "header-attached" :
671674 data_dtype += [(name , "uint16" , BLOCK_SIZE )]
672- elif file_format == 'one-file-per-signal' :
673- data_dtype [0 ] = "int16"
674675 else :
675- data_dtype [0 ] += [( name , "int16" )]
676+ data_dtype [0 ] = "int16"
676677
677678 # 1: RHD2000 auxiliary input channel
678679 for chan_info in channels_by_type [1 ]:
@@ -684,10 +685,9 @@ def read_rhd(filename, file_format: str):
684685 ordered_channels .append (chan_info )
685686 if file_format == "header-attached" :
686687 data_dtype += [(name , "uint16" , BLOCK_SIZE // 4 )]
687- elif file_format == "one-file-per-signal" :
688- data_dtype [1 ] = "uint16"
689688 else :
690- data_dtype [1 ] += [(name , "uint16" )]
689+ data_dtype [1 ] = "uint16"
690+
691691
692692
693693 # 2: RHD2000 supply voltage channel
@@ -700,10 +700,9 @@ def read_rhd(filename, file_format: str):
700700 ordered_channels .append (chan_info )
701701 if file_format == "header-attached" :
702702 data_dtype += [(name , "uint16" )]
703- elif file_format == "one-file-per-signal" :
704- data_dtype [1 ] = "uint16"
705703 else :
706- data_dtype [1 ] += [(name , "uint16" )]
704+ data_dtype [1 ] = "uint16"
705+
707706
708707 # temperature is not an official channel in the header
709708 for i in range (global_info ["num_temp_sensor_channels" ]):
@@ -733,10 +732,9 @@ def read_rhd(filename, file_format: str):
733732 ordered_channels .append (chan_info )
734733 if file_format == "header-attached" :
735734 data_dtype += [(name , "uint16" , BLOCK_SIZE )]
736- elif file_format == 'one-file-per-signal' :
737- data_dtype [3 ] = "uint16"
738735 else :
739- data_dtype [3 ] += [(name , "uint16" )]
736+ data_dtype [3 ] = "uint16"
737+
740738
741739 # 4: USB board digital input channel
742740 # 5: USB board digital output channel
@@ -754,10 +752,8 @@ def read_rhd(filename, file_format: str):
754752 ordered_channels .append (chan_info )
755753 if file_format == "header-attached" :
756754 data_dtype += [(name , "uint16" , BLOCK_SIZE )]
757- elif file_format == "one-file-per-signal" :
758- data_dtype [sig_type ] = "uint16"
759755 else :
760- data_dtype [sig_type ] += [( name , "uint16" ,)]
756+ data_dtype [sig_type ] = "uint16"
761757
762758 if bool (global_info ["notch_filter_mode" ]) and version >= V ("3.0" ):
763759 global_info ["notch_filter_applied" ] = True
0 commit comments