Skip to content
Snippets Groups Projects
Commit 6f7aea28 authored by marwan's avatar marwan
Browse files

fix clustering coeff. bug

parent 2612e05b
No related branches found
Tags v5.21
No related merge requests found
......@@ -84,6 +84,9 @@ function xout=crp(varargin)
% $Revision$
%
% $Log$
% Revision 5.21 2016/09/23 12:54:02 marwan
% link axis of RP and data for simultaneous effects when zooming etc.
%
% Revision 5.20 2016/06/14 11:52:12 marwan
% fix for option 'rr' in order to exclude the LOI
%
......@@ -301,7 +304,7 @@ if isnumeric(varargin{1}) % read commandline input
Nx=length(x); Ny=length(y);
NX=Nx-t*(m-1);NY=Ny-t*(m-1);
if (NX<1 | NY<1) & nogui==0;
errordlg('The embedding vectors cannot be created. Dimension M and/ or delay T are to big. Please use smaller values.','Dimension/ delay to big')
errordlg('The embedding vectors cannot be created. Dimension M and/ or delay T are too big. Please use smaller values.','Dimension/ delay too big')
waitforbuttonpress
end
% normalise the data
......@@ -392,7 +395,7 @@ else % read input from the GUI
Nx=length(x); Ny=length(y);
NX=Nx-t*(m-1);NY=Ny-t*(m-1);
if (NX<1 | NY<1) & strcmpi(action,'apply');
errordlg('The embedding vectors cannot be created. Dimension M and/ or delay T are to big. Please use smaller values.','Dimension/ delay to big')
errordlg('The embedding vectors cannot be created. Dimension M and/ or delay T are too big. Please use smaller values.','Dimension/ delay too big')
waitforbuttonpress
action='';
end
......@@ -440,7 +443,7 @@ if nogui>0
action='compute';
if (NX<1 | NY<1)
disp('Warning: The embedding vectors cannot be created.')
disp('Dimension M and/ or delay T are to big. Please use smaller values.')
disp('Dimension M and/ or delay T are too big. Please use smaller values.')
action='';
end
end
......
......@@ -86,6 +86,9 @@ function xout=crp2(varargin)
% $Revision$
%
% $Log$
% Revision 5.23 2016/09/23 12:54:02 marwan
% link axis of RP and data for simultaneous effects when zooming etc.
%
% Revision 5.22 2016/03/03 14:57:40 marwan
% updated input/output check (because Mathworks is removing downwards compatibility)
% bug in crqad_big fixed (calculation of xcf).
......@@ -404,7 +407,7 @@ else % read input from the GUI
NX=Nx-t*(m-1);NY=Ny-t*(m-1);
xscale=1:Nx; yscale=1:Ny;
if (NX<1 | NY<1) & strcmpi(action,'apply');
errordlg('The embedding vectors cannot be created. Dimension M and/ or delay T are to big. Please use smaller values.','Dimension/ delay to big')
errordlg('The embedding vectors cannot be created. Dimension M and/ or delay T are too big. Please use smaller values.','Dimension/ delay too big')
waitforbuttonpress
action='';
end
......@@ -484,7 +487,7 @@ if nogui>0
action='compute';
if (NX<1 | NY<1)
disp('Warning: The embedding vectors cannot be created.')
disp('Dimension M and/ or delay T are to big. Please use smaller values.')
disp('Dimension M and/ or delay T are too big. Please use smaller values.')
action='';
end
end
......
......@@ -82,6 +82,9 @@ function xout=crp_big(varargin)
% $Revision$
%
% $Log$
% Revision 5.18 2016/09/23 12:54:02 marwan
% link axis of RP and data for simultaneous effects when zooming etc.
%
% Revision 5.17 2016/03/03 14:57:40 marwan
% updated input/output check (because Mathworks is removing downwards compatibility)
% bug in crqad_big fixed (calculation of xcf).
......@@ -288,7 +291,7 @@ if isnumeric(varargin{1})==1 % read commandline input
Nx=length(x); Ny=length(y);
NX=Nx-t*(m-1);NY=Ny-t*(m-1);
if (NX<1 | NY<1) & nogui==0;
errordlg('The embedding vectors cannot be created. Dimension M and/ or delay T are to big. Please use smaller values.','Dimension/ delay to big')
errordlg('The embedding vectors cannot be created. Dimension M and/ or delay T are too big. Please use smaller values.','Dimension/ delay too big')
waitforbuttonpress
end
% normalise the data
......@@ -378,7 +381,7 @@ else % read input from the GUI
Nx=length(x); Ny=length(y);
NX=Nx-t*(m-1);NY=Ny-t*(m-1);
if (NX<1 | NY<1) & strcmpi(action,'apply');
errordlg('The embedding vectors cannot be created. Dimension M and/ or delay T are to big. Please use smaller values.','Dimension/ delay to big')
errordlg('The embedding vectors cannot be created. Dimension M and/ or delay T are too big. Please use smaller values.','Dimension/ delay too big')
waitforbuttonpress
action='';
end
......@@ -424,7 +427,7 @@ if nogui>0
action='compute';
if (NX<1 | NY<1)
disp('Warning: The embedding vectors cannot be created.')
disp('Dimension M and/ or delay T are to big. Please use smaller values.')
disp('Dimension M and/ or delay T are too big. Please use smaller values.')
action='';
end
end
......
......@@ -149,6 +149,9 @@ function xout=crqa(varargin)
% $Revision$
%
% $Log$
% Revision 5.60 2017/03/30 14:33:27 marwan
% fixing a bug in tt.m if applied to CRP
%
% Revision 5.59 2016/09/30 15:11:02 marwan
% bug with wrong axes handle for the results plots fixed
%
......@@ -361,7 +364,7 @@ splash_gpl('crp');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% check and read the input
try
%try
errcode=1;
set(0,'ShowHidden','on')
......@@ -477,8 +480,11 @@ errcode=1;
return
end
x=double(varargin{1});
if isempty(varargin{2}) | ~isnumeric(varargin{2}), y=x; else
y=double(varargin{2}); end
if isempty(varargin{2}) | ~isnumeric(varargin{2}) | all(size(varargin{2}))
y=x;
else
y=double(varargin{2});
end
% if sum(double(diff(x(:,1))<=0)), time_scale_flag=0; end
if (isnumeric(varargin{2}) & max(size(varargin{2}))==1) | ~isnumeric(varargin{2})
......@@ -684,9 +690,14 @@ errcode=1;
% normalize data if necessary
if nonorm
x = (x - repmat(mean(x),length(x),1)) ./ repmat(std(x),length(x),1);
y = (y - repmat(mean(y),length(y),1)) ./ repmat(std(y),length(y),1);
xMean = mean(x(~isnan(x)));
yMean = mean(y(~isnan(y)));
xStd = std(x(~isnan(x)));
yStd = std(y(~isnan(y)));
x = (x - repmat(xMean,length(x),1)) ./ repmat(xStd,length(x),1);
y = (y - repmat(yMean,length(y),1)) ./ repmat(yStd,length(y),1);
end
......@@ -749,6 +760,7 @@ case 'init'
axes_height = 5.8;
axes_base = 3;
axes_hoffset = 2.5;
h = 0;
h(1)=axes(props.axes,...
'Tag','crqa_axes_Data',...
'Box','On',...
......@@ -756,10 +768,10 @@ case 'init'
if time_scale_flag
plot(xscale,x(:,2:end),'color',props.line.Color)
if ~all(x(:)==y(:)) hold on; plot(yscale,y(:,2:end),'r'), end
if ~isequal(x(~isnan(x)),y(~isnan(y))) hold on; plot(yscale,y(:,2:end),'r'), end
else
plot(xscale,x(:,1:end),'color',props.line.Color)
if ~all(x(:)==y(:)) hold on; plot(yscale,y(:,1),'r'), end
if ~isequal(x(~isnan(x)),y(~isnan(y))) hold on; plot(yscale,y(:,1),'r'), end
end
set(h(1),'Tag','crqa_axes_Data','color',props.axes.Color)
ylabel('Data')
......@@ -780,7 +792,7 @@ case 'init'
cla
text(0.5,0.5,sprintf('%6.4f',x_var(1,2)),'FontWeight','bold','HorizontalAlign','Center')
end
if ~all(x(:)==y(:))
if ~isequal(x(~isnan(x)),y(~isnan(y)))
hold on;
if time_scale_flag
y_var = winplot(y(:,2),w,wstep,2);
......@@ -794,12 +806,13 @@ case 'init'
text(0.5,0.5,sprintf('%6.5f, %6.5f',x_var(2,2),y_var(1,2)),'FontWeight','bold','HorizontalAlign','Center')
end
h3=axes('Units','Char',...
'Pos',get(h,'Pos'),...
'XLim',get(h,'XLim'),...
'YLim',get(h,'YLim'),...
'Position',get(h(2),'Position'),...
'XLim',get(h(2),'XLim'),...
'YLim',get(h(2),'YLim'),...
'YAxisLocation','right',...
'Color','none',...
'Tag','crqa_axes_CoVar',...
'XTick',[],...
'visible','off');
end
set(gcf,'CurrentAxes',h(2));
......@@ -1155,7 +1168,7 @@ if strcmpi(method,'Maximum Norm, fixed RR') method = 'rr'; end
if nogui == 1 & plugin_exist & ( method_n < 4 | method_n == 8 ) & length(x) == length(y)
disp('(plugin used)')
end
plugin_exist = 0;
errcode=20;
% general histograms of line structures for significance test
......@@ -1183,10 +1196,12 @@ for i=1:wstep:Nx-w+1;
if time_scale_flag
x_var=var(x(i:i+w-1,2)); y_var=var(y(i:i+w-1,2));
xx = x(i:i+w-1,2); yy = y(i:i+w-1,2);
x_var=var(xx(~isnan(xx))); y_var=var(yy(~isnan(yy)));
temp=cov(x(i:i+w-1,2),y(i:i+w-1,2));
else
x_var=var(x(i:i+w-1,1)); y_var=var(y(i:i+w-1,1));
xx = x(i:i+w-1,1); yy = y(i:i+w-1,1);
x_var=var(xx(~isnan(xx))); y_var=var(yy(~isnan(yy)));
temp=cov(x(i:i+w-1,1),y(i:i+w-1,1));
end
xy_var=temp(1,2);
......@@ -1237,6 +1252,10 @@ for i=1:wstep:Nx-w+1;
errcode=22;
% import RQA
rqa_in = [];
RR = NaN; DET = NaN; LAM = NaN; Lmax = NaN;
L = NaN; ENTR = NaN; Vmax = NaN; TT = NaN; t1 = NaN; t2 = NaN;
RT = NaN; RTmax = NaN; RF = NaN; ENTW = NaN;
try
fid = fopen(tmp_rqadatafile,'r'); % open RQA data file
while 1
......@@ -1290,7 +1309,7 @@ for i=1:wstep:Nx-w+1;
if time_scale_flag
if length(x(i:i+w-1,:)) > 2000
X=crp_big(x(i:i+w-1,:),y(i:i+w-1,:),m,t,e,method,'nonorm','silent');
else
else
X=crp(x(i:i+w-1,:),y(i:i+w-1,:),m,t,e,method,'nonorm','silent');
end
else
......@@ -1442,7 +1461,7 @@ for i=1:wstep:Nx-w+1;
% global clustering coefficient
errcode=279;
kv = sum(X_theiler,1); % degree of nodes
Clust = mean(diag(double(X_theiler)*double(X_theiler)*double(X_theiler))' ./ (kv .* (kv-1)));
Clust = nanmean(diag(double(X_theiler)*double(X_theiler)*double(X_theiler))' ./ (kv .* (kv-1)));
% transitivity
denom = sum(sum(double(X_theiler) * double(X_theiler)));
Trans = trace(double(X_theiler)*double(X_theiler)*double(X_theiler))/denom;
......@@ -1541,7 +1560,8 @@ if ~nogui
h=findobj('Tag','crqa_axes_RTE','Parent',gcf); h_axes.h(7)=h(1);
h=findobj('Tag','crqa_axes_T2','Parent',gcf); h_axes.h(8)=h(1);
h=findobj('Tag','crqa_axes_Var','Parent',gcf); h_axes.h(9)=h(1);
if ~all(x(:)==y(:)), h=findobj('Tag','crqa_axes_CoVar','Parent',gcf); h_axes.h(10)=h(1); end
if ~isequal(x(~isnan(x)),y(~isnan(y))), h=findobj('Tag','crqa_axes_CoVar','Parent',gcf); h_axes.h(10)=h(1); end
for i=1:9,
set(gcf,'CurrentAxes',h_axes.h(i))
if size(Y,1)==1
......@@ -1554,11 +1574,11 @@ if ~nogui
% set(h_axes.h(i+1),'visible','off');
% end
else
if i==9
if i==9 % Variance and covariance plot
cla
h2=stairs(xscale(1:wstep:length(Y)),Y(1:wstep:end,index(i)));
set(h2,'color',props.line.Color)
if ~all(x(:)==y(:))
if ~isequal(x(~isnan(x)),y(~isnan(y)))
set(gca,'Color','none')
hold on; h2=stairs(xscale(1:wstep:length(Y)),Y(1:wstep:end,index(10)),'r');
set(gcf,'CurrentAxes',h_axes.h(i+1));cla
......@@ -1566,7 +1586,7 @@ if ~nogui
h3=stairs(xscale(1:wstep:length(Y)),Y(1:wstep:end,index(11))); set(h3,'color',[0 .4 0]);
ylabel(tx(i+1));
set(h_axes.h(i+1),'Tag',tags{i+1},'Units','Norm','Color','none','YAxisLocation','right','YColor',[0 .4 0])
set(h_axes.h(i+1),'Tag',tags{i+1},'Units','Norm','Color','none','YAxisLocation','right','YColor',[0 .4 0],'xtick',[])
end
else
plot(xscale(1:wstep:length(Y)),Y(1:wstep:end,index(i)),'color',props.line.Color)
......@@ -1582,7 +1602,7 @@ if ~nogui
set(h(1),'UserData',Y,'Enable','On')
xlim = get(h_axes.h(9),'xlim');
if length(Y(:,1)) > 1, set(h_crqa_axes_Data,'xlim',xlim), end
if ~all(x(:)==y(:)) & length(Y(:,1)) == 1, set(h_axes.h(10),'visible','off'); delete(get(h_axes.h(10),'children')), end
if ~isequal(x(~isnan(x)),y(~isnan(y))) & length(Y(:,1)) == 1, set(h_axes.h(10),'visible','off'); delete(get(h_axes.h(10),'children')), end
else
if nargout, xout=Y(:,argout_index); end
end
......@@ -1597,8 +1617,8 @@ end
%if 0
catch
if 0
%catch
if nogui~=2, if ishandle(hw), close(hw), end , end
if nargout, xout = NaN; end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment