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:


Is filtering in a narrow band and calculating the Hilbert transform a senseful way of calculating the phase of the signal?
Does my explanation of the difference between the two methods make sense?
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?
Without seeing your data, it's hard to tell whether you have contributions of closer frequencies or not.  That is certainly possible.  So, my suggestion to you would be this: try out your two different methods on pure sine waves where you know that there are no closer frequencies.  In other words, generate some dummy data which is just one single frequency.  If your two methods give the exact same answer on that data, then maybe it is in fact the contributions of closer frequencies that are messing up your original calculation.  But if the two methods do not give the exact same answer, then you likely have an error in your method.