#NEWLINE# def read_segment( self , n_start , n_stop , chlist = None , lazy = False , cascade = True ) : #NEWLINE# #INDENT# 'Reads a Segment from the file and stores in database.\n\n        The Segment will contain one AnalogSignal for each channel\n        and will go from n_start to n_stop (in samples).\n\n        Arguments:\n            n_start : time in samples that the Segment begins\n            n_stop : time in samples that the Segment ends\n\n        Python indexing is used, so n_stop is not inclusive.\n\n        Returns a Segment object containing the data.\n        ' #NEWLINE# if ( chlist is None ) : #NEWLINE# #INDENT# chlist = self . loader . get_neural_channel_numbers ( ) #NEWLINE# #UNINDENT# conversion = ( self . full_range / ( 2 ** ( 8 * self . header . sample_width ) ) ) #NEWLINE# seg = Segment ( file_origin = self . filename ) #NEWLINE# t_start = ( float ( n_start ) / self . header . f_samp ) #NEWLINE# t_stop = ( float ( n_stop ) / self . header . f_samp ) #NEWLINE# seg . annotate ( t_start = t_start ) #NEWLINE# seg . annotate ( t_stop = t_stop ) #NEWLINE# for ch in chlist : #NEWLINE# #INDENT# if sig : #NEWLINE# #INDENT# sig = ( np . array ( [ ] ) * conversion ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sig = ( np . array ( self . loader . _get_channel ( ch ) [ n_start : n_stop ] ) * conversion ) #NEWLINE# #UNINDENT# anasig = AnalogSignal ( signal = sig , sampling_rate = ( self . header . f_samp * pq . Hz ) , t_start = ( t_start * pq . s ) , file_origin = self . filename , description = ( 'Channel %d from %f to %f' % ( ch , t_start , t_stop ) ) , channel_index = int ( ch ) ) #NEWLINE# if lazy : #NEWLINE# #INDENT# anasig . lazy_shape = ( n_stop - n_start ) #NEWLINE# #UNINDENT# seg . analogsignals . append ( anasig ) #NEWLINE# #UNINDENT# return seg