To apply window function on Wigner-Ville Distribut

2019-02-21 00:55发布

问题:

We were thinking here how to create Hamming-64 window of overlap 64. It is done by

h = hamming(64);
h2 = hamming(38);
h = conv(h, h2);

Now, we are thinking how you can apply this window function to the resulted variabels of the Wigner-Ville Distribution function of Auger et al in Time-Frequency Toolbox. The function tfrwv.m does not have any parameter for window function.

So we have these variables

[B,T,F] = tfrwv(data, 1:length(data), length(data));

Here is one answer to related problem, but not completely the same. One says that apply the window function to the results

Just multiply, point-by-point

The dimensions of h are 101x1 double, while T and F 5001x1 double. So extrapolation seems to be needed to the window vector if multiplying point-by-point.

One more explanation here

About half way through the second code block, I apply a window function to a buffered signal. This is effectively a vector multiplication of the window function with each buffered block of time series data. I just use a sneaky diagonal matrix trick to do it efficiently.

How can you apply a window function to the variables B, T, and F?

回答1:

Check out this paper on Wigner distribution. From page 8 to 11. I think tfr(indices,icol) = x(ti+tau,1) .* conj(x(ti-tau,xcol)); in the code realize the formula (23). The sum and exponential part is equivalent to tfr= fft(tfr);. Or you also can regard those two lines of code I cited as formula (24). Note: in both the paper and code they assume the signal is periodic with N/2, where N is length(data). It's Ok that you don't need to change your data here. They just sort kinds of extending the original data.

Cited from the paper, Before processing the WDF, a modified Hamming window is applied to the time domain signal to reduce the leakage caused by the discontinuity of the finite record of data, which will be called as data tapering. To my understanding, what you can do here is

data1 = conv(h,data);
[B,T,F] = tfrwv(data1, 1:length(data1), length(data1)); 

My answer is done based on your implementation. You can have a try now.


What I don't fully understand is the method that you created Hamming-64 window of overlap 60%. In spectrogram, the code split your data into small segments with the length of each 64. If you want to achieve the same effect of spectrogram with tfrwv, I guess you may also need to split your data, and use conv(data(1:64),hamming(64)), conv(data(38:101),hamming(64)),conv(data(76:139),hamming(64)),....as the input of tfrwv respectively.



回答2:

Extension to lennon310's answer.

I run

data1 = conv(h,data);
[B,T,F] = tfrwv(data1, 1:length(data1), length(data1));

and then plot it with picture of no windowing

I know that the picture without windowing is proper, since I can see there 60 Hz horizontal line caused by the settings of the measurement system in MIT-BIH arrhythmia database. The patient is 68 years with old myocardii infarctum so the beats per second reaching 65 is proper with this method.

The picture with the implementation of my original version of hamming-64 is not proper. The person would not live long with such beats per minute.



回答3:

2nd Extension to lennon310's answer

data1 = conv(data(1:64),hamming(64)); [B,T,F] = tfrwv(data1, 1:length(data1), length(data1));    
data1 = conv(data(38:101),hamming(64)); [b,t,f] = tfrwv(data1, 1:length(data1), length(data1));

I do not know how I should combine the picees of data from b to B. Matrix diagonalization does not seem to be the appropriate choice.

I run using only hamming(64) for simplification, discussed here about implementation of matrix diagonalization

    B = 0; T = 0; F = 0;    
    data1 = conv(data(1 : 64),hamming(64)); [B,T,F] = tfrwv(data1, 1:length(data1), length(data1));    
    for i=1:10
        data1 = conv(data( 1 + i*37 : 64 + i*37 ),hamming(64)); [b,t,f] = tfrwv(data1, 1:length(data1), length(data1));    
        B = blkdiag(B,b); T = [T t]; F = [F; f];
    end

I get

This is not proper result. The problem is in understanding what the matrix B should be. What should the matrix B look like after adding b to B?



回答4:

There was one mistake and its symptoms in my 3rd extension to lennon310's answer. 4th extension to lennon310's answer

I run

h = hamming(64);
h2 = hamming(38);
h = conv(h, h2);    
B = 0; T = 0; F = 0;    
data1 = filter(data(1 : 64),1,h); [B,T,F] = tfrwv(data1, 1:length(data1), length(data1));    
for i=1:133
    data1 = filter(data( 1 + i*37 : 64 + i*37 ),1,h); [b,t,f] = tfrwv(data1, 1:length(data1), length(data1));    
    B = [B b']; T = [T t]; F = [F; f];       
end
data1 = filter(data(4959 : 5001),1,h); [b,t,f] = tfrwv(data1, 1:length(data1), length(data1));    
B = [B b']; T = [T t]; F = [F; f];       
T = 49.8899*T;      % dummy constant to get appropriate time interval

and get pictures like this

I have not managed to show all thin peaks in one picture. A new question about it here.

I am plotting this by

t = 1/360; % 360 samples per second
fs = 360.5;
imagesc(T*t, F*fs, abs(B))

The algorithm is accumulating the points to the right dimension. I am not sure if multiplying by the dummy constant is the right way to go earlier.