<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157033</link>
    <title>MATLAB Central Newsreader - How to count number of spikes in a signal (related to noise)</title>
    <description>Feed for thread: How to count number of spikes in a signal (related to noise)</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 02 Oct 2007 14:53:09 -0400</pubDate>
      <title>How to count number of spikes in a signal (related to noise)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157033#394790</link>
      <author>G.A.M. </author>
      <description>I have a signal which, if no noise is present, looks roughly&lt;br&gt;
like a parabola y = -X.^2. (i.e., x squared)&lt;br&gt;
&lt;br&gt;
The ideal signal should be smooth like a parabola. However,&lt;br&gt;
with noise, there can be many jagged spikes in the signal.&lt;br&gt;
&lt;br&gt;
I would like to count the number of these spikes. This is&lt;br&gt;
part of my effort to quantify noise in the signal.&lt;br&gt;
&lt;br&gt;
Can anyone suggest a good option for counting the spikes in&lt;br&gt;
a signal (in a given range)?&lt;br&gt;
&lt;br&gt;
The jagged spikes (noise) can occur along the up and down&lt;br&gt;
slopes or near the top and they can sometimes be very large&lt;br&gt;
- even more than 50% of the amplitude of the parabola.&lt;br&gt;
Individual spikes are usually very narrow as well.</description>
    </item>
    <item>
      <pubDate>Tue, 02 Oct 2007 16:07:29 -0400</pubDate>
      <title>Re: How to count number of spikes in a signal (related to noise)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157033#394805</link>
      <author>Bill </author>
      <description>Fit the data to your parabola model.&lt;br&gt;
&lt;br&gt;
use diff on the error channel to find values over a &lt;br&gt;
threshold spec.&lt;br&gt;
&lt;br&gt;
count the diffs over your acceptance level.</description>
    </item>
    <item>
      <pubDate>Tue, 02 Oct 2007 16:17:14 -0400</pubDate>
      <title>Re: How to count number of spikes in a signal (related to noise)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157033#394808</link>
      <author>Dave Robinson</author>
      <description>&quot;G.A.M. &quot; &amp;lt;x0zero@gmail.com&amp;gt; wrote in message &amp;lt;fdtm0l$hp2&lt;br&gt;
$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have a signal which, if no noise is present, looks &lt;br&gt;
roughly&lt;br&gt;
&amp;gt; like a parabola y = -X.^2. (i.e., x squared)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The ideal signal should be smooth like a parabola. &lt;br&gt;
However,&lt;br&gt;
&amp;gt; with noise, there can be many jagged spikes in the signal.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I would like to count the number of these spikes. This is&lt;br&gt;
&amp;gt; part of my effort to quantify noise in the signal.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Can anyone suggest a good option for counting the spikes &lt;br&gt;
in&lt;br&gt;
&amp;gt; a signal (in a given range)?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The jagged spikes (noise) can occur along the up and down&lt;br&gt;
&amp;gt; slopes or near the top and they can sometimes be very &lt;br&gt;
large&lt;br&gt;
&amp;gt; - even more than 50% of the amplitude of the parabola.&lt;br&gt;
&amp;gt; Individual spikes are usually very narrow as well.&lt;br&gt;
&lt;br&gt;
Just a thought, if your noise spikes are very sharp, as you &lt;br&gt;
suggest, it sounds like a task ideally tackled using &lt;br&gt;
Wavelets. That is to say the noise is mainly present in the &lt;br&gt;
fast detail, whereas your signal in mainly in the slow &lt;br&gt;
detail.&lt;br&gt;
&lt;br&gt;
Off the top of my head, I guess you could do something like &lt;br&gt;
a wavelet smooth, to remove the fast transient information, &lt;br&gt;
then subtract the smoothed parabola from the full waveform, &lt;br&gt;
to end up with just the noise, which you could then &lt;br&gt;
characterize much more easily. &lt;br&gt;
&lt;br&gt;
There is probably a lot mor sophisticated Wavelet &lt;br&gt;
techniques that you could use - perhaps one of the guru's &lt;br&gt;
will respond.&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
&lt;br&gt;
Dave Robinson</description>
    </item>
    <item>
      <pubDate>Wed, 03 Oct 2007 11:20:24 -0400</pubDate>
      <title>Re: How to count number of spikes in a signal (related to noise)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157033#394920</link>
      <author> Rune Allnor</author>
      <description>On 2 Okt, 16:53, &quot;G.A.M. &quot; &amp;lt;x0z...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; I have a signal which, if no noise is present, looks roughly&lt;br&gt;
&amp;gt; like a parabola y = -X.^2. (i.e., x squared)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The ideal signal should be smooth like a parabola. However,&lt;br&gt;
&amp;gt; with noise, there can be many jagged spikes in the signal.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I would like to count the number of these spikes. This is&lt;br&gt;
&amp;gt; part of my effort to quantify noise in the signal.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Can anyone suggest a good option for counting the spikes in&lt;br&gt;
&amp;gt; a signal (in a given range)?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The jagged spikes (noise) can occur along the up and down&lt;br&gt;
&amp;gt; slopes or near the top and they can sometimes be very large&lt;br&gt;
&amp;gt; - even more than 50% of the amplitude of the parabola.&lt;br&gt;
&amp;gt; Individual spikes are usually very narrow as well.&lt;br&gt;
&lt;br&gt;
Without having seen any of your data, this is what I&lt;br&gt;
would try first:&lt;br&gt;
&lt;br&gt;
1) Differentiate the data twice. The result ought to&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;be constant for a perfect parabola.&lt;br&gt;
2) Search the double-diff'ed data for large&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;deviations from this constant value.&lt;br&gt;
&lt;br&gt;
Rune</description>
    </item>
    <item>
      <pubDate>Wed, 03 Oct 2007 16:10:02 -0400</pubDate>
      <title>Re: How to count number of spikes in a signal (related to noise)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157033#394983</link>
      <author> &quot;G.A.M.</author>
      <description>On Oct 3, 8:37 am, &quot;Aslak Grinsted&quot; &amp;lt;r...@phunck.cmo&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; L=extr(x);&lt;br&gt;
