2013-10-03 69 views
2

我有受電流尖峯影響的加速度計數據的數據集。加速度計數據中的Matlab濾波器電位尖峯

我正在尋找一種很好的方法來濾除或減少這些峯值,因爲需要在這些數據上計算FFT和其他統計指標(如峯度和偏度)的滾動窗口。我不能簡單地刪除這些異常值或將它們替換爲NaN。 採樣2000 [赫茲]

到現在爲止我已經嘗試了MATLAB 2012B:

  • 小波去噪(Haar小波)
  • 中值濾波
  • Despike和iterpolate方法

你能建議一個適當的方法來處理這些數據嗎?

Download example dataset

+2

您是否嘗試過舊的低通濾波?爲什麼它不起作用? –

+0

嘗試,但它切斷了太多的信息,並沒有消除尖峯:( –

+0

你知道綠色標記的價值,或者是你在尋找一個自動化的算法來計算這個值? – user2469775

回答

2

我會建議一些地方平滑。通過定義閾值並平均低於和高於所有值。

Af = data.example1; 
% Thresholds 
Tl = -0.6; 
To = 0.6; 

peaks = find(Af < Tl | Af > To); 
Af(peaks) = (Af(peaks-1) + Af(peaks+1))/2; 

這種方法的問題是您的大綱有時包含多達6個樣本。 所以你需要使用一個while循環來平滑多個步驟:

Af = data.example1; 
% Thresholds 
Tl = -0.6; 
To = 0.6; 

% initialisation 
peaks = find(Af < Tl | Af > To); 
counter = 0; 

while ~isempty(peaks) 
    peaks = find(Af < Tl | Af > To); 
    Af(peaks) = (Af(peaks-1) + Af(peaks+1))/2; 
    counter=counter+1; 
end 

後6次迭代你會得到如下結果: enter image description here

1

我已經非常使用的文件despiking從MATLAB中央文件交換對於類似的問題效果很好,儘管我看到你也嘗試過。

我採取的另一種方法是將峯值視爲統計異常值,並使用this function刪除它們,它使用。 (NIST網站因爲顯而易見的原因而關閉,所以這裏是Google cached版本)

編輯補充:我錯了。我的despiking算法不是來自上面鏈接的文件交換功能。它實際上是從期刊文章中刪除的(代碼在文章的補充信息中列出,但它們沒有將代碼發佈到文件交換器)。該文件是:

去除噪聲的實用方法:應用到尖峯,非平穩準週期噪聲和基線漂移

德爾菲娜斯坦,金H.帕克和馬丁G. Boutelle

Anal. Chem., 2009, 81 (12), pp 4987–4994由於版權由美國化學學會和作者持有,我不能在這裏複製代碼,但如果您有權訪問大學圖書館帳戶,則可以下載副本。如果你不這樣做,我會把鏈接留在文件交換版本中,但我沒有使用它,所以我不能保證它的功效。

1

版主合併了這個問題this question - 這就是爲什麼它看起來有點凌亂。這個答案考慮了第二個問題中的其他問題!

下面是不是一個完全乾淨的解決方案,將代碼從my previous answer採用,但我添加了一個例外你的情況,所以你不需要在你的數據的開始和/或結束手動刪除值。它只丟棄這些不應該導致問題的無效值。

Af = csvread(strcat('example_data_with_peak.txt'),5,0); 

% Thresholds 
Tl = -0.04; 
To = 0.04; 

% initialisation 
peaks = find(Af < Tl | Af > To); 
counter = 0; 

while ~isempty(peaks) 
    peaks = find(Af < Tl | Af > To); 
    try 
     Af(peaks) = (Af(peaks-1) + Af(peaks+1))/2; 
    catch 
     if peaks(1) == 1 
      Af(1) = 0; 
     else 
      Af(end) = 0; 
     end 
    end 
    counter=counter+1; 
end 

figure(2); 
plot(Af) 

enter image description here

爲了確定您可以使用somethink這樣的門檻,但也相當蠻力:

thresh = 15*mean(abs(findpeaks(Af))); 
+0

非常感謝! :-) –

+1

不客氣,我添加了一行,如何確定門檻。沒有關於您的特定問題的知識很難找到更好的解決方案。 – thewaywewalk

0

對於其他人可能需要這種這裏就是我最終使用。這裏的數據文件data file link

由於去@thewaywewalk

Matlab filter electical spikes in accelerometric data

clear all, clc,clf,tic 
aa=csvread(strcat('/tmp/example_data_with_peak.txt'),5,0); %will skip the first 5 rows that are text and zeros 
figure(1); 
plot(aa) 
Af=aa; 
% Thresholds 
Tl = -mean(abs(aa))*10 
To =mean(abs(aa))*10 

% initialisation 
[peaks_r,peaks_c] = find(Af < Tl | Af > To); 
peaks = find(Af < Tl | Af > To); 

counter = 0; 

while ~isempty(peaks) 
    peaks = find(Af < Tl | Af > To); 
    try 
     Af(peaks) = (Af(peaks-1) + Af(peaks+1))/2; 
    catch 
     if peaks(1) == 1 
      Af(1) = 0; 
     else 
      Af(end) = 0; 
     end 
    end 
    counter=counter+1; 
end 
counter 
figure(2); 
plot(Af) 

下面是之前和之後的圖像。

Before and After