Filtering peaks to find number of pulses

5 visualizzazioni (ultimi 30 giorni)
Yargo Duran Pacheco
Yargo Duran Pacheco il 19 Mag 2015
Modificato: Armindo il 21 Feb 2019
Greetings,
As shown in the image below, I am trying to filter these "false" peaks(get rid of the close ones, which have the same "height" as the previous one) and thus find the number of pulses. Looking over the Help section and this forum I couldn't find any questions exactly like this one.
I've used this command to plot this graphic: findpeaks(data,'MinPeakProminence',3);
Thanks in advance.

Risposte (3)

Greg Dionne
Greg Dionne il 4 Apr 2016
It looks like you are using FINDPEAKS to find the flat parts of pulses. This might not be the right approach, but in a pinch, you can simply add a very small number to the input to prevent equal-height peaks that all appear within the same range.
Something like:
findpeaks(data(:) + 0.001*(1:numel(data))','MinPeakProminence',3)
If you want the first peak of each range (rather than the last) you can do something like this:
findpeaks(data(:) - 0.001*(1:numel(data))','MinPeakProminence',3)
Since you have the Signal Processing Toolbox, have a look at pulsewidth() or midcross(). That might be more in line of what you wish to do.

Image Analyst
Image Analyst il 19 Mag 2015
Modificato: Image Analyst il 19 Mag 2015
Which of the two peaks do you want? Or do you want the average location? Can't you adjust the findpeaks() options to get rid of those? If not, find out when the peak locations are within some specified distance of each other and take either the first, second, or average index location instead of both of them. Attach your data if you want more help.
  5 Commenti
Joseph Cheng
Joseph Cheng il 19 Mag 2015
Modificato: Joseph Cheng il 19 Mag 2015
Additionally, i would recommend using a threshold and then using something like diff to discover the rising and falling edge positions to count the number of pulses. This would also help determine which points are noise spikes like the 1 point wide pulses. are they real pulses, part of either neighboring pulses but a drop in signal made it look like a pulse, or not even a pulse but a noise spike while the signal was low?
Image Analyst
Image Analyst il 19 Mag 2015
2 was the threshold. If some of the pulses might be isolated noise spikes, then you could use regionprops() to detect and eliminate any pulses that did not span the minimum required number of indexes, like for example the thin pulse where x is about 90.

Accedi per commentare.


Armindo
Armindo il 21 Feb 2019
Modificato: Armindo il 21 Feb 2019
rising and falling edge can be found like this:
%Get the rising edge, is given by default matlab function findpeaks like this:
% rising edge
[pks,RisingEdgeIndx] = findpeaks(data)
%falling edge
% first Invert the signal like this
dataRev = data(end:-1:1);
[pks,locs] = findpeaks(dataRev)
% get the right indexes
FallingEdgeIndx = length(data) - locs +1;
FallingEdgeIndx = FallingEdgeIndx(end:-1:1);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by