code: def select_events(dat, detected, method, value):
      
      if method == 'above_thresh':
          above_sel = dat >= value
          detected = _select_period(detected, above_sel)
      elif method == 'below_thresh':
          below_sel = dat <= value
          detected = _select_period(detected, below_sel)
  
      return detected
docs: Select start sample and end sample of the events.
  
      Parameters
      ----------
      dat : ndarray (dtype='float')
          vector with the data after selection-transformation
      detected : ndarray (dtype='int')
          N x 3 matrix with start, peak, end samples
      method : str
          'above_thresh', 'below_thresh'
      value : float
          for 'threshold', it's the value of threshold for the spindle selection.
  
      Returns
      -------
      ndarray (dtype='int')
          N x 3 matrix with start, peak, end samples