问题标签 [peakutils]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
358 浏览

python - AttributeError:模块 'peakutils' 没有属性 'indexes'

我正在尝试使用 peakutils 来查找峰值。这是我的代码:

但是,当我运行它时,它显示一个错误:

我曾尝试使用 python2.7 和 python3.6,但无论哪种方式都不起作用。

有人能帮我吗?

0 投票
4 回答
1459 浏览

python - 如何获得复杂 RTL-SDR 信号峰值的坐标?

我可以使用以下方法从 RTL-SDR 捕获信号:

如果我使用 Matplotlib 和 Seaborn 绘制信号,它们看起来像这样: 在此处输入图像描述

现在,我需要的是获得高于某个功率水平的所有峰值的坐标,例如,-20。

我发现了一个很有希望的各种Python 选项列表。但是,所有这些示例都使用了一个简单的 Numpy 数组,不同的算法可以轻松地使用它。

这是最好的尝试(因为我的猜测是我从 RTL-SDR 获得了一个复杂的信号,并且必须将其“转换”为具有实数值的数组?):

将这几行添加到上面的脚本中,我确实得到了一些输出,但是,首先,功率水平 -20 以上的五个峰值的值太多了。其次,这些值在给定的上下文中没有多大意义。

在此处输入图像描述

那么,我需要进行哪些更改才能获得有意义的结果,例如“Peak 1 is at 433.22 MHz”?

理想情况下,我应该得到类似的坐标Peak 1: X = 433.22, Y = -18.0,但我想一旦我知道如何获得正确的 X 值,我就可以自己弄清楚。

0 投票
2 回答
1109 浏览

python - Why does peakutils.peak.indexes() seem to ignore the provided threshold value?

I'm retrieving the arrays holding the power levels and frequencies, respectively, of a signal from the plt.psd() method:

enter image description here Please ignore the green and red signals. Just the blue one is relevant for this question.

I'm able to have the peakutils.peak.indexes() method return the X and Y coordinates of a number of the most significant peaks (of the blue signal):

enter image description here As can be seen, the coordinates fit the blue peaks quite nicely.

What I'm not satisfied with is the number of peak coordinates I receive from the peak.indexes() method. I'd like to have only the coordinates of all peaks above a certain power level returned, e.g., -25 (which would then be exactly 5 peaks for the blue signal). According to the documentation of the peak.indexes() method this is done by providing the desired value as thres parameter.

But no matter what I try as thres, the method seems to entirely ignore my value and instead solely rely on the min_dist parameter to determine the number of returned peaks.

  • What is wrong with my threshold value (which I believe means "peaks above the lower 60% of the plot" in my code now) and how do I correctly specify a certain power level (instead of a percentage value)?

[EDIT]

I figured out that apparently the thres parameter can only take positive values between float 0. and 1. So, by changing my line slightly as follows I can now influence the number of returned peaks as desired:

But that still leaves me with the question whether it's possible to somehow limit the result to the five highest peaks (provided num_of_peaks above thres >= 5).

I believe something like the following would return the five highest values:

Unfortunately, though, negative values seem to be interpreted as the highest values in my power_lvls array. Can this line be changed such that (+)10 would be considered higher than, e.g., -40? Or is there another (better?) solution?

[EDIT 2]

These are the values I get as the six "highest" peaks: enter image description here

After trying various things for hours without any improvement I'm starting to think that these are neither valleys nor peaks, just some "random" values?! Which leads me to believe that there is a problem with my argsort line that I have to figure out first?!

[EDIT 3]

The bottleneck.partition() method seems to return the correct values (even if apparently it does so in random order, not from leftmost peak to rightmost peak):

enter image description here Luckily, the order of the peaks is not important for what I have planned to do with the coordinates. I do, however, have to figure out yet how to match the Y values I have now to their corresponding X values ...

Also, while I do have a solution now, for learning purposes it would still be interesting to know what was wrong with my argsort attempt.

0 投票
0 回答
173 浏览

pycharm - 无法从 pycharm 安装 peakutils

我正在使用 python 2.7 并想安装 PeakUtils。我无法从 Pycharm 安装模块。

错误消息是非零退出代码 (1)。

建议的解决方案

尝试从系统终端运行此命令。确保使用为位于“/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7”的 Python 解释器安装的正确版本的“pip”。

命令输出

收集 PeakUtils==1.3.0 无法获取 URL https://pypi.python.org/simple/peakutils/:确认 ssl 证书时出现问题:[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 警报协议版本 (_ssl.c:590 ) - 跳过

找不到满足 PeakUtils==1.3.0 要求的版本(来自版本:)没有找到 PeakUtils==1.3.0 的匹配分布

0 投票
1 回答
950 浏览

python - 如何获得多个峰下的面积值

我有一些来自生物分析仪的数据,它给了我时间(x 轴)和吸光度值(y 轴)。时间是每 0.05 秒,从 32 秒到 138 秒,所以你可以想象我有多少数据点。我已经使用 plotly 和 matplotlib 创建了一个图形,只是为了让我有更多的库可以使用来找到解决方案,所以任何一个库中的解决方案都可以!我要做的是让我的脚本找到每个峰值下的区域并返回我的值。

这个片段获取我的 Y 值、X 值和峰值的索引。现在有没有办法得到每条曲线下的面积?假设有 15 个索引。

图表如下所示:在此处输入图像描述

0 投票
1 回答
152 浏览

scipy - 如何减少峰值检测问题中的错误?

我正在尝试识别心电图的 R 峰值。我使用以下代码行来执行此操作:

我得到以下输出: 在此处输入图像描述

但是,对于以下信号,它也不能准确地检测到较小的峰值。

在此处输入图像描述

是否有任何额外的参数可以添加到 scipy.signal.find_peaks_cwt 以使其更准确?或者使用 peakutils 的任何方式来做到这一点?

现在它已经停止错误检测小峰,但似乎仍然随机错过大峰,有人知道为什么吗? 在此处输入图像描述

0 投票
1 回答
60 浏览

python - 使用 reticulate 包从 Python peakutils 包调用函数时出现类型错误

我想peakutils在 R 中使用 Python 包。为此,我使用了该reticulate包。这是我想做的一个例子。

在此处输入图像描述

这很棒,并且按预期工作。现在,假设我想更改min_dist参数,根据文档,它是一个整数。我通过min_dist = 3L了,像这样:

并收到以下错误:

py_call_impl(callable, dots$args, dots$keywords) 中的错误:
TypeError: 只有一个元素的整数数组可以转换为索引

它期望一个具有单个元素的数组,该元素是一个整数,但是——据我所知——这正是我要传递的,所以为什么我会收到这个错误?

0 投票
0 回答
14 浏览

module - 为什么没有名为“peakutils”的模块?

您好,我通过 CMD 安装了模块 peakutils

点安装 peakutils

这是响应:要求已经满足:peakutils in

c:\users\karls\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (1.3.3) 要求已经满足:c:\users\karls\appdata 中的 numpy \local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages(来自 peakutils)(1.20.2)要求已经满足:c:\users\karls\appdata\local\packages 中的 scipy \pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages(来自 peakutils)(1.6.2)

但是,如果我想在用 Jupyter 编写的脚本中使用这个模块

响应:

ModuleNotFoundError:没有名为“peakutils”的模块

这是什么原因造成的,该怎么办?