Newer
Older
[X matext] = crp_plugin(x, y, m0, t, e, mflag, hCRP, plugin_path, 0);
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
else
% use builtin implementation
if ~nogui
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Import Embedding Vectors'),drawnow
end
ex=ceil(find(~(ds+1))/m);
x(:,ex)=[]; y(:,ex)=[];
m=m-length(ex);
if m==0,
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','No embedding vectors!'),drawnow
return
end
if m0>1
x2=x(1:end-t*(m0-1),:);
y2=y(1:end-t*(m0-1),:);
for i=1:m0-1,
if check_stop(hCRP,hCtrl,nogui,obj), break, end
x2(:,m*i+1:m*(i+1))=x(1+t*i:end-t*(m0-i-1),:);
y2(:,m*i+1:m*(i+1))=y(1+t*i:end-t*(m0-i-1),:);
end
x=x2; y=y2; Nx=size(x,1); Ny=size(y,1);
m=m0*m; clear x2 y2
end
x1=repmat(x,1,Ny);
for mi=1:m,
x2(:,mi)=reshape(rot90(x1(:,0+mi:m:Ny*m+mi-m)),Nx*Ny,1);
end
if ~nonorm, unit = ''; else unit = '\sigma'; end
switch(mflag)
%%%%%%%%%%%%%%%%% local CRP, fixed distance maximum norm
errcode=111;
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Compute Distance Matrix'),drawnow
s=zeros(m,Nx*Ny);
X=uint8(zeros(Ny,Nx));
if check_stop(hCRP,hCtrl,nogui,obj), return, end
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Compute Distance Matrix'),drawnow
s1=x1-y1;
switch mflag
case 1
%%%%%%%%%%%%%%%%% maximum norm
if m>1
if check_stop(hCRP,hCtrl,nogui,obj), return, end
s=max(abs(s1'));
else
s=abs(s1);
end
matext=[num2str(round(100*e)/100) unit ' (fixed distance maximum norm)'];
case 5
%%%%%%%%%%%%%%%%% maximum norm, fixed RR
errcode=115;
if m>1
if check_stop(hCRP,hCtrl,nogui,obj), return, end
s=max(abs(s1'));
else
s=abs(s1);
end
ss = sort(s(:));
idx = ceil(e * length(ss));
e = ss(idx);
matext=[num2str(round(100*e)/100) '\sigma (fixed distance maximum norm, fixed RR)'];
case 2
%%%%%%%%%%%%%%%%% euclidean norm
errcode=112;
if m>1
if check_stop(hCRP,hCtrl,nogui,obj), return, end
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Transpose Matrix'),drawnow
s=s1.^2';
if check_stop(hCRP,hCtrl,nogui,obj), return, end
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Sum Matrix'),drawnow
s1=sum(s);
if check_stop(hCRP,hCtrl,nogui,obj), return, end
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Squareroot Matrix'),drawnow
s=sqrt(s1);
else
s=abs(s1);
end
matext=[num2str(round(100*e)/100) unit ' (fixed distance euclidean norm)'];
case 3
%%%%%%%%%%%%%%%%% minimum norm
errcode=113;
if m>1
if check_stop(hCRP,hCtrl,nogui,obj), return, end
s = sum(abs(s1),2);
else
s=abs(s1);
end
matext=[num2str(round(100*e)/100) unit ' (fixed distance minimum norm)'];
%%%%%%%%%%%%%%%%% now apply threshold
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')'),'String','Building CRP Matrix'),drawnow
X2 = s<e;
X=reshape(uint8(X2),Ny,Nx);
clear s s1 x1 y1
errcode=114;
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Normalize Embedding Vectors'),drawnow
Dx=sqrt(sum(((x1(:,:)).^2)'))';
if check_stop(hCRP,hCtrl,nogui,obj), return, end
Dy=sqrt(sum(((y1(:,:)).^2)'))';
if check_stop(hCRP,hCtrl,nogui,obj), return, end
x1=x1./repmat(Dx,1,m);
if check_stop(hCRP,hCtrl,nogui,obj), return, end
y1=y1./repmat(Dy,1,m); clear Dx Dy
if check_stop(hCRP,hCtrl,nogui,obj), return, end
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Reshape Embedding Vectors'),drawnow
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Compute Distance Matrix'),drawnow
if m>1
s=sqrt(sum(((x1(:,:)-y1(:,:)).^2)'));
else
s=abs(x1(:,1)-y1(:,1));
end
if check_stop(hCRP,hCtrl,nogui,obj), return, end
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Building CRP Matrix'),drawnow
X=uint8(reshape((s/max(s))<(e/max(s)),Ny,Nx)); clear s x1 y1
matext=[num2str(round(100*e)/100) unit ' (normalized distance euclidean norm)'];
if e>=1
e=round(e)/100;
txt=['The value for fixed neigbours amount has to be smaller '...
'than one. Continue the computation with a value of ' ...
num2str(e)];
if nogui==0
warndlg(txt,'Threshold value mismatch');
drawnow
waitforbuttonpress
set(findobj('Tag','Size','Parent',gcf),'String',num2str(e))
end
end
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Reshape Embedding Vectors'),drawnow
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Compute Distance Matrix'),drawnow
if m>1
s=sqrt(sum(((x1(:,:)-y1(:,:)).^2)'));
else
s=abs(x1(:,1)-y1(:,1));
end
if check_stop(hCRP,hCtrl,nogui,obj), return, end
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Sort Distance Matrix'),drawnow
mine=round(Ny*e);
[SS, JJ]=sort(reshape(s,Ny,Nx)); JJ=JJ';
if check_stop(hCRP,hCtrl,nogui,obj), return, end
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Building CRP Matrix'),drawnow
X1(Nx*Ny)=uint8(0); X1(JJ(:,1:mine)+repmat([0:Ny:Nx*Ny-1]',1,mine))=uint8(1);
if check_stop(hCRP,hCtrl,nogui,obj), return, end
X=reshape(X1,Ny,Nx); clear X1 SS JJ s
matext=[num2str(round(1000*mine/Ny)/10) '% (fixed neighbours amount)'];
warning('Method not available!')
matext='';
%%%%%%%%%%%%%%%%% order matrix
warning('Method not available!')
matext='';
%%%%%%%%%%%%%%%%% order pattern recurrence plot
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Compute Order Patterns'),drawnow
% create a order pattern test
cmdStr = '';
for i=2:m;
cmdStr = [cmdStr, ' permX(:,', num2str(i-1) ,') < permX(:,', num2str(i), ') + eps'];
if i < m, cmdStr = [cmdStr, ' &']; end
end
if m==1
cmdStr = '1';
disp('Warning: No order patterns for dimension one; please use higher dimension!')
end
% order patterns by permutation of the set of values
clear patt*
for i=1:size(x,1)
permX=perms(x(i,:));
orderPattern = find(eval(cmdStr));
if isempty(orderPattern) orderPattern = 0; end
pattX(i) = orderPattern(1);
end
for i=1:size(y,1)
permX=perms(y(i,:));
orderPattern = find(eval(cmdStr));
if isempty(orderPattern) orderPattern = 0; end
pattY(i) = orderPattern(1);
end
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Create Order Patterns Matrix'),drawnow
px = permute(pattX', [ 1 3 2 ]);
py = permute(pattY', [ 3 1 2 ]);
X = uint8(px(:,ones(1,length(y)),:) == py(ones(1,length(x)),:,:));
X = X';
if check_stop(hCRP,hCtrl,nogui,obj), return, end
matext='';
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
%%%%%%%%%%%%%%%%% Levenshtein
case 10
errcode=120;
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Compute Distance Matrix'),drawnow
s1 = levenshtein(x1, y1);
X = reshape(s1,Ny,Nx);
matext='';
%%%%%%%%%%%%%%%%% DTW
case 11
errcode=121;
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Compute Distance Matrix'),drawnow
s1 = dtw(x1, y1);
X = reshape(s1,Ny,Nx);
matext='';
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
%%%%%%%%%%%%%%%%% global CRP
case length(check_meth)
errcode=110+length(check_meth);
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Reshape Embedding Vectors'),drawnow
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Compute Distance Matrix'),drawnow
if m>1
s=sqrt(sum(((x1(:,:)-y1(:,:)).^2)'));
else
s=abs(x1(:,1)-y1(:,1));
end
if check_stop(hCRP,hCtrl,nogui,obj), return, end
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Building CRP Matrix'),drawnow
X=reshape(s,Ny,Nx);
matext='';
end
end % end plugin
if nogui==0
for i=1:length(obj.enable), set(obj.children(i),'Enable',obj.enable{i}); end
set(h(1),'String','Create Recurrence Plot',...
'ToolTip','Starts the computation - be patient.',...
'Callback','crp2 compute')
setptr([hCRP,hCtrl],'arrow')
end
%%%%%%%%%%%%%%%%% show CRP
if nogui==0
Shuttle.hCRP=hCRP;
Shuttle.hCtrl=hCtrl;
Shuttle.matext=matext;
Shuttle.xscale=xscale;
Shuttle.yscale=yscale;
Shuttle.mflag=mflag;
Shuttle.m=m;
Shuttle.t=t;
Shuttle.cm=cm;
Shuttle.txt_cross=txt_cross;
if isempty(X)
warn_str = ['Uuups! Empty matrix.',10,'I give up ...'];
if strcmpi(computer,'GLNXA64')
warn_str = [warn_str,10,'(Maybe non-appropriate plugin version due to different glibc.)']
end
warning(warn_str);
return
end
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
end
if strcmpi(get(findobj('Tag','SetPoint','Parent',hCtrl),'Enable'),'off')
set(findobj('Tag','TextLOSsearch','Parent',hCtrl),'Enable','On')
set(findobj('Tag','SetPoint','Parent',hCtrl),'Enable','On')
set(findobj('Tag','ClearPoint','Parent',hCtrl),'Enable','On')
set(findobj('Tag','ClearAllPoint','Parent',hCtrl),'Enable','On')
set(findobj('Tag','LOSwidthXtext','Parent',hCtrl),'Enable','On')
set(findobj('Tag','LOSwidthX','Parent',hCtrl),'Enable','On')
set(findobj('Tag','LOSwidthYtext','Parent',hCtrl),'Enable','On')
set(findobj('Tag','LOSwidthY','Parent',hCtrl),'Enable','On')
set(findobj('Tag','Apply2','Parent',hCtrl),'Enable','On')
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% store2
case 'store2'
errcode=15;
t=get(findobj('Tag','Apply2','Parent',hCtrl),'UserData');
if isempty(t)
warndlg('The LOS vector is still empty. Please start the computation of the LOS before storing.','No LOS')
waitforbuttonpress
else
assignin('base','t_out', t)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LOSmove
case 'LOSmove'
errcode=16;
if isempty(get(gco,'UserData'))
set(gco,'UserData',1,'ButtonDownFcn','crp2 LOSmove_end')
set(gcf,'WindowButtonMotionFcn','crp2 LOSmove')
end
h1 = round(get(gca,'CurrentPoint'));
set(gco, 'XData', h1(1,1), 'YData', h1(1,2))
clear h1
case 'LOSmove_end'
errcode=161;
if ~isempty(get(gco,'UserData'))
set(gco,'UserData',[],'ButtonDownFcn','')
set(gcf,'WindowButtonMotionFcn','')
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LOSclear
case 'LOSclear'
errcode=17;
if gcf==hCtrl
figure(hCRP)
k=waitforbuttonpress;
h1 = round(get(gca,'CurrentPoint')); h1(2,:)=[]; h1(:,3)=[];
finalRect = rbbox;
h2 = round(get(gca,'CurrentPoint')); h2(2,:)=[]; h2(:,3)=[];
h(1,1)=min(h1(:,1),h2(:,1));h(2,1)=max(h1(:,1),h2(:,1));
h(1,2)=min(h1(:,2),h2(:,2));h(2,2)=max(h1(:,2),h2(:,2));
i=find(fixp(:,1)>=h(1,1) & fixp(:,2)>=h(1,2) & fixp(:,1)<=h(2,1) & fixp(:,2)<=h(2,2));
for j=1:length(i); delete(findobj('tag','fixp','Parent',findobj('Parent',hCRP,'Tag','CRPPlot'),'xdata',fixp(i(j),1))), end
else
h(1,1)=get(gco,'XData');h(1,2)=get(gco,'YData');
delete(gco)
end
clear h
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LOSallclear
case 'LOSallclear'
errcode=171;
delete(findobj('tag','fixp','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LOSset
case 'LOSset'
errcode=18;
if gcf==hCtrl
figure(hCRP)
ginput(1);
end
h=round(get(gca,'currentp'));
fixp(end+1,1)=h(1,1); fixp(end,2)=h(1,2);
[i j]=sort(fixp(:,1));
fixp=fixp(j,:);
h0=uicontextmenu;
line(h(1,1),h(1,2),1000,...
'MarkerSize',12,...
'Marker','.',...
'Color',[1 0 0],...
'Tag','fixp',...
'UIContextMenu',h0)
uimenu(h0, 'Label', 'Set Point', 'Callback', 'crp2 LOSset')
uimenu(h0, 'Label', 'Move Point', 'Callback', 'crp2 LOSmove')
uimenu(h0, 'Label', 'Clear Point', 'Callback', 'crp2 LOSclear')
clear h h0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LOSsearch
case 'LOSsearch'
errcode=19;
if nogui==0
setptr([hCRP,hCtrl],'watch')
h=findobj('Tag','Apply2','Parent',hCtrl);
obj.children=get(hCtrl,'Children');
obj.enable=get(obj.children,'Enable');
set(obj.children,'Enable','off')
set(h(1),'String','Stop',...
'ToolTip','Stops the computation.',...
'Enable','on',...
'Callback','set(gcbo,''String'',''Stopped'')')
end
x0=0;
y0=0;
Dmax1=str2num(get(findobj('Tag','LOSwidthX','Parent',hCtrl),'string'));
Dmax2=str2num(get(findobj('Tag','LOSwidthY','Parent',hCtrl),'string'));
X=double(get(findobj('Tag','CRPData','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'UserData'));
N=size(X); Nleer=0; Nvoll=0;
minvalue=min(min(X));maxvalue=max(max(X));
if (length(find(X==minvalue))+length(find(X==maxvalue))==length(X(:)))
flagpoint=0;
% looks for the beginning of the diagonal LOS
errcode=191;
for i=1:N(2);
if check_stop_LOS(hCRP,hCtrl,nogui,obj), break, end
if i<=N(1)
if ~isempty(fixp), if i>=fixp(1,1), x0=fixp(1,1); y0=fixp(1,2); end, end
if X(i+y0,1+x0)~=0
v=i+y0;
h=1+x0;
break
end
end
if X(1+y0,i+x0)~=0
h=i+x0;
v=1+y0;
break
end
end
Nleer=i-1;
% t(1:v)=h;
t(1+x0:h)=v;
% start estimation of the LOS
errcode=192;
mflag=0;
i=2;
% h_wait=waitbar(0,'Compute LOS ...',props.window);
h_wait=waitbar(0,'Compute LOS ...');
set(h_wait,'HandleVisibility','on');
while h<N(2)-1 & v<N(1)-1 & mflag~=1,
waitbar(h/N(2))
if check_stop_LOS(hCRP,hCtrl,nogui,obj), break, end
dw=1;
if v < 1, v = 1; end
if h < 1, h = 1; end
W=X(v:v+dw,h:h+dw);
W(1,1)=0;
if ~isempty(fixp)
if find(h==fixp(:,1))
if dv <= 0
if isempty(h0), h0 = h; end
t0 = t(end) + dv;
fixold = find(h==fixp(:,1));
if ~isempty(fixold) & fixold > 1; fixold = fixp(fixold - 1,1); else fixold = 0; end
h1 = max([h0-min([Dmax1,Dmax2]);1;fixold]);
h2 = max([h0;1;fixold]);
% h1 = max([h-2*(h-h0);1])
if length(t) > h1 & length(t) > h2
t1 = t(h1);
p = polyfit([h1 h2 h],[t1 t2 t0],1);
t(h1:h) = polyval(p,h1:h);
% t(h1:h) = spline([h1 h2 h],[t1 t2 t0],h1:h);
end
v = v + dv;
dv = 1; dw = 0;
end
flagpoint=1;
end
end
if flagpoint==0;
% looks for the existence of the next recurrence point in diagonal direction
errcode=193;
while sum(sum(W))==0 & mflag==0 & flagpoint==0,
Nleer=Nleer+1;
if ~isempty(fixp)
if find(h+dw==fixp(:,1))
W=1; dh=dw;
flagpoint=1;
break
end
end
dw=dw+1;
if v+dw < N(1) & h+dw < N(2)
W=X(v:v+dw,h:h+dw);
W(1,1)=0;
else
mflag=1;
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
end
end
if mflag==1
break
end
% determines the coordinates of the next recurrence point
errcode=194;
dh0=min(find(sum(W)));
dv0=min(find(sum(W')));
dh=min(find(W(dv0,:)));
dv=min(find(W(:,dh0)));
if dh>dh0, dh=dh0;end
if dv>dv0, dv=dv0;end
% determines the local width of the diagonal LOS
errcode=195;
dh1=dh;
dv1=dv;
% neues Fenster
WL1=Dmax1;
WL2=Dmax2;
if v+dv1-2+WL2>=N(1), WL2=N(1)-(v+dv1-2); end
if h+dh1-2+WL1>=N(2), WL1=N(2)-(h+dh1-2); end
Wn=X(v+dv1-1:v+dv1-2+WL2,h+dh-1:h+dh-2+WL1);
% Schwerpunkt davon ausrechnen
if sum(sum(Wn))~=0, Sh=sum(sum(Wn).*[1:WL1])/sum(sum(Wn));else Sh=WL1/2;end
if sum(sum(Wn'))~=0,Sv=sum(sum(Wn').*[1:WL2])/sum(sum(Wn'));else Sv=WL2/2;end
% neue Dmax berechnen
if Sh>=Sv, Dmax2n=WL1*Sv/Sh; Dmax1n=WL1; end
if Sv>Sh, Dmax1n=WL2*Sh/Sv; Dmax2n=WL2; end
% while X(v+dv1-1,h:dh-1)==1 & v+dv1-1<N(1) &dv1<Dmax2
while X(v+dv1-1,h+dh-1)==1 & v+dv1-1<N(1) &dv1<Dmax2n
dv1=dv1+1;
end
% while X(v:dv-1,h+dh1-1)==1 & h+dh1-1<N(2) & dh1<Dmax1
while X(v+dv-1,h+dh1-1)==1 & h+dh1-1<N(2) & dh1<Dmax1n
if ~isempty(fixp)
if find(h+dh1-1==fixp(:,1)) & find(h+fix((dh1+dh)/2)==fixp(:,1))
dv=fixp(find((h+dh1-1)==fixp(:,1)),2)-v;
if isempty(dv), dv=fixp(find((h+fix((dh1+dh)/2))==fixp(:,1)),2)-v; end
flagpoint=1;
break
end
end
dh1=dh1+1;
end
% compute the mean of the diagonal LOS
errcode=196;
if flagpoint==0
dh=fix((dh1+dh)/2);
dv=fix((dv1+dv)/2);
if dh>0
dh=dh-1;
end
if dv>0
dv=dv-1;
end
% dh=dh+dh1;
end
end % flagpoint end
flagpoint=0;
% output
if dh~=0 & dv~=0
t(h:h+dh)=v:dv/dh:v+dv;
elseif dv~=0
t(h)=v+dv;
elseif dv==0
t(h:h+dh)=v;
end
Nvoll=Nvoll+sqrt(dv^2+dh^2);
if dh==0 & dv==0
dh=1;
end
% moves the startpoint for further looking
h=h+dh;
v=v+dv;
end
else
% DTW algorithm
h_wait=waitbar(0,'Compute LOS ...');
set(h_wait,'HandleVisibility','on',props.window);
t=1;
i=y0+1; j=x0+1;
flag2=0;
while i<N(1)-Dmax1-1 & j<N(2)-Dmax2-1
errcode=197;
waitbar(i/N(1)), j0=j;
% [temp pos]=min([sum(sum(X(i:i+Dmax1,j+1:j+1+Dmax2))),sum(sum(X(i+1:i+1+Dmax1,j+1:j+1+Dmax2))),sum(sum(X(i+1:i+1+Dmax1,j:j+Dmax2)))]);
[temp pos]=min([(mean(X(i,j+1:j+1+Dmax2))),(mean(diag(X(i+1:i+1+Dmax1,j+1:j+1+Dmax2)))),(mean(X(i+1:i+1+Dmax1,j)))]);
switch(pos)
case 1
j=j+1;
flag1=1;
case 2
i=i+1; j=j+1;
flag1=1;
flag2=1;
case 3
i=i+1;
flag2=1;
end
if ~isempty(fixp) & flag1==1 & flag2==1
errcode=1981;
h=find(fixp(:,1)==j);
if ~isempty(h) & i<max(fixp(h,2));
h2=find(i<=fixp(h,2));
i=fixp(h(h2(1)),2); flag1=0; end
end
if ~isempty(fixp) & flag2==1 & flag1==1
errcode=1982;
h=find(fixp(:,2)==i);
if ~isempty(h) & j<max(fixp(h,1));
h2=find(j<=fixp(h,1));
j=fixp(h(h2(1)),1);
t(j0:j-1)=t(j0);
flag2=0; end
end
t(j)=i;
end
t(find(~t))=1;
end
delete(h_wait)
errcode=199;
h1=findobj('Parent',hCRP,'Tag','CRPPlot');
h2=findobj('Tag','Diagonal','Parent',h1);
if isempty(h2)
h2=line('Parent',h1,'visible','on','Tag','Diagonal','color',[1 0 0],...
'LineWidth',1);
end
set(h2,'xdata',[1:length(t)],'ydata',t,'visible','on')
set(findobj('Tag','Apply2','Parent',hCtrl),'UserData',t)
if nogui==0
setptr([hCRP,hCtrl],'arrow')
h=findobj('Tag','Apply2','Parent',hCtrl);
set(h(1),'String','Apply',...
'ToolTip','Searches the LOS.',...
'Callback','crp2 LOSsearch')
for i=1:length(obj.enable), set(obj.children(i),'Enable',obj.enable{i}); end
end
set(findobj('Tag','Store2','Parent',hCtrl),'Enable','On')
end
try, set(0,props.root), end
warning on
set(0,'ShowHidden','Off')
%%%%%%% error handling
try
if nogui==0
for i=1:length(obj.enable), set(obj.children(i),'Enable',obj.enable{i}); end
set(h(1),'String','Apply',...
'ToolTip','Starts the computation - be patient.',...
'Callback','crp compute')
setptr([hCRP,hCtrl],'arrow')
end
if nargout, xout = NaN; end
end
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
z=whos;x=lasterr;y=lastwarn;in=varargin{1};
print_error('crp2',z,x,y,in,mflag,action)
try, set(0,props.root), end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out=check_stop_LOS(hCRP,hCtrl,nogui,obj)
global errcode
errcode=errcode+.02;
out=0;
if nogui==0
h=findobj('Tag','Apply2','Parent',hCtrl);
if strcmpi(get(h(1),'String'),'stopped')
set(h(1),'String','Apply',...
'ToolTip','Searches the LOS.',...
'Callback','crp2 LOSsearch')
for i=1:length(obj.enable), set(obj.children(i),'Enable',obj.enable{i}); end
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')'),'String','Stopped'),drawnow
setptr([hCRP,hCtrl],'arrow')
out=1;
end
end