code: def filter_(data, axis='time', low_cut=None, high_cut=None, order=4,
              ftype='butter', Rs=None, notchfreq=50, notchquality=25):
      nyquist = data.s_freq / 2.
      btype = None
      if low_cut is not None and high_cut is not None:
          if low_cut > nyquist or high_cut > nyquist:
              raise ValueError('cutoff has to be less than Nyquist '
                               'frequency')
          btype = 'bandpass'
          Wn = (low_cut / nyquist,
                high_cut / nyquist)
      elif low_cut is not None:
          if low_cut > nyquist:
              raise ValueError('cutoff has to be less than Nyquist '
                               'frequency')
          btype = 'highpass'
          Wn = low_cut / nyquist
      elif high_cut is not None:
          if high_cut > nyquist:
              raise ValueError('cutoff has to be less than Nyquist '
                               'frequency')
          btype = 'lowpass'
          Wn = high_cut / nyquist
      if btype is None and ftype != 'notch':
          raise TypeError('You should specify at least low_cut or high_cut')
      if Rs is None:
          Rs = 40
      if ftype == 'notch':
          b_a = [iirnotch(w0 / nyquist, notchquality) for w0 in arange(notchfreq, nyquist, notchfreq)]
      else:
          lg.debug('order {0: 2}, Wn {1}, btype {2}, ftype {3}'
                   ''.format(order, str(Wn), btype, ftype))
          b_a = [iirfilter(order, Wn, btype=btype, ftype=ftype, rs=Rs), ]
      fdata = data._copy()
      for i in range(data.number_of('trial')):
          x = data.data[i]
          for b, a in b_a:
              x = filtfilt(b, a, x, axis=data.index_of(axis))
          fdata.data[i] = x
      return fdata