Thread Subject: How to count number of spikes in a signal (related to noise)

Subject: How to count number of spikes in a signal (related to noise)

From: G.A.M.

Date: 2 Oct, 2007 14:53:09

Message: 1 of 6

I have a signal which, if no noise is present, looks roughly
like a parabola y = -X.^2. (i.e., x squared)

The ideal signal should be smooth like a parabola. However,
with noise, there can be many jagged spikes in the signal.

I would like to count the number of these spikes. This is
part of my effort to quantify noise in the signal.

Can anyone suggest a good option for counting the spikes in
a signal (in a given range)?

The jagged spikes (noise) can occur along the up and down
slopes or near the top and they can sometimes be very large
- even more than 50% of the amplitude of the parabola.
Individual spikes are usually very narrow as well.

Subject: How to count number of spikes in a signal (related to noise)

From: Bill

Date: 2 Oct, 2007 16:07:29

Message: 2 of 6

Fit the data to your parabola model.

use diff on the error channel to find values over a
threshold spec.

count the diffs over your acceptance level.


Subject: How to count number of spikes in a signal (related to noise)

From: Dave Robinson

Date: 2 Oct, 2007 16:17:14

Message: 3 of 6

"G.A.M. " <x0zero@gmail.com> wrote in message <fdtm0l$hp2
$1@fred.mathworks.com>...
> I have a signal which, if no noise is present, looks
roughly
> like a parabola y = -X.^2. (i.e., x squared)
>
> The ideal signal should be smooth like a parabola.
However,
> with noise, there can be many jagged spikes in the signal.
>
> I would like to count the number of these spikes. This is
> part of my effort to quantify noise in the signal.
>
> Can anyone suggest a good option for counting the spikes
in
> a signal (in a given range)?
>
> The jagged spikes (noise) can occur along the up and down
> slopes or near the top and they can sometimes be very
large
> - even more than 50% of the amplitude of the parabola.
> Individual spikes are usually very narrow as well.

Just a thought, if your noise spikes are very sharp, as you
suggest, it sounds like a task ideally tackled using
Wavelets. That is to say the noise is mainly present in the
fast detail, whereas your signal in mainly in the slow
detail.

Off the top of my head, I guess you could do something like
a wavelet smooth, to remove the fast transient information,
then subtract the smoothed parabola from the full waveform,
to end up with just the noise, which you could then
characterize much more easily.

There is probably a lot mor sophisticated Wavelet
techniques that you could use - perhaps one of the guru's
will respond.

Regards

Dave Robinson

Subject: How to count number of spikes in a signal (related to noise)

From: Rune Allnor

Date: 3 Oct, 2007 11:20:24

Message: 4 of 6

On 2 Okt, 16:53, "G.A.M. " <x0z...@gmail.com> wrote:
> I have a signal which, if no noise is present, looks roughly
> like a parabola y = -X.^2. (i.e., x squared)
>
> The ideal signal should be smooth like a parabola. However,
> with noise, there can be many jagged spikes in the signal.
>
> I would like to count the number of these spikes. This is
> part of my effort to quantify noise in the signal.
>
> Can anyone suggest a good option for counting the spikes in
> a signal (in a given range)?
>
> The jagged spikes (noise) can occur along the up and down
> slopes or near the top and they can sometimes be very large
> - even more than 50% of the amplitude of the parabola.
> Individual spikes are usually very narrow as well.

Without having seen any of your data, this is what I
would try first:

1) Differentiate the data twice. The result ought to
   be constant for a perfect parabola.
2) Search the double-diff'ed data for large
   deviations from this constant value.

Rune

Subject: How to count number of spikes in a signal (related to noise)

From: "G.A.M.

Date: 3 Oct, 2007 16:10:02

Message: 5 of 6

On Oct 3, 8:37 am, "Aslak Grinsted" <r...@phunck.cmo> wrote:
> > L=extr(x);
> > Nmax=sum(L(1));
> > Nmin=sum(L(2));
>
> > Total number of spikes is
> > N=Nmax+Nmin;
>
> > Hope it helps.
> > Mira
>
> yes you could use extr from the file exchange but you
> probably still need to remove the parabola shape from the
> signal. I think that wavelets is a bit overkill my self.
> Perhaps you can subtract a windowed mean:
>
> L=extr(x-smooth(x,10));
>
> or something similar ... or if it truly is like a parabola
> then perhaps you could robustfit to find a good set of
> model parameters and subtract that before counting local
> extrema.
>
> Also take a look at the stats output from robustfit. It
> might be exactly the kind of things you need
> for "quantifying the noise".

Thank you for your reply. Your two suggestions both sound very
intriguing. I will try both. I am currently smoothing with a median
filter and it works very well.

Using extr on the differences between the raw signal and the median
filtered signal is something I will try.

I also like the idea of using the stats from robustfit and I will try
this to see how well it works.

Your replies have been very helpful.

Subject: How to count number of spikes in a signal (related to noise)

From: "G.A.M.

Date: 3 Oct, 2007 16:23:21

Message: 6 of 6

On Oct 3, 9:37 am, "Dave Robinson" <dave.robin...@somewhere.biz>
wrote:
> "Aslak Grinsted" <r...@phunck.cmo> wrote in message
>
> <fe02ea$md...@fred.mathworks.com>...
>
>
>
> > > L=extr(x);
> > > Nmax=sum(L(1));
> > > Nmin=sum(L(2));
>
> > > Total number of spikes is
> > > N=Nmax+Nmin;
>
> > > Hope it helps.
> > > Mira
>
> > yes you could use extr from the file exchange but you
> > probably still need to remove the parabola shape from the
> > signal. I think that wavelets is a bit overkill my self.
> > Perhaps you can subtract a windowed mean:
>
> > L=extr(x-smooth(x,10));
>
> > or something similar ... or if it truly is like a
> parabola
> > then perhaps you could robustfit to find a good set of
> > model parameters and subtract that before counting local
> > extrema.
>
> > Also take a look at the stats output from robustfit. It
> > might be exactly the kind of things you need
> > for "quantifying the noise".
>
> The reason that I originally suggested using Wavelets, is
> that I thought it might be more robust than conventional
> smoothing, as the original question never stated that noise
> came from a zero mean distribution.


You are correct. I need to do a lot of work in regard to the error
distribution. So far I am just using my domain knowledge. I believe
the errors tend to be more negative than positive and I do not believe
the mean is zero.


>This could have
> ramifications to the shape of the recovered 'base'
> distribution if the noise had a bias.
>


In practice, the median filter seems to work well. But that's just an
untested assumption at this point. I have not tried wavelets because I
don't know how to use a wavelet smooth yet (and I haven't found the
help I need in the ML documentation yet).



Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
spike jones Bill 2 Oct, 2007 12:10:06
noise G.A.M. 2 Oct, 2007 10:55:05
signals G.A.M. 2 Oct, 2007 10:55:05
variance G.A.M. 2 Oct, 2007 10:55:05
filters G.A.M. 2 Oct, 2007 10:55:05
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com