def detect_events(self, data, method, params, label):
        """Detect events and display on signal.

        Parameters
        ----------
        data : instance of ChanTime
            one segment with all channels of interest
        method : str
            Method used for detection.
        params : dict
            Parameters used for detection.
        label : str
            Name of event type, on event labels
        """
        if self.annot is None:  # remove if buttons are disabled
            self.parent.statusBar().showMessage('No score file loaded')
            return

        lg.info('Adding event type ' + label)
        self.annot.add_event_type(label)
        self.display_eventtype()
        n_eventtype = self.idx_eventtype.count()
        self.idx_eventtype.setCurrentIndex(n_eventtype - 1)

        if params['max_dur'] in [0, 'None']:
            params['max_dur'] = None

        freq = (float(params['f1']), float(params['f2']))
        duration = (params['min_dur'], params['max_dur'])

        if method in SPINDLE_METHODS:
            detector = DetectSpindle(method=method, frequency=freq,
                                     duration=duration, merge=params['merge'])
            detector.rolloff = params['rolloff']
            detector.min_interval = params['interval']

            if 'Ferrarelli2007' == method:
                detector.det_thresh = params['0']
                detector.sel_thresh = params['1']
                
            if 'Nir2011' == method:
                detector.smooth['dur'] = params['0']
                detector.det_thresh = params['1']
                detector.sel_thresh = params['2']
                
            if 'Moelle2011' == method:
                detector.moving_rms['dur'] = params['0']
                detector.smooth['dur'] = params['1']
                detector.det_thresh = params['2']            
            
            if 'Wamsley2012' == method:
                detector.det_wavelet['dur'] = params['0']
                detector.det_wavelet['sd'] = params['1']
                detector.smooth['dur'] = params['2']  
                detector.det_thresh = params['3']  
            
            if 'Martin2013' == method:
                detector.moving_rms['dur'] = params['0']
                detector.moving_rms['step'] = params['1']
                detector.det_thresh = params['2']
            
            if 'Ray2015' == method:
                detector.smooth['dur'] = params['0']
                detector.zscore['step'] = params['1']
                detector.det_thresh = params['2']  
                detector.sel_thresh = params['3']             
            
            if 'Lacourse2018' == method:
                detector.windowing['dur'] = params['0']
                detector.windowing['step'] = params['1']
                detector.abs_pow_thresh = params['2']
                detector.rel_pow_thresh = params['3']
                detector.covar_thresh = params['4']
                detector.corr_thresh = params['5']
                
            if 'FASST' == method:
                detector.det_thresh = params['0']
                detector.smooth['dur'] = params['1']
                
            if 'FASST2' == method:
                detector.det_thresh = params['0']
                detector.moving_rms['dur'] = params['1']
                detector.smooth['dur'] = params['2']
            
            if 'UCSD' == method:
                detector.det_wavelet['dur'] = params['0']
                detector.det_wavelet['width'] = params['1']
                detector.det_wavelet['win'] = params['2']
                detector.det_thresh = params['3']  
                detector.sel_thresh = params['4'] 
                
            if 'Concordia' == method:
                detector.moving_rms['dur'] = params['0']
                detector.smooth['dur'] = params['1']
                detector.det_thresh = params['2']            
                detector.det_thresh_hi = params['3']            
                detector.tolerance = params['4']            
                detector.sel_thresh = params['5']            
                
        elif method in SLOW_WAVE_METHODS:
            detector = DetectSlowWave(method=method, duration=duration)

            detector.det_filt['freq'] = freq
            detector.trough_duration = (params['min_trough_dur'],
                                        params['max_trough_dur'])
            detector.max_trough_amp = params['max_trough_amp']
            detector.min_ptp = params['min_ptp']
            detector.invert = params['invert']

        else:
            lg.info('Method not recognized: ' + method)
            return

        events = detector(data, parent=self)

        if events:
            self.annot.add_events(events, name=label)

        self.update_annotations()
Detect events and display on signal.

        Parameters
        ----------
        data : instance of ChanTime
            one segment with all channels of interest
        method : str
            Method used for detection.
        params : dict
            Parameters used for detection.
        label : str
            Name of event type, on event labels