Implementation of Hilbert-Huang Transform Using C Language
Implementation of Hilbert-Huang Transform Using C Language
Implementation of Hilbert-Huang Transform Using C Language
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
生 物 医 学 信 号 检 测 与 处 理<br />
<strong>Implementation</strong> <strong>of</strong> <strong>Hilbert</strong>-<strong>Huang</strong> <strong>Transform</strong> <strong>Using</strong> C <strong>Language</strong><br />
Wang Lei, Vai Mang I, Mak Peng Un<br />
BME Lab, EEE, FST, University <strong>of</strong> Macau, Macau, China<br />
Abstract: <strong>Hilbert</strong>-<strong>Huang</strong> <strong>Transform</strong>, proposed by N. E. <strong>Huang</strong> in 1998, is a novel algorithm for nonlinear and<br />
non-stationary signal processing. Up to now, most <strong>of</strong> the researchers focus on the applications <strong>of</strong> HHT in different<br />
areas. However, in this paper we try to focus on the implementation <strong>of</strong> HHT in C and the possibility in porting to<br />
FPGA. With our implementation, IMFs with acceptable accuracy were achieved, which can be used in other<br />
applications. Since the program is written in ANSI C, it also <strong>of</strong>fers a good portability in different platforms<br />
including hardware implementation (FPGA or ASIC).<br />
Keywords: HHT; EMD; IMF; C; Instantaneous Frequency<br />
1. Introduction<br />
Digital Signal Processing technology is widely used<br />
in Biomedical Engineering. As it is known, most <strong>of</strong><br />
the biomedical signals, such as ECG and EMG, are<br />
nonlinear and non-stationary signals. However, most<br />
<strong>of</strong> the methods, e.g. Fourier Integral <strong>Transform</strong>, Fast<br />
Fourier <strong>Transform</strong> (FFT) and Wavelet <strong>Transform</strong> have<br />
a strong priori assumption that the signals being<br />
processed should be linear and/or stationary. They are<br />
actually not suitable for biomedical signals which are<br />
nonlinear and non-stationary.<br />
<strong>Hilbert</strong>-<strong>Huang</strong> <strong>Transform</strong> (HHT), a novel algorithm<br />
proposed by N. E. <strong>Huang</strong> in 1998, provides a possible<br />
solution to those nonlinear and non-stationary signals.<br />
The algorithm is composed <strong>of</strong> two main parts –<br />
Empirical Mode Decomposition (EMD) and <strong>Hilbert</strong><br />
<strong>Transform</strong>. The first part will decompose the signal<br />
into Intrinsic Mode Functions (IMF) which will meet<br />
the requirement <strong>of</strong> the <strong>Hilbert</strong> <strong>Transform</strong> and then can<br />
be further analyzed to get the instantaneous<br />
frequencies <strong>of</strong> the original signals.<br />
HHT have been widely used in a variety <strong>of</strong><br />
research areas, including researches in Biomedical<br />
Engineering, such as EEG, EMG, ECG, pulse wave<br />
and so on. Some fruitful results have been achieved.<br />
However, the HHT is a very computation oriented<br />
algorithm and will consume much time.<br />
Currently, most <strong>of</strong> the researches were based on the<br />
s<strong>of</strong>tware (mainly in Matlab) implementation which<br />
may be not running fast enough for real time<br />
application, especially when running on an embedded<br />
platform such as home health care devices. What we<br />
are planning to do is trying to develop a hardware<br />
based real-time HHT analysis system. As the first step,<br />
we try to implement the HHT in ANSI C that is<br />
possible to migrate to other hardware description<br />
language to make the hardware implementation<br />
become possible, for example, migrate to FPGA or<br />
ASIC chip.<br />
2. <strong>Hilbert</strong>-<strong>Huang</strong> <strong>Transform</strong><br />
The general accepted definition <strong>of</strong> Instantaneous<br />
Frequency (IF) is the derivative <strong>of</strong> an analytic signal.<br />
IF can be express with <strong>Hilbert</strong> <strong>Transform</strong>. The<br />
Instantaneous Frequency <strong>of</strong> a signal x(t) is<br />
'<br />
'<br />
1 H [ xt ()] xt () H[ xt ()] x()<br />
t<br />
IF <br />
(1)<br />
2 2<br />
2 x ( t) H [ x( t)]<br />
Here H[x(t)] is the <strong>Hilbert</strong> <strong>Transform</strong> <strong>of</strong> the signal<br />
x(t). However, not all kinds <strong>of</strong> signals have a<br />
meaningful IF according to equation (1). It’s only<br />
works on narrow band signal.<br />
2.1 IMF<br />
To make clear the limitation <strong>of</strong> <strong>Hilbert</strong> <strong>Transform</strong><br />
The work presented in this paper is supported by the Research Committee <strong>of</strong> the University <strong>of</strong> Macau under Grants RG061/06-07S/VMI/FST,<br />
RG075/07-08S/VMI/FST, UL012/09-Y1/EEE/VMI01/FST and by The Science and Technology Development Fund <strong>of</strong> Macau under grant<br />
014/2007/A1.<br />
111
生 物 医 学 信 号 检 测 与 处 理<br />
that most <strong>of</strong> the nonlinear and non-stationary signals<br />
can not have a meaningful Instantaneous Frequency,<br />
N. E. <strong>Huang</strong> proposed some restrictions to the signals<br />
which can have meaningful IF. The restrictive<br />
conditions called Intrinsic Mode Function (IMF). An<br />
IMF must satisfy the following two conditions [2]:<br />
1. In the whole data set, the number <strong>of</strong> extrema and<br />
the number <strong>of</strong> zero crossings must either equal or<br />
differ by one.<br />
2. At any data point, the mean value <strong>of</strong> the envelope<br />
defined by the local maxima and envelop defined<br />
by the local minima is zero.<br />
n<br />
<br />
x()<br />
t imf r<br />
i1<br />
n<br />
(2)<br />
2.2 EMD<br />
As discussed above, an IMF has a meaningful IF<br />
using <strong>Hilbert</strong> <strong>Transform</strong>. However, most <strong>of</strong> the signals<br />
are not IMF. To solve this problem, N. E. <strong>Huang</strong><br />
proposed the Empirical Mode Decomposition (EMD).<br />
This method can decompose the nonlinear and nonstationary<br />
signals into finite IMFs, so we can have the<br />
Instantaneous Frequencies from those IMFs using<br />
<strong>Hilbert</strong> <strong>Transform</strong>. And add the IFs from IMFs<br />
together we can have the IFs <strong>of</strong> the original signal. To<br />
implement this method, a sifting process has been<br />
designed. The steps are:<br />
First, we extract the maxima and minima data<br />
points from the original signal x(t). Then, interpolate<br />
all the maxima and minima data points separately with<br />
cubic spline to get the upper and lower envelopes,<br />
followed by the calculation <strong>of</strong> the mean <strong>of</strong> the upper<br />
and lower envelopes (m). After finding the m, the<br />
difference between the original signal and the mean<br />
can be calculated:<br />
h x()<br />
t m<br />
If h is not an IMF, we set it as the original signal to<br />
repeat the above steps until get an IMF. If h is an IMF,<br />
it will be regarded as the IMF (imf) and the residua<br />
should be found as: r=x(t)-imf. Then the residua will<br />
be treated as the original signal x(t) and the above<br />
steps will be repeated to get another IMF. This process<br />
will be stopped when the residua r or imf satisfy the<br />
stop criteria. Finally the original signal can be express<br />
as the sum <strong>of</strong> all the IMFs and residua:<br />
Figure 1<br />
2.3 <strong>Hilbert</strong> <strong>Transform</strong><br />
For signal x(t), the definition <strong>of</strong> <strong>Hilbert</strong> <strong>Transform</strong><br />
is:<br />
1<br />
H[<br />
x(<br />
t)]<br />
P<br />
<br />
<br />
<br />
'<br />
x(<br />
t )<br />
dt<br />
'<br />
t t<br />
'<br />
1<br />
* x(<br />
t)<br />
t<br />
(3)<br />
112
生 物 医 学 信 号 检 测 与 处 理<br />
P is Cauchy principal value here. And for every<br />
IMF after EMD sifting, we do the <strong>Hilbert</strong> transform<br />
for them and calculate the corresponding analytic<br />
signal. After further processing we can expressed x(t)<br />
in a three-dimensional figure which is energy-timefrequency<br />
distribution.<br />
3. <strong>Implementation</strong><br />
3.1 Structure <strong>of</strong> The Program<br />
There are two main loops in the program. One is to<br />
extract IMFs (small loop). The other is to check if the<br />
residua meet the EMD stop criteria (big loop). Figure<br />
1 shows the flow chat <strong>of</strong> the program.<br />
The first loop is to identify extremum data points<br />
and the mean <strong>of</strong> upper and lower envelopes for the ‘h’.<br />
If ‘h’ is an IMF, the iteration times <strong>of</strong> decomposition<br />
should be saved and the first loop should be stopped.<br />
If ‘h’ is not an IMF, set ‘h’ as the original signal and<br />
start the decomposition again. The mean between<br />
upper and lower envelopes <strong>of</strong> ‘h’ will be used to get<br />
another difference <strong>of</strong> the signals.<br />
The second loop is to verify if the EMD sifting<br />
should be stopped or not. About the EMD sifting, N. E.<br />
<strong>Huang</strong> gave such a description: the sifting process can<br />
be stopped either when the component, imf n or the<br />
residua, r n , becomes so small that it is less than<br />
predetermined value <strong>of</strong> substantial consequence, or<br />
when the residua, r n , becomes a monotonic function<br />
from which no more IMF can be extracted[2].<br />
According to this description, stop criteria for EMD<br />
sifting can be set.<br />
Because the program needs to save both upper and<br />
lower envelopes, and the mean and difference between<br />
mean and originals, as well as IMFs, the program<br />
needs a large memory space.<br />
3.2 Experiments<br />
For testing our implementation, we took the ECG<br />
signal ‘sig100a’ from MIT-BIH Arrhythmia Database<br />
as the source signal. By decomposing the ECG signal,<br />
totally 11 IMFs were extracted from the original<br />
signal. The original ECG signal and the first to fifth<br />
IMFs are shown in Figure 2, other IMFs and residua<br />
are shown in Figure 3.<br />
E CG signal<br />
im f1<br />
im f2<br />
im f3<br />
im f4<br />
im f5<br />
1<br />
0<br />
-1<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
0.5<br />
0<br />
-0.5<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
0.2<br />
0<br />
-0.2<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
0.5<br />
0<br />
-0.5<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
0.2<br />
0<br />
-0.2<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
0.2<br />
0<br />
-0.2<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
Time(normalized)<br />
Figure 2<br />
0.2<br />
0<br />
-0.2<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
0.5<br />
0<br />
-0.5<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
0.2<br />
0<br />
-0.2<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
0.2<br />
0<br />
-0.2<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
0.1<br />
0<br />
-0.1<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
0.05<br />
0<br />
-0.05<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
-0.3<br />
residua-0.2<br />
-0.4<br />
0 200 400 600 800 1000 1200 1400 1600 1800 2000<br />
Time(normalized)<br />
im f6<br />
im f7<br />
im f8<br />
im f9<br />
im f1 0<br />
im f1 1<br />
Figure 3<br />
We also tried to apply EMD sifting to other ECG<br />
signals and found that for different signals the execute<br />
time <strong>of</strong> program are different. That may because <strong>of</strong> the<br />
number <strong>of</strong> IMFs and iteration time <strong>of</strong> every IMF is<br />
depends on the complexity <strong>of</strong> signals.<br />
113
生 物 医 学 信 号 检 测 与 处 理<br />
To test the speed <strong>of</strong> the implementation, we<br />
compare the time consumed by our implementation<br />
and an implementation in Matlab running on the same<br />
PC. It was found that the C implementation is slightly<br />
faster than the Matlab implementation.<br />
4. Conclusions and Discussions<br />
We have done an effective EMD sifting system<br />
with pure ANSI C. With the program we can extract<br />
IMFs from nonlinear non-stationary signals. But the<br />
program needs a lot <strong>of</strong> memory, and for different<br />
signals it will take different execution time. So it still<br />
needs effort to improve the algorithm to make it uses<br />
as less memory as possible, and make the program<br />
running faster. At the other hand, it is also needed to<br />
modify the algorithm to make it be more “parallel” so<br />
suitable to be implemented in hardware (FPGA).<br />
5. References<br />
[1] N. E. <strong>Huang</strong> , Z. Shen and S.R. Long, “The empirical<br />
Mode decomposition and <strong>Hilbert</strong> spectrum for nonlinear<br />
and non-station time series analysis,” Proc Roy, Soc.<br />
London A, vol. 454, pp, 903~995, 1998<br />
[2] N. E. <strong>Huang</strong>, S. P. Shen, “<strong>Hilbert</strong>-<strong>Huang</strong> <strong>Transform</strong> and<br />
Its Application.” World Scientific Pub Co Inc, 2005<br />
[3] Semion Kizhner, Thomas P. Flatley, Dr. Norden E.<br />
<strong>Huang</strong>, “On the <strong>Hilbert</strong>-<strong>Huang</strong> <strong>Transform</strong> Data<br />
Processing System Development” IEEE Aerospace<br />
Conference Proceedings, 2004<br />
[4] Xiaoli Yang, Jing0tian Tang, “<strong>Hilbert</strong>-<strong>Huang</strong> <strong>Transform</strong><br />
and Wavelet <strong>Transform</strong> for ECG Detection.” Wireless<br />
Communications, Networking and Mobile Computing,<br />
2008. WiCOM’08. 5 th International Comference<br />
[5] Li Hong sheng, Li Zhengqin, Chen Wenwu, Zhao Zhao,<br />
“<strong>Implementation</strong> <strong>of</strong> <strong>Hilbert</strong>-<strong>Huang</strong> <strong>Transform</strong>(HHT)<br />
Based on DSP.” Signal Processing, 2004. Proceedings.<br />
ICSP '04. 2004 7th International Conference<br />
通 讯 作 者 : 王 磊<br />
单 位 : 澳 門 大 學 科 技 學 院 生 物 醫 學 工 程 實 驗 室<br />
邮 箱 :ma76559@umac.mo<br />
114