code: def peak_in_power(events, dat, s_freq, method, value=None):
      
      dat = diff(dat)  # remove 1/f
  
      peak = empty(events.shape[0])
      peak.fill(nan)
  
      if method is not None:
          for i, one_event in enumerate(events):
  
              if method == 'peak':
                  x0 = one_event[1] - value / 2 * s_freq
                  x1 = one_event[1] + value / 2 * s_freq
  
              elif method == 'interval':
                  x0 = one_event[0]
                  x1 = one_event[2]
  
              if x0 < 0 or x1 >= len(dat):
                  peak[i] = nan
              else:
                  f, Pxx = periodogram(dat[x0:x1], s_freq)
                  idx_peak = Pxx[f < MAX_FREQUENCY_OF_INTEREST].argmax()
                  peak[i] = f[idx_peak]
  
      return peak
docs: Define peak in power of the signal.
  
      Parameters
      ----------
      events : ndarray (dtype='int')
          N x 3 matrix with start, peak, end samples
      dat : ndarray (dtype='float')
          vector with the original data
      s_freq : float
          sampling frequency
      method : str or None
          'peak' or 'interval'. If None, values will be all NaN
      value : float
          size of the window around peak, or nothing (for 'interval')
  
      Returns
      -------
      ndarray (dtype='float')
          vector with peak frequency