title: How can I smooth out these signal traces using python?
body: <p>The fast rise and exponential decay transients "spikes" you can see to the left in green represent neural activity that is changing over time.  in blue is a baseline reference signal.  both blue and green have some drift overtime as you can see. </p>
  
  <p>Because I was experiencing baseline drift and a generally noisy signal, I tried to high pass filter.  I was able to high-pass filter them by inverse low-pass filtering them (see the brief tutorial <a href="http://mpastell.com/2010/01/18/fir-with-scipy/" rel="nofollow noreferrer">here</a>).  to the right is the filtered signal.</p>
  
  <pre><code>N=101
  Fc=0.001  
  Fs=1.14  # it's imaging data being acquired at just over 1Hz
  
  h=scipy.signal.firwin(N, Fc, Fs/2)
  h=-h
  h[N/2] = h[N/2] + 1
  
  #this is filter design output from the tutorial
  #mfreqz(h)
  #show()
  
  y=scipy.signal.lfilter(h, 1.0, data)
  yy=scipy.signal.lfilter(h, 1.0, data2)
  </code></pre>
  
  <p>It worked to get rid of the drift, although it introduced some artifacts, such as introducing a "fake peak" at the beginning, shrinking the original green peaks, and causing what looks like "undershoot" at the bottom of one of the green peaks. </p>
  
  <p>I can probably tolerate some of these artifacts, but it is still too choppy for my liking.  Is there a way to smooth the noisiness here? </p>
  
  <p><img src="https://i.stack.imgur.com/6lgAa.png" alt="enter image description here"></p>