【问题标题】:How do I apply a standard deviation threshold when calculating a histogram from signal data in MATLAB从 MATLAB 中的信号数据计算直方图时如何应用标准偏差阈值
【发布时间】:2016-09-29 22:37:25
【问题描述】:

我正在使用 MATLAB 计算 EMG 信号的特征,方法是将 EMG 信号分割成 200 个样本的窗口,然后计算每个窗口的特征。

请帮助我尝试使用直方图功能。

我可以使用以下代码轻松地为一个数据窗口生成一个 bin 向量:

    binCount = 9;
    [histBins, ~] = histcounts(dataWindow, binCount);

但是,我正在进行的实验表明,直方图按照 3 个标准差 (sigma) 阈值分为 9 个 bin。我对阈值如何适应生成直方图箱感到困惑。

是否为每个数据窗口计算了一个 3 sigma 阈值,并且落在该阈值内的数据点用于生成直方图?示例伪代码:

    for i = 1:numDataWindows
        dataWindow = windows(i);
        Calculate 3 standard deviations threshold using dataWindow
        Get data points from dataWindow that fall within threshold
        Generate histogram on data points within threshold
        ...
        Store histogram bins for later use
    end

或者是在开窗之前从整个数据信号生成 3 sigma 阈值,以便在生成每个直方图之前将相同的阈值应用于每个数据窗口?

【问题讨论】:

  • 添加实验说明链接?
  • 嘿@Dan。抱歉迟了回应。昨天和我的主管讨论了这个问题后,我们决定选择第一个选项。我正在查看的论文中的实验描述并不多,但我添加了一张图片来提供我的意思的视觉解释:imgur.com/tphJrP9。我将采用一个数据窗口并计算该窗口的 3 sigma 阈值。然后我将采用该范围内的信号(最顶部和最底部的虚线)并将直方图应用于信号的该部分。我将为每个数据窗口执行此操作。
  • 那么您现在能回答这个问题还是仍然卡住了?
  • 抱歉回复晚了。花了一段时间才有机会编写一些 MATLAB 代码来尝试一下。不,我不再被困住了。我将发布我正在使用的代码作为答案,因此任何其他有类似查询或可能替代建议的人都可以使用它

标签: matlab histogram feature-extraction threshold standard-deviation


【解决方案1】:

因此,在回答我的问题时,我选择了第一个选项,即采用数据窗口并计算该窗口的 3 sigma 阈值。然后,所有落在该阈值内的数据都将用于直方图特征。如果有人对此问题有其他观点,请随时发表评论或提供您自己的解决方案。

这是我为单个数据窗口编写的测试 MATLAB 代码:

    % Get a single data window
    win = myChanWinData(1);

    % Find mean and standard deviation
    winMu = mean(win);
    winStd = std(win);

    % Get upper and lower boundaries of 3 sigma threshold
    k = 3;
    upper = winMu + winStd * k;
    lower = winMu - winStd * k;

    % Find indices where data falls within upper and lower boundaries
    threshStatus = not(abs(sign(sign(lower - win) + sign(upper - win))));
    myOnes = find(threshStatus == 1);

    % Extract the data values at the found positive indices
    newData = win(myOnes);

    % Generate histogram using data within our desired threshold
    numBins = 9;
    minV = min(newData);
    maxV = max(newData);
    [binCounts, ~] = histcounts(newData, numBins, 'BinLimits', [minV, maxV]);

请注意,我找到索引的行(以 "threshStatus =" 开头)取自 @Angus 对此问题的回答:http://uk.mathworks.com/matlabcentral/answers/8556-how-to-find-vector-elements-between-two-values-efficiently

【讨论】:

    猜你喜欢
    • 2021-06-14
    • 2017-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-01
    • 2017-09-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多