I wonder if there is an easy and efficient way to mark a signal, which is a signal from photodiode attached to the monitor gathering the information about its luminance changes. Luminance changes abruptly.
In the following figure, I've pointed out the piece of signal from one luminance change from higher to lower value.
Now, the problem is, I don't know what would be the best way to "mark" gathered signal with "markers", ie. information when luminance change occured. Unfortunately, I do not have any code to review, cause, to be honest, I don't know where to start. I'll be grateful for your tips and advices. Thank you in advance.
PS It is crucial, to use a method, which will put a marker in a right place in time. The sampling frequency of the signal on images above was 1024 Hz and the
x scale is expressed in seconds.
Sample data: http://www.filedropper.com/data_6
When I tried to find a solution to my problem I got an idea which maybe is a good trail.
I've used a lowpass filter on my signal, ie.
# 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.5*sf), cf/(0.5*sf)), btype=btype, analog=0, output='ba') return ss.filtfilt(b, a, sig)
...for 40 Hz cut:
import IBD.ElectricalStimulation.Filters as filt filtered = filt.filt(signal, 1024, 40, btype='lowpass') py.plot(time_scale, filtered)
...which gave me:
Next, I derivated the filtered signal with step (n) equals 1, and then I raised it to the power of 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)
It results in:
Now the problem is, that I can't "mark" every single event. Some changes of the lumination are to low to be "seen" by derivative operation.