IQ Demodulation and Hilbert Transform
When dealing with medical signals the relevant representation we want to assess is a decomposition in two terms :
The envelope carries the energy of the signal and slowly variates in relation to a carrier term which quickly oscillate according to the instantaneous phase . Where the envelope is used to perform B-Mode imaging, the instantaneous phase is used for Doppler imaging.
The two main approaches to assess this representation are : (quadrature) demodulation which outputs an representation of the signal, and, Hilbert transform that gives the analytic signal which is another complex representation. Both of them are closely related and come from two words. The one comes from the analog domain as it can be obtained with some mixers and low pass filters. The analytic signal comes from a more mathematical approach and is difficult to produce in the analog domain.
We will talk about both processes and representations in this paper, don't mix demodulation with representation. The first leads to the second. Accordingly Hilbert Transform is the process that permits to form the analytical signal. But we will also see that we can use the Hilbert Transform to assess the IQ representation and the IQ demodulation to assess the analytic signal.
IQ Representation
This representation comes from telecommunication where signals of interest are modulated by a sinusoid of known frequency. In the case of ultrasound, the signal is not as frequency centered but the technique still works. By assuming the central frequency we can decompose the instantaneous phase as following :
Here $\theta(t)$ is the phase and slowly variates in relation to $\omega t$. Thanks to some trigonometric formula this can be rewritten as :
This decomposition splits the signal in two terms. One term in and is called in-phase component as originally we wrote the signal with the function. Another term in which is the quadrature component since is the quadrature of . We then define and allowing us to rewrite the former expression as :
This is the representation. Assuming a central frequency, we decompose the signal along a "in-phase envelope" and a "quadrature envelope". From those we can obtain a complex description of the signal :
The norm of this latter gives and the argument gives . Note that we don't need to provide the exact central frequency to perform an exact envelope and phase detection but the representation (aka the value of but also ) won't be the same.
We chose the example signal as following : is a hanning window, is set so that the central period is one and is a sinusoid that makes one full oscillation : it worth at , 0 at and at t=6. We can see that and behaves as some kind of signed envelope for the in-phase and quadrature component. The envelope is perfectly assessed.
Quadrature demodulation
Here a link on how to compute and by mixing and filtering the signal. The idea is to mix (multiply) the signal with two oscillator shifted by 90° (aka and ). This translate the frequency spectrum but also generate mirrored components that need to be low-pass filtered. This is achieved with some analog filters.
Analytic signal
I won't define the Hilbert transform. I will only use one of its proprieties : it acts as an 90° phase shifter :
The analytical signal is just an extension of the signal in the complex domain :
The norm of the analytic signal is and the argument is . Note that this time this representation doesn't imply to provide a central frequency.
The 90° phase shifter propriety of the Hilbert transform is easy to see here. Again the envelope is perfectly assessed
Hilbert Transform
This transformation can be achieved by two FFT. It consists in suppressing the negative frequency. In practice it can be approximated by some FIR filters. Here a link on how to do that.
From the Analytic to the $IQ$ representation
Those two representations seem really close, can we derive one from the other ? Indeed it is possible. If we start from the analytic signal and by providing the central frequency we can derive a representation by :
Hence both processing can be used to produce any of the two representations thank to this formula. Here we can easily see that representation depends on the chosen where doesn't. Let's play with that : using the former formula we compute different representations with different .
Choosing the original provides the same result as before. Choosing omega 50% bigger or smaller changes the representation but doesn't change the enveloppe (black solid line). In theory choosing any $\omega$ works but in practice, computing and by mixing the signal with a sinusoid and performing low pass filtering constrains the choice of this latter. Note that if we choose we come back to the analytic signal. Choosing the right ensures us that and spectrum will be as low in frequency as possible as we can see in this example : the green lines variate more slowly than the red and blue lines an thus is a more relevant representation.
Comparing IQ and analytic representation
Finally the representation is noting else than a down mixed version of the analytic signal. Down mixing is multiplying the signal with an oscillator of frequency $\omega$. In the Fourier space, this corresponds to a translation. Applying it in the real domain generates mirrored replicas of the spectrum that needs to be filtered out but on the complex analytic signal those don't appear.
At first the analytic signal seems more powerful. It doesn't imply to choose a centered frequency. But the representation as it is down mixed has the great advantage to be at a lower frequency hence requiring to be sampled at a lower rate. This reduces memory storage and computation required in the following processing stage. If only the envelope is retained, both representations are equivalent as an intermediate step to perform the envelope but if the phase has to be retained, the representation offers a natural way to store both the envelope and the phase information. Retaining the signal as the couple amplitude and angle also works but angles are not allways easy to manipulate as they often need to be wrapped/unwrap for further processing.
Comparing Hilbert Transform and $IQ$ demodulation
If it has to be performed in the analog domain, demodulation is the way to go. In the digital domain, Hilbert transform has the great advantage that it can be performed by a simple couple of FIR filters, to be broadband and it doesn't imply to choose a centered frequency . The demodulation can be performed by simulating the analog filter or by a smart approach called quadrature sampling. Here a link on this smart approach. Choosing the right implementation depends on the hardware architecture and functionality needed but Hilbert approach is more common those days.
Conclusion
Those two representations are really close. There is some confusion about what is called and . They can be defined as above but sometimes also as the in-phase signal and the quadrature components we evoked earlier. The quadrature demodulation comes from the analog world and is performed by mixing the signal with the output of an oscillator at a chosen frequency. Hence it implies choosing a parameter. The Hilbert Transform is parameter free but can't be performed in the analog domain. If no Doppler processing is implied both representations are equivalent. In the contrary, is the natural way of storing both the amplitude and phase information at lower sample rate. Switching from one representation to the other is easy so both Hilbert transform and quadrature demodulation can be use to obtain both representation. Both have been used in high quality ultrasound scanners.
Further Reading
To better understand frequency mixing and quadrature demodulation, I recommend reading this paper:
Quadrature Signals: Complex, But Not Complicated by Richard Lyons
Annex : Code used to generate the plots
import numpy as np
from scipy import signal as sp
from matplotlib import pyplot as plt
# Constants
N = 1000 # number of samples
omega = 2*np.pi # pulsation
T = 2*np.pi/omega # period
cycles = 8 # cycles of carrier wave
# Compute signals
t = np.linspace(0,T*cycles,N) # time
a = np.hanning(N) # envelope
theta = np.pi/2*np.sin(2*np.pi*t/np.max(t)) # phase
phi = omega*t + theta # instantaneous phase
x = a*np.cos(phi) # signal
inphase = a*np.cos(omega*t)*np.cos(theta) # in-phase component
quadrature = -a*np.sin(omega*t)*np.sin(theta) # quadrature component
I = a*np.cos(theta) # I
Q = a*np.sin(theta) # Q
H = np.imag(sp.hilbert(x)) # Hilbert Transform
# IQ demodulation
plt.figure(1)
plt.title('IQ demodulation')
plt.plot(t,x,'k',label='signal')
plt.plot(t,inphase,'g',label='in-phase')
plt.plot(t,I,'g--',label='I')
plt.plot(t,quadrature,'r',label='quadrature')
plt.plot(t,Q,'r--',label='Q')
plt.plot(t,np.abs(I+1j*Q),'k--',label='envelope = $norm(I+j Q)$')
plt.legend(loc='lower left')
plt.show()
# Hilber transform
plt.figure(2)
plt.title('Hilbert transform')
plt.plot(t,x,'k',label='signal')
plt.plot(t,H,'r',label='hibert')
plt.plot(t,np.abs(x + 1j*H),'k--',label='envelope = $norm(signal+j hilbert)$')
plt.legend(loc='lower left')
plt.show()
# Choosing different omega
analytic = x + 1j*H
IQ = analytic * np.exp(-1j*omega*t)
IQplus = analytic * np.exp(-1.50j*omega*t)
IQminus = analytic * np.exp(-0.50j*omega*t)
plt.figure(3)
plt.title('Choosing different omega')
plt.plot(t,np.real(IQ),'g',label='I')
plt.plot(t,np.imag(IQ),'g--',label='Q')
plt.plot(t,np.abs(IQ),'k')
plt.plot(t,np.real(IQplus),'r',label='$I_{+50\%}$')
plt.plot(t,np.imag(IQplus),'r--',label='$Q_{+50\%}$')
plt.plot(t,np.abs(IQplus),'k')
plt.plot(t,np.real(IQminus),'b',label='$I_{-50\%}$')
plt.plot(t,np.imag(IQminus),'b--',label='$Q_{-50\%}$')
plt.plot(t,np.abs(IQminus),'k')
plt.legend(loc='lower left')
plt.show()