4343 _event_channel_dtype ,
4444)
4545
46+ from neo .core .baseneo import NeoReadWriteError
4647
4748class PlexonRawIO (BaseRawIO ):
4849 extensions = ["plx" ]
@@ -302,22 +303,24 @@ def _parse_header(self):
302303
303304 signal_streams = np .array (signal_streams , dtype = _signal_stream_dtype )
304305
305- self .stream_id_samples = {}
306- self .stream_id_sampling_frequency = {}
307- self .stream_index_to_stream_id = {}
306+ self ._stream_id_samples = {}
307+ self ._stream_id_sampling_frequency = {}
308+ self ._stream_index_to_stream_id = {}
308309 for stream_index , stream_id in enumerate (signal_streams ["id" ]):
309310 # Keep a mapping from stream_index to stream_id
310- self .stream_index_to_stream_id [stream_index ] = stream_id
311+ self ._stream_index_to_stream_id [stream_index ] = stream_id
311312
312- # We extract the number of samples for each stream
313313 mask = signal_channels ["stream_id" ] == stream_id
314+
314315 signal_num_samples = np .unique (channel_num_samples [mask ])
315- assert signal_num_samples .size == 1 , "All channels in a stream must have the same number of samples"
316+ if signal_num_samples .size > 1 :
317+ raise NeoReadWriteError (f"Channels in stream { stream_id } don't have the same number of samples" )
316318 self .stream_id_samples [stream_id ] = signal_num_samples [0 ]
317319
318320 signal_sampling_frequency = np .unique (signal_channels [mask ]["sampling_rate" ])
319- assert signal_sampling_frequency .size == 1 , "All channels in a stream must have the same sampling frequency"
320- self .stream_id_sampling_frequency [stream_id ] = signal_sampling_frequency [0 ]
321+ if signal_sampling_frequency .size > 1 :
322+ raise NeoReadWriteError (f"Channels in stream { stream_id } don't have the same sampling frequency" )
323+ self ._stream_id_sampling_frequency [stream_id ] = signal_sampling_frequency [0 ]
321324
322325 self ._global_ssampling_rate = global_header ["ADFrequency" ]
323326
@@ -398,15 +401,15 @@ def _segment_t_start(self, block_index, seg_index):
398401
399402 def _segment_t_stop (self , block_index , seg_index ):
400403 t_stop = float (self ._last_timestamps ) / self ._global_ssampling_rate
401- if hasattr (self , "stream_id_samples " ):
402- for stream_id in self .stream_id_samples .keys ():
403- t_stop_sig = self .stream_id_samples [stream_id ] / self .stream_id_sampling_frequency [stream_id ]
404+ if hasattr (self , "_stream_id_samples " ):
405+ for stream_id in self ._stream_id_samples .keys ():
406+ t_stop_sig = self ._stream_id_samples [stream_id ] / self ._stream_id_sampling_frequency [stream_id ]
404407 t_stop = max (t_stop , t_stop_sig )
405408 return t_stop
406409
407410 def _get_signal_size (self , block_index , seg_index , stream_index ):
408- stream_id = self .stream_index_to_stream_id [stream_index ]
409- return self .stream_id_samples [stream_id ]
411+ stream_id = self ._stream_index_to_stream_id [stream_index ]
412+ return self ._stream_id_samples [stream_id ]
410413
411414 def _get_signal_t_start (self , block_index , seg_index , stream_index ):
412415 return 0.0
@@ -419,7 +422,7 @@ def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, strea
419422 if i_start is None :
420423 i_start = 0
421424 if i_stop is None :
422- i_stop = self .stream_id_samples [stream_id ]
425+ i_stop = self ._stream_id_samples [stream_id ]
423426
424427
425428
0 commit comments