如何在半复杂情况下正确检测局部最大值和曲线窗口? [英] How to detect local maxima and curve windows correctly in semi complex scenarios?

查看:145
本文介绍了如何在半复杂情况下正确检测局部最大值和曲线窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列数据,需要在一定数量的读数(窗口大小)内检测系列中的峰值,并排除一定水平的背景噪音。我还需要捕获可感知曲线的起始点和停止点(即,当它开始滴答,然后停止滴答)。

I have a series of data and need to detect peak values in the series within a certain number of readings (window size) and excluding a certain level of background "noise." I also need to capture the starting and stopping points of the appreciable curves (ie, when it starts ticking up and then when it stops ticking down).

数据很高

这里是一个快速草图,捕捉我目前最常见的情景:

Here's a quick sketch that captures the most common scenarios that I'm up against visually:

我尝试的一种方法是沿着曲线传递一个大小为X的窗口向后检测峰。它开始工作很好,但我错过了很多条件最初不是预期。我开始工作的另一种方法是一个不断增长的窗口,将发现更长的持续时间曲线。另一种方法使用更多基于微积分的方法来监视一些速度/梯度方面。没有一个似乎击中了甜蜜的点,可能是因为我缺乏统计分析的经验。

One method I attempted was to pass a window of size X along the curve going backwards to detect the peaks. It started off working well, but I missed a lot of conditions initially not anticipated. Another method I started to work out was a growing window that would discover the longer duration curves. Yet another approach used a more calculus based approach that watches for some velocity / gradient aspects. None seemed to hit the sweet spot, probably due to my lack of experience in statistical analysis.

也许我需要使用某种统计分析软件包来掩盖我的基础vs写我自己的算法?或者有没有一种有效的方法直接用SQL处理这种局部最大技术?我不知道如何有效地处理这个问题。我尝试的每种方法似乎是我不断缺失各种阈值,检测太多的峰值或不捕获整个事件(在读取过程中报告峰值数据点过早)。

Perhaps I need to use some kind of a statistical analysis package to cover my bases vs writing my own algorithm? Or would there be an efficient method for tackling this directly with SQL with some kind of local max techniques? I'm simply not sure how to approach this efficiently. Each method I try it seems that I keep missing various thresholds, detecting too many peak values or not capturing entire events (reporting a peak datapoint too early in the reading process).

最终,这是在Ruby中实现的,所以如果你可以建议最有效和正确的方法来解决这个问题与Ruby,不胜感激,但 我开放一个语言不可知的算法方法 。或者是否有某个库可以解决我在检测最大峰值的情况下遇到的各种问题?

Ultimately this is implemented in Ruby and so if you could advise as to the most efficient and correct way to approach this problem with Ruby that would be appreciated, however I'm open to a language agnostic algorithmic approach as well. Or is there a certain library that would address the various issues I'm up against in this scenario of detecting the maximum peaks?

推荐答案

我的想法很简单,在得到你感兴趣的窗口后,你会需要找到所有的峰值在这个窗口,你可以只是比较最后一个值与下一个,在这之后,你会有峰值发生在哪里,你可以决定在哪里最佳峰值。

my idea is simple, after get your windows of interest you will need find all the peaks in this window, you can just compare the last value with the next , after this you will have where the peaks occur and you can decide where are the best peak.

我在matlab中写了一个简单的源代码来显示我的想法!

I wrote one simple source in matlab to show my idea!

从音频文件: - )

waveFile='Chick_eco.wav';

[y, fs, nbits]=wavread(waveFile);

subplot(2,2,1); plot(y); legend('Original signal');

startIndex=15000;
WindowSize=100;
endIndex=startIndex+WindowSize-1;
frame = y(startIndex:endIndex);

nframe=length(frame)

%find the peaks 

peaks = zeros(nframe,1);

k=3;

while(k <= nframe - 1)
    y1 = frame(k - 1);
    y2 = frame(k);
    y3 = frame(k + 1);
    if (y2 > 0)
    if (y2 > y1 && y2 >= y3)
        peaks(k)=frame(k);
    end
    end
    k=k+1;
end



peaks2=peaks;
peaks2(peaks2<=0)=nan;


subplot(2,2,2); plot(frame); legend('Get Window Length = 100');


subplot(2,2,3); plot(peaks); legend('Where are the PEAKS');



subplot(2,2,4); plot(frame); legend('Peaks in the Window');
hold on; plot(peaks2, '*');


for j = 1 : nframe
if (peaks(j) > 0)
     fprintf('Local=%i\n', j);
     fprintf('Value=%i\n', peaks(j));   

end
end


%Where the Local Maxima occur
[maxivalue, maxi]=max(peaks)

您可以看到所有的峰及其出现位置

you can see all the peaks and where it occurs

37

Value = 3.266296e-001

Value=3.266296e-001

Local = 51

Local=51

Value = 4.333496e-002

Value=4.333496e-002

Local = 65

Local=65

Value = 5.049438e-001

Value=5.049438e-001

Local = 80

Local=80

Value = 4.286804e-001

Value=4.286804e-001

Local = 84

Local=84

Value = 3.110046e-001

Value=3.110046e-001

这篇关于如何在半复杂情况下正确检测局部最大值和曲线窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