1212from collections .abc import Iterable
1313from logging import getLogger
1414
15- from numpy import (arange , array , asarray , diff , empty , hstack , inf ,
16- issubsctype , linspace , nan_to_num , ndarray , ones , ravel ,
15+ from numpy import (arange , array , asarray , diff , empty , hstack , inf ,
16+ linspace , nan_to_num , ndarray , ones , ravel ,
1717 setdiff1d , floor )
1818from numpy .lib .stride_tricks import as_strided
1919from math import isclose
@@ -78,7 +78,7 @@ def read_data(self, chan=[], ref_chan=[], grp_name=None, concat_chan=False,
7878 concat_chan : bool
7979 if True, data from all channels will be concatenated
8080 average_channels : bool
81- if True, all channels will be averaged into a single virtual
81+ if True, all channels will be averaged into a single virtual
8282 channel with label 'avg_chan'
8383 max_s_freq: : int
8484 maximum sampling frequency
@@ -121,7 +121,7 @@ def read_data(self, chan=[], ref_chan=[], grp_name=None, concat_chan=False,
121121 t0 , t1 ))
122122 active_chan = chan if chan else [seg ['chan' ].split (' (' )[0 ]]
123123 if isinstance (active_chan , str ):
124- active_chan = [active_chan ]
124+ active_chan = [active_chan ]
125125 chan_to_read = active_chan + ref_chan
126126
127127 data = self .dataset .read_data (chan = chan_to_read , begtime = t0 ,
@@ -154,7 +154,7 @@ def read_data(self, chan=[], ref_chan=[], grp_name=None, concat_chan=False,
154154 [x (chan = ch )[0 ] for x in subseg ])
155155
156156 if average_channels :
157- one_segment .data [0 ] = one_segment .data [0 ].mean (0 ,
157+ one_segment .data [0 ] = one_segment .data [0 ].mean (0 ,
158158 keepdims = True )
159159 one_segment .axis ['chan' ][0 ] = array (['avg_chan' ], dtype = '<U2' )
160160 active_chan = ['avg_chan' ]
@@ -248,7 +248,7 @@ def select(data, trial=None, invert=False, **axes_to_select):
248248 selected_values = asarray (values_to_select , dtype = 'U' )
249249
250250 else :
251- if isinstance (values_to_select , ndarray ) and issubsctype (values_to_select .dtype , bool ):
251+ if isinstance (values_to_select , ndarray ) and issubclass (values_to_select .dtype , bool ):
252252 bool_values = values_to_select
253253 elif (values_to_select [0 ] is None and
254254 values_to_select [1 ] is None ):
@@ -325,7 +325,7 @@ def resample(data, s_freq, axis='time'):
325325 return output
326326
327327
328- def smart_chan (dataset , simple_chan_name , test_chan = None ):
328+ def smart_chan (dataset , simple_chan_name , test_chan = None ):
329329 """From a list of simple channel names, attempts to find the corresponding
330330 channel names in the dataset and returns a list (with same order).
331331 Parameters
@@ -334,19 +334,19 @@ def smart_chan(dataset, simple_chan_name, test_chan=None):
334334 info about record
335335 simple_chan_name : list of str
336336 simple names for channels, e.g. ['F3', 'Fp2', 'ECG']
337-
337+
338338 Returns
339339 -------
340340 list
341341 corresponding channel labels as they appear in dataset
342342 """
343343 chan_key = {}
344-
344+
345345 if test_chan is None :
346346 orig_chan_name = dataset .header ['chan_name' ]
347347 else :
348348 orig_chan_name = test_chan
349-
349+
350350 for s in simple_chan_name :
351351 # look for exact matches
352352 candidates = [x for x in orig_chan_name if s == x ]
@@ -356,9 +356,9 @@ def smart_chan(dataset, simple_chan_name, test_chan=None):
356356 elif len (candidates ) > 1 :
357357 raise ValueError ( f'The record contains { len (candidates )} '
358358 f'duplicates of channel label { s } ' )
359-
359+
360360 # look for s in first position
361- candidates = [x for x in orig_chan_name if s == x [:min (len (s ),
361+ candidates = [x for x in orig_chan_name if s == x [:min (len (s ),
362362 len (x ))]]
363363 if len (candidates ) == 1 :
364364 chan_key [s ] = candidates [0 ]
@@ -367,7 +367,7 @@ def smart_chan(dataset, simple_chan_name, test_chan=None):
367367 # s appears in first position more than once
368368 raise ValueError (
369369 f'Too many candidates corresponding to { s } : { candidates } ' )
370-
370+
371371 # look for unique occurrences of s somewhere in chan label
372372 candidates = [x for x in orig_chan_name if s in x ]
373373 if len (candidates ) == 1 :
@@ -383,7 +383,7 @@ def smart_chan(dataset, simple_chan_name, test_chan=None):
383383 raise ValueError (
384384 f'Too many candidates corresponding to { s } : { candidates } ' )
385385 raise ValueError (f'Unable to find channel containing { s } ' )
386-
386+
387387 return [chan_key [x ] for x in simple_chan_name ]
388388
389389
0 commit comments