No BSD License  

Highlights from
Hilbert-Huang Transform

4.75

4.8 | 14 ratings Rate this file 196 Downloads (last 30 days) File Size: 995.46 KB File ID: #19681
image thumbnail

Hilbert-Huang Transform

by Alan Tan

 

23 Apr 2008 (Updated 28 Apr 2008)

This submission is a realization of the Hilbert-Huang transform (HHT).

| Watch this File

File Information
Description

The function plot_hht is a realization of the Hilbert-Huang transform (HHT). The HHT decomposes a signal into intrinsic mode functions (or IMFs), and obtain the instantaneous frequency data. It is designed to work well for data that are nonstationary and nonlinear (http://en.wikipedia.org/wiki/Hilbert-Huang_Transform). Learn more about the HHT from the attached pdf.

The function plot_hht is best used with spsnip_gui available at http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11002&objectType=FILE.

Essential files: plot_hht.m, emd.m, findpeaks.m
Accompanying files: Hum.wav, HHT.pdf

Required Products Signal Processing Toolbox
Spline Toolbox
MATLAB release MATLAB 5.3.1 (R11.1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (33)
24 Apr 2008 The Author

Forgot to add that you will need to have the Spline Toolbox to run this one.

24 Apr 2008 The Author

If you don't have phase.m in your version of Matlab (I have in mine!), you can substitute with angle.m in the plot_hht function.

25 Apr 2008 Chian Wong

The user would also need the Signal Processing Toolbox to perform the Hilbert Transform itself, though this is elementary to code.

03 May 2008 Legolas Long

why can't i use it correctly?

05 Oct 2008 Kechang Fu  
06 Jan 2009 SQ Yuan  
26 Mar 2009 Asim

To Author, can you please explain how we are defining the variable 'Ts'? If I have a dataseries collected everyday for 45 years, will this column 1 will be Ts or just the value 1? In my dataset I have two column with second with dataset and first with day of measurement (regular basis).

29 Mar 2009 Alan Tan

Hi Asim, Ts is a single number (not a column of numbers) denoting the sampling time. If you have samples collected every, say 1 day, then set Ts = 1. Please send me an email if you have other doubts -- do not post your questions here since I do not monitor this site regularly. Thank you.

30 Mar 2009 Yu

to Auther,

hi, you did a very good job, and with your function i saved a lot of time. i have a question about thd 's'- sensitivity. i got different extreme peaks , when i change the 's'. can you tell me whats the meaning of 's'?
thank you

01 Apr 2009 Alan Tan

For the benefit of other readers, the following is the reply given to Yu over email.

Hi Yu, I am assuming the s you mentioned is output of the getspline function. The array s is formed by invoking Matlab's spline function, i.e., spline([0 p N+1],[0 x(p) 0],1:N). You'd note that additional endpoint conditions (loosely put, the spline should settle towards 0 at the endpoints) have been imposed as a means to contain the endpoints (of the resulting spline) to within reasonable bounds. Removing these conditions may result in the 'extreme peaks' you mentioned. I hope that clears your doubt.

15 May 2009 delinda he

Would you guys please help me to figure out how does the Hilbert transform work??
function plot_hht(x,Ts)
% Plot the HHT.
% plot_hht(x,Ts)
% :: Syntax
% The array x is the input signal and Ts is the sampling period.
% Example on use: [x,Fs] = wavread('Hum.wav');
% plot_hht(x(1:6000),1/Fs);
% Func : emd

% Get HHT.
imf = emd(x); %emd is a function, it returns the IMF (intrinsic mode functions)

%%%%%%% The following one is to calculate Hilbert transform for each IMFs, but I do no know how it works???????@#$%%

for k = 1:length(imf)
   b(k) = sum(imf{k}.*imf{k});
   th = angle(hilbert(imf{k}));
   d{k} = diff(th)/Ts/(2*pi);
end
[u,v] = sort(-b);
b = 1-b/max(b);

% Set time-frequency plots. I do not how it plot the time-frequency figures too
N = length(x);
c = linspace(0,(N-2)*Ts,N-1);
for k = v(1:2)
   figure, plot(c,d{k},'k.','Color',b([k k k]),'MarkerSize',3);
   set(gca,'FontSize',8,'XLim',[0 c(end)],'YLim',[0 1/2/Ts]); xlabel('Time'), ylabel('Frequency');
end

Thanks for your help.
 

16 Oct 2009 Raymond Cheng

Thanks for your sharing.

15 Nov 2009 Agnes

Please describe me what the plots are exactelly. I suppose that the first is the HHT of the datas, but what is the second?what is the difference between them? And the other plots are the various envelopes?
And if I have a 0.7 KHz sampling rate, than I have to give 700 as the Ts or 1/700?
Thanks for your help!

16 Nov 2009 Alan Tan

The following reply is given to Agnes over email.

Hi Agnes, The 2 initial plots are the time-frequency plots of the HHT corresponding to the 2 IMFs with of the highest energy. Subsequent plots are the IMFs, plotted against time.

29 Dec 2009 Jaime Delgado Saa

Hello, Thanks for this tool, It works fine for me.One question: do you use normalized hilbert transform for the calculation of the instantaneous frequency of the imf's.

just curious : why the pictures are black and white?

04 Jan 2010 Alan Tan

Hi Jaime, thank you for the comment.

From Matlab's help on the supplied hilbert.m function, it appears that there is no normalization involved. I had no particular reason on the choice of the figure colours -- you can always change the colour of the plot by modifying Line 25 of the plot_hht.m function.

21 Feb 2010 Mark Shore

Just tried this, no comments yet except that the spline toolbox is not required (at least for 2009b). A call is made to spline.m which is found in MATLAB's standard toolbox in the polyfun directory.

24 Feb 2010 Rakesh

The 1st two plots are the plots of 2 imfs with highest engery content. However, according to the theory, all imfs (and hence their frqs) are plotted with respect to time. I did "hold on" and have plotted time-freq distribution for all the imfs. the plot looks kind of crowded but still gives enough information. However i still hav following questions,

1. in hilbert spectrum, in 3D plot, vertical axis amplitude is function of time. but u have obtained a single value of energy for each imf. but actually it should have been function of time.Am i right?

2. How should I get Spactrogram type of plot?

11 Mar 2010 Hans

To Author,
  
I have another one more question is that, my data is .edf but once i plot the hht using hht_plot.m, the result came out is empty but IMF is running and not empty, is there something wrong with my data?

31 May 2010 Alan Tan

@Rakesh: Not sure what you meant with the 3d plot and vertical axis. Sorry.
@Hans: I have not experimented with files of .edf extension; I can't help much with that -- sorry.

06 Jun 2010 Paul Harfas

Hi.
First, I must say this piece of code helped me with my work, thank you for your effort.
I am currently working on improving your code by adding extrema at the beginning and end of the data series based on the actual data points (slope-based method), not just adding zeros. Adding zeros will result in "fake" (artificially induced) oscillations that will propagate through adjacent modes (IMFs) and induce errors. I will post back when I reach a result.

@rakesh: to obtain a surface (3D) plot of the time-frequency-energy distribution, you should plot abs(hilbert(imf{k})).^2 as the value on the Z axis (plot_hht.m line 15).

14 Jun 2010 Bubo Bubic

Hi,
I got next message trying to run plot_hht.m:

??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space cancrash MATLAB and/or your computer.

Error in ==> fileparts

Then I run from command line
set(0,'RecursionLimit',2600) (maximum value 2600) and computer crashes every time! For lower values got the same above message.
Please help with suggestion or advices.
Thanks

26 Aug 2010 Omar  
26 Aug 2010 Omar

I'm interested in using the envelope of my signal that might I get using your code for further analysis. But, by plotting both original signal and its envelope on the same figure, it does not show me that the envelope follow the peaks of my original signal as shown in figure 1.2 (upper envelope) in the HHT.pdf file. So, could you please suggest me an idea how to make the envelope follow the local maxima.

Thanks again,
Omar

17 Oct 2010 Lukasz

Shouldn't you unwrap the angle th before sending it to diff?

26 Oct 2010 aami

cud any one plz give me the link to the code for decomposing an image using EMD...
Thanx in advance...
 
Meenu

30 Nov 2010 pankaj badoni

hi please anyone tell how to apply this one on images esp of medical images.

plz..reply fast.

16 Feb 2011 Ali Obodi

To Author,

 when i run plot_hht.m, i had following message appeared on command window:

??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space cancrash MATLAB and/or your computer.

Error in ==> fileparts

Then, i used
set(0,'RecursionLimit',1000) (maximum value 1000) and computer crashes every time! when i used lower values i had the same previous message.
Please need advice regarding this problem. Many thanks

11 Apr 2011 RAM KINKER MISHRA

function hht_meanfreq(x,Ts)
imf = emd(xsin);
%emd finds the decomposed segments
for i=1:length(imf)
imf1=cell2mat(imf(i));
%conversion of cell to matrix as i am use to work with matrix
a1(i,:)=imf1;
a(i,:)=abs(hilbert(a1(i,:)));
% absolute value of each hilbert transformed IMF
th(i,:)=angle(hilbert(a1(i,:)));
%fINDING PHASE OF EACH IMF
d(i,:) = diff(th(i,:))/Ts/(2*pi);
%CALCULAION OF INSTANTANEOUS FREQUENCY
end

for j=1:length(imf)
    mnf1(j)=sum(d(j,:).*(a(j,1:end-1)).^2)/norm(a(j,1:end-1))^2;
    %CALCULATION OF MEAN INSTATNTANEOUS FREQUENCY OF EACH IMF
end
for z=1:length(imf)
mnf=sum(norm(a(z,:).*mnf1(z)))/sum(norm(a(z,:)));
%FINDING MEAN FREQUENCY
end

11 Apr 2011 RAM KINKER MISHRA

My aim is to find the mean frequency derived via Hilbert-Huang transform.
Algorithm
1. first find the mean instantaneous frequency for each IMF.
2.Then using these instantaneous frequencies i will find out the mean frequency of the overall signal.
I have tried to implement the algorithm in the above program but i am not able to get the result properly.

02 May 2011 MANOJ KUMAR PALO

please provide me the matlab code of hilbert -transform

04 May 2011 RAM KINKER MISHRA

This is the code i am using.

function hht_meanfreq(x,Ts)
imf = emd(xsin);
%emd finds the decomposed segments
for i=1:length(imf)
imf1=cell2mat(imf(i));
%conversion of cell to matrix as i am %use to work with matrix
a1(i,:)=imf1;
a(i,:)=abs(hilbert(a1(i,:)));
%absolute value of each hilbert %transformed IMF
th(i,:)=angle(hilbert(a1(i,:)));
%fINDING PHASE OF EACH IMF
d(i,:) = diff(th(i,:))/Ts/(2*pi);
%CALCULAION OF INSTANTANEOUS FREQUENCY
end

for j=1:length(imf)
 mnf1(j)
=sum(d(j,:).*(a(j,1:end-1)).^2)/norm(a(j,1:end-1))^2;
%CALCULATION OF MEAN %INSTATNTANEOUS %FREQUENCY OF EACH IMF
end
for z=1:length(imf)
mnf=sum(norm(a(z,:).*mnf1(z)))/sum(norm(a(z,:)));
%FINDING MEAN FREQUENCY
end

08 Feb 2012 Sergi Andruschenko  
Please login to add a comment or rating.
Updates
24 Apr 2008

Added requirement for the Spline Toolbox.

24 Apr 2008

Replaced phase() with angle() in plot_hht().

28 Apr 2008

Added requirement for the Signal Processing Toolbox. Thanks to Chian Wong for pointing out.

Tag Activity for this File
Tag Applied By Date/Time
audio processing Alan Tan 22 Oct 2008 09:58:49
video processing Alan Tan 22 Oct 2008 09:58:49
hilberthuang transform hht Alan Tan 22 Oct 2008 09:58:49
signal processing Alan Tan 30 Mar 2009 00:07:04
hilberthuang transform hht Tatiana Pelc 29 Oct 2009 12:40:43
audio processing Tatiana Pelc 29 Oct 2009 12:40:46
signal processing Tatiana Pelc 29 Oct 2009 12:40:49
video processing Tatiana Pelc 29 Oct 2009 12:40:51
hilberthuang transform hht manikandan H 03 Feb 2010 09:49:22
nora Nora 11 May 2010 11:07:43
audio Jose Ercolino 27 May 2010 22:39:39
dsp Jose Ercolino 27 May 2010 22:39:39
frequency Jose Ercolino 27 May 2010 22:39:39
signal processing Jose Ercolino 27 May 2010 22:39:58
frequency William 09 Oct 2011 22:16:06

Contact us at files@mathworks.com