"Aino" <aino.tietavainen@removeThis.helsinki.fi> wrote in message <hu9kli$qi2$1@fred.mathworks.com>...
> function [FD]=Higuchi(COP)
> %This function calculates a fractal dimension of a COP trace using
> %Higuchi's [Higuchi 1988] method.
>
> N=length(COP);
> kmax=100;
> L_m=zeros(1,kmax);
> L_m_length=zeros(kmax,kmax);
>
> for k=1:kmax
> for m=1:k;
> L_m=zeros(1,kmax);
> for i=1:fix((Nm)/k)
> L_m(i)=abs(COP(m+i*k)COP(m+(i1)*k));
> end
> a=((N1))/(fix((Nm)/k)*k);
> L_m_length(m,k)=(sum(L_m)*a)/k;
> end
> L_m_length_mean(k)=mean(nonzeros(L_m_length(:,k))); %Extra zeros from the matrix
> L_m_length_std(k)=std(nonzeros(L_m_length(:,k)));
> end
>
> k=1:kmax;
> p=polyfit(log(1./k), log(L_m_length_mean), 1);
> FD=p(1);%FD is the slope
>
> ________________________________________
>
> I sure hope it does what it is supposed to do. But I now have a more resent problem concerning it. The kmax is supposed to be found by plotting FDs that are acquired with different kmaxs against kmaxs. The suitable kmax should be the one at what point the plot plateaus. First of all, does that mean that the FD increases as the kmax increases? And second of all, what if (as in my case) the FD get all the way to 2 before it plateaus? The longer the trace is, the longer the kmax needed, it would seem..
>
> Thank you for your answers.
>
> Aino
>
> "Sarah " <sarah.menetre@schiller.fr> wrote in message <hm87ru$g4g$1@fred.mathworks.com>...
> > Hello Tikkuhirvi,
> >
> > I would be interested to know if you have solved your problem exposed here about the Higuchi's fractal dimension code. Was the proposition from Steen Johansen the solution you adopted ?
> > Because I found nowhere (neither in the Biomedical signal and image processing book from Kayvan Najarian, Robert Splinter nor on the websites), something like "dimension is the slope of the inverse function you are using" !
> >
> > Thank you in advance,
> >
> > Sarah
Dear Aino, Sarah and all others, The mistake you all made was the wrong algorithm. For exact algorithm please refer to Higuchi's original work (even the mistake is there even in IEEE paper by Rosana Esteller et al but the paper by Polychronaki et al explains the Higuchi FD algorithm correctly). The mistake is the curve length formula, which contains the term, k dividing the entire value. Here is the correct MATLAB Code: Please download it from MATLAB Central. If you think that I have solved your problem, please mail me: vsalaiselvam@yahoo.com. Thanks to all.
***********COMPLETE MATLAB CODE FOR HIGUCHI FD!!!****************
function [varargout]=hfd(x,kmax)
if ~exist('kmax','var')isempty(kmax),
kmax=5;
end;
N=length(x);
Lmk=zeros(kmax,kmax);
for k=1:kmax,
for m=1:k,
Lmki=0;
for i=1:fix((Nm)/k),
Lmki=Lmki+abs(x(m+i*k)x(m+(i1)*k));
end;
Ng=(N1)/(fix((Nm)/k)*k);
Lmk(m,k)=(Lmki*Ng)/k;%Here is the problem in your code, Mr. Tikkuhirvi & Mr. Aino
end;
end;
Lk=zeros(1,kmax);
for k=1:kmax,
Lk(1,k)=sum(Lmk(1:k,k))/k;
end;
lnLk=log(Lk);
lnk=log(1./[1:kmax]);
b=polyfit(lnk,lnLk,1);
xhfd=b(1);
varargout={xhfd,lnk,lnLk,Lk,Lmk};
***********COMPLETE MATLAB CODE FOR HIGUCHI FD!!!****************
