def spec_weight(freqs, hp=None, lp=None, bleed=7):
  freqs = np.abs(freqs)  # Make filter symmetrical for negative frequencies.
  bleed = int(bleed)

  # construct brick-wall response
  response = np.ones(freqs.size)
  if lp:
    response[freqs > float(lp)] = 0.
  if hp:
    response[freqs < float(hp)] = 0.

  # smooth spectrum to prevent ringing
  win, pad = np.hanning(bleed), np.ones(bleed)
  padded = np.hstack([pad * response[0], response, pad * response[-1]])
  response = np.convolve(padded, win / np.sum(win), 'same')
  return response[pad.size:-pad.size]
Construct weight vector for filtering in the frequency domain.
dataset/ETHPy150Open breuderink/eegtools/eegtools/featex.py/spec_weight