2
$\begingroup$

I am interested in tracking how the phase of a signal at a particular frequency changes over time.

The method I am using calculates a series of STFTs and takes the arctangent of the imaginary and real components of the desired bin for each FFT, however, due to noise in the system I am having issues with phase unwrapping.

Are there any alternate and perhaps more robust methods of extracting phase from a signal in this manner?

Thank you

$\endgroup$
1
$\begingroup$

If your signal is not exactly integer periodic within the width of the FFT, then you may need to window and interpolate.

Try windowing the data using a Blackman-Nutall window, doing an FFTshift to center the window at element 0, performing the FFT, interpolating the complex results to the periodicity of your signal (windowed Sinc interpolation works), then taking atan2() of that interpolated complex result.

Increasing the Overlap of the FFT windows helps reduce the phase shift between adjacent overlapped windows, which can make phase unwrapping much easier.

$\endgroup$
3
$\begingroup$

like hotpaw, unless you know something prior about the signal (like it's periodic with period $P$), i'm thinking that you're windowing in the neighborhood of samples $m \le n < m+N$.

STFT: $$ X_m[k] \triangleq (-1)^k \, e^{-j\pi k/N} \ \sum\limits_{n=0}^{N-1} x[n+m] w[n] \, e^{-j2\pi nk/N} $$

$w[n]$ is a decent window centered about $n \approx \tfrac{N-1}{2}$, specifically $$w[n]=w[N-1-n] \ .$$

if $x[n]$ and $w[n]$ are both real, then $X[k]$ is Hermitian symmetric: $X[N-k]=\overline{X[k]}$. and $X[0]$ must be real. so the complex angle of $X[0]$ is either $0$ or $\pm \pi$ depending on if $X[0]$ is positive or negative.

$$ \arg\{ X[0] \} = \begin{cases} 0 & \text{for } \Re\{X[0]\} \ge 0 \\ \pm \pi & \text{for } \Re\{X[0]\} < 0 \\ \end{cases}$$

because $ \Im\{ X[0] \} = 0 $.

then you can calculate phase increments:

$$\begin{align} \arg\{ X[k] \} - \arg\{ X[k-1] \} &= \arg\left\{ \frac{X[k]}{X[k-1]} \right\} \\ \\ &= \arg\left\{ \frac{X[k]\overline{X[k-1]}}{\Big|X[k-1]\Big|^2} \right\} \\ \\ &= \arg\left\{ X[k]\overline{X[k-1]} \right\} \\ \\ &= \arg\left\{ \big(\Re\{X[k]\}+j\Im\{X[k]\}\big)\big(\Re\{X[k-1]\}-j\Im\{X[k-1]\}\big) \right\} \\ \\ &= \arg\left\{ \Re\{X[k]\} \Re\{X[k-1]\} + \Im\{X[k]\} \Im\{X[k-1]\} + j\big( \Im\{X[k]\} \Re\{X[k-1]\} - \Re\{X[k]\} \Im\{X[k-1]\} \big) \right\} \\ \\ &= \arctan\left(\frac{ \Im\{X[k]\} \Re\{X[k-1]\} - \Re\{X[k]\} \Im\{X[k-1]\}} {\Re\{X[k]\} \Re\{X[k-1]\} + \Im\{X[k]\} \Im\{X[k-1]\}} \right) \\ \end{align}$$

or recursively

$$ \arg\{ X[k] \} = \arg\{ X[k-1] \} + \arctan\left(\tfrac{ \Im\{X[k]\} \Re\{X[k-1]\} - \Re\{X[k]\} \Im\{X[k-1]\}} {\Re\{X[k]\} \Re\{X[k-1]\} + \Im\{X[k]\} \Im\{X[k-1]\}} \right) $$

for $ 1 \le k \le \tfrac{N}{2} $.

this is assuming that every little phase increment is smaller in magnitude than $\tfrac{\pi}{2}$. this is how you deal with unwrapping phase naturally.

$\endgroup$
2
$\begingroup$

you might look at

J. Kulmer, P. Mowlaee and M. K. Watanabe, "A probabilistic approach for phase estimation in single-channel speech enhancement using von mises phase priors," 2014 IEEE International Workshop on Machine Learning for Signal Processing (MLSP), Reims, 2014, pp. 1-6.

This uses some ideas from circular statistics

https://en.wikipedia.org/wiki/Directional_statistics

If you would permit an oversimplification, don't use $\theta$ to form short term averages or trends, use $\cos(\theta)$ and $\sin(\theta)$ instead.

$\endgroup$
  • $\begingroup$ Thank you, I will try to get access to the paper you cited. I would be very grateful if you could elaborate a little on your answer, I assume the solution is not as simple as remapping the arctan angle via sin/cosine functions. $\endgroup$ – CatsLoveJazz Jul 6 '17 at 22:10
  • $\begingroup$ I first learned about Von Mises from Bishop's Neural Net book where he had an example on measuring average wind direction. If you average the cos and sine components, and then calculate angle, you avoid the problems with averaging angle like wrap around. Look at the Wikipedia article and Google on circular statistics. There is a lot of material $\endgroup$ – Stanley Pawlukiewicz Jul 6 '17 at 22:17

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.