# Disparity in phase calculation between STFT and Hilbert transform

I have a signal which includes several frequencies (EEG), and I want to calculate the phase of this signal in a particular frequency in a particular moment.

For this I have used two approaches a Short Time Fourier Transform (STFT) and a Hilbert transform:

I'm not worried about a possible constant (or close to constant) phase difference between the two, but about a non constant difference, which is the case, the two phases do not correlate very much.

So my impression is that both differ for the reasons below with a longer explanation on the method:

My signal has a frequency sampling of 2ms.

Let's call the time of interest T0. And foi our frequency of interest (10 hz for this particular case, though it changes).

For a particular signal segment (800 ms) I calculate an spectrogram and find the closest peak in the spectrogram to the foi, and then I calculate the a small bandwidth around it let's call it Hilbert Bandwidth (~+- 1.25Hz). (I do this to make sure there is some signal to filter later).

For the STFT, and I use a 200 ms window centered over T0. Therefore 100 points (given 2 ms sampling) . Giving me a frequency resolution of 5 Hz. As I want the phase in a particular moment, I tried to use a window as small as possible. Then I calculate the of the foi based ont his transform.

For the Hilbert Transform I apply a bandpass Butterworth filter (order 2) using the Hilbert Bandwidth, and use a Hilbert transformation to calculate the phase.

This two phases (Hilbert and STFT) differ, so my reasoning here is: - That the STFT phase for the foi has contributions of closer frequencies that I cannot separate due to the length of the window. While the Hilbert does not as I have applied a bandpass filter narrower than the resolutuion of the STFT.

So I have three questions:

1. Is filtering in a narrow band and calculating the Hilbert transform a senseful way of calculating the phase of the signal?

2. Does my explanation of the difference between the two methods make sense?

3. For a given signal, which of the two methods would be more reliable for estimating the phase at a particular time point in a particular frequency?

• Did you compensate for the delay of the Butterworth filter? Dec 7 '16 at 12:02
• I did not, I'm not particularly worried about an approximately constant phase delay. The measure I use is the phase difference between the two, so as far as it's concentrated around some value I'm fine I can compesate for that later, but the problem is that they are not concentrated and seem that one of the two is not giving a reliable measure. Dec 12 '16 at 9:26
• If you don't compensate for the filter delay, you might be computing the phase angle from the I at one point in time and the Q at another, resulting in garbage atan2() IQ inputs. Dec 13 '16 at 22:42