&amp;gt; &amp;gt; Nmax=sum(L(1));&lt;br&gt;
&amp;gt; &amp;gt; Nmin=sum(L(2));&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Total number of spikes is&lt;br&gt;
&amp;gt; &amp;gt; N=Nmax+Nmin;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Hope it helps.&lt;br&gt;
&amp;gt; &amp;gt; Mira&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; yes you could use extr from the file exchange but you&lt;br&gt;
&amp;gt; probably still need to remove the parabola shape from the&lt;br&gt;
&amp;gt; signal. I think that wavelets is a bit overkill my self.&lt;br&gt;
&amp;gt; Perhaps you can subtract a windowed mean:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; L=extr(x-smooth(x,10));&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; or something similar ... or if it truly is like a parabola&lt;br&gt;
&amp;gt; then perhaps you could robustfit to find a good set of&lt;br&gt;
&amp;gt; model parameters and subtract that before counting local&lt;br&gt;
&amp;gt; extrema.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Also take a look at the stats output from robustfit. It&lt;br&gt;
&amp;gt; might be exactly the kind of things you need&lt;br&gt;
&amp;gt; for &quot;quantifying the noise&quot;.&lt;br&gt;
&lt;br&gt;
Thank you for your reply. Your two suggestions both sound very&lt;br&gt;
intriguing. I will try both. I am currently smoothing with a median&lt;br&gt;
filter and it works very well.&lt;br&gt;
&lt;br&gt;
Using extr on the differences between the raw signal and the median&lt;br&gt;
filtered signal is something I will try.&lt;br&gt;
&lt;br&gt;
I also like the idea of using the stats from robustfit and I will try&lt;br&gt;
this to see how well it works.&lt;br&gt;
&lt;br&gt;
Your replies have been very helpful.</description>
    </item>
    <item>
      <pubDate>Wed, 03 Oct 2007 16:23:21 -0400</pubDate>
      <title>Re: How to count number of spikes in a signal (related to noise)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157033#394986</link>
      <author> &quot;G.A.M.</author>
      <description>On Oct 3, 9:37 am, &quot;Dave Robinson&quot; &amp;lt;dave.robin...@somewhere.biz&amp;gt;&lt;br&gt;
wrote:&lt;br&gt;
&amp;gt; &quot;Aslak Grinsted&quot; &amp;lt;r...@phunck.cmo&amp;gt; wrote in message&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;fe02ea$md...@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; L=extr(x);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Nmax=sum(L(1));&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Nmin=sum(L(2));&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Total number of spikes is&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; N=Nmax+Nmin;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hope it helps.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Mira&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; yes you could use extr from the file exchange but you&lt;br&gt;
&amp;gt; &amp;gt; probably still need to remove the parabola shape from the&lt;br&gt;
&amp;gt; &amp;gt; signal. I think that wavelets is a bit overkill my self.&lt;br&gt;
&amp;gt; &amp;gt; Perhaps you can subtract a windowed mean:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; L=extr(x-smooth(x,10));&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; or something similar ... or if it truly is like a&lt;br&gt;
&amp;gt; parabola&lt;br&gt;
&amp;gt; &amp;gt; then perhaps you could robustfit to find a good set of&lt;br&gt;
&amp;gt; &amp;gt; model parameters and subtract that before counting local&lt;br&gt;
&amp;gt; &amp;gt; extrema.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Also take a look at the stats output from robustfit. It&lt;br&gt;
&amp;gt; &amp;gt; might be exactly the kind of things you need&lt;br&gt;
&amp;gt; &amp;gt; for &quot;quantifying the noise&quot;.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The reason that I originally suggested using Wavelets, is&lt;br&gt;
&amp;gt; that I thought it might be more robust than conventional&lt;br&gt;
&amp;gt; smoothing, as the original question never stated that noise&lt;br&gt;
&amp;gt; came from a zero mean distribution.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
You are correct. I need to do a lot of work in regard to the error&lt;br&gt;
distribution. So far I am just using my domain knowledge. I believe&lt;br&gt;
the errors tend to be more negative than positive and I do not believe&lt;br&gt;
the mean is zero.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt;This could have&lt;br&gt;
&amp;gt; ramifications to the shape of the recovered 'base'&lt;br&gt;
&amp;gt; distribution if the noise had a bias.&lt;br&gt;
&amp;gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
In practice, the median filter seems to work well. But that's just an&lt;br&gt;
untested assumption at this point. I have not tried wavelets because I&lt;br&gt;
don't know how to use a wavelet smooth yet (and I haven't found the&lt;br&gt;
help I need in the ML documentation yet).</description>
    </item>
  </channel>
</rss>

