@verbose
def find_events(raw, stim_channel=None, output='onset', consecutive='increasing', min_duration=0, shortest_event=2, mask=None, uint_cast=False, mask_type='not_and', verbose=None):
 min_samples = (min_duration * raw.info['sfreq'])
 stim_channel = _get_stim_channel(stim_channel, raw.info)
 pick = pick_channels(raw.info['ch_names'], include=stim_channel)
 if (len(pick) == 0):
  raise ValueError('No stim channel found to extract event triggers.')
 (data, _) = raw[pick, :]
 events = _find_events(data, raw.first_samp, verbose=verbose, output=output, consecutive=consecutive, min_samples=min_samples, mask=mask, uint_cast=uint_cast, mask_type=mask_type)
 n_short_events = np.sum((np.diff(events[:, 0]) < shortest_event))
 if (n_short_events > 0):
  raise ValueError(("You have %i events shorter than the shortest_event. These are very unusual and you may want to set min_duration to a larger value e.g. x / raw.info['sfreq']. Where x = 1 sample shorter than the shortest event length." % n_short_events))
 return events

@ verbose def find_events ( raw , stim_channel = None , output = 'onset' , consecutive = 'increasing' , min_duration = 0 , shortest_event = 2 , mask = None , uint_cast = False , mask_type = 'not_and' , verbose = None ) : min_samples = ( min_duration * raw . info [ 'sfreq' ] ) stim_channel = _get_stim_channel ( stim_channel , raw . info ) pick = pick_channels ( raw . info [ 'ch_names' ] , include = stim_channel ) if ( len ( pick ) == 0 ) : raise ValueError ( 'No stim channel found to extract event triggers.' ) ( data , _ ) = raw [ pick , : ] events = _find_events ( data , raw . first_samp , verbose = verbose , output = output , consecutive = consecutive , min_samples = min_samples , mask = mask , uint_cast = uint_cast , mask_type = mask_type ) n_short_events = np . sum ( ( np . diff ( events [ : , 0 ] ) < shortest_event ) ) if ( n_short_events > 0 ) : raise ValueError ( ( "You have %i events shorter than the shortest_event. These are very unusual and you may want to set min_duration to a larger value e.g. x / raw.info['sfreq']. Where x = 1 sample shorter than the shortest event length." % n_short_events ) ) return events
find events from raw file .