#NEWLINE# def _read_segment( self , start = 0 , stop = None , sel = None , data_buffer = None , projector = None , verbose = None ) : #NEWLINE# #INDENT# 'Read a chunk of raw data\n\n        Parameters\n        ----------\n        start : int, (optional)\n            first sample to include (first is 0). If omitted, defaults to the\n            first sample in data.\n        stop : int, (optional)\n            First sample to not include.\n            If omitted, data is included to the end.\n        sel : array, optional\n            Indices of channels to select.\n        data_buffer : array or str, optional\n            numpy array to fill with data read, must have the correct shape.\n            If str, a np.memmap with the correct data type will be used\n            to store the data.\n        projector : array\n            SSP operator to apply to the data.\n        verbose : bool, str, int, or None\n            If not None, override default verbose level (see mne.verbose).\n\n        Returns\n        -------\n        data : array, [channels x samples]\n           the data matrix (channels x samples).\n        times : array, [samples]\n            returns the time values corresponding to the samples.\n        ' #NEWLINE# start = int ( start ) #NEWLINE# stop = ( self . n_times if ( stop is None ) else min ( [ int ( stop ) , self . n_times ] ) ) #NEWLINE# if ( start >= stop ) : #NEWLINE# #INDENT# raise ValueError ( 'No data in this range' ) #NEWLINE# #UNINDENT# n_sel_channels = ( self . info [ 'nchan' ] if ( sel is None ) else len ( sel ) ) #NEWLINE# if ( ( sel is not None ) and ( len ( sel ) > 1 ) and np . all ( ( np . diff ( sel ) == 1 ) ) ) : #NEWLINE# #INDENT# sel = slice ( sel [ 0 ] , ( sel [ ( - 1 ) ] + 1 ) ) #NEWLINE# #UNINDENT# idx = ( slice ( None , None , None ) if ( sel is None ) else sel ) #NEWLINE# data_shape = ( n_sel_channels , ( stop - start ) ) #NEWLINE# dtype = self . _dtype #NEWLINE# if isinstance ( data_buffer , np . ndarray ) : #NEWLINE# #INDENT# if ( data_buffer . shape != data_shape ) : #NEWLINE# #INDENT# raise ValueError ( ( 'data_buffer has incorrect shape: %s != %s' % ( data_buffer . shape , data_shape ) ) ) #NEWLINE# #UNINDENT# data = data_buffer #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( data_buffer , string_types ) : #NEWLINE# #INDENT# data = np . memmap ( data_buffer , mode = 'w+' , dtype = dtype , shape = data_shape ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data = np . zeros ( data_shape , dtype = dtype ) #NEWLINE# #UNINDENT# #UNINDENT# cumul_lens = np . concatenate ( ( [ 0 ] , np . array ( self . _raw_lengths , dtype = 'int' ) ) ) #NEWLINE# cumul_lens = np . cumsum ( cumul_lens ) #NEWLINE# files_used = np . logical_and ( np . less ( start , cumul_lens [ 1 : ] ) , np . greater_equal ( ( stop - 1 ) , cumul_lens [ : ( - 1 ) ] ) ) #NEWLINE# cals = self . _cals . ravel ( ) [ np . newaxis , : ] #NEWLINE# if ( self . comp is not None ) : #NEWLINE# #INDENT# if ( projector is not None ) : #NEWLINE# #INDENT# mult = ( self . comp * cals ) #NEWLINE# mult = np . dot ( projector [ idx ] , mult ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mult = ( self . comp [ idx ] * cals ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( projector is not None ) : #NEWLINE# #INDENT# mult = ( projector [ idx ] * cals ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mult = None #NEWLINE# #UNINDENT# #UNINDENT# cals = cals . T [ idx ] #NEWLINE# offset = 0 #NEWLINE# for fi in np . nonzero ( files_used ) [ 0 ] : #NEWLINE# #INDENT# start_file = self . _first_samps [ fi ] #NEWLINE# if ( offset == 0 ) : #NEWLINE# #INDENT# start_file += ( start - cumul_lens [ fi ] ) #NEWLINE# #UNINDENT# stop_file = np . min ( [ ( ( stop - cumul_lens [ fi ] ) + self . _first_samps [ fi ] ) , ( self . _last_samps [ fi ] + 1 ) ] ) #NEWLINE# if ( ( start_file < self . _first_samps [ fi ] ) or ( stop_file < start_file ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Bad array indexing, could be a bug' ) #NEWLINE# #UNINDENT# n_read = ( stop_file - start_file ) #NEWLINE# this_sl = slice ( offset , ( offset + n_read ) ) #NEWLINE# self . _read_segment_file ( data [ : , this_sl ] , idx , fi , int ( start_file ) , int ( stop_file ) , cals , mult ) #NEWLINE# offset += n_read #NEWLINE# #UNINDENT# return data