2015-02-09 28 views
1

我不知道是否有一個簡單而有效的方法來標記信號,這是一個來自附着在監視器上的光電二極管收集有關其亮度變化信息的信號。亮度突然變化。標記信號

在下圖中,我指出了亮度從高到低的一個亮度變化。現在

enter image description here

,問題是,我不知道什麼是收集的聲音信號與「標誌」,即最好的方式來「標記」。信息發生亮度變化時。不幸的是,我沒有任何代碼來審查,因此,說實話,我不知道從哪裏開始。我會很感激你的提示和建議。先謝謝你。

enter image description here

PS這是至關重要的,使用的方法,這將放標誌物在正確的地方的時候。上面圖像上信號的採樣頻率是1024Hz,並且x比例以秒錶示。

的樣本數據: http://www.filedropper.com/data_6

UPDATE 2015年2月10日

當我試圖找到一個解決我的問題,我有一個想法,這可能是一個很好的線索。

我對信號使用了低通濾波器,即。爲40赫茲切

# File name "Filters.py" 

import scipy.signal as ss 

def filt(sig, sf, cf, btype='higphass'): 
    """ 
    :param sig: signal. 
    :param sf: sampling frequency. 
    :param cf: cut frequencies - array. 
    :param btype: bandpass type. 
    :return: bandpassed signal. 
    """ 
    if btype == 'higphass' or btype == 'lowpass': 
     b, a = ss.butter(3, Wn=cf/(0.5*sf), btype=btype, analog=0, output='ba') 
     return ss.filtfilt(b, a, sig) 
    elif btype == 'bandstop' or btype == 'bandpass': 
     b, a = ss.butter(3, Wn=(cf[0]/(0.5*sf), cf[1]/(0.5*sf)), btype=btype, analog=0, output='ba') 
     return ss.filtfilt(b, a, sig) 

...:

import IBD.ElectricalStimulation.Filters as filt 

filtered = filt.filt(signal, 1024, 40, btype='lowpass') 
py.plot(time_scale, filtered) 

...這給了我:

enter image description here

接着,我與衍生化步驟中的濾波後的信號(n)的等於1,然後我將它提升到2的冪。

# Derivate signal. 
step = 1 
accuracy_range = 9 
derivative = np.diff(filtered, n=step) 
derivative = np.append(derivative, np.zeros(step)) ** 2 
derivative[derivative > accuracy_range] = np.max(filtered) 
derivative[derivative < accuracy_range] = 0 
py.plot(time_scale, derivative) 

它導致:

enter image description here

現在的問題是,我不能「標記」每一個事件。偏差的一些變化低到可以通過微分操作「看到」。

+0

你能上傳一些示例數據? – 2015-02-09 15:07:21

+0

已添加。 'data.txt'文件中的數據是使用'numpy.savetxt()'方法編寫的。 Numpy數組本身以'float32'類型編碼。 – bluevoxel 2015-02-09 15:31:35

回答

0

好的。所以我找到了解決我的問題的解決方案。這不是完美的,但它的工作原理。目前。它看起來如下:

def walk_on_the_beach(sig, t, interval=1000): 
    """ 
    :param sig: signal. 
    :param t: threshold. 
    :param interval: interval between next value check (ms). 
    """ 
    last_value = 0 
    interval_flag = True 
    interval_iterator = 0 
    markers = np.zeros(np.size(sig)) 
    for i in np.arange(np.size(sig)): 
     absolute = np.abs(last_value - sig[i]) 
     last_value = sig[i] 
     if interval_flag: 
      if absolute > t: 
       markers[i] = np.max(sig) 
       interval_flag = False 
     else: 
      if interval_iterator == interval: 
       interval_flag = True 
       interval_iterator = 0 
      else: 
       interval_iterator += 1 

    return markers 

py.plot(time_scale[:100000], walk_on_the_beach(filtered, 0.02)) 

enter image description here