#NEWLINE# def crop( self , tmin = 0.0 , tmax = None , copy = None ) : #NEWLINE# #INDENT# 'Crop raw data file.\n\n        Limit the data from the raw file to go between specific times. Note\n        that the new tmin is assumed to be t=0 for all subsequently called\n        functions (e.g., time_as_index, or Epochs). New first_samp and\n        last_samp are set accordingly.\n\n        Parameters\n        ----------\n        tmin : float\n            New start time in seconds (must be >= 0).\n        tmax : float | None\n            New end time in seconds of the data (cannot exceed data duration).\n        copy : bool\n            This parameter has been deprecated and will be removed in 0.13.\n            Use inst.copy() instead.\n            Whether to return a new instance or modify in place.\n\n        Returns\n        -------\n        raw : instance of Raw\n            The cropped raw object.\n        ' #NEWLINE# raw = _check_copy_dep ( self , copy , default = True ) #NEWLINE# max_time = ( ( raw . n_times - 1 ) / raw . info [ 'sfreq' ] ) #NEWLINE# if ( copy is None ) : #NEWLINE# #INDENT# tmax = max_time #NEWLINE# #UNINDENT# if ( tmin > tmax ) : #NEWLINE# #INDENT# raise ValueError ( 'tmin must be less than tmax' ) #NEWLINE# #UNINDENT# if ( tmin < 0.0 ) : #NEWLINE# #INDENT# raise ValueError ( 'tmin must be >= 0' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( tmax > max_time ) : #NEWLINE# #INDENT# raise ValueError ( ( 'tmax must be less than or equal to the max raw time (%0.4f sec)' % max_time ) ) #NEWLINE# #UNINDENT# #UNINDENT# ( smin , smax ) = np . where ( _time_mask ( self . times , tmin , tmax , sfreq = self . info [ 'sfreq' ] ) ) [ 0 ] [ [ 0 , ( - 1 ) ] ] #NEWLINE# cumul_lens = np . concatenate ( ( [ 0 ] , np . array ( raw . _raw_lengths , dtype = 'int' ) ) ) #NEWLINE# cumul_lens = np . cumsum ( cumul_lens ) #NEWLINE# keepers = np . logical_and ( np . less ( smin , cumul_lens [ 1 : ] ) , np . greater_equal ( smax , cumul_lens [ : ( - 1 ) ] ) ) #NEWLINE# keepers = np . where ( keepers ) [ 0 ] #NEWLINE# raw . _first_samps = np . atleast_1d ( raw . _first_samps [ keepers ] ) #NEWLINE# raw . _first_samps [ 0 ] += ( smin - cumul_lens [ keepers [ 0 ] ] ) #NEWLINE# raw . _last_samps = np . atleast_1d ( raw . _last_samps [ keepers ] ) #NEWLINE# raw . _last_samps [ ( - 1 ) ] -= ( ( cumul_lens [ ( keepers [ ( - 1 ) ] + 1 ) ] - 1 ) - smax ) #NEWLINE# raw . _raw_extras = [ r for ( ri , r ) in enumerate ( raw . _raw_extras ) if ( ri in keepers ) ] #NEWLINE# raw . _filenames = [ r for ( ri , r ) in enumerate ( raw . _filenames ) if ( ri in keepers ) ] #NEWLINE# if raw . preload : #NEWLINE# #INDENT# raw . _data = raw . _data [ : , smin : ( smax + 1 ) ] . copy ( ) #NEWLINE# #UNINDENT# raw . _update_times ( ) #NEWLINE# return raw