0
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ Did you compensate for the delay of the Butterworth filter? $\endgroup$ – hotpaw2 Dec 7 '16 at 12:02
  • $\begingroup$ 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. $\endgroup$ – luismf Dec 12 '16 at 9:26
  • $\begingroup$ 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. $\endgroup$ – hotpaw2 Dec 13 '16 at 22:42
1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Thanks for the suggestion. It was one of my first reality checks, and both matched between them, and with real phase of the sine wave. $\endgroup$ – luismf Dec 12 '16 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.