0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 function varargout = civ(varargin)
0023
0024
0025
0026 gui_Singleton = 1;
0027 gui_State = struct('gui_Name', mfilename, ...
0028 'gui_Singleton', gui_Singleton, ...
0029 'gui_OpeningFcn', @civ_OpeningFcn, ...
0030 'gui_OutputFcn', @civ_OutputFcn, ...
0031 'gui_LayoutFcn', [] , ...
0032 'gui_Callback', []);
0033 if nargin && ischar(varargin{1})
0034 gui_State.gui_Callback = str2func(varargin{1});
0035 end
0036
0037 if nargout
0038 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0039 else
0040 gui_mainfcn(gui_State, varargin{:});
0041 end
0042
0043
0044
0045
0046
0047 function civ_OpeningFcn(hObject, eventdata, handles, varargin)
0048
0049
0050
0051
0052
0053 global test_batch patch_new_exe
0054
0055
0056
0057
0058
0059
0060
0061 handles.output = hObject;
0062
0063 guidata(hObject, handles);
0064
0065
0066 filebase='';
0067 nom_type=[];
0068 ext=[];
0069 testall=0;
0070 browse=[];
0071
0072
0073 if ~isempty(varargin)
0074 varcell=varargin{1};
0075 filebase=varcell{1};
0076 nom_type_read=varcell{2};
0077 num1=varcell{3};
0078 num2=varcell{4};
0079 num_a=varcell{5};
0080 num_b=varcell{6};
0081 subdir=varcell{7};
0082 ind_opening=varcell{8};
0083 ext=varcell{11};
0084 else
0085 num1=1;
0086 num2=2;
0087 num_a=1;
0088 num_b=1;
0089 subdir='A';
0090 ind_opening=1;
0091 end
0092
0093 if exist('ext','var') && length(ext)>1 && (~isempty(imformats(ext([2:end])))|...
0094 isequal(ext,'.avi')||isequal(ext,'.AVI'));
0095 set(handles.ext_ima,'String',ext)
0096 if exist('nom_type_read','var')
0097 browse.nom_type_ima=nom_type_read;
0098 end
0099 elseif isequal(ext,'.nc')
0100 if exist('nom_type_read','var')
0101 browse.nom_type_nc=nom_type_read;
0102 end
0103 end
0104 set(handles.displ_filebase,'String',filebase);
0105 set(handles.ImaDoc,'UserData',testall);
0106 set(handles.ImaDoc,'String',ext)
0107
0108
0109
0110
0111
0112
0113
0114 path_uvmat=which('uvmat');
0115 path_UVMAT=fileparts(path_uvmat);
0116 if isunix
0117 syst='LINUX'
0118
0119 xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml');
0120 display(xmlfile)
0121 if exist(xmlfile,'file')
0122 t=xmltree(xmlfile);
0123 sparam=convert(t);
0124 end
0125 else
0126 syst='WIN'
0127
0128 xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml');
0129 if exist(xmlfile,'file')
0130 t=xmltree(xmlfile);
0131 sparam=convert(t);
0132 end
0133 end
0134
0135 patch_new_exe='';
0136
0137 sge=0;
0138
0139 if isfield(sparam,'PatchNew_exe')
0140 patch_new_exe=sparam.PatchNew_exe;
0141 end
0142 if isfield(sparam,'Todo_path')
0143 todo_path=sparam.Todo_path
0144 end
0145 if isfield(sparam,'SGE')
0146 sge=str2num(sparam.SGE);
0147 end
0148 name_todo=fullfile(todo_path,'TODO.txt');
0149 display(name_todo)
0150 test_batch=1;
0151 if ~sge
0152 if isequal(todo_path,'') || isequal(todo_path,[])
0153 display(['no batch distributed processing available:file path TODO.txt not defined in UVMAT/PARAM_' syst])
0154 test_batch=0;
0155 end
0156 if exist(name_todo,'file')~=2
0157 msgbox_uvmat('WARNING',['no batch distributed processing available, queue file ' name_todo ' absent']);
0158
0159 end
0160 end
0161
0162
0163 if test_batch==0
0164 set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])
0165 end
0166
0167 set(handles.subdir_civ1,'String',subdir)
0168 set(handles.subdir_civ2,'String',subdir)
0169
0170
0171 if isequal(ind_opening,[])
0172 ind_opening=1;
0173 end
0174
0175 enable_civ1(handles,'off')
0176 enable_civ2(handles,'off')
0177 enable_pair1(handles,'on')
0178 enable_fix1(handles,'off')
0179 desable_patch1(handles)
0180 desable_fix2(handles)
0181 desable_patch2(handles)
0182 set(handles.CIV1,'Value',0)
0183 set(handles.FIX1,'Value',0)
0184 set(handles.PATCH1,'Value',0)
0185 set(handles.CIV2,'Value',0)
0186 set(handles.FIX2,'Value',0)
0187 set(handles.PATCH2,'Value',0)
0188 set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784])
0189 if isequal(ind_opening,1)
0190 set(handles.CIV1,'Value',1)
0191 enable_civ1(handles,'on')
0192 elseif isequal(ind_opening,2)
0193 set(handles.FIX1,'Value',1)
0194 enable_fix1(handles,'on')
0195 elseif isequal(ind_opening,3)
0196 set(handles.PATCH1,'Value',1)
0197 enable_patch1(handles)
0198 elseif isequal(ind_opening,4)
0199 set(handles.CIV2,'Value',1)
0200 enable_civ2(handles,1)
0201 elseif isequal(ind_opening,5)
0202 set(handles.FIX2,'Value',1)
0203 enable_fix2(handles)
0204 set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
0205 set(handles.list_pair_civ2,'Enable','On')
0206 set(handles.list_pair_civ2,'Enable','On')
0207 enable_pair1(handles,'off')
0208 elseif isequal(ind_opening,6)
0209 set(handles.PATCH2,'Value',1)
0210 enable_patch2(handles)
0211 set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
0212 set(handles.list_pair_civ2,'Enable','On')
0213 enable_pair1(handles,'off')
0214 end
0215
0216
0217 if isempty(num2)|isequal(num2,num1)
0218 num_ref_i=num1;
0219 else
0220 num_ref_i=floor((num1+num2)/2);
0221 browse.incr_pair(1)=num2-num1;
0222 browse.incr_pair(2)=0;
0223 end
0224 if isempty(num_b)|isequal(num_a,num_b)
0225 if isempty(num_a)
0226 num_ref_j=1;
0227 else
0228 num_ref_j=num_a;
0229 end
0230 else
0231 num_ref_j=floor((num_a+num_b)/2);
0232 browse.incr_pair(2)=num_b-num_a;
0233 end
0234 set(handles.first_i,'String',num2str(num_ref_i));
0235 set(handles.last_i,'String',num2str(num_ref_i));
0236 set(handles.first_j,'String',num2str(num_ref_j));
0237 set(handles.last_j,'String',num2str(num_ref_j));
0238 set(handles.ref_i,'String',num2str(num_ref_i));
0239 set(handles.ref_j,'String',num2str(num_ref_j));
0240 set(handles.browse_root,'UserData',browse);
0241 if ~isempty(varargin)
0242 displ_filebase_Callback(hObject, eventdata, handles);
0243 end
0244
0245 set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001])
0246 set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001])
0247 set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001])
0248 set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001])
0249
0250
0251
0252
0253
0254 function varargout = civ_OutputFcn(hObject, eventdata, handles)
0255
0256
0257
0258
0259
0260 varargout{1} = handles.output;
0261
0262
0263
0264 function browse_root_Callback(hObject, eventdata, handles)
0265
0266 filebase=get(handles.displ_filebase,'String');
0267 oldfile='';
0268 if isempty(filebase)|isequal(filebase,'')
0269 dir_perso=prefdir;
0270 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
0271 display(profil_perso)
0272 if exist(profil_perso,'file')
0273 h=load (profil_perso);
0274 if isfield(h,'filebase')&& ischar(h.filebase)
0275 oldfile=h.filebase;
0276 end
0277 if isfield(h,'RootPath') && ischar(h.RootPath)
0278 oldfile=h.RootPath;
0279 end
0280 end
0281 else
0282 oldfile=filebase;
0283 end
0284 testall=get(handles.ImaDoc,'UserData');
0285 ind_opening=1;
0286 browse.incr_pair=[0 0];
0287 if testall
0288 menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
0289 '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'};
0290 else
0291 menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
0292 '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';...
0293 '*.*', 'All Files (*.*)'};
0294 end
0295 [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile);
0296 fileinput=[PathName FileName];
0297 sizf=size(fileinput);
0298 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
0299 [path,name,ext]=fileparts(fileinput);
0300 testeditxml=0;
0301 if isequal(ext,'.xml')
0302 testeditxml=1;
0303 t_browse=xmltree(fileinput);
0304 head_element=get(t_browse,1);
0305 if isfield(head_element,'name')& isequal(head_element.name,'ImaDoc')
0306 testeditxml=0;
0307 end
0308 end
0309 if testeditxml==1 | isequal(ext,'.xls')
0310 heditxml=editxml({fileinput});
0311 set(heditxml,'Tag','browser')
0312 waitfor(heditxml,'Tag','idle')
0313 if ~ishandle(heditxml)
0314 return
0315 end
0316 attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes');
0317 set(handles.browse,'UserData',fileinput)
0318 fileinput=get(attr,'UserData');
0319 if ~exist(fileinput,'file')
0320 return
0321 end
0322 end
0323
0324 [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput);
0325 filebase=fullfile(RootPath,RootFile);
0326 if isequal(get(handles.compare,'Value'),1)
0327 browse=[];
0328 else
0329 browse=get(handles.browse_root,'UserData');
0330 end
0331 if length(ext)>1 & (~isempty(imformats(ext([2:end])))|...
0332 isequal(ext,'.avi')|isequal(ext,'.AVI'));
0333 set(handles.ext_ima,'String',ext)
0334 browse.nom_type_ima=nom_type;
0335 browse.field_count=str2num(field_count);
0336 A=imread(fileinput);
0337 npxy=size(A)
0338 set(handles.ext_ima,'UserData',npxy)
0339 end
0340 set(handles.ImaDoc,'String',ext);
0341
0342
0343 if isequal(ext,'.nc')
0344 browse.nom_type_nc=nom_type;
0345 ind_opening=2;
0346 Data=nc2struct(fileinput,[]);
0347 if isfield(Data,'absolut_time_T0')
0348 if isfield(Data,'fix') && isequal(Data.fix,1)
0349 ind_opening=3;
0350 end
0351 if isfield(Data,'patch') && isequal(Data.patch,1)
0352 ind_opening=4;
0353 end
0354 if isfield(Data,'civ2') && isequal(Data.civ2,1)
0355 ind_opening=5;
0356 end
0357 if isfield(Data,'fix2') && isequal(Data.fix2,1)
0358 ind_opening=6;
0359 end
0360 testciv=1;
0361 else
0362 ind_opening=3;
0363 testciv=0;
0364 end
0365 set(handles.subdir_civ1,'String',subdir);
0366 set(handles.subdir_civ2,'String',subdir);
0367 browse.testciv=testciv;
0368 browse.ind_opening=ind_opening;
0369 end
0370 set(handles.displ_filebase,'String',filebase);
0371 set(handles.ImaDoc,'String',ext);
0372 if ~isempty(str2num(field_count))
0373 ref_i=str2num(field_count);
0374 if ~isempty(str2num(str2))
0375 ref_i=floor((ref_i+str2num(str2))/2);
0376 browse.incr_pair(1)=str2num(str2)-str2num(field_count);
0377 browse.incr_pair(2)=0;
0378 end
0379 set(handles.first_i,'String',num2str(ref_i));
0380 set(handles.last_i,'String',num2str(ref_i));
0381 set(handles.ref_i,'String',num2str(ref_i));
0382 end
0383 if isempty(str2num(str_a))
0384 set(handles.ref_j,'String','1');
0385 else
0386 ref_j=str2num(str_a);
0387 if ~isempty(str2num(str_b))
0388 ref_j=floor((str2num(str_a)+str2num(str_b))/2);
0389 browse.incr_pair(2)=str2num(str_b)-str2num(str_a);
0390 end
0391 set(handles.first_j,'String',num2str(ref_j));
0392 set(handles.last_j,'String',num2str(ref_j));
0393 set(handles.ref_j,'String',num2str(ref_j));
0394 end
0395
0396
0397 enable_civ1(handles,'off')
0398 enable_civ2(handles,'off')
0399 enable_pair1(handles,'on')
0400 enable_fix1(handles,'off')
0401 desable_patch1(handles)
0402 desable_fix2(handles)
0403 desable_patch2(handles)
0404 set(handles.CIV1,'Value',0)
0405 set(handles.FIX1,'Value',0)
0406 set(handles.PATCH1,'Value',0)
0407 set(handles.CIV2,'Value',0)
0408 set(handles.FIX2,'Value',0)
0409 set(handles.PATCH2,'Value',0)
0410 set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784])
0411 if isequal(ind_opening,1)
0412 set(handles.CIV1,'Value',1)
0413 enable_civ1(handles,'on')
0414 elseif isequal(ind_opening,2)
0415 set(handles.FIX1,'Value',1)
0416 enable_fix1(handles,'on')
0417 elseif isequal(ind_opening,3)
0418 set(handles.PATCH1,'Value',1)
0419 enable_patch1(handles)
0420 elseif isequal(ind_opening,4)
0421 set(handles.CIV2,'Value',1)
0422 enable_civ2(handles,1)
0423 elseif isequal(ind_opening,5)
0424 enable_pair1(handles,'off')
0425 set(handles.FIX2,'Value',1)
0426 enable_fix2(handles)
0427 set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
0428 set(handles.list_pair_civ2,'Enable','On')
0429 set(handles.list_pair_civ2,'Enable','On')
0430 elseif isequal(ind_opening,6)
0431 enable_pair1(handles,'off')
0432 set(handles.PATCH2,'Value',1)
0433 enable_patch2(handles)
0434 set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
0435 set(handles.list_pair_civ2,'Enable','On')
0436 end
0437 set(handles.browse_root,'UserData',browse);
0438 testall=isequal(menu(filtindex,1),{'*.*'});
0439 set(handles.ImaDoc,'UserData',testall);
0440
0441 displ_filebase_Callback(hObject, eventdata, handles);
0442
0443
0444
0445 function ImaDoc_Callback(hObject, eventdata, handles)
0446 displ_filebase_Callback(hObject, eventdata, handles)
0447
0448
0449
0450
0451 function displ_filebase_Callback(hObject, eventdata, handles)
0452
0453 global test_batch
0454
0455 set(handles.compare,'Visible','on')
0456 ext_ima=get(handles.ext_ima,'String');
0457 nom_type_ima=[];
0458 field_count=1;
0459 nom_type_nc=[];
0460 npx=[];
0461 npy=[];
0462 time=[];
0463 TimeUnit=[];
0464 CoordUnit=[];
0465 pxcmx_search=[];
0466 pxcmy_search=[];
0467 filebase=get(handles.displ_filebase,'String');
0468
0469 ext=get(handles.ImaDoc,'String');
0470 browse=get(handles.browse_root,'UserData');
0471 if ~isempty(browse)
0472 if isfield(browse,'nom_type_ima')
0473 nom_type_ima=browse.nom_type_ima;
0474 end
0475 if isfield(browse,'field_count')
0476 field_count=browse.field_count;
0477 end
0478 end
0479
0480
0481 first_i=str2num(get(handles.first_i,'String'));
0482 if isempty(first_i)| first_i < 1
0483 first_i=1;
0484 end
0485 last_i=str2num(get(handles.last_i,'String'));
0486 if isempty(last_i)| last_i < first_i
0487 last_i=first_i;
0488 end
0489 first_j=str2num(get(handles.first_j,'String'));
0490 if isempty(first_j)| first_j < 1
0491 first_j=1;
0492 end
0493 last_j=str2num(get(handles.last_j,'String'));
0494 if isempty(last_j)| last_j < first_j
0495 last_j=first_j;
0496 end
0497 incr_i=str2num(get(handles.incr_i,'String'));
0498 if isempty(incr_i) | incr_i < 1;
0499 set(handles.incr_i,'String','1')
0500 end
0501 incr_j=str2num(get(handles.incr_j,'String'));
0502 if isempty(incr_j) | incr_j < 1;
0503 set(handles.incr_j,'String','1')
0504 end
0505 dt=[];
0506 testmode=0;
0507 nbfield=[];
0508 nburst=[];
0509 pxcmx=1;
0510 pxcmy=1;
0511
0512
0513 if ~isequal(ext,'.xml') && ~ isequal(ext,'.civ')&& ~ isequal(ext,'.avi')&&~ isequal(ext,'.AVI')
0514 if exist([filebase '.xml'],'file')
0515 ext='.xml';
0516 elseif exist([filebase '.civxml'],'file')
0517 ext='.civxml';
0518 elseif exist([filebase '.civ'],'file')
0519 ext='.civ';
0520 elseif exist([filebase '.avi'],'file')
0521 ext='.avi';
0522 elseif exist([filebase '.AVI'],'file')
0523 ext='.AVI';
0524 end
0525 set(handles.ImaDoc,'String',ext)
0526 end
0527
0528
0529 mode='';
0530
0531 if isequal(ext,'.civxml') | isequal(ext,'.xml')| isequal(ext,'.civ')
0532 set(handles.ref_i,'Visible','On')
0533 set(handles.ref_j,'Visible','On')
0534 set(handles.dt,'Visible','Off')
0535 set(handles.dt_text,'String','ref. ind.')
0536 elseif isequal(ext,'.avi') | isequal(ext,'.AVI')
0537 set(handles.ref_j,'Visible','Off')
0538 set(handles.dt,'Visible','Off')
0539 set(handles.dt_text,'String','ref. ind.')
0540 else
0541 set(handles.ref_i,'Visible','Off')
0542 set(handles.ref_j,'Visible','Off')
0543 set(handles.dt,'Visible','On')
0544 set(handles.dt_text,'String','dt(ms)=')
0545 end
0546 if isequal(ext,'.civxml')
0547 [nbfield,nburst,time]=read_civxml([filebase '.civxml']);
0548 mode='pair j1-j2';
0549 if isempty(nom_type_ima)
0550 nom_type_ima='_i_j';
0551 end
0552 elseif isequal(ext,'.xml')
0553 [XmlData,warntext]=imadoc2struct([filebase '.xml']);
0554 if isfield(XmlData,'Time')
0555 time=XmlData.Time;
0556 nbfield=size(XmlData.Time,1);
0557 nburst=size(XmlData.Time,2);
0558 end
0559 ext_ima_read=[];
0560 nom_type_read=[];
0561 if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')
0562 [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName);
0563 end
0564 if isfield(XmlData,'Camera')
0565 if isfield(XmlData.Camera,'TimeUnit')
0566 TimeUnit=XmlData.Camera.TimeUnit;
0567 end
0568 if isfield(XmlData.Camera,'ImageSize')
0569 ImageSize=XmlData.Camera.ImageSize;
0570 if ~isempty(ImageSize)&& ~isempty(ImageSize)
0571 xindex=findstr(ImageSize,'x');
0572 if length(xindex)>=2
0573 npx=str2num(ImageSize(1:xindex(1)-1));
0574 npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1));
0575 end
0576 end
0577 end
0578 end
0579 pxcmx_search=1;
0580 pxcmy_search=1;
0581 if isfield(XmlData,'GeometryCalib')
0582 tsai=XmlData.GeometryCalib;
0583 if isfield(tsai,'f') & isfield(tsai,'Tz') & isfield(tsai,'dpx') & isfield(tsai,'dpy')& isfield(tsai,'R')
0584 rot2D=tsai.R([1:2],[1,2]);
0585 pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx);
0586 pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy);
0587 end
0588 if isfield(tsai,'CoordUnit')
0589 CoordUnit=tsai.CoordUnit;
0590 end
0591 end
0592 if ~isempty(ext_ima_read) && ~isempty(nom_type_read)
0593 if isempty(ext_ima)
0594 ext_ima=ext_ima_read;
0595 else
0596 if ~strcmp(ext_ima_read,ext_ima)
0597 msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image'])
0598 end
0599 end
0600 nom_type_ima=nom_type_read;
0601 end
0602 elseif isequal(ext,'.civ')
0603 [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']);
0604 if error==2, warndlg(['no file ' filebase '.civ']);
0605 elseif error==1, warndlg('inconsistent number of fields in the .civ file');
0606 end
0607
0608 nom_type_ima='png_old';
0609 elseif isequal(lower(ext),'.avi')
0610 nom_type_ima='*';
0611 ext_ima=ext;
0612 set(handles.mode,'String',{'series(Di)'})
0613 dt=0.04;
0614 if exist([filebase ext],'file')==2
0615 info=aviinfo([filebase ext]);
0616 dt=1/info.FramesPerSecond;
0617 nbfield=info.NumFrames;
0618 end
0619 time=(dt*[0:nbfield-1])';
0620 set(handles.dt,'String',num2str(dt*1000));
0621 end
0622 if isempty(time)
0623 set(handles.ImaDoc,'String','');
0624 end
0625
0626 if isempty(time) && ~isequal(ext,'.nc')
0627 subdir=get(handles.subdir_civ1,'String');
0628 incr_pair=[0 0];
0629 if isfield(browse,'incr_pair')
0630 incr_pair=browse.incr_pair;
0631 end
0632 nbdetect=0;
0633 field_i=field_count;
0634 idetect=1;
0635 while idetect==1
0636 field_i=field_i+1;
0637 imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
0638 if strcmp(nom_type_ima,'none')||strcmp(nom_type_ima,'')
0639 idetect=0;
0640 nbdetect=1;
0641 else
0642 idetect=(exist(imagename,'file')==2);
0643 end
0644
0645 nbdetect=nbdetect+(exist(imagename,'file')==2);
0646 end
0647 nb_field=field_i;
0648 field_i=field_count;
0649 idetect=1;
0650 while idetect==1
0651 field_i=field_i-1;
0652 imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
0653 if isequal(nom_type_ima,'none')||strcmp(nom_type_ima,'')
0654 idetect=0;
0655 nbdetect=1;
0656 else
0657 idetect=(exist(imagename,'file')==2);
0658 end
0659 nbdetect=nbdetect+idetect;
0660 end
0661 first_i=max(field_i+1,1);
0662
0663 dt=(1/1000)*str2num(get(handles.dt,'String'));
0664 time=(dt*[0:nb_field-1])';
0665 set(handles.mode,'String',{'series(Di)'})
0666 end
0667 if isequal(nom_type_ima,'none')
0668 first_i=1;
0669 last_i=1;
0670 first_j=1;
0671 last_j=1;
0672 end
0673 if exist('time','var')
0674 if size(time,1)+size(time,2)>=3
0675 nbfield=size(time,1);
0676 nbfield2=size(time,2);
0677 set(handles.displ_filebase,'UserData',time);
0678 if isempty(TimeUnit)
0679 set(handles.dt_unit,'String','e-03');
0680 set(handles.TimeUnit,'String','');
0681 else
0682 set(handles.dt_unit,'String',['m' TimeUnit]);
0683 set(handles.TimeUnit,'String',TimeUnit);
0684 end
0685 set(handles.nb_field,'String',num2str(nbfield));
0686 set(handles.nb_field2,'String',num2str(nbfield2));
0687 end
0688 end
0689 set(handles.CoordUnit,'String',[CoordUnit '/'])
0690 set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]);
0691
0692 set(handles.ext_ima,'String',ext_ima)
0693 set(handles.first_i,'String',num2str(first_i));
0694 set(handles.last_i,'String',num2str(last_i));
0695 set(handles.first_j,'String',num2str(first_j));
0696 set(handles.last_j,'String',num2str(last_j));
0697 browse.nom_type_ima=nom_type_ima;
0698 set(handles.browse_root,'UserData',browse)
0699
0700
0701 if isequal(nom_type_ima,'_i')| isequal(nom_type_nc,'_i1-i2')|~exist('nbfield2','var')|(nbfield2==1)
0702 set(handles.mode,'String',{'series(Di)'})
0703 set(handles.mode,'Value',1)
0704 elseif isequal(nom_type_ima,'png_old')|isequal(nom_type_nc,'netc_old')
0705 set(handles.mode,'String',{'pair j1-j2'})
0706 set(handles.mode,'Value',1)
0707 elseif (nbfield==1)
0708 set(handles.mode,'String',{'series(Dj)'})
0709 set(handles.mode,'Value',1)
0710 else
0711 set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})
0712 if isequal(mode,'volume')
0713 set(handles.mode,'Value',3)
0714 elseif nbfield2 <= 5
0715 set(handles.mode,'Value',1)
0716 else
0717 set(handles.mode,'Value',2)
0718 end
0719 end
0720
0721
0722 pathdir=fileparts(filebase);
0723 listot=dir(pathdir);
0724 idir=0;
0725 listdir={''};
0726 for ilist=1:length(listot)
0727 if listot(ilist).isdir
0728 name=listot(ilist).name;
0729 if ~isequal(name,'.') && ~isequal(name,'..')
0730 idir=idir+1;
0731 listdir{idir,1}=listot(ilist).name;
0732 end
0733 end
0734 end
0735 set(handles.list_subdir_civ1,'Value',1)
0736 set(handles.list_subdir_civ2,'Value',1)
0737 set(handles.list_subdir_civ1,'String',['browse...';listdir])
0738 set(handles.list_subdir_civ2,'String',['browse...';listdir])
0739
0740 subdir_civ1=get(handles.subdir_civ1,'String');
0741 subdir_civ2=get(handles.subdir_civ2,'String');
0742
0743 mode_Callback(hObject, eventdata, handles)
0744
0745
0746 set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001])
0747 set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001])
0748 set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001])
0749 set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001])
0750 set(handles.RUN, 'Enable','On')
0751 set(handles.RUN,'BackgroundColor',[1 0 0])
0752 if isequal(test_batch,1)
0753 set(handles.BATCH, 'Enable','On')
0754 set(handles.BATCH,'BackgroundColor',[1 0 0])
0755 end
0756
0757
0758 dir_perso=prefdir;
0759 profil_perso=fullfile(prefdir,'uvmat_perso.mat');
0760 RootPath=fileparts(filebase);
0761 if exist(profil_perso,'file')
0762 save (profil_perso,'RootPath','-append');
0763 else
0764 txt=ver;
0765 Release=txt(1).Release;
0766 relnumb=str2num(Release(3:4));
0767 if relnumb >= 14
0768 save (profil_perso,'RootPath','-V6');
0769 else
0770 save (profil_perso,'RootPath');
0771 end
0772 end
0773
0774 set(gcf,'Pointer','arrow')
0775
0776
0777
0778
0779 function mode_Callback(hObject, eventdata, handles)
0780 browse=get(handles.browse_root,'UserData');
0781
0782 compare_list=get(handles.compare,'String');
0783 val=get(handles.compare,'Value');
0784 compare=compare_list{val};
0785 if strcmp(compare,'displacement')
0786 mode='displacement';
0787 else
0788 mode_list=get(handles.mode,'String');
0789 mode_value=get(handles.mode,'Value');
0790 mode=mode_list{mode_value};
0791 end
0792 displ_num=[];
0793 first_i=str2num(get(handles.first_i,'String'));
0794
0795 time=get(handles.displ_filebase,'UserData');
0796 siztime=size(time);
0797 nbfield=siztime(1);
0798 nbfield2=siztime(2);
0799 indchosen=1;
0800 if isequal(mode,'pair j1-j2')
0801 dt=1;
0802 displ='';
0803 index=0;
0804 numlist_a=[];
0805 numlist_B=[];
0806
0807 displ_dt=1;
0808 nbfield2=min(nbfield2,10);
0809
0810
0811
0812 for numod_a=1:nbfield2-1
0813 for numod_b=(numod_a+1):nbfield2
0814 index=index+1;
0815 numlist_a(index)=numod_a;
0816 numlist_b(index)=numod_b;
0817 if ~isempty(time)
0818 dt(numod_a,numod_b)=time(first_i,numod_b)-time(first_i,numod_a);
0819 displ_dt(index)=dt(numod_a,numod_b);
0820 else
0821 displ_dt(index)=1;
0822 end
0823 end
0824 end
0825 [dtsort,indsort]=sort(displ_dt);
0826 if ~isempty(numlist_a)
0827 displ_num(1,:)=numlist_a(indsort);
0828 displ_num(2,:)=numlist_b(indsort);
0829 end
0830 displ_num(3,:)=0;
0831 displ_num(4,:)=0;
0832 set(handles.jtext,'Visible','Off')
0833 set(handles.first_j,'Visible','Off')
0834 set(handles.last_j,'Visible','Off')
0835 set(handles.incr_j,'Visible','Off')
0836 set(handles.nb_field2,'Visible','Off')
0837 set(handles.ref_j,'Visible','Off')
0838 elseif isequal(mode,'series(Dj)')
0839 for index=1:min(nbfield2-1,200)
0840 displ_num(1,index)=-floor(index/2);
0841 displ_num(2,index)=ceil(index/2);
0842 displ_num(3,index)=0;
0843 displ_num(4,index)=0;
0844 end
0845 set(handles.jtext,'Visible','On')
0846 set(handles.first_j,'Visible','On')
0847 set(handles.last_j,'Visible','On')
0848 set(handles.incr_j,'Visible','On')
0849 set(handles.nb_field2,'Visible','On')
0850 set(handles.ref_j,'Visible','On')
0851 if nbfield > 1
0852 set(handles.itext,'Visible','On')
0853 set(handles.first_i,'Visible','On')
0854 set(handles.last_i,'Visible','On')
0855 set(handles.incr_i,'Visible','On')
0856 set(handles.nb_field,'Visible','On')
0857 set(handles.ref_i,'Visible','On')
0858 else
0859 set(handles.itext,'Visible','Off')
0860 set(handles.first_i,'Visible','Off')
0861 set(handles.last_i,'Visible','Off')
0862 set(handles.incr_i,'Visible','Off')
0863 set(handles.nb_field,'Visible','Off')
0864 set(handles.ref_i,'Visible','Off')
0865 end
0866 elseif isequal(mode,'series(Di)')
0867 for index=1:200
0868 displ_num(1,index)=0;
0869 displ_num(2,index)=0;
0870 displ_num(3,index)=-floor(index/2);
0871 displ_num(4,index)=ceil(index/2);
0872 end
0873 set(handles.itext,'Visible','On')
0874 set(handles.first_i,'Visible','On')
0875 set(handles.last_i,'Visible','On')
0876 set(handles.incr_i,'Visible','On')
0877 set(handles.nb_field,'Visible','On')
0878 set(handles.ref_i,'Visible','On')
0879 if nbfield2 > 1
0880 set(handles.jtext,'Visible','On')
0881 set(handles.first_j,'Visible','On')
0882 set(handles.last_j,'Visible','On')
0883 set(handles.incr_j,'Visible','On')
0884 set(handles.nb_field2,'Visible','On')
0885 set(handles.ref_j,'Visible','On')
0886 else
0887 set(handles.jtext,'Visible','Off')
0888 set(handles.first_j,'Visible','Off')
0889 set(handles.last_j,'Visible','Off')
0890 set(handles.incr_j,'Visible','Off')
0891 set(handles.nb_field2,'Visible','Off')
0892 set(handles.ref_j,'Visible','Off')
0893 end
0894 elseif isequal(mode,'displacement')
0895 displ_num(1,1)=0;
0896 displ_num(2,1)=0;
0897 displ_num(3,1)=0;
0898 displ_num(4,1)=0;
0899 if nbfield > 1
0900 set(handles.itext,'Visible','On')
0901 set(handles.first_i,'Visible','On')
0902 set(handles.last_i,'Visible','On')
0903 set(handles.incr_i,'Visible','On')
0904 set(handles.nb_field,'Visible','On')
0905 set(handles.ref_i,'Visible','On')
0906 else
0907 set(handles.itext,'Visible','Off')
0908 set(handles.first_i,'Visible','Off')
0909 set(handles.last_i,'Visible','Off')
0910 set(handles.incr_i,'Visible','Off')
0911 set(handles.nb_field,'Visible','Off')
0912 set(handles.ref_i,'Visible','Off')
0913 end
0914 if nbfield2 > 1
0915 set(handles.jtext,'Visible','On')
0916 set(handles.first_j,'Visible','On')
0917 set(handles.last_j,'Visible','On')
0918 set(handles.incr_j,'Visible','On')
0919 set(handles.nb_field2,'Visible','On')
0920 set(handles.ref_j,'Visible','On')
0921 else
0922 set(handles.jtext,'Visible','Off')
0923 set(handles.first_j,'Visible','Off')
0924 set(handles.last_j,'Visible','Off')
0925 set(handles.incr_j,'Visible','Off')
0926 set(handles.nb_field2,'Visible','Off')
0927 set(handles.ref_j,'Visible','Off')
0928 end
0929 end
0930 set(handles.list_pair_civ1,'UserData',displ_num);
0931 find_netcpair_civ1(hObject, eventdata, handles)
0932 find_netcpair_civ2(hObject, eventdata, handles)
0933
0934
0935
0936
0937
0938 function find_netcpair_civ1(hObject, eventdata, handles)
0939 set(gcf,'Pointer','watch')
0940
0941 filebase=get(handles.displ_filebase,'String');
0942 [filepath,Nme,ext_dir]=fileparts(filebase);
0943 browse=get(handles.browse_root,'UserData');
0944 compare_list=get(handles.compare,'String');
0945 val=get(handles.compare,'Value');
0946 compare=compare_list{val};
0947 if strcmp(compare,'displacement')
0948 mode='displacement';
0949 else
0950 mode_list=get(handles.mode,'String');
0951 mode_value=get(handles.mode,'Value');
0952 mode=mode_list{mode_value};
0953 end
0954
0955
0956 nom_type_ima=[];
0957 if isfield(browse,'nom_type_ima')
0958 nom_type_ima=browse.nom_type_ima;
0959 end
0960
0961
0962 nom_type_nc=[];
0963 if isfield(browse,'nom_type_nc')
0964 nom_type_nc=browse.nom_type_nc;
0965 end
0966 if isempty(nom_type_nc)
0967 [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)'));
0968 end
0969 browse.nom_type_nc=nom_type_nc;
0970 set(handles.browse_root,'UserData',browse)
0971
0972
0973 subdir_civ1=get(handles.subdir_civ1,'String');
0974 first_i=str2num(get(handles.first_i,'String'));
0975 last_i=str2num(get(handles.last_i,'String'));
0976 incr=str2num(get(handles.incr_i,'String'));
0977 num1=first_i:incr:last_i;
0978 if isempty(num1)
0979 set(handles.list_pair_civ1,'String',{''});
0980 return
0981 end
0982 ref_i=str2num(get(handles.ref_i,'String'));
0983 if isequal(mode,'pair j1-j2')
0984 ref_j=0;
0985 else
0986 ref_j=str2num(get(handles.ref_j,'String'));
0987 end
0988 if isequal(get(handles.dt_text,'String'),'dt(ms)=')
0989 ref_i=floor((first_i+last_i)/2);
0990 ref_j=1;
0991 end
0992 time=get(handles.displ_filebase,'UserData');
0993 if isempty(time)
0994 time=[0 1];
0995 end
0996 dt_unit=str2num(get(handles.dt,'String'));
0997 displ_num=get(handles.list_pair_civ1,'UserData');
0998
0999
1000 if isempty(displ_num)
1001 nbpair=0;
1002 else
1003 nbpair=length(displ_num(1,:));
1004 if isequal(mode,'series(Di)')
1005 nbpair=min(2*ref_i-1,nbpair);
1006 elseif isequal(mode,'series(Dj)')
1007 nbpair=min(2*ref_j-1,nbpair);
1008 end
1009 end
1010 nbpair=min(200,nbpair);
1011
1012
1013
1014 displ_pair={''};
1015 select=ones(size(1:nbpair));
1016 testpair=0;
1017 if get(handles.CIV1,'Value')==0
1018 dirname=fullfile(filepath,subdir_civ1,ext_dir);
1019 if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir')
1020 msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']);
1021 set(handles.list_pair_civ1,'String',{});
1022 return
1023 end
1024 for ipair=1:nbpair
1025 filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
1026 ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
1027 select(ipair)=exist(filename,'file')==2;
1028 end
1029 if ~exist('select','var') || isequal(select,zeros(size(1:nbpair)))
1030 if isfield(browse,'incr_pair')
1031 num_i1=ref_i-floor(browse.incr_pair(1)/2);
1032 num_i2=ref_i+ceil(browse.incr_pair(1)/2);
1033 num_j1=ref_j-floor(browse.incr_pair(2)/2);
1034 num_j2=ref_j+ceil(browse.incr_pair(2)/2);
1035 filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1);
1036 select(1)=exist(filename,'file')==2;
1037 testpair=1;
1038 else
1039 if isequal(mode,'series(Dj)')
1040 msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]);
1041 else
1042 msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]);
1043 end
1044 set(handles.list_pair_civ1,'String',{''});
1045
1046 return
1047 end
1048 end
1049 end
1050 if isequal(mode,'series(Di)')
1051 if testpair
1052 displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))];
1053 elseif ~isequal(get(handles.dt_text,'String'),'dt(ms)=')
1054 for ipair=1:nbpair
1055 if select(ipair)
1056 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
1057 dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));
1058 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)];
1059 end
1060 else
1061 displ_pair{ipair}='...';
1062 end
1063 end
1064 else
1065 for ipair=1:nbpair
1066 if select(ipair)
1067 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)];
1068 else
1069 displ_pair{ipair}='...';
1070 end
1071 end
1072 end
1073 elseif isequal(mode,'series(Dj)')
1074 if testpair
1075 displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))];
1076 else
1077 for ipair=1:nbpair
1078 if select(ipair)
1079 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
1080 dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));
1081 displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)];
1082 end
1083 elseif testpair
1084 displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))];
1085 else
1086 displ_pair{ipair}='...';
1087 end
1088 end
1089 end
1090 elseif isequal(mode,'pair j1-j2')
1091 for ipair=1:nbpair
1092 if select(ipair)
1093 dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));
1094 displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ...
1095 ' :dt= ' num2str(dt*1000)];
1096 else
1097 displ_pair{ipair}='...';
1098 end
1099 end
1100 elseif isequal(mode,'displacement')
1101 displ_pair={'Di=Dj=0'};
1102 end
1103 set(handles.list_pair_civ1,'String',displ_pair');
1104 ichoice=min(find(select));
1105 if (isempty(ichoice) | ichoice < 1); ichoice=1; end;
1106 initial=get(handles.list_pair_civ1,'Value');
1107 if initial>nbpair |~isequal(select(initial),1)
1108 set(handles.list_pair_civ1,'Value',ichoice);
1109 end
1110
1111 initial=get(handles.list_pair_civ2,'Value');
1112 if initial>length(displ_pair')
1113 if ichoice <= length(displ_pair')
1114 set(handles.list_pair_civ2,'Value',ichoice);
1115 else
1116 set(handles.list_pair_civ2,'Value',1);
1117 end
1118 end
1119 set(handles.list_pair_civ2,'String',displ_pair');
1120 set(gcf,'Pointer','arrow')
1121
1122
1123
1124
1125 function find_netcpair_civ2(hObject, eventdata, handles)
1126 set(gcf,'Pointer','watch')
1127
1128 filebase=get(handles.displ_filebase,'String');
1129 [filepath,Nme,ext_dir]=fileparts(filebase);
1130 browse=get(handles.browse_root,'UserData');
1131 compare_list=get(handles.compare,'String');
1132 val=get(handles.compare,'Value');
1133 compare=compare_list{val};
1134 if strcmp(compare,'displacement')
1135 mode='displacement';
1136 else
1137 mode_list=get(handles.mode,'String');
1138 mode_value=get(handles.mode,'Value');
1139 mode=mode_list{mode_value};
1140 end
1141
1142
1143 nom_type_ima='ima_num';
1144 if isfield(browse,'nom_type_ima')
1145 nom_type_ima=browse.nom_type_ima;
1146 end
1147 nom_type_nc='_i1-i2';
1148 if isfield(browse,'nom_type_nc')
1149 nom_type_nc=browse.nom_type_nc;
1150 end
1151 if isequal(nom_type_ima,'png_old') | isequal(nom_type_ima,'netc_old')| isequal(nom_type_ima,'raw_SMD')| isequal(nom_type_nc,'netc_old')
1152 nom_type_nc='netc_old';
1153 elseif isequal(nom_type_ima,'none')|isequal(nom_type_nc,'none')
1154 nom_type_nc='none';
1155 elseif isequal(nom_type_ima,'avi')|isequal(nom_type_ima,'_i')|isequal(nom_type_ima,'ima_num')|isequal(nom_type_nc,'_i1-i2')
1156 nom_type_nc='_i1-i2';
1157 else
1158 if isequal(mode,'series(Di)')
1159 nom_type_nc='_i1-i2_j';
1160 else
1161 nom_type_nc='_i_j1-j2';
1162 end
1163 end
1164 browse.nom_type_nc=nom_type_nc;
1165 set(handles.browse_root,'UserData',browse)
1166
1167
1168 subdir_civ1=get(handles.subdir_civ1,'String');
1169 subdir_civ2=get(handles.subdir_civ2,'String');
1170 first_i=str2num(get(handles.first_i,'String'));
1171 last_i=str2num(get(handles.last_i,'String'));
1172 incr=str2num(get(handles.incr_i,'String'));
1173 num1=first_i:incr:last_i;
1174 if isempty(num1)
1175 set(handles.list_pair_civ2,'Value',1);
1176 set(handles.list_pair_civ2,'String',{''});
1177 return
1178 end
1179 ref_i=str2num(get(handles.ref_i,'String'));
1180 if isequal(mode,'pair j1-j2')
1181 ref_j=0;
1182 else
1183 ref_j=str2num(get(handles.ref_j,'String'));
1184 end
1185 if isequal(get(handles.dt_text,'String'),'dt(ms)=')
1186 ref_i=ceil((first_i+last_i)/2);
1187 ref_j=1;
1188 end
1189
1190 time=get(handles.displ_filebase,'UserData');
1191 if isempty(time)
1192 time=[0 1];
1193 end
1194 dt_unit=str2num(get(handles.dt,'String'));
1195 displ_num=get(handles.list_pair_civ1,'UserData');
1196
1197
1198
1199 if isempty(displ_num)
1200 nbpair=0;
1201 else
1202 nbpair=length(displ_num(1,:));
1203 if isequal(mode,'series(Di)')
1204 nbpair=min(2*ref_i-1,nbpair);
1205 elseif isequal(mode,'series(Dj)')
1206 nbpair=min(2*ref_j-1,nbpair);
1207 end
1208 end
1209 nbpair=min(200,nbpair);
1210
1211
1212
1213 displ_pair={''};
1214 select=ones(size(1:nbpair));
1215 if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0
1216 if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir')
1217 errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist'])
1218 set(handles.list_pair_civ2,'Value',1);
1219 set(handles.list_pair_civ2,'String',{''});
1220 return
1221 end
1222 for ipair=1:nbpair
1223 filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,...
1224 ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1);
1225 select(ipair)=exist(filename,'file')==2;
1226 end
1227 if isequal(select,zeros(size(1:nbpair)))
1228 if isfield(browse,'incr_pair')
1229 num_i1=ref_i-floor(browse.incr_pair(1)/2);
1230 num_i2=ref_i+floor((browse.incr_pair(1)+1)/2);
1231 num_j1=ref_j-floor(browse.incr_pair(2)/2);
1232 num_j2=ref_j+floor((browse.incr_pair(2)+1)/2);
1233 filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2);
1234 select(1)=exist(filename,'file')==2;
1235 else
1236 if isequal(mode,'series(Dj)')
1237 errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2])
1238 else
1239 errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2])
1240 end
1241 set(handles.list_pair_civ2,'Value',1);
1242 set(handles.list_pair_civ2,'String',{''});
1243 return
1244 end
1245 end
1246 end
1247 if isequal(mode,'series(Di)')
1248
1249 for ipair=1:nbpair
1250 if select(ipair)
1251 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
1252 dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));
1253 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)];
1254 end
1255 else
1256 displ_pair{ipair}='...';
1257 end
1258 end
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268 elseif isequal(mode,'series(Dj)')
1269 for ipair=1:nbpair
1270 if select(ipair)
1271 if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair)
1272 dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));
1273 displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)];
1274 end
1275 else
1276 displ_pair{ipair}='...';
1277 end
1278 end
1279 elseif isequal(mode,'pair j1-j2')
1280 for ipair=1:nbpair
1281 if select(ipair)
1282 dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));
1283 displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ...
1284 ' :dt= ' num2str(dt*1000)];
1285 else
1286 displ_pair{ipair}='...';
1287 end
1288 end
1289 elseif isequal(mode,'displacement')
1290 displ_pair={'Di=Dj=0'};
1291 end
1292 val=get(handles.list_pair_civ2,'Value');
1293 ichoice=min(find(select));
1294 if (isempty(ichoice) | ichoice < 1); ichoice=1; end;
1295 if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0
1296 val=ichoice;
1297 end
1298 if val>length(displ_pair')
1299 set(handles.list_pair_civ2,'Value',1);
1300 else
1301 set(handles.list_pair_civ2,'Value',val);
1302 end
1303 set(handles.list_pair_civ2,'String',displ_pair');
1304
1305
1306 set(gcf,'Pointer','arrow')
1307
1308
1309
1310 function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...
1311 find_pair_indices(handles,mode)
1312 first_i=str2num(get(handles.first_i,'String'));
1313 last_i=str2num(get(handles.last_i,'String'));
1314 incr=str2num(get(handles.incr_i,'String'));
1315 num1=[first_i:incr:last_i];
1316 if isequal(get(handles.first_j,'Visible'),'on')
1317 first_j=str2num(get(handles.first_j,'String'));
1318 last_j=str2num(get(handles.last_j,'String'));
1319 incr_j=str2num(get(handles.incr_j,'String'));
1320 else
1321 first_j=1;
1322 last_j=1;
1323 incr_j=1;
1324 end
1325 num_j=[first_j:incr_j:last_j];
1326 list_civ1=get(handles.list_pair_civ1,'String');
1327 index_civ1=get(handles.list_pair_civ1,'Value');
1328 str_civ1=list_civ1{index_civ1};
1329 if isempty(str_civ1)||isequal(str_civ1,'')
1330 msgbox_uvmat('ERROR','no image pair selected for civ1')
1331 return
1332 end
1333 list_civ2=get(handles.list_pair_civ2,'String');
1334 index_civ2=get(handles.list_pair_civ2,'Value');
1335 if index_civ2>length(list_civ2)
1336 list_civ2=list_civ1;
1337 index_civ2=index_civ1;
1338 end
1339 str_civ2=list_civ2{index_civ2};
1340 if isequal(first_i,[])|isequal(first_j,[]), errordlg('first field number not defined'),...
1341 set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1342 if isequal(last_i,[])| isequal(last_j,[]),errordlg('last field number not defined'),...
1343 set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1344 if isequal(incr,[])| isequal(incr_j,[]),errordlg('increment in field number not defined'),...
1345 set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1346 if last_i < first_i | last_j < first_j , errordlg('last field number must be larger than the first one'),...
1347 set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1348 if isequal (mode,'series(Di)')
1349
1350 indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));
1351 str_raw=str_civ1(indsel);
1352 indsepar=find(str_raw=='|');
1353 d1=str2num(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1]));
1354 if indsepar==length(str_raw)
1355 d2=str2num(str_civ1([indsel(indsepar)+1:end]));
1356 else
1357 d2=str2num(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1]));
1358 end
1359 num1_civ1=num1-d1;
1360 num2_civ1=num1+d2;
1361 num_a_civ1=num_j;
1362 num_b_civ1=num_j;
1363
1364
1365 indsel=find((double(str_civ2)<48)|(double(str_civ2)>57));
1366 str_raw=str_civ2(indsel);
1367 indsepar=find(str_raw=='|');
1368 d1=str2num(str_civ2([indsel(indsepar-1)+1:indsel(indsepar)-1]));
1369 if indsepar==length(str_raw)
1370 d2=str2num(str_civ2([indsel(indsepar)+1:end]));
1371 else
1372 d2=str2num(str_civ2([indsel(indsepar)+1:indsel(indsepar+1)-1]));
1373 end
1374 if isempty(d1)
1375 num1_civ2=num1;
1376 else
1377 num1_civ2=num1-d1;
1378 end
1379 if isempty(d2)
1380 num2_civ2=num1;
1381 else
1382 num2_civ2=num1+d2;
1383 end
1384 num_a_civ2=num_j;
1385 num_b_civ2=num_j;
1386
1387
1388 lastfield=str2num(get(handles.nb_field,'String'));
1389 if isequal(lastfield,[])
1390 indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1));
1391 else
1392 indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1));
1393 end
1394 if length(indsel)>=1
1395 firstind=indsel(1);
1396 lastind=indsel(end);
1397 set(handles.first_i,'String',num2str(num1(firstind)))
1398 set(handles.last_i,'String',num2str(num1(lastind)))
1399 num1=num1(indsel);
1400 num1_civ1=num1_civ1(indsel);
1401 num1_civ2=num1_civ2(indsel);
1402 num2_civ1=num2_civ1(indsel);
1403 num2_civ2=num2_civ2(indsel);
1404 end
1405 elseif isequal (mode,'series(Dj)')
1406 lastfield_j=str2num(get(handles.nb_field2,'String'));
1407 num1_civ1=num1;
1408 num2_civ1=num1;
1409 num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j));
1410 num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j));
1411 num1_civ2=num1;
1412 num2_civ2=num1;
1413 num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j));
1414 num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j));
1415
1416 if isequal(lastfield_j,[])
1417 indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1));
1418 else
1419 indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1));
1420 end
1421 if length(indsel)>=1
1422 firstind=indsel(1);
1423 lastind=indsel(end);
1424 set(handles.first_j,'String',num2str(num_j(firstind)))
1425 set(handles.last_j,'String',num2str(num_j(lastind)))
1426 num_j=num_j(indsel);
1427 num_a_civ1=num_a_civ1(indsel);
1428 num_a_civ2=num_a_civ2(indsel);
1429 num_b_civ1=num_b_civ1(indsel);
1430 num_b_civ2=num_b_civ2(indsel);
1431 end
1432 elseif isequal(mode,'pair j1-j2')
1433 num1_civ1=num1;
1434 num1_civ2=num1;
1435 displ_num=get(handles.list_pair_civ1,'UserData');
1436 num2_civ1=num1;
1437 num_a_civ1=displ_num(1,index_civ1);
1438 num_b_civ1=displ_num(2,index_civ1);
1439 num2_civ2=num1;
1440 num_a_civ2=displ_num(1,index_civ2);
1441 num_b_civ2=displ_num(2,index_civ2);
1442 elseif isequal(mode,'displacement')
1443 num1_civ1=num1;
1444 num2_civ1=num1;
1445 num_a_civ1=num_j;
1446 num_b_civ1=num_j;
1447 num1_civ2=num1;
1448 num2_civ2=num1;
1449 num_a_civ2=num_j;
1450 num_b_civ2=num_j;
1451 end
1452
1453
1454
1455
1456 function list_pair_civ1_Callback(hObject, eventdata, handles)
1457
1458
1459 list_pair=get(handles.list_pair_civ1,'String');
1460 index_pair=get(handles.list_pair_civ1,'Value');
1461 displ_num=get(handles.list_pair_civ1,'UserData');
1462 num_a=displ_num(1,index_pair);
1463 num_b=displ_num(2,index_pair);
1464 list_pair2=get(handles.list_pair_civ2,'String');
1465 if index_pair<=length(list_pair2)
1466 set(handles.list_pair_civ2,'Value',index_pair);
1467 end
1468
1469
1470 mode_list=get(handles.mode,'String');
1471 mode_value=get(handles.mode,'Value');
1472 mode=mode_list{mode_value};
1473 if isequal(mode,'series(Di)')
1474 first_i=str2num(get(handles.first_i,'String'));
1475 last_i=str2num(get(handles.last_i,'String'));
1476 incr_i=str2num(get(handles.incr_i,'String'));
1477 num1=first_i:incr_i:last_i;
1478 lastfield=str2num(get(handles.nb_field,'String'));
1479 if ~isequal(lastfield,[])
1480 ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ...
1481 (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
1482 num1=num1(ind);
1483 end
1484 set(handles.first_i,'String',num2str(num1(1)));
1485 set(handles.last_i,'String',num2str(num1(end)));
1486 elseif isequal(mode,'series(Dj)')
1487 first_j=str2num(get(handles.first_j,'String'));
1488 last_j=str2num(get(handles.last_j,'String'));
1489 incr_j=str2num(get(handles.incr_j,'String'));
1490 num_j=first_j:incr_j:last_j;
1491 lastfield2=str2num(get(handles.nb_field2,'String'));
1492 if ~isequal(lastfield2,[])
1493 ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
1494 (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2));
1495 num1=num_j(ind);
1496 end
1497 set(handles.first_j,'String',num2str(num1(1)));
1498 set(handles.last_j,'String',num2str(num1(end)));
1499 end
1500
1501
1502
1503 function list_pair_civ2_Callback(hObject, eventdata, handles)
1504
1505 index_pair=get(handles.list_pair_civ2,'Value');
1506
1507
1508 mode_list=get(handles.mode,'String');
1509 mode_value=get(handles.mode,'Value');
1510 mode=mode_list{mode_value};
1511 if isequal(mode,'series(Di)')
1512 first_i=str2num(get(handles.first_i,'String'));
1513 last_i=str2num(get(handles.last_i,'String'));
1514 incr_i=str2num(get(handles.incr_i,'String'));
1515 num1=first_i:incr_i:last_i;
1516 lastfield=str2num(get(handles.nb_field,'String'));
1517 if ~isequal(lastfield,[])
1518 ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ...
1519 (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
1520 num1=num1(ind);
1521 end
1522 set(handles.first_i,'String',num2str(num1(1)));
1523 set(handles.last_i,'String',num2str(num1(end)));
1524 elseif isequal(mode,'series(Dj)')
1525 first_j=str2num(get(handles.first_j,'String'));
1526 last_j=str2num(get(handles.last_j,'String'));
1527 incr_j=str2num(get(handles.incr_j,'String'));
1528 num_j=first_j:incr_j:last_j;
1529 lastfield2=str2num(get(handles.nb_field2,'String'));
1530 if ~isequal(lastfield2,[])
1531 ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
1532 (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2));
1533 num1=num_j(ind);
1534 end
1535 set(handles.first_j,'String',num2str(num1(1)));
1536 set(handles.last_j,'String',num2str(num1(end)));
1537 end
1538
1539
1540
1541
1542 function RUN_Callback(hObject, eventdata, handles)
1543 global civ1_exe civ2_exe patch_exe patch_new_exe sge
1544
1545 compare=get(handles.compare,'Value');
1546
1547 operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'};
1548 run_flag=1;
1549 box_test(1)=get(handles.CIV1,'Value');
1550 box_test(2)=get(handles.FIX1,'Value');
1551 box_test(3)=get(handles.PATCH1,'Value');
1552 box_test(4)=get(handles.CIV2,'Value');
1553 box_test(5)=get(handles.FIX2,'Value');
1554 box_test(6)=get(handles.PATCH2,'Value');
1555 index=find(box_test==1);
1556 if isempty(index)
1557 errordlg('no selected operation')
1558 set(handles.RUN, 'Enable','On')
1559 set(handles.RUN,'BackgroundColor',[1 0 0])
1560 return
1561 end
1562 index_first=min(index);
1563 index_last=max(index);
1564 box_used=box_test([index_first : index_last]);
1565 [box_missing,ind_missing]=min(box_used);
1566 if isequal(box_missing,0)
1567 errordlg(['missing' cell2mat(operations(ind_missing))]);
1568 set(handles.RUN, 'Enable','On')
1569 set(handles.RUN,'BackgroundColor',[1 0 0])
1570 return
1571 end
1572
1573
1574 filebase=get(handles.displ_filebase,'String');
1575 if isempty(filebase)||isequal(filebase,'')
1576 msgbox_uvmat('ERROR','no input files')
1577 return
1578 end
1579
1580 if isequal(get(handles.get_mask_civ1,'Value'),1)
1581 get_mask_civ1_Callback(hObject, eventdata, handles);
1582 end
1583 if isequal(get(handles.get_mask_fix1,'Value'),1)
1584 get_mask_fix1_Callback(hObject, eventdata, handles);
1585 end
1586 if isequal(get(handles.get_mask_civ2,'Value'),1)
1587 get_mask_civ2_Callback(hObject, eventdata, handles);
1588 end
1589 if isequal(get(handles.get_mask_fix2,'Value'),1)
1590 get_mask_fix2_Callback(hObject, eventdata, handles);
1591 end
1592
1593
1594 if box_test(1)==1 | box_test(3)==1 | box_test(4)==1 | box_test(6)==1
1595 path_uvmat=which('uvmat');
1596 path_UVMAT=fileparts(path_uvmat);
1597 if isunix
1598
1599 xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml')
1600 if exist(xmlfile,'file')
1601 t=xmltree(xmlfile);
1602 sparam=convert(t);
1603 end
1604 else
1605
1606 xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml')
1607 if exist(xmlfile,'file')
1608 t=xmltree(xmlfile);
1609 sparam=convert(t);
1610 end
1611 end
1612 if isfield(sparam,'Civ1_exe')
1613 civ1_exe=sparam.Civ1_exe;
1614 end
1615 if isfield(sparam,'Civ2_exe')
1616 civ2_exe=sparam.Civ2_exe;
1617 end
1618 if isfield(sparam,'Patch_exe')
1619 patch_exe=sparam.Patch_exe;
1620 end
1621 if isfield(sparam,'Stinterp_exe')
1622 stinterp_exe=sparam.Stinterp_exe;
1623 end
1624 if isfield(sparam,'SGE')
1625 sge=str2num(sparam.SGE);
1626 end
1627 if ~isunix
1628 dircur=pwd;
1629 if ~isequal(dircur([2 3]),':\')
1630 errordlg('move to a Matlab current working directory with a Windows name, e.g. m:/...')
1631 set(handles.RUN, 'Enable','On')
1632 set(handles.RUN,'BackgroundColor',[1 0 0])
1633 return;
1634 end
1635 end
1636 end
1637
1638
1639 set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001])
1640 set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001])
1641 set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001])
1642 set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001])
1643 set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
1644 set(handles.RUN, 'Enable','Off')
1645 drawnow
1646
1647 [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
1648 set_civ_filenames(handles,compare,box_test);
1649
1650 nbfield=size(num1_civ1,2);
1651 nbslice=size(num1_civ1,1);
1652
1653
1654 if box_test(1)==1
1655 RUN_CIV1(handles,filecell.ima1.civ1,filecell.ima2.civ1,filecell.nc.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc)
1656 if compare==3
1657 RUN_CIV1(handles,filecell.imaA1.civ1,filecell.imaA2.civ1,filecell.ncA.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc)
1658 end
1659 end
1660
1661
1662 if box_test(2)==1
1663 filebase=get(handles.displ_filebase,'String');
1664
1665 field1.vel_type='civ1';
1666 field1.nb='nb_vectors';
1667 field1.X='vec_X';
1668 field1.Y='vec_Y';
1669 field1.U='vec_U';
1670 field1.V='vec_V';
1671 field1.fixflag='vec_FixFlag';
1672 flagindex(1)=get(handles.vec_Fmin2, 'Value');
1673 flagindex(2)=get(handles.vec_F3, 'Value');
1674 flagindex(3)=get(handles.vec_F2, 'Value');
1675 thresh_vecC=str2num(get(handles.thresh_vecC,'String'));
1676 thresh_vel=str2num(get(handles.thresh_vel,'String'));
1677 inf_sup=get(handles.inf_sup1,'Value');
1678 menu=get(handles.field_ref1,'String');
1679 index=get(handles.field_ref1,'Value');
1680 if isempty(menu)
1681 fieldchoice='';
1682 else
1683 fieldchoice=menu{index};
1684 end
1685 h = waitbar(0,['removing velocity vectors, fix1']);
1686 test_mask=get(handles.get_mask_fix1,'Value');
1687 maskdispl=get(handles.mask_fix1,'String');
1688 maskbase=[get(handles.displ_filebase,'String') '_' maskdispl];
1689 for ifile=1:nbfield
1690 waitbar(ifile/nbfield);
1691 for j=1:nbslice
1692 if test_mask==0
1693 maskname='noFile use default';
1694 maskflag=0;
1695 else
1696 maskname=name_generator(maskbase,num1_civ1(ifile),1,'.png','_i');
1697 maskflag= exist(maskname,'file')==2;
1698 if ~maskflag;
1699 maskname='noFile use default';
1700 end
1701 end
1702 if ~isempty(file_ref_fix1)
1703 file_ref=file_ref_fix1{ifile,j};
1704 else
1705 file_ref='';
1706 end
1707 error=RUN_FIX(filecell.nc.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,...
1708 thresh_vel,inf_sup,file_ref,fieldchoice)
1709
1710 if compare==3 &&(isequal(mode,'pair j1-j2') || isequal(mode,'series(Dj)') || isequal(mode,'series(Di)'))
1711 if test_mask==0
1712 maskname='noFile use default';
1713 maskflag=0;
1714 else
1715 maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl];
1716 maskname=name_generator(maskbase,num1_civ1(ifile),1,'.png','_i');
1717 maskflag= exist(maskname,'file')==2;
1718 if ~maskflag;
1719 maskname='noFile use default';
1720 end
1721 end
1722 error=RUN_FIX(filecell.ncA.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,...
1723 thresh_vel,inf_sup,file_ref,fieldchoice)
1724 if ~isempty(error)
1725 errordlg(error)
1726 return
1727 end
1728 end
1729 end
1730 end
1731 close(h)
1732 end
1733
1734
1735 if box_test(3)==1
1736 rho_patch1=str2num(get(handles.rho_patch1,'String'));
1737 if isempty(rho_patch1)
1738 rho_patch1='1000';
1739 set(handles.rho_patch1,'String','1')
1740 else
1741 rho_patch1=num2str(1000*rho_patch1);
1742 end
1743 nx_patch1=get(handles.nx_patch1,'String');
1744 if isequal(str2num(nx_patch1),[])
1745 nx_patch1='50' ;
1746 set(handles.nx_patch1,'String','50');
1747 end
1748 ny_patch1=get(handles.ny_patch1,'String');
1749 if isequal(str2num(ny_patch1),[])
1750 ny_patch1='50' ;
1751 set(handles.ny_patch1,'String','50');
1752 end
1753 subdomain_patch1=get(handles.subdomain_patch1,'String');
1754 thresh_patch1=get(handles.thresh_patch1,'String');
1755 test_interp=get(handles.test_interp,'Value');
1756 icount=0;
1757 for ifile=1:nbfield
1758
1759
1760 for j=1:nbslice
1761 icount=icount+1;
1762 barlength=0.188*icount/(nbfield*nbslice);
1763 set(handles.waitbar_patch1,'Position',[0.946 0.627-barlength 0.03 barlength])
1764 drawnow
1765 if isequal(get(handles.test_stereo1,'Value'),0)
1766 cmd=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp);
1767 s=-1;
1768 if sge
1769 [s,w]=unix(['qrsh -q -fast.q ' cmd]);
1770 end
1771 if s~=0
1772 eval(['!' cmd]);
1773 end
1774
1775
1776 elseif isequal(get(handles.test_stereo1,'Value'),1)
1777 if exist('stinterp_exe','var')
1778 cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},filecell.st{ifile,j},...
1779 nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,[filebase_A '.xml'],[filebase_B '.xml']);
1780 eval(['!' cmd]);
1781 else
1782 RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},...
1783 str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']);
1784 end
1785 end
1786 if compare==3 && isequal(get(handles.test_stereo1,'Value'),0)
1787 cmd=RUN_PATCH(filecell.ncA.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp);
1788 s=-1;
1789 if sge
1790 [s,w]=unix(['qrsh -q -fast.q ' cmd]);
1791 end
1792 if s~=0
1793 eval(['!' cmd]);
1794 end
1795 end
1796 end
1797 end
1798 end
1799
1800
1801
1802 if box_test(4)==1
1803 RUN_CIV2(handles,filecell.ima1.civ2,filecell.ima2.civ2,filecell.nc.civ1,filecell.nc.civ2,num1_civ2,num2_civ2,...
1804 num_a_civ2,num_b_civ2,nom_type_nc)
1805 end
1806
1807
1808 if box_test(5)==1
1809
1810 field2.vel_type='civ2';
1811 field2.nb='nb_vectors2';
1812 field2.X='vec2_X';
1813 field2.Y='vec2_Y';
1814 field2.U='vec2_U';
1815 field2.V='vec2_V';
1816 field2.fixflag='vec2_FixFlag';
1817 flagindex(1)=get(handles.vec_Fmin2_2, 'Value');
1818 flagindex(2)=get(handles.vec_F3_2, 'Value');
1819 flagindex(3)=get(handles.vec_F4, 'Value');
1820 thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));
1821 thresh_vel2=str2num(get(handles.thresh_vel2,'String'));
1822 inf_sup=get(handles.inf_sup2,'Value');
1823 menu=get(handles.field_ref2,'String');
1824 index=get(handles.field_ref2,'Value');
1825 if isempty(menu)
1826 fieldchoice='';
1827 else
1828 fieldchoice=menu{index};
1829 end
1830
1831 h = waitbar(0,['removing velocity vectors, fix2']);
1832 test_mask=get(handles.get_mask_fix2,'Value');
1833 maskdispl=get(handles.mask_fix2,'String');
1834 maskbase=[get(handles.displ_filebase,'String') '_' maskdispl];
1835 for ifile=1:nbfield
1836 waitbar(ifile/nbfield);
1837 for j=1:nbslice
1838 if test_mask==0
1839 maskname='noFile use default';
1840 maskflag=0;
1841 else
1842 maskname=name_generator(maskbase,num1_civ2(ifile),1,'.png','_i');
1843 maskflag= exist(maskname,'file')==2;
1844 if ~maskflag;
1845 maskname='noFile use default';
1846 end
1847 end
1848 if ~isempty(file_ref_fix2)
1849 file_ref=file_ref_fix2{ifile,j};
1850 else
1851 file_ref='';
1852 end
1853 'TESTfix'
1854 filecell.nc.civ2{ifile,j}
1855 error=RUN_FIX(filecell.nc.civ2{ifile,j},field2,flagindex,2,thresh_vec2C,maskflag,maskname,...
1856 thresh_vel2,inf_sup,file_ref,fieldchoice);
1857 if ~isempty(error)
1858 msgbox_uvmat('ERROR',error)
1859 return
1860 end
1861 if compare==3
1862 if test_mask==0
1863 maskname='noFile use default';
1864 maskflag=0;
1865 else
1866 maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl];
1867 maskname=name_generator(maskbase,num1_civ2(ifile),1,'.png','_i');
1868 maskflag= exist(maskname,'file')==2;
1869 if ~maskflag;
1870 maskname='noFile use default';
1871 end
1872 end
1873 error=RUN_FIX(filecell.ncA.civ2{ifile,j},field2,flagindex,1,thresh_vec2C,maskflag,maskname,...
1874 thresh_vel2,inf_sup,file_ref,fieldchoice);
1875 if ~isempty(error)
1876 msgbox_uvmat('ERROR',error)
1877 return
1878 end
1879 end
1880 end
1881 end
1882 close(h)
1883 end
1884
1885
1886 if box_test(6)==1
1887 rho_patch2=str2num(get(handles.rho_patch2,'String'));
1888 if isempty(rho_patch2)
1889 rho_patch2='1000';
1890 set(handles.rho_patch2,'String','1')
1891 else
1892 rho_patch2=num2str(1000*rho_patch2);
1893 end
1894 nx_patch2=get(handles.nx_patch2,'String');
1895 ny_patch2=get(handles.ny_patch2,'String');
1896 thresh_patch2=get(handles.thresh_patch2,'String');
1897 if isequal(str2num(nx_patch2),[])
1898 nx_patch2='50' ;
1899 set(handles.nx_patch2,'String','50');
1900 end
1901 if isequal(str2num(ny_patch2),[])
1902 ny_patch2='50' ;
1903 set(handles.ny_patch2,'String','50');
1904 end
1905 subdomain_patch2=get(handles.subdomain_patch2,'String');
1906 icount=0;
1907 for ifile=1:nbfield
1908
1909
1910 for j=1:nbslice
1911 icount=icount+1;
1912 barlength=0.188*icount/(nbfield*nbslice);
1913 set(handles.waitbar_patch2,'Position',[0.946 0.188-barlength 0.03 barlength])
1914 drawnow
1915 if compare~=3 | isequal(get(handles.test_stereo2,'Value'),0)
1916 cmd=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0);
1917 s=-1;
1918 if sge
1919 [s,w]=unix(['qrsh -q -fast.q ' cmd]);
1920 end
1921 if s~=0
1922 eval(['!' cmd]);
1923 end
1924 elseif compare==3 && isequal(get(handles.test_stereo2,'Value'),1)
1925 if exist('stinterp_exe','var')
1926 cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},filecell.st{ifile,j},...
1927 nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,[filebase_A '.xml'],[filebase_B '.xml']);
1928 eval(['!' cmd])
1929 else
1930 RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},...
1931 str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml'])
1932 end
1933 end
1934 if compare==3 && isequal(get(handles.test_stereo2,'Value'),0)
1935 cmd=RUN_PATCH(filecell.ncA.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0);
1936 s=-1;
1937 if sge
1938 [s,w]=unix(['qrsh -q -fast.q ' cmd]);
1939 end
1940 if s~=0
1941 eval(['!' cmd]);
1942 end
1943 end
1944 end
1945 end
1946 end
1947
1948 set(handles.RUN, 'Enable','On')
1949 set(handles.RUN,'BackgroundColor',[1 0 0])
1950
1951
1952 if isfield(filecell,'st')
1953 fileresu=filecell.st{1,1};
1954 elseif isfield(filecell,'nc')
1955 if isfield(filecell.nc,'civ2')
1956 fileresu=filecell.nc.civ2{1,1};
1957 else
1958 fileresu=filecell.nc.civ1{1,1};
1959 end
1960 end
1961 [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu);
1962 namedoc=fullfile(RootPath,subdir,RootFile);
1963 detect=1;
1964 while detect==1
1965 namefigfull=[namedoc '.fig'];
1966 hh=dir(namefigfull);
1967 if ~isempty(hh)
1968 detect=1;
1969 namedoc=[namedoc '.0'];
1970 else
1971 detect=0;
1972 end
1973 end
1974 saveas(gcbf,namefigfull);
1975
1976
1977
1978
1979
1980 function BATCH_Callback(hObject, eventdata, handles)
1981 global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe
1982 compare=get(handles.compare,'Value');
1983
1984
1985 operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'};
1986 run_flag=1;
1987 box_test(1)=get(handles.CIV1,'Value');
1988 box_test(2)=get(handles.FIX1,'Value');
1989 box_test(3)=get(handles.PATCH1,'Value');
1990 box_test(4)=get(handles.CIV2,'Value');
1991 box_test(5)=get(handles.FIX2,'Value');
1992 box_test(6)=get(handles.PATCH2,'Value');
1993 index=find(box_test==1);
1994 if isempty(index)
1995 errordlg('no selected operation')
1996 set(handles.BATCH, 'Enable','On')
1997 set(handles.BATCH,'BackgroundColor',[1 0 0])
1998 return
1999 end
2000 index_first=min(index);
2001 index_last=max(index);
2002 box_used=box_test([index_first : index_last]);
2003 [box_missing,ind_missing]=min(box_used);
2004 if isequal(box_missing,0)
2005 errordlg(['missing' cell2mat(operations(ind_missing))]);
2006 set(handles.BATCH, 'Enable','On')
2007 set(handles.BATCH,'BackgroundColor',[1 0 0])
2008 return
2009 end
2010
2011
2012 filebase=get(handles.displ_filebase,'String');
2013 if isempty(filebase)||isequal(filebase,'')
2014 msgbox_uvmat('ERROR','no input files')
2015 return
2016 end
2017
2018
2019 if isequal(get(handles.get_mask_civ1,'Value'),1)
2020 get_mask_civ1_Callback(hObject, eventdata, handles);
2021 end
2022 if isequal(get(handles.get_mask_fix1,'Value'),1)
2023 get_mask_fix1_Callback(hObject, eventdata, handles);
2024 end
2025 if isequal(get(handles.get_mask_civ2,'Value'),1)
2026 get_mask_civ2_Callback(hObject, eventdata, handles);
2027 end
2028 if isequal(get(handles.get_mask_fix2,'Value'),1)
2029 get_mask_fix2_Callback(hObject, eventdata, handles);
2030 end
2031
2032
2033 path_uvmat=which('uvmat');
2034 path_UVMAT=fileparts(path_uvmat);
2035 if isunix
2036 xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml');
2037 if exist(xmlfile,'file')
2038 t=xmltree(xmlfile);
2039 sparam=convert(t);
2040 end
2041 else
2042 xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml');
2043 if exist(xmlfile,'file')
2044 t=xmltree(xmlfile);
2045 sparam=convert(t);
2046 end
2047 end
2048 sge=0;
2049 if isfield(sparam,'Civ_exe')
2050 Civ_exe=sparam.Civ_exe
2051 end
2052 if isfield(sparam,'Civ1_exe')
2053 civ1_exe=sparam.Civ1_exe
2054 end
2055 if isfield(sparam,'Civ2_exe')
2056 civ2_exe=sparam.Civ2_exe
2057 end
2058 if isfield(sparam,'Patch_exe')
2059 patch_exe=sparam.Patch_exe
2060 end
2061 if isfield(sparam,'PatchNew_exe')
2062 patch_new_exe=sparam.PatchNew_exe
2063 end
2064 if isfield(sparam,'Fix_exe')
2065 fix_exe=sparam.Fix_exe
2066 end
2067 if isfield(sparam,'Todo_path')
2068 todo_path=sparam.Todo_path
2069 end
2070 if isfield(sparam,'SGE')
2071 sge=str2num(sparam.SGE)
2072 end
2073
2074
2075 ind_answer=2;
2076 if sge
2077 [s,w]=unix('qstat -q civ.q|grep job_| wc -l');
2078 if isequal(s,0)
2079 w(end)=[];
2080 str_displ={[w ' jobs in the waiting list'];'Select a priority:'};
2081 str={'urgent';'normal';'low'};
2082 [ind_answer,v] = listdlg('PromptString',str_displ,...
2083 'SelectionMode','single',...
2084 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3);
2085 if isequal(v,0)
2086 return
2087 end
2088 else
2089 warndlg_uvmat('batch system not available','ERROR')
2090 return
2091 end
2092 end
2093
2094
2095 set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001])
2096 set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001])
2097 set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001])
2098 set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001])
2099 set(handles.BATCH, 'Enable','Off')
2100 set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])
2101
2102
2103
2104
2105 if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\')
2106 cur_dir=pwd;
2107 if ~isequal(cur_dir(2:3),':\')
2108 cd(matlabroot);
2109 end
2110 [ss,ww]=dos(['net use ' filebase(1:2)]);
2111 if isequal(ss,0)
2112 rankpath=findstr(ww,'\\');
2113 if ~isempty(rankpath)
2114 wwrest=ww(rankpath:end);
2115 rankend=min(find(double(wwrest)==10))-1;
2116 filebase=[wwrest(1:rankend) filebase(3:end)];
2117 set(handles.displ_filebase,'String',filebase);
2118 end
2119 else
2120 warndlg_uvmat('for BATCH option, UBC file names, beginning by \\, are needed','ERROR');
2121 set(handles.BATCH, 'Enable','On')
2122 set(handles.BATCH,'BackgroundColor',[1 0 0])
2123 return
2124 end
2125 end
2126
2127 [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
2128 set_civ_filenames(handles,compare,box_test);
2129
2130 nbfield=size(num1_civ1,2);
2131 nbslice=size(num1_civ1,1);
2132
2133
2134
2135
2136 if box_test(1)==1
2137 par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1});
2138 end
2139
2140
2141 if box_test(2)==1
2142 flagindex1(1)=get(handles.vec_Fmin2, 'Value');
2143 flagindex1(2)=get(handles.vec_F3, 'Value');
2144 flagindex1(3)=get(handles.vec_F2, 'Value');
2145 thresh_vecC1=str2num(get(handles.thresh_vecC,'String'));
2146 thresh_vel1=str2num(get(handles.thresh_vel,'String'));
2147 test_mask=get(handles.get_mask_fix1,'Value');
2148
2149 nbslice_mask=get(handles.mask_fix1,'UserData');
2150
2151
2152
2153
2154
2155 menu=get(handles.field_ref1,'String');
2156 index=get(handles.field_ref1,'Value');
2157 if isempty(menu)
2158 fieldchoice='';
2159 else
2160 fieldchoice=menu{index};
2161 warndlg('reference field is not used presently with batch, use RUN option')
2162 end
2163 end
2164
2165
2166 if box_test(3)==1
2167 rho_patch1=str2num(get(handles.rho_patch1,'String'));
2168 if isempty(rho_patch1)
2169 rho_patch1='1000';
2170 set(handles.rho_patch1,'String','1')
2171 else
2172 rho_patch1=num2str(1000*rho_patch1);
2173 end
2174 nx_patch1=get(handles.nx_patch1,'String');
2175 ny_patch1=get(handles.ny_patch1,'String');
2176 if isequal(str2num(nx_patch1),[])
2177 nx_patch1='50' ;
2178 set(handles.nx_patch1,'String','50');
2179 end
2180 if isequal(str2num(ny_patch1),[])
2181 ny_patch1='50' ;
2182 set(handles.ny_patch1,'String','50');
2183 end
2184 subdomain_patch1=get(handles.subdomain_patch1,'String');
2185 thresh_patch1=get(handles.thresh_patch1,'String');
2186 test_interp=get(handles.test_interp,'Value');
2187 end
2188
2189
2190 if box_test(4)==1
2191 par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1)));
2192 end
2193
2194
2195 if box_test(5)==1
2196 flagindex2(1)=get(handles.vec_Fmin2_2, 'Value');
2197 flagindex2(2)=get(handles.vec_F3_2, 'Value');
2198 flagindex2(3)=get(handles.vec_F4, 'Value');
2199 thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));
2200 thresh_vel2=str2num(get(handles.thresh_vel2,'String'));
2201 test_mask=get(handles.get_mask_fix2,'Value');
2202 nbslice_mask=get(handles.mask_fix2,'UserData');
2203
2204
2205
2206
2207
2208 end
2209
2210
2211
2212 if box_test(6)==1
2213 rho_patch2=str2num(get(handles.rho_patch2,'String'));
2214 if isempty(rho_patch2)
2215 rho_patch2='1000';
2216 set(handles.rho_patch2,'String','1')
2217 else
2218 rho_patch2=num2str(1000*rho_patch2);
2219 end
2220 nx_patch2=get(handles.nx_patch2,'String');
2221 ny_patch2=get(handles.ny_patch2,'String');
2222 if isequal(str2num(nx_patch2),[])
2223 nx_patch2='50' ;
2224 set(handles.nx_patch2,'String','50');
2225 end
2226 if isequal(str2num(ny_patch2),[])
2227 ny_patch2='50' ;
2228 set(handles.ny_patch2,'String','50');
2229 end
2230 subdomain_patch2=get(handles.subdomain_patch2,'String');
2231 thresh_patch2=get(handles.thresh_patch2,'String');
2232
2233 end
2234
2235 if ~sge
2236
2237
2238 name_lock=fullfile(todo_path,'lock');
2239 iwait=0;
2240 while(exist(name_lock) & iwait<15)
2241 pause(1);
2242 iwait=iwait+1;
2243 end
2244 if iwait==15
2245 errordlg(['I''m tired to wait for the lock file, please delete it then click again on BATCH' name_lock ])
2246 set(handles.BATCH, 'Enable','On')
2247 set(handles.BATCH,'BackgroundColor',[1 0 0])
2248 return
2249 end
2250 p0=fopen(name_lock,'w');
2251 name_todo=fullfile(todo_path,'TODO.txt');
2252 p1=fopen(name_todo,'a');
2253 if (p1<0)
2254 errordlg(['error in opening ' name_todo])
2255 set(handles.BATCH, 'Enable','On')
2256 set(handles.BATCH,'BackgroundColor',[1 0 0])
2257 return;
2258 end
2259 end
2260
2261
2262
2263 p1text=[];
2264 time=get(handles.displ_filebase,'UserData');
2265 civAll=get(handles.Experimental,'Value');
2266 if isequal(civAll,1)
2267 civAllxml=xmltree;
2268 civAllCmd=[];
2269 civAllxml=set(civAllxml,1,'name','CivDoc');
2270 end
2271 for ifile=1:nbfield
2272 for j=1:nbslice
2273 i_cmd=0;
2274 cmd='';
2275 if sge
2276 cmd='#!/bin/bash';
2277 cmd=char({cmd;'#$ -cwd'});
2278 cmd=char({cmd;'hostname && date'});
2279 end
2280
2281 filename_cmx=cell2mat(filecell.nc.civ1(ifile,j));
2282 filename_cmx([end-1:end])='cm';
2283 filename_cmx=[filename_cmx 'x'];
2284
2285
2286 if box_test(1)==1
2287 par_civ1.filename_ima_a=cell2mat(filecell.ima1.civ1(ifile,j));
2288
2289 par_civ1.filename_ima_b=cell2mat(filecell.ima2.civ1(ifile,j));
2290
2291
2292 namelog=[filename_cmx([1:end-3]) 'log'];
2293 par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j)));
2294 par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2);
2295 par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);
2296 par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);
2297 test_mask=get(handles.get_mask_civ1,'Value');
2298 if test_mask==0
2299 par_civ1.maskname='noFile use default';
2300 par_civ1.maskflag='n';
2301 else
2302 maskdispl=get(handles.mask_civ1,'String');
2303 maskbase=[filebase '_' maskdispl];
2304 par_civ1.maskname=name_generator(maskbase,num1_civ1(ifile),1,'.png','_i');
2305 if exist(par_civ1.maskname,'file')
2306 par_civ1.maskflag='y';
2307 else
2308 par_civ1.maskname='noFile use default';
2309 par_civ1.maskflag='n';
2310 end
2311 end
2312 i_cmd=i_cmd+1;
2313 if isequal(civAll,0)
2314 cmd=char({cmd;BATCH_CIV1(filename_cmx([1:end-4]),namelog,par_civ1,handles)});
2315 else
2316 civAllCmd=[civAllCmd ' civ1 '];
2317 str=BATCH_CIV1_Unified(filename_cmx([1:end-4]),namelog,par_civ1,handles);
2318 fieldnames=fields(str);
2319 [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1');
2320 for ilist=1:length(fieldnames)
2321 val=eval(['str.' fieldnames{ilist}]);
2322 if ischar(val)
2323 [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist});
2324 [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
2325 end
2326 end
2327 end
2328 end
2329
2330
2331 if box_test(2)==1
2332 test_mask=get(handles.get_mask_fix1,'Value');
2333 if test_mask==0
2334 maskname='';
2335 else
2336 maskdispl=get(handles.mask_fix1,'String');
2337 maskbase=[filebase '_' maskdispl];
2338 maskname=name_generator(maskbase,num1_civ1(ifile),1,'.png','_i');
2339 end
2340 if isequal(civAll,0)
2341 cmd_FIX=[fix_exe ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ...
2342 ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ...
2343 ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname];
2344 cmd=char({cmd ;cmd_FIX});
2345 else
2346 fix1.inputFileName=filecell.nc.civ1{ifile,j} ;
2347 fix1.fi1=num2str(flagindex1(1));
2348 fix1.fi2=num2str(flagindex1(2));
2349 fix1.fi3=num2str(flagindex1(3));
2350 fix1.threshC=num2str(thresh_vecC1);
2351 fix1.threshV=num2str(thresh_vel1);
2352 fieldnames=fields(fix1);
2353 [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1');
2354 for ilist=1:length(fieldnames)
2355 val=eval(['fix1.' fieldnames{ilist}]);
2356 if ischar(val)
2357 [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist});
2358 [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
2359 end
2360 end
2361 civAllCmd=[civAllCmd ' fix1 '];
2362 end
2363 end
2364
2365
2366 if box_test(3)==1
2367 if isequal(civAll,0)
2368 cmd_PATCH=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp);
2369 cmd=char({cmd ;cmd_PATCH});
2370 else
2371 patch1.inputFileName=filecell_nc1{ifile,j} ;
2372 patch1.nopt=subdomain_patch1;
2373 patch1.maxdiff=thresh_patch1;
2374 patch1.ro=rho_patch1;
2375 patch1.m=nx_patch1;
2376 patch1.n=ny_patch1;
2377 grid_tmp=get(handles.grid_patch1,'String');
2378 if ~isequal(grid_tmp,'none')
2379 patch1.gridPatch=grid_tmp;
2380 end
2381 patch1.convectFlow='n';
2382 fieldnames=fields(patch1);
2383 [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1');
2384 for ilist=1:length(fieldnames)
2385 val=eval(['patch1.' fieldnames{ilist}]);
2386 if ischar(val)
2387 [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist});
2388 [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
2389 end
2390 end
2391
2392 civAllCmd=[civAllCmd ' patch1 '];
2393 end
2394 end
2395
2396 if box_test(4)==1 | box_test(5)==1 | box_test(6)==1
2397 filename_cmx=filecell.nc.civ2{ifile,j};
2398 filename_cmx([end-1:end])=[ 'cm'];
2399 filename_cmx=[filename_cmx 'x'];
2400 end
2401
2402 if box_test(4)==1
2403 par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j};
2404 par_civ2.filename_ima_a([end-3:end])=[];
2405 par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j};
2406 par_civ2.filename_ima_b([end-3:end])=[];
2407 namelog=[filename_cmx([1:end-3]) 'log'];
2408 par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j)));
2409 par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2);
2410 par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc);
2411 par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc);
2412 par_civ2.filename_nc1=filecell.nc.civ1{ifile,j};
2413 par_civ2.filename_nc1([end-2:end])=[];
2414 test_mask=get(handles.get_mask_civ2,'Value');
2415 if test_mask==0
2416 par_civ2.maskname='noFile use default';
2417 par_civ2.maskflag='n';
2418 else
2419 maskdispl=get(handles.mask_civ2,'String');
2420 maskbase=[filebase '_' maskdispl];
2421 par_civ2.maskname=name_generator(maskbase,num1_civ2(ifile),1,'.png','_i');
2422 if exist(par_civ2.maskname,'file')
2423 par_civ2.maskflag='y';
2424 else
2425 par_civ2.maskname='noFile use default';
2426 par_civ2.maskflag='n';
2427 end
2428 end
2429 i_cmd=i_cmd+1;
2430 cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par_civ2);
2431 if(isunix)
2432 cmd=char({cmd ; ['cp -f ' filename_cmx '2 ' filename_cmx]; cmd_CIV2});
2433 else
2434 cmd=char({cmd ; ['copy /Y ' filename_cmx '2 ' filename_cmx]; cmd_CIV2});
2435 end
2436 end
2437
2438
2439 if box_test(5)==1
2440 test_mask=get(handles.get_mask_fix2,'Value');
2441 if test_mask==0
2442 maskname='';
2443 else
2444 maskdispl=get(handles.mask_fix2,'String');
2445 maskbase=[filebase '_' maskdispl];
2446 maskname =name_generator(maskbase,num1_civ2(ifile),1,'.png','_i');
2447 end
2448 cmd_FIX=[fix_exe ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ...
2449 ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ...
2450 ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname];
2451 cmd=char({cmd ;cmd_FIX});
2452 end
2453
2454
2455 if box_test(6)==1
2456 cmd_PATCH=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,0);
2457 cmd=char({cmd; cmd_PATCH});
2458 end
2459
2460 if isequal(civAll,1)
2461 save(civAllxml,[filename_cmx([1:end-4]) '.xml']);
2462 cmd=char({cmd;[Civ_exe ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]});
2463
2464
2465 end
2466
2467
2468 if sge
2469 [Rootbat,Filebat,extbat]=fileparts(filename_cmx);
2470 filename_bat=fullfile(Rootbat,['job_' Filebat extbat]);
2471 else
2472 filename_bat=filename_cmx;
2473 end
2474 filename_bat(end-2:end)='bat';
2475
2476 dlmwrite(filename_bat,cmd,'');
2477 if sge
2478 pvalue=num2str((1-ind_answer)*500);
2479 namelog=[filename_bat '.patch.log'];
2480 ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat];
2481 eval( ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]);
2482 else
2483 if(isunix)
2484 cmdtodo=['. ' filename_bat ];
2485 else
2486 cmdtodo=[filename_bat];
2487 end
2488 count= fprintf(p1,'%s\n', cmdtodo);
2489 end
2490 end
2491 end
2492 if ~sge
2493 fclose(p1);
2494 fclose(p0);
2495 delete(name_lock);
2496 end
2497
2498 set(handles.BATCH, 'Enable','On')
2499 set(handles.BATCH,'BackgroundColor',[1 0 0])
2500
2501
2502 if isfield(filecell,'nc')
2503 if isfield(filecell.nc,'civ2')
2504 fileresu=filecell.nc.civ2{1,1};
2505 else
2506 fileresu=filecell.nc.civ1{1,1};
2507 end
2508 end
2509 [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu);
2510 namedoc=fullfile(RootPath,subdir,RootFile);
2511 detect=1;
2512 while detect==1
2513 namefigfull=[namedoc '.fig'];
2514 hh=dir(namefigfull);
2515 if ~isempty(hh)
2516 detect=1;
2517 namedoc=[namedoc '.0'];
2518 else
2519 detect=0;
2520 end
2521 end
2522 saveas(gcbf,namefigfull);
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536 function [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
2537 set_civ_filenames(handles,compare,box_test)
2538
2539
2540 filebase=get(handles.displ_filebase,'String');
2541 browse=get(handles.browse_root,'UserData');
2542 compare_list=get(handles.compare,'String');
2543 val=get(handles.compare,'Value');
2544 compare=compare_list{val};
2545 if strcmp(compare,'displacement')
2546 mode='displacement';
2547 else
2548 mode_list=get(handles.mode,'String');
2549 mode_value=get(handles.mode,'Value');
2550 mode=mode_list{mode_value};
2551 end
2552 time=get(handles.displ_filebase,'UserData');
2553 ext_ima=get(handles.ext_ima,'String');
2554 nom_type_nc=browse.nom_type_nc;
2555 nom_type_ima2=browse.nom_type_ima;
2556 if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end;
2557 if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end;
2558 [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...
2559 find_pair_indices(handles,mode);
2560
2561
2562 filebase_B=filebase;
2563 if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV')
2564 test_disp=1;
2565 nom_type_ima1=browse.nom_type_ima_1;
2566 [Path2,Name2]=fileparts(filebase_B);
2567 Path1=Path2;
2568 Name1=get(handles.displ_filebase2,'String');
2569 filebase_A=fullfile(Path1,Name1);
2570 if length(Name1)>6
2571 Name1=Name1(end-5:end);
2572 end
2573 if length(Name2)>6
2574 Name2=Name2(end-5:end);
2575 end
2576 filebase_AB=fullfile(Path2,[Name2 '-' Name1]);
2577 else
2578 test_disp=0;
2579 filebase_A=filebase;
2580 nom_type_ima1=nom_type_ima2;
2581 filebase_AB=filebase;
2582 end
2583 if strcmp(compare,'displacement')
2584 filebase_ima1=filebase_A;
2585 filebase_ima2=filebase_B;
2586 filebase_nc=filebase_AB;
2587 else
2588 filebase_ima1=filebase_B;
2589 filebase_ima2=filebase_B;
2590 filebase_nc=filebase_B;
2591 end
2592
2593
2594 file_ref_fix1={};
2595 file_ref_fix2={};
2596 nbfield=length(num1_civ1);
2597 nbslice=length(num_a_civ1);
2598 if box_test(2)==1
2599 ref=get(handles.ref_fix1,'UserData');
2600 if ~isempty(ref)
2601 first_i=str2num(get(handles.first_i,'String'));
2602 last_i=str2num(get(handles.last_i,'String'));
2603 incr_i=str2num(get(handles.incr_i,'String'));
2604 first_j=str2num(get(handles.first_j,'String'));
2605 last_j=str2num(get(handles.last_j,'String'));
2606 incr_j=str2num(get(handles.incr_j,'String'));
2607 num_i_ref=[first_i:incr_i:last_i];
2608 num_j_ref=[first_j:incr_j:last_j];
2609 if isequal(mode,'displacement')
2610 num_i1=num_i_ref;
2611 num_i2=num_i_ref;
2612 num_j1=num_j_ref;
2613 num_j2=num_j_ref;
2614 elseif isequal(mode,'pair j1-j2')
2615 num_i1=num_i_ref;
2616 num_i2=num_i1;
2617 num_j1=ref.num_a*ones(size(num_i_ref));
2618 num_j2=ref.num_b*ones(size(num_i_ref));
2619 elseif isequal(mode,'series(Di)')
2620 delta1=floor((ref.num2-ref.num1)/2);
2621 delta2=ceil((ref.num2-ref.num1)/2);
2622 num_i1=num_i_ref-delta1*ones(size(num_i_ref));
2623 num_i2=num_i_ref+delta2*ones(size(num_i_ref));
2624 if isempty(ref.num_a)
2625 ref.num_a=1;
2626 end
2627 num_j1=ref.num_a*ones(size(num_i1));
2628 num_j2=num_j1;
2629 elseif isequal(mode,'series(Dj)')
2630 delta1=floor((ref.num_b-ref.num_a)/2);
2631 delta2=ceil((ref.num_b-ref.num_a)/2);
2632 num_i1=ref.num1*ones(size(num_i_ref));
2633 num_i2=num_i1;
2634 num_j1=num_j_ref-delta1*ones(size(num_j_ref));
2635 num_j2=num_j_ref+delta2*ones(size(num_j_ref));
2636 end
2637 for ifile=1:nbfield
2638 for j=1:nbslice
2639 file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);
2640 file_ref_fix1(ifile,j)={file_ref};
2641 if ~exist(file_ref,'file')
2642 warndlg_uvmat(['reference file ' file_ref ' not found for fix1'],'ERROR')
2643 set(handles.RUN, 'Enable','On')
2644 set(handles.RUN,'BackgroundColor',[1 0 0])
2645 set(handles.BATCH, 'Enable','On')
2646 set(handles.BATCH,'BackgroundColor',[1 0 0])
2647 return
2648 end
2649 end
2650 end
2651 end
2652 end
2653
2654
2655 if box_test(5)==1
2656 ref=get(handles.ref_fix2,'UserData');
2657 if ~isempty(ref)
2658 first_i=str2num(get(handles.first_i,'String'));
2659 last_i=str2num(get(handles.last_i,'String'));
2660 incr_i=str2num(get(handles.incr_i,'String'));
2661 first_j=str2num(get(handles.first_j,'String'));
2662 last_j=str2num(get(handles.last_j,'String'));
2663 incr_j=str2num(get(handles.incr_j,'String'));
2664 num_i_ref=[first_i:incr_i:last_i];
2665 num_j_ref=[first_j:incr_j:last_j];
2666 if isequal(mode,'displacement')
2667 num_i1=num_i_ref;
2668 num_i2=num_i_ref;
2669 num_j1=num_j_ref;
2670 num_j2=num_j_ref;
2671 elseif isequal(mode,'pair j1-j2')
2672 num_i1=num_i_ref;
2673 num_i2=num_i1;
2674 num_j1=ref.num_a;
2675 num_j2=ref.num_b;
2676 elseif isequal(mode,'series(Di)')
2677 delta1=floor((ref.num2-ref.num1)/2);
2678 delta2=ceil((ref.num2-ref.num1)/2);
2679 num_i1=num_i_ref-delta1*ones(size(num_i_ref));
2680 num_i2=num_i_ref+delta2*ones(size(num_i_ref));
2681 num_j1=ref.num_a*ones(size(num_i1));
2682 num_j2=num_j1;
2683 elseif isequal(mode,'series(Dj)')
2684 delta1=floor((ref.num_b-ref.num_a)/2);
2685 delta2=ceil((ref.num_b-ref.num_a)/2);
2686 num_i1=ref.num1*ones(size(num_i_ref));
2687 num_i2=num_i1;
2688 num_j1=num_j_ref-delta1*ones(size(num_j_ref));
2689 num_j2=num_j_ref+delta2*ones(size(num_j_ref));
2690 end
2691 for ifile=1:nbfield
2692 for j=1:nbslice
2693 file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);
2694 file_ref_fix2(ifile,j)={file_ref};
2695 if ~exist(file_ref,'file')
2696 warndlg_uvmat(['reference file ' file_ref ' not found for fix2'],'ERROR')
2697 set(handles.RUN, 'Enable','On')
2698 set(handles.RUN,'BackgroundColor',[1 0 0])
2699 set(handles.BATCH, 'Enable','On')
2700 set(handles.BATCH,'BackgroundColor',[1 0 0])
2701 return
2702 end
2703 end
2704 end
2705 end
2706 end
2707
2708
2709 subdir_civ1=get(handles.subdir_civ1,'String');
2710 subdir_civ2=get(handles.subdir_civ2,'String');
2711 if isequal(subdir_civ1,''),subdir_civ1='A'; end
2712 if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end
2713 currentdir=pwd;
2714 [Path_ima,Name]=fileparts(filebase);
2715 if ~exist(Path_ima,'dir')
2716 warndlg_uvmat(['path to images ' Path_ima ' not found'],'ERROR')
2717 return
2718 end
2719 cd(Path_ima);
2720 dircur=pwd;
2721 m2='';
2722 [erread,message]=fileattrib(Path_ima);
2723 if ~isempty(message) & ~isequal(message.UserWrite,1)
2724 errordlg(['No writting access to ' Path_ima])
2725 cd(currentdir);
2726 return
2727 end
2728
2729
2730
2731 if box_test(1)==1;
2732 detect=1;
2733 while detect==1
2734 for ifile=1:nbfield;
2735 for j=1:nbslice
2736 filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);
2737 detect=exist(filename,'file')==2;
2738 if detect
2739 subdir_civ1=[subdir_civ1 '.0'];
2740 subdir_civ2=subdir_civ1;
2741 break
2742 end
2743 filecell.nc.civ1(ifile,j)={filename};
2744 end
2745 if detect
2746 break
2747 end
2748 end
2749
2750 if ~exist(fullfile(Path_ima,subdir_civ1),'dir')
2751 [m1,m2,m3]=mkdir(subdir_civ1)
2752 if ~isequal(m2,'')
2753 msgbox_uvmat('ERROR', m2)
2754
2755 end
2756 end
2757 if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))
2758 for ifile=1:nbfield
2759 for j=1:nbslice
2760 filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);
2761 detect=exist(filename,'file')==2;
2762 if detect
2763 subdir_civ1=[subdir_civ1 '.0'];
2764 subdir_civ2=subdir_civ1;
2765 break
2766 end
2767 filecell.ncA.civ1(ifile,j)={filename};
2768 end
2769 if detect
2770 break
2771 end
2772 end
2773
2774 if ~exist(fullfile(Path_ima,subdir_civ1),'dir')
2775 [m1,m2,m3]=mkdir(subdir_civ1);
2776 if ~isequal(m2,'')
2777 msgbox_uvmat('ERROR', m2)
2778
2779 end
2780 end
2781 end
2782 end
2783
2784 for ifile=1:nbfield
2785 for j=1:nbslice
2786 filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1);
2787 idetect(j)=exist(filename,'file')==2;
2788 filecell.ima1.civ1(ifile,j)={filename};
2789 filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2);
2790 idetect_1(j)=exist(filename,'file')==2;
2791 filecell.ima2.civ1(ifile,j)={filename};
2792 end
2793 [idetectmin,indexj]=min(idetect);
2794 if idetectmin==0,
2795 warndlg_uvmat([filecell.ima1.civ1{ifile,indexj} ' not found'],'ERROR')
2796 set(handles.RUN, 'Enable','On')
2797 set(handles.RUN,'BackgroundColor',[1 0 0])
2798 set(handles.BATCH, 'Enable','On')
2799 set(handles.BATCH,'BackgroundColor',[1 0 0])
2800 cd(currentdir)
2801 return
2802 end
2803 [idetectmin,indexj]=min(idetect_1);
2804 if idetectmin==0,
2805 warndlg_uvmat([filecell.ima2.civ1{ifile,indexj} ' not found'],'ERROR')
2806 set(handles.RUN, 'Enable','On')
2807 set(handles.RUN,'BackgroundColor',[1 0 0])
2808 set(handles.BATCH, 'Enable','On')
2809 set(handles.BATCH,'BackgroundColor',[1 0 0])
2810 cd(currentdir)
2811 return
2812 end
2813 end
2814 if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)'))
2815 for ifile=1:nbfield
2816 for j=1:nbslice
2817 filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1);
2818 idetect(j)=exist(filename,'file')==2;
2819 filecell.imaA1.civ1(ifile,j)={filename} ;
2820 filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2);
2821 idetect_1(j)=exist(filename,'file')==2;
2822 filecell.imaA2.civ1(ifile,j)={filename};
2823 end
2824 [idetectmin,indexj]=min(idetect);
2825 if idetectmin==0,
2826 warndlg_uvmat([filecell.imaA1.civ1{ifile,indexj} ' not found'],'ERROR')
2827 set(handles.RUN, 'Enable','On')
2828 set(handles.RUN,'BackgroundColor',[1 0 0])
2829 set(handles.BATCH, 'Enable','On')
2830 set(handles.BATCH,'BackgroundColor',[1 0 0])
2831 cd(currentdir)
2832 return
2833 end
2834 [idetectmin,indexj]=min(idetect_1);
2835 if idetectmin==0,
2836 warndlg_uvmat([filecell.imaA2.civ1{ifile,indexj} ' not found'],'ERROR')
2837 set(handles.RUN, 'Enable','On')
2838 set(handles.RUN,'BackgroundColor',[1 0 0])
2839 set(handles.BATCH, 'Enable','On')
2840 set(handles.BATCH,'BackgroundColor',[1 0 0])
2841 cd(currentdir)
2842 return
2843 end
2844 end
2845 end
2846
2847
2848 elseif (box_test(2)==1 || box_test(3)==1);
2849 for ifile=1:nbfield
2850 for j=1:nbslice
2851 filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',...
2852 nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);
2853 detect=exist(filename,'file')==2;
2854 filecell.nc.civ1(ifile,j)={filename};
2855 end
2856 end
2857 if strcmp(compare,'stereo PIV')
2858 for ifile=1:nbfield
2859 for j=1:nbslice
2860 filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);
2861 filecell.ncA.civ1(ifile,j)={filename};
2862 if ~exist(filename,'file')
2863 warndlg_uvmat(['input file ' filename ' not found'],'ERROR')
2864 set(handles.RUN, 'Enable','On')
2865 set(handles.RUN,'BackgroundColor',[1 0 0])
2866 set(handles.BATCH, 'Enable','On')
2867 set(handles.BATCH,'BackgroundColor',[1 0 0])
2868 cd(currentdir)
2869 return
2870 end
2871 end
2872 end
2873 end
2874 end
2875
2876 if (box_test(4)==1)&...
2877 ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))|~isequal(subdir_civ2,subdir_civ1))
2878 detect=1;
2879 while detect==1
2880 for ifile=1:nbfield
2881 for j=1:nbslice
2882 filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);
2883 detect=exist(filename,'file')==2;
2884 if detect
2885 subdir_civ2=[subdir_civ2 '.0'];
2886 break
2887 end
2888 filecell.nc.civ2(ifile,j)={filename};
2889 end
2890 if detect
2891 break
2892 end
2893 end
2894
2895 if ~exist(fullfile(Path_ima,subdir_civ2),'dir')
2896 [m1,m2,m3]=mkdir(subdir_civ2);
2897 if ~isequal(m2,'')
2898 msgbox_uvmat('ERROR', m2)
2899
2900 end
2901 end
2902 if strcmp(compare,'stereo PIV')
2903 for ifile=1:nbfield
2904 for j=1:nbslice
2905 filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',...
2906 nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2);
2907 detect=exist(filename,'file')==2;
2908 if detect
2909 subdir_civ2=[subdir_civ2 '.0'];
2910 break
2911 end
2912 filecell.ncA.civ2(ifile,j)={filename};
2913 end
2914 if detect
2915 break
2916 end
2917 end
2918
2919 if ~exist(fullfile(Path_ima,subdir_civ2),'dir')
2920 [m1,m2,m3]=mkdir(subdir_civ2);
2921 if ~isequal(m2,'')
2922 msgbox_uvmat('ERROR', m2)
2923
2924 end
2925 end
2926 end
2927 end
2928 end
2929 cd(currentdir);
2930
2931
2932
2933 if box_test(4)==1 | box_test(5)==1 | box_test(6)==1
2934
2935 if box_test(1)==0;
2936 for ifile=1:nbfield
2937 for j=1:nbslice
2938 filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',...
2939 nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);
2940 filecell.nc.civ1(ifile,j)={filename};
2941 if ~exist(filename,'file')
2942 warndlg_uvmat(['input file ' filename ' not found'],'ERROR')
2943 set(handles.RUN, 'Enable','On')
2944 set(handles.RUN,'BackgroundColor',[1 0 0])
2945 set(handles.BATCH, 'Enable','On')
2946 set(handles.BATCH,'BackgroundColor',[1 0 0])
2947 return
2948 elseif box_test(3)==0;
2949
2950 Data=nc2struct(filename,[]);
2951 test_patch=0;
2952 if isfield(Data,'patch') & isequal(Data.patch,1)
2953 test_patch=1;
2954 end
2955 if isequal(test_patch,0)
2956 errordlg(['no patch data in ' filename])
2957 set(handles.RUN, 'Enable','On')
2958 set(handles.RUN,'BackgroundColor',[1 0 0])
2959 set(handles.BATCH, 'Enable','On')
2960 set(handles.BATCH,'BackgroundColor',[1 0 0])
2961 return
2962 end
2963 end
2964 end
2965 end
2966 if strcmp(compare,'stereo PIV')
2967 for ifile=1:nbfield
2968 for j=1:nbslice
2969 filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',...
2970 nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);
2971 filecell.ncA.civ2(ifile,j)={filename};
2972 if ~exist(filename,'file')
2973 warndlg_uvmat(['input file ' filename ' not found'],'ERROR')
2974 set(handles.RUN, 'Enable','On')
2975 set(handles.RUN,'BackgroundColor',[1 0 0])
2976 set(handles.BATCH, 'Enable','On')
2977 set(handles.BATCH,'BackgroundColor',[1 0 0])
2978 cd(currentdir)
2979 return
2980 end
2981 end
2982 end
2983 end
2984 end
2985
2986 detect=1;
2987
2988 for ifile=1:nbfield
2989 for j=1:nbslice
2990 filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',...
2991 nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);
2992 detect=exist(filename,'file')==2;
2993 filecell.nc.civ2(ifile,j)={filename};
2994 end
2995 end
2996
2997 if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2)
2998 filecell.ima1.civ2=filecell.ima1.civ1;
2999 elseif box_test(4)==1
3000 for ifile=1:nbfield
3001 for j=1:nbslice
3002 filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1);
3003 idetect_2(j)=exist(filename,'file')==2;
3004 filecell.ima1.civ2(ifile,j)={filename};
3005 end
3006 [idetectmin,indexj]=min(idetect_2);
3007 if idetectmin==0,
3008 warndlg_uvmat(['input image ' filecell.ima1.civ2{ifile,indexj} ' not found'],'ERROR')
3009 set(handles.RUN, 'Enable','On')
3010 set(handles.RUN,'BackgroundColor',[1 0 0])
3011 set(handles.BATCH, 'Enable','On')
3012 set(handles.BATCH,'BackgroundColor',[1 0 0])
3013 return
3014 end
3015 end
3016 end
3017
3018 if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2)
3019 filecell.ima2.civ2=filecell.ima2.civ1;
3020 elseif box_test(4)==1
3021 for ifile=1:nbfield
3022 for j=1:nbslice
3023 filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2);
3024 idetect_3(j)=exist(filename,'file')==2;
3025 filecell.ima2.civ2(ifile,j)={filename};
3026 end
3027
3028 [idetectmin,indexj]=min(idetect_3);
3029 if idetectmin==0,
3030 warndl_uvmat(['input image ' filecell.ima2.civ2{ifile,indexj} ' not found'],'ERROR')
3031 set(handles.RUN, 'Enable','On')
3032 set(handles.RUN,'BackgroundColor',[1 0 0])
3033 set(handles.BATCH, 'Enable','On')
3034 set(handles.BATCH,'BackgroundColor',[1 0 0])
3035
3036 return
3037 end
3038 end
3039 end
3040 end
3041 if (box_test(5)==1 | box_test(6)==1 )& box_test(4)==0
3042 for ifile=1:nbfield
3043 for j=1:nbslice
3044 filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',...
3045 nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);
3046 filecell.nc.civ2(ifile,j)={filename};
3047 if ~exist(filename,'file')
3048 warndlg_uvmat(['input file ' filename ' not found'],'ERROR')
3049 set(handles.RUN, 'Enable','On')
3050 set(handles.RUN,'BackgroundColor',[1 0 0])
3051 set(handles.BATCH, 'Enable','On')
3052 set(handles.BATCH,'BackgroundColor',[1 0 0])
3053
3054 return
3055 else
3056
3057 Data=nc2struct(filename,[]);
3058 test_civ2=0;
3059 if isfield(Data,'civ2') & isequal(Data.civ2,1)
3060 test_civ2=1;
3061 end
3062 if isequal(test_civ2,0)
3063 errordlg(['no civ2 data in ' filename])
3064 set(handles.RUN, 'Enable','On')
3065 set(handles.RUN,'BackgroundColor',[1 0 0])
3066 set(handles.BATCH, 'Enable','On')
3067 set(handles.BATCH,'BackgroundColor',[1 0 0])
3068
3069 return
3070 end
3071 end
3072 end
3073 end
3074 end
3075
3076 if strcmp(compare,'stereo PIV')
3077 if box_test(3)==1 & isequal(get(handles.test_stereo1,'Value'),1)
3078 for ifile=1:nbfield
3079 for j=1:nbslice
3080 filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',...
3081 nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);
3082 filecell.st(ifile,j)={filename};
3083 end
3084 end
3085 end
3086 if box_test(6)==1 & isequal(get(handles.test_stereo2,'Value'),1)
3087 for ifile=1:nbfield
3088 for j=1:nbslice
3089 filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',...
3090 nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);
3091 filecell.st(ifile,j)={filename};
3092 end
3093 end
3094 end
3095 end
3096 set(handles.subdir_civ1,'String',subdir_civ1);
3097 set(handles.subdir_civ2,'String',subdir_civ2);
3098 browse.nom_type_nc=nom_type_nc;
3099 set(handles.browse_root,'UserData',browse);
3100
3101
3102
3103 if isequal(nom_type_ima1,'*')
3104 nom_type_imanew='_i';
3105 else
3106 nom_type_imanew1=nom_type_ima1;
3107 end
3108 if isequal(nom_type_ima2,'*')
3109 nom_type_imanew='_i';
3110 else
3111 nom_type_imanew2=nom_type_ima2;
3112 end
3113 if ~isequal(ext_ima,'.png')
3114 npxy=get(handles.ext_ima,'UserData');
3115 if numel(npxy)<2
3116 filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ext_ima,nom_type_ima1);
3117 A=imread(filename);
3118 npxy=size(A);
3119 end
3120 npy=npxy(1);
3121 npx=npxy(2);
3122 if box_test(1)==1
3123 h = waitbar(0,['copy images to the .png format for civ1']);
3124 for ifile=1:nbfield
3125 waitbar(ifile/nbfield);
3126 for j=1:nbslice
3127 filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1);
3128 if ~exist(filename,'file')
3129 A=read_image(filecell.ima1.civ1{ifile,j},nom_type_ima2,npx,npy,num1_civ1(ifile));
3130 imwrite(A,filename,'BitDepth',16);
3131 end
3132 filecell.ima1.civ1(ifile,j)={filename};
3133 filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2);
3134 if ~exist(filename,'file')
3135 A=read_image(filecell.ima2.civ1{ifile,j},nom_type_ima2,npx,npy,num2_civ1(ifile));
3136 imwrite(A,filename,'BitDepth',16);
3137 end
3138 filecell.ima2.civ1(ifile,j)={filename};
3139 end
3140 end
3141 close(h)
3142 end
3143 if box_test(4)==1
3144 h = waitbar(0,['copy images to the .png format for civ2']);
3145 for ifile=1:nbfield
3146 waitbar(ifile/nbfield);
3147 for j=1:nbslice
3148 filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1);
3149 if ~exist(filename,'file')
3150 A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),nom_type_ima2,npx,npy,num1_civ2(ifile));
3151 imwrite(A,filename,'BitDepth',16);
3152 end
3153 filecell.ima1.civ2(ifile,j)={filename};
3154 filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2);
3155 if ~exist(filename,'file')
3156 A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),nom_type_ima2,npx,npy,num2.civ1(ifile));
3157 imwrite(A,filename,'BitDepth',16);
3158 end
3159 filecell.ima2.civ2(ifile,j)={filename};
3160 end
3161 end
3162 close(h);
3163 end
3164 end
3165
3166
3167
3168
3169 function RUN_CIV1(handles,filecell,filecell_1,filecell_nc1,num1,num2,num_a,num_b,nom_type_nc)
3170
3171 global civ1_exe sge
3172
3173
3174 ibx_val=str2num(get(handles.ibx,'String'));
3175 if isempty(ibx_val)
3176 ibx='21'; set(handles.ibx,'String','21')
3177 else
3178 ibx=num2str(ibx_val);
3179 end
3180 iby_val=str2num(get(handles.iby,'String'));
3181 if isempty(iby_val)
3182 iby='21'; set(handles.iby,'String','21')
3183 else
3184 iby=num2str(iby_val);
3185 end
3186 isx=get(handles.isx,'String');
3187 if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end;
3188 if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end
3189 isy=get(handles.isy,'String');
3190 if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;
3191 if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end
3192 shiftx=get(handles.shiftx,'String');
3193 if isempty(str2num(shiftx)), shiftx='0'; set(handles.shiftx,'String','0'), end;
3194 shifty=get(handles.shifty,'String');
3195 if isempty(str2num(shifty)), shifty='0'; set(handles.shifty,'String','0'), end;
3196 rho=get(handles.rho,'String');
3197 dx=get(handles.dx_civ1,'String');
3198 if isequal(str2num(dx),[]), dx='20'; set(handles.dx_civ1,'String','20'); end
3199 dy=get(handles.dy_civ1,'String');
3200 if isequal(str2num(dy),[]), dy='20'; set(handles.dy_civ1,'String','20');end
3201 if isequal(str2num(dy),[]), dy='20'; end
3202 pxcmx='1';
3203 pxcmy='1';
3204 image_first=cell2mat(filecell(1,1));
3205 if ~exist(image_first,'file')
3206 warndlg_uvmat(['image ' image_first 'not found'],'ERROR')
3207 set(handles.RUN, 'Enable','On')
3208 set(handles.RUN,'BackgroundColor',[1 0 0])
3209 return
3210 end
3211 A=imread(cell2mat(filecell(1,1)));
3212 sizim=size(A);
3213 npx=num2str(sizim(2));
3214 npy=num2str(sizim(1));
3215 time=get(handles.displ_filebase,'UserData');
3216 gridname=get(handles.grid_civ1,'String');
3217 gridflag='y';
3218 if isequal(gridname,'')| isempty(gridname)
3219 gridname='nogrid';
3220 gridflag='n';
3221 end
3222 if isequal(get(handles.ImaThreshold,'Value'),1)
3223 threshflag='y';
3224 min_ima=get(handles.MinIma,'String');
3225 max_ima=get(handles.MaxIma,'String');
3226 else
3227 threshflag='n';
3228 min_ima='0';
3229 max_ima='4096';
3230 end
3231
3232 filebase=get(handles.displ_filebase,'String');
3233 sizcell=size(filecell);
3234 nbfield=sizcell(1);
3235 nbslice=sizcell(2);
3236 icount=0;
3237 for ifile=1:nbfield
3238
3239
3240 for j=1:nbslice
3241 icount=icount+1;
3242 barlength=0.188*icount/(nbfield*nbslice);
3243 set(handles.waitbar_1,'Position',[0.946 0.877-barlength 0.03 barlength])
3244 drawnow
3245 filename_ima=cell2mat(filecell(ifile,j));
3246 filename_ima([end-3:end])=[];
3247 filename_ima_1=cell2mat(filecell_1(ifile,j));
3248 filename_ima_1([end-3:end])=[];
3249 filename_cmx=cell2mat(filecell_nc1(ifile,j));
3250 filename_cmx([end-1:end])=[ 'cm'];
3251 filename_cmx=[filename_cmx 'x'];
3252 namelog=[filename_cmx([1:end-3]) 'log'];
3253 if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j)
3254 Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j)));
3255 if isequal(Dt,'0')
3256 Dt='1' ;
3257 end
3258 T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2);
3259 else
3260 Dt='1';
3261 T0='0';
3262 end
3263 term_a=num2stra(num_a(j),nom_type_nc);
3264 term_b=num2stra(num_b(j),nom_type_nc);
3265 test_mask=get(handles.get_mask_civ1,'Value');
3266 if test_mask==0
3267 maskname='noFile use default';
3268 maskflag='n';
3269 else
3270 maskdispl=get(handles.mask_civ1,'String');
3271 maskbase=[filebase '_' maskdispl];
3272 maskname=name_generator(maskbase,num1(ifile),1,'.png','_i');
3273 if exist(maskname,'file')
3274 maskflag='y';
3275 else
3276 maskname='noFile use default';
3277 maskflag='n';
3278 end
3279 end
3280 textcmx={'############## CMX file';...
3281 ['FirstImage ' filename_ima];...
3282 ['LastImage ' filename_ima_1];...
3283 'XX' ;...
3284 ['Mask ' maskflag] ;...
3285 ['MaskName ' maskname];...
3286 ['ImageSize ' npx ' ' npy];...
3287 ['CorrelationBoxesSize ' ibx ' ' iby];...
3288 ['SearchBoxeSize ' isx ' ' isy];...
3289 ['RO ' rho];...
3290 ['GridSpacing ' dx ' ' dy];...
3291 'XX 1.0';...
3292 ['Dt_TO ' Dt ' ' T0];...
3293 ['PixCmXY ' pxcmx ' ' pxcmy];...
3294 'XX 1';...
3295 ['ShiftXY ' shiftx ' ' shifty];...
3296 ['Grid ' gridflag];...
3297 ['GridName ' gridname] ;...
3298 'XX 85';...
3299 'XX 1.0';...
3300 'XX 1.0';...
3301 'Hart 1';...
3302 'DecimalShift 0';...
3303 'Deformation 0';...
3304 'CorrelationMin 0';...
3305 'IntensityMin 0';...
3306 ['SeuilImage ' threshflag];...
3307 ['SeuilImageValues ' min_ima ' ' max_ima];...
3308 ['ImageToUse ' term_a ' ' term_b];...
3309 'ImageUsedBefore null null'};
3310 textout=char(textcmx);
3311 dlmwrite(filename_cmx,textout,'');
3312 s=-1;
3313 ['!' civ1_exe ' -f ' filename_cmx ]
3314 eval(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]);
3315
3316
3317
3318
3319
3320
3321
3322 end
3323 end
3324
3325
3326
3327
3328
3329
3330 function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc)
3331
3332
3333 global civ2_exe sge
3334
3335
3336 field.vel_type='civ2';
3337 field.nb='nb_vectors2';
3338 field.X='vec2_X';
3339 field.Y='vec2_Y';
3340 field.U='vec2_U';
3341 field.V='vec2_V';
3342
3343
3344 ibx=get(handles.ibx_civ2,'String');
3345 iby=get(handles.iby_civ2,'String');
3346 rho=get(handles.rho_civ2,'String');
3347 decimal=int2str(get(handles.decimal,'Value'));
3348 deformation=int2str(get(handles.deformation,'Value'));
3349 dx=get(handles.dx_civ2,'String');
3350 dy=get(handles.dy_civ2,'String');
3351 if isequal(str2num(dx),[])
3352 dx='20';
3353 end
3354 if isequal(str2num(dy),[])
3355 dy='20';
3356 end
3357 pxcmx='1';
3358 pxcmy='1';
3359 A=imread(cell2mat(filecell_2(1,1)));
3360 sizim=size(A);
3361 npx=num2str(sizim(2));
3362 npy=num2str(sizim(1));
3363 time=get(handles.displ_filebase,'UserData');
3364 filebase=get(handles.displ_filebase,'String');
3365 gridname=get(handles.grid_civ2,'String');
3366 gridflag='y';
3367 if isequal(gridname,'')| isempty(gridname)
3368 gridname='nogrid';
3369 gridflag='n';
3370 end
3371 sizcell=size(filecell_2);
3372 nbfield=sizcell(1);
3373 nbslice=sizcell(2);
3374
3375
3376
3377
3378 icount=0;
3379 for ifile=1:nbfield
3380
3381
3382 for j=1:nbslice
3383 icount=icount+1;
3384 barlength=0.188*icount/(nbfield*nbslice);
3385 set(handles.waitbar_civ2,'Position',[0.946 0.407-barlength 0.03 barlength])
3386 drawnow
3387 filename_ima_2=cell2mat(filecell_2(ifile,j));
3388 filename_ima_2([end-3:end])=[];
3389 filename_ima_3=cell2mat(filecell_3(ifile,j));
3390 filename_ima_3([end-3:end])=[];
3391 filename_cmx=cell2mat(filecell_nc2(ifile,j));
3392 filename_cmx([end-1:end])=[ 'cm'];
3393 filename_cmx=[filename_cmx 'x'];
3394 namelog=[filename_cmx([1:end-3]) 'log'];
3395 if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j)
3396 Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j)));
3397 if isequal(Dt,'0')
3398 Dt='1'
3399 end
3400 T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2);
3401 else
3402 Dt='1';
3403 T0='0';
3404 end
3405 term_a=num2stra(num_a(j),nom_type_nc);
3406 term_b=num2stra(num_b(j),nom_type_nc);
3407 filename_nc1=cell2mat(filecell_nc1(ifile,j));
3408 filename_nc1([end-2:end])=[];
3409 test_mask=get(handles.get_mask_civ2,'Value');
3410 if test_mask==0
3411 maskname='noFile use default';
3412 maskflag='n';
3413 else
3414 maskdispl=get(handles.mask_civ2,'String');
3415 maskbase=[filebase '_' maskdispl];
3416 maskname =name_generator(maskbase,num1(ifile),1,'.png','_i');
3417 if ~exist(maskname,'file')
3418 maskflag='y';
3419 else
3420 maskname='noFile use default';
3421 maskflag='n';
3422 end
3423 end
3424
3425 textcmx={'############## CMX file';...
3426 ['FirstImage ' filename_ima_2];...
3427 ['LastImage ' filename_ima_3];...
3428 'XX' ;...
3429 ['Mask ' maskflag];...
3430 ['MaskName ' maskname];...
3431 ['ImageSize ' npx ' ' npy];...
3432 ['CorrelationBoxesSize ' ibx ' ' iby];...
3433 ['SearchBoxeSize ' ibx ' ' iby];...
3434 ['RO ' rho];...
3435 ['GridSpacing ' dx ' ' dy];...
3436 'XX 1.0';...
3437 ['Dt_TO ' Dt ' ' T0];...
3438 ['PixCmXY ' pxcmx ' ' pxcmy];...
3439 'XX 1';...
3440 ['ShiftXY 0 0'];...
3441 ['Grid ' gridflag];...
3442 ['GridName ' gridname];...
3443 'XX 85';...
3444 'XX 1.0';...
3445 'XX 1.0';...
3446 'Hart 1';...
3447 ['DecimalShift ' decimal];...
3448 ['Deformation ' deformation];...
3449 'CorrelationMin 0';...
3450 'IntensityMin 0';...
3451 'SeuilImage n';...
3452 'SeuilImageValues 0 4096';...
3453 ['ImageToUse ' term_a ' ' term_b];...
3454 ['ImageUsedBefore ' filename_nc1]};
3455 textout=char(textcmx);
3456 dlmwrite(filename_cmx,textout,'');
3457 s=-1;
3458 ['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]
3459 eval(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]);
3460
3461
3462
3463
3464
3465
3466
3467 end
3468 end
3469
3470
3471
3472
3473
3474
3475 function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp)
3476 global patch_exe patch_new_exe
3477 namelog=[filename_nc([1:end-3]) '_patch.log'];
3478 if test_interp==0
3479 cmd_PATCH=[patch_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ...
3480 ' > ' namelog ' 2>&1']
3481 else
3482 cmd_PATCH=[patch_new_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ...
3483 ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1'];
3484 end
3485
3486
3487
3488
3489 function cmd=RUN_STINTERP(stinterp_exe,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB)
3490 namelog=[filename_nc([1:end-3]) '_stinterp.log'];
3491 cmd=[stinterp_exe ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ...
3492 ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB ' -xy x -Nfy 1024 > ' namelog ' 2>&1'];
3493
3494
3495 function first_j_Callback(hObject, eventdata, handles)
3496 last_j_Callback(hObject, eventdata, handles)
3497
3498
3499
3500 function CIV1_Callback(hObject, eventdata, handles)
3501 val=get(handles.CIV1,'Value');
3502 if isequal(val,1)
3503 enable_civ1(handles,'on')
3504 enable_pair1(handles,'on')
3505 else
3506 enable_civ1(handles,'off')
3507 end
3508 find_netcpair_civ1(hObject, eventdata, handles);
3509
3510
3511
3512 function FIX1_Callback(hObject, eventdata, handles)
3513
3514 enable_fix1(handles,get(handles.FIX1,'Value'))
3515
3516
3517
3518
3519 function PATCH1_Callback(hObject, eventdata, handles)
3520
3521 if get(handles.PATCH1,'Value')==1
3522 enable_patch1(handles)
3523 else
3524 desable_patch1(handles)
3525 end
3526
3527
3528
3529 function CIV2_Callback(hObject, eventdata, handles)
3530 state=get(handles.CIV2,'Value');
3531 enable_civ2(handles,state)
3532 if state
3533 find_netcpair_civ2(hObject, eventdata, handles)
3534 enable_pair1(handles,'on')
3535 end
3536
3537
3538
3539 function FIX2_Callback(hObject, eventdata, handles)
3540 if get(handles.FIX2,'Value')==1
3541 enable_fix2(handles)
3542 if get(handles.CIV2,'Value')==0
3543 find_netcpair_civ2(hObject, eventdata, handles)
3544 end
3545 else
3546 desable_fix2(handles)
3547 end
3548
3549
3550
3551
3552 function PATCH2_Callback(hObject, eventdata, handles)
3553
3554 if get(handles.PATCH2,'Value')==1
3555 enable_patch2(handles)
3556 if get(handles.CIV2,'Value')==0
3557 find_netcpair_civ2(hObject, eventdata, handles)
3558 end
3559 else
3560 desable_patch2(handles)
3561 end
3562
3563
3564
3565
3566 function first_i_Callback(hObject, eventdata, handles)
3567
3568 last_i_Callback(hObject, eventdata, handles)
3569
3570
3571
3572
3573 function calcul_search_Callback(hObject, eventdata, handles)
3574
3575
3576 list_pair=get(handles.list_pair_civ1,'String');
3577 index=get(handles.list_pair_civ1,'Value');
3578 displ_num=get(handles.list_pair_civ1,'UserData');
3579 time=get(handles.displ_filebase,'UserData');
3580 pxcm_xy=get(handles.calcul_search,'UserData');
3581 pxcmx=pxcm_xy(1);
3582 pxcmy=pxcm_xy(2);
3583 mode_list=get(handles.mode,'String');
3584 mode_value=get(handles.mode,'Value');
3585 mode=mode_list{mode_value};
3586 if isequal (mode, 'series(Di)' )
3587 ref_i=str2num(get(handles.ref_i,'String'));
3588 num1=ref_i-floor(index/2);
3589 num2=ref_i+ceil(index/2);
3590 num_a=1;
3591 num_b=1;
3592 elseif isequal (mode, 'series(Dj)')
3593 num1=1;
3594 num2=1;
3595 ref_j=str2num(get(handles.ref_j,'String'));
3596 num_a=ref_j-floor(index/2);
3597 num_b=ref_j+ceil(index/2);
3598 elseif isequal(mode,'pair j1-j2')
3599 ref_i=str2num(get(handles.ref_i,'String'));
3600 num1=ref_i;
3601 num2=ref_i;
3602 num_a=displ_num(1,index);
3603 num_b=displ_num(2,index);
3604 end
3605 dt=time(num2,num_b)-time(num1,num_a);
3606 ibx=str2num(get(handles.ibx,'String'));
3607 iby=str2num(get(handles.iby,'String'));
3608 umin=dt*pxcmx*str2num(get(handles.umin,'String'));
3609 umax=dt*pxcmx*str2num(get(handles.umax,'String'));
3610 vmin=dt*pxcmy*str2num(get(handles.vmin,'String'));
3611 vmax=dt*pxcmy*str2num(get(handles.vmax,'String'));
3612 shiftx=round((umin+umax)/2);
3613 shifty=round((vmin+vmax)/2);
3614 isx=(umax+2-shiftx)*2+ibx;
3615 isx=2*ceil(isx/2)+1;
3616 isy=(vmax+2-shifty)*2+iby;
3617 isy=2*ceil(isy/2)+1;
3618 set(handles.shiftx,'String',num2str(shiftx));
3619 set(handles.shifty,'String',num2str(shifty));
3620 set(handles.isx,'String',num2str(isx));
3621 set(handles.isy,'String',num2str(isy));
3622
3623
3624
3625
3626
3627 function subdir_civ1_Callback(hObject, eventdata, handles)
3628 subdir=get(handles.subdir_civ1,'String');
3629 set(handles.subdir_civ2,'String',subdir);
3630 if get(handles.CIV1,'Value')==0
3631 find_netcpair_civ1(hObject, eventdata, handles);
3632 end
3633
3634
3635
3636
3637 function subdir_civ2_Callback(hObject, eventdata, handles)
3638
3639 if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0
3640 find_netcpair_civ2(hObject, eventdata, handles);
3641 end
3642
3643
3644
3645
3646 function get_mask_civ1_Callback(hObject, eventdata, handles)
3647 maskval=get(handles.get_mask_civ1,'Value');
3648 if isequal(maskval,0)
3649 set(handles.mask_civ1,'String','')
3650 else
3651 mask_displ='no mask';
3652 filebase=get(handles.displ_filebase,'String');
3653 [ nbslice, flag_mask]=get_mask(filebase,handles);
3654 if isequal(flag_mask,1)
3655 mask_displ=[num2str(nbslice) 'mask'];
3656 elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')
3657 common_path=fileparts(filebase);
3658 filebase_a=fullfile(common_path,get(handles.displ_filebase2,'String'));
3659 [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
3660 if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
3661 mask_displ='no mask';
3662 end
3663 end
3664 if isequal(mask_displ,'no mask')
3665 set(handles.get_mask_civ1,'Value',0)
3666 set(handles.get_mask_fix1,'Value',0)
3667 set(handles.get_mask_civ2,'Value',0)
3668 set(handles.get_mask_fix2,'Value',0)
3669 else
3670 set(handles.get_mask_fix1,'Value',1)
3671 set(handles.get_mask_civ2,'Value',1)
3672 set(handles.get_mask_fix2,'Value',1)
3673 end
3674 set(handles.mask_civ1,'String',mask_displ)
3675 set(handles.mask_fix1,'String',mask_displ)
3676 set(handles.mask_civ2,'String',mask_displ)
3677 set(handles.mask_fix2,'String',mask_displ)
3678 end
3679
3680
3681 function get_mask_fix1_Callback(hObject, eventdata, handles)
3682 maskval=get(handles.get_mask_fix1,'Value');
3683 if isequal(maskval,0)
3684 set(handles.mask_fix1,'String','')
3685 else
3686 mask_displ='no mask';
3687 filebase=get(handles.displ_filebase,'String');
3688 [nbslice, flag_mask]=get_mask(filebase,handles);
3689 if isequal(flag_mask,1)
3690 mask_displ=[num2str(nbslice) 'mask'];
3691 elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')
3692 filebase_a=get(handles.displ_filebase2,'String');
3693 [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
3694 if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
3695 mask_displ='no mask';
3696 end
3697 end
3698 if isequal(mask_displ,'no mask')
3699 set(handles.get_mask_fix1,'Value',0)
3700 set(handles.get_mask_civ2,'Value',0)
3701 set(handles.get_mask_fix2,'Value',0)
3702 else
3703 set(handles.get_mask_civ2,'Value',1)
3704 set(handles.get_mask_fix2,'Value',1)
3705 end
3706 set(handles.mask_fix1,'String',mask_displ)
3707 set(handles.mask_civ2,'String',mask_displ)
3708 set(handles.mask_fix2,'String',mask_displ)
3709 end
3710
3711
3712 function get_mask_civ2_Callback(hObject, eventdata, handles)
3713 maskval=get(handles.get_mask_civ2,'Value');
3714 if isequal(maskval,0)
3715 set(handles.mask_civ2,'String','')
3716 else
3717 mask_displ='no mask';
3718 filebase=get(handles.displ_filebase,'String');
3719 [nbslice, flag_mask]=get_mask(filebase,handles);
3720 if isequal(flag_mask,1)
3721 mask_displ=[num2str(nbslice) 'mask'];
3722 elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')
3723 filebase_a=get(handles.displ_filebase2,'String');
3724 [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
3725 if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
3726 mask_displ='no mask';
3727 end
3728 end
3729 if isequal(mask_displ,'no mask')
3730 set(handles.get_mask_civ2,'Value',0)
3731 set(handles.get_mask_fix2,'Value',0)
3732 else
3733 set(handles.get_mask_fix2,'Value',1)
3734 end
3735 set(handles.mask_civ2,'String',mask_displ)
3736 set(handles.mask_fix2,'String',mask_displ)
3737 end
3738
3739
3740 function get_mask_fix2_Callback(hObject, eventdata, handles)
3741 maskval=get(handles.get_mask_fix2,'Value');
3742 if isequal(maskval,0)
3743 set(handles.mask_fix2,'String','')
3744 else
3745 mask_displ='no mask';
3746 filebase=get(handles.displ_filebase,'String');
3747 [nbslice, flag_mask]=get_mask(filebase,handles);
3748 if isequal(flag_mask,1)
3749 mask_displ=[num2str(nbslice) 'mask'];
3750 elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')
3751 filebase_a=get(handles.displ_filebase2,'String');
3752 [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
3753 if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
3754 mask_displ='no mask';
3755 end
3756 end
3757 if isequal(mask_displ,'no mask')
3758 set(handles.get_mask_fix2,'Value',0)
3759 end
3760 set(handles.mask_fix2,'String',mask_displ)
3761 end
3762
3763
3764 function [nbslice, flag_mask]=get_mask(filebase,handles)
3765
3766
3767
3768
3769 flag_mask=0;
3770 nbslice=1;
3771
3772
3773 [Path,Name]=fileparts(filebase);
3774 currentdir=pwd;
3775 cd(Path);
3776 maskfiles=dir([Name '_*mask_*.png']);
3777 cd(currentdir);
3778 if isempty(maskfiles)
3779 msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat')
3780 else
3781 flag_mask=1;
3782 maskname=maskfiles(1).name;
3783 [Path2,Name,ext]=fileparts(maskname);
3784 Namedouble=double(Name);
3785 val=(48>Namedouble)|(Namedouble>57);
3786 ind_mask=findstr('mask',Name);
3787 i=ind_mask-1;
3788 while val(i)==0 & i>0
3789 i=i-1;
3790 end
3791 nbslice=str2num(Name(i+1:ind_mask-1));
3792 if ~isequal(nbslice,[]) & Name(i)=='_'
3793 flag_mask=1;
3794 else
3795 msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2])
3796 return
3797 nbslice=1;
3798 end
3799 end
3800
3801
3802
3803 function grid_civ1_Callback(hObject, eventdata, handles)
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815 function str=num2stra(num,nom_type);
3816 if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD')
3817 str=char(96+num);
3818 elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')...
3819 |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none')
3820 str='';
3821 else
3822 str=num2str(num);
3823 end
3824
3825 function mask_civ1_Callback(hObject, eventdata, handles)
3826 set(handles.mask_civ1,'UserData',[])
3827 set(handles.mask_civ1,'String','')
3828
3829 function mask_civ2_Callback(hObject, eventdata, handles)
3830 set(handles.mask_civ2,'UserData',[])
3831 set(handles.mask_civ2,'String','')
3832
3833 function mask_fix1_Callback(hObject, eventdata, handles)
3834 set(handles.mask_fix1,'UserData',[])
3835 set(handles.mask_fix1,'String','')
3836
3837 function mask_fix2_Callback(hObject, eventdata, handles)
3838 set(handles.mask_fix2,'UserData',[])
3839 set(handles.mask_fix2,'String','')
3840
3841
3842
3843 function list_subdir_civ1_Callback(hObject, eventdata, handles)
3844 list_subdir_civ1=get(handles.list_subdir_civ1,'String');
3845 val=get(handles.list_subdir_civ1,'Value');
3846 if val>1
3847 subdir=list_subdir_civ1{val};
3848 set(handles.subdir_civ1,'String',subdir);
3849 set(handles.list_subdir_civ1,'Value',1);
3850 end
3851
3852
3853
3854
3855 function list_subdir_civ2_Callback(hObject, eventdata, handles)
3856 list_subdir_civ2=get(handles.list_subdir_civ2,'String');
3857 val=get(handles.list_subdir_civ2,'Value');
3858 if val>1
3859 subdir=list_subdir_civ2{val};
3860 set(handles.subdir_civ2,'String',subdir);
3861 set(handles.list_subdir_civ2,'Value',1);
3862 end
3863
3864
3865
3866 function last_i_Callback(hObject, eventdata, handles)
3867 first_i=str2num(get(handles.first_i,'String'));
3868 last_i=str2num(get(handles.last_i,'String'));
3869 ref_i=ceil((first_i+last_i)/2);
3870 set(handles.ref_i,'String', num2str(ref_i))
3871 ref_i_Callback(hObject, eventdata, handles)
3872
3873
3874 function last_j_Callback(hObject, eventdata, handles)
3875 first_j=str2num(get(handles.first_j,'String'));
3876 last_j=str2num(get(handles.last_j,'String'));
3877 ref_j=ceil((first_j+last_j)/2);
3878 set(handles.ref_j,'String', num2str(ref_j))
3879 ref_j_Callback(hObject, eventdata, handles)
3880
3881
3882
3883 function browse_gridciv1_Callback(hObject, eventdata, handles)
3884 value=get(handles.browse_gridciv1,'Value');
3885 if value
3886 filebase=get(handles.displ_filebase,'String');
3887 [FileName, PathName, filterindex] = uigetfile( ...
3888 {'*.grid', ' (*.grid)';
3889 '*.grid', '.grid files '; ...
3890 '*.*', 'All Files (*.*)'}, ...
3891 'Pick a file',filebase);
3892 filegrid=fullfile(PathName,FileName);
3893 if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file')
3894 set(handles.browse_gridciv1,'Value',0);
3895 set(handles.grid_civ1,'string','');
3896 set(handles.dx_civ1,'Visible','on');
3897 set(handles.dy_civ1,'Visible','on');
3898 set(handles.grid_civ2,'string','');
3899 if get(handles.CIV2,'Value')
3900 set(handles.dx_civ2,'Visible','on');
3901 set(handles.dy_civ2,'Visible','on');
3902 end
3903 else
3904 set(handles.grid_civ1,'string',filegrid);
3905 set(handles.dx_civ1,'Visible','off');
3906 set(handles.dy_civ1,'Visible','off');
3907 set(handles.grid_civ2,'string',filegrid);
3908 set(handles.dx_civ2,'Visible','off');
3909 set(handles.dy_civ2,'Visible','off');
3910
3911
3912 end
3913 else
3914 set(handles.grid_civ1,'string','');
3915 set(handles.dx_civ1,'Visible','on');
3916 set(handles.dy_civ1,'Visible','on');
3917 set(handles.grid_civ2,'string','');
3918 if get(handles.CIV2,'Value')
3919 set(handles.dx_civ2,'Visible','on');
3920 set(handles.dy_civ2,'Visible','on');
3921 end
3922 end
3923
3924
3925
3926 function browse_gridciv2_Callback(hObject, eventdata, handles)
3927
3928 filebase=get(handles.displ_filebase,'String');
3929 [FileName, PathName, filterindex] = uigetfile( ...
3930 {'*.grid', ' (*.grid)';
3931 '*.grid', '.grid files '; ...
3932 '*.*', 'All Files (*.*)'}, ...
3933 'Pick a file',filebase);
3934 filegrid=fullfile(PathName,FileName);
3935 set(handles.grid_civ2,'string',filegrid);
3936 set(handles.dx_civ2,'String',' ');
3937 set(handles.dy_civ2,'String',' ');
3938
3939
3940
3941 function get_gridpatch1_Callback(hObject, eventdata, handles)
3942
3943
3944
3945
3946 filebase=get(handles.displ_filebase,'String');
3947 [FileName, PathName, filterindex] = uigetfile( ...
3948 {'*.grid', ' (*.grid)';
3949 '*.grid', '.grid files '; ...
3950 '*.*', 'All Files (*.*)'}, ...
3951 'Pick a file',filebase);
3952 filegrid=fullfile(PathName,FileName);
3953 set(handles.grid_patch1,'string',filegrid);
3954
3955
3956
3957
3958 function get_gridpatch2_Callback(hObject, eventdata, handles)
3959
3960
3961
3962 function enable_civ1(handles,state)
3963 if isequal(state,0)
3964 state='off';
3965 end
3966 if isequal(state,1)
3967 state='on';
3968 end
3969 if isequal(state,'on')
3970 set(handles.frame_civ1,'BackgroundColor',[1 1 0])
3971 set(handles.frame_para_civ1,'BackgroundColor',[1 1 0])
3972 set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0])
3973 else
3974 set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784])
3975 set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784])
3976 set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784])
3977 end
3978 set(handles.ibx,'Visible',state)
3979 set(handles.iby,'Visible',state)
3980 set(handles.isx,'Visible',state)
3981 set(handles.isy,'Visible',state)
3982 set(handles.shiftx,'Visible',state)
3983 set(handles.shifty,'Visible',state)
3984 set(handles.rho,'Visible',state)
3985 set(handles.dx_civ1,'Visible',state)
3986 set(handles.dy_civ1,'Visible',state)
3987 set(handles.calcul_search,'Visible',state)
3988 set(handles.u_text,'Visible',state)
3989 set(handles.v_text,'Visible',state)
3990 set(handles.min,'Visible',state)
3991 set(handles.max,'Visible',state)
3992 set(handles.umin,'Visible',state)
3993 set(handles.umax,'Visible',state)
3994 set(handles.vmin,'Visible',state)
3995 set(handles.vmax,'Visible',state)
3996 set(handles.grid_civ1,'Visible',state)
3997 set(handles.mask_civ1,'Visible',state)
3998 set(handles.browse_gridciv1,'Visible',state)
3999 set(handles.get_mask_civ1,'Visible',state)
4000 set(handles.parameters,'Visible',state)
4001 set(handles.grid,'Visible',state)
4002 set(handles.dx_civ1,'Visible',state)
4003 set(handles.dy_civ1,'Visible',state)
4004 set(handles.ImaThreshold,'Visible',state)
4005 if isequal(state,'off')
4006 set(handles.MinIma,'Visible','off')
4007 set(handles.MaxIma,'Visible','off')
4008 set(handles.ImaThreshold,'Value',0)
4009 end
4010 set(handles.dx_civ1_title,'Visible',state)
4011 set(handles.dy_civ1_title,'Visible',state)
4012 set(handles.ImaThreshold_title,'Visible',state)
4013 set(handles.ib_title,'Visible',state)
4014 set(handles.is_title,'Visible',state)
4015 set(handles.shift_title,'Visible',state)
4016 set(handles.rho_title,'Visible',state)
4017
4018
4019 function enable_fix1(handles,state)
4020 if isequal(state,0)
4021 state='off';
4022 end
4023 if isequal(state,1)
4024 state='on';
4025 end
4026 if isequal(state,'on')
4027 set(handles.frame_fix1,'BackgroundColor',[1 1 0])
4028 else
4029 set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7])
4030 end
4031 set(handles.REMOVE,'Visible',state)
4032 set(handles.vec_Fmin2,'Visible',state)
4033 set(handles.vec_F2,'Visible',state)
4034 set(handles.vec_F3,'Visible',state)
4035 set(handles.thresh_vecC,'Visible',state)
4036 set(handles.thresh_vecC_title,'Visible',state)
4037 set(handles.thresh_vel,'Visible',state)
4038 set(handles.thresh_vel_text,'Visible',state)
4039 set(handles.mask_fix1,'Visible',state)
4040 set(handles.get_mask_fix1,'Visible',state)
4041 set(handles.get_ref_fix1,'Visible',state)
4042 set(handles.ref_fix1,'Visible',state)
4043 set(handles.inf_sup1,'Visible',state)
4044 set(handles.field_ref1,'Visible',state)
4045
4046
4047
4048 function enable_patch1(handles)
4049 global patch_new_exe
4050 set(handles.frame_patch1,'BackgroundColor',[1 1 0])
4051 set(handles.rho_patch1,'Visible','on')
4052 set(handles.rho_text1,'Visible','on')
4053 set(handles.thresh_patch1,'Visible','on')
4054 set(handles.thresh_text1,'Visible','on')
4055 set(handles.subdomain_patch1,'Visible','on')
4056 set(handles.subdomain_text1,'Visible','on')
4057 set(handles.nx_patch1,'Visible','on')
4058 set(handles.ny_patch1,'Visible','on')
4059 set(handles.nx_patch1_title,'Visible','on')
4060 set(handles.ny_patch1_title,'Visible','on')
4061 if (~isequal(patch_new_exe,[]) & ~isequal(patch_new_exe,[]))
4062 set(handles.test_interp,'Visible','on');
4063 end
4064 set(handles.get_gridpatch1,'Visible','on')
4065 set(handles.grid_patch1,'string','none');
4066 set(handles.grid_patch1,'Visible','on')
4067
4068
4069 function desable_patch1(handles)
4070 set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784])
4071 set(handles.rho_patch1,'Visible','off')
4072 set(handles.rho_text1,'Visible','off')
4073 set(handles.thresh_patch1,'Visible','off')
4074 set(handles.thresh_text1,'Visible','off')
4075 set(handles.subdomain_patch1,'Visible','off')
4076 set(handles.subdomain_text1,'Visible','off')
4077 set(handles.nx_patch1,'Visible','off')
4078 set(handles.ny_patch1,'Visible','off')
4079 set(handles.nx_patch1_title,'Visible','off')
4080 set(handles.ny_patch1_title,'Visible','off')
4081 set(handles.test_interp,'Visible','off')
4082 set(handles.get_gridpatch1,'Visible','off')
4083 set(handles.grid_patch1,'Visible','off')
4084
4085
4086 function enable_civ2(handles,state)
4087 if isequal(state,0)
4088 state='off';
4089 end
4090 if isequal(state,1)
4091 state='on';
4092 end
4093 if isequal(state,'on')
4094 set(handles.frame_civ2,'BackgroundColor',[1 1 0])
4095 set(handles.frame_para_civ2,'BackgroundColor',[1 1 0])
4096 set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0])
4097 set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
4098 else
4099 set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784])
4100 set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784])
4101 set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784])
4102 set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784])
4103 end
4104 set(handles.ibx_civ2,'Visible',state)
4105 set(handles.iby_civ2,'Visible',state)
4106 set(handles.decimal,'Visible',state)
4107 set(handles.deformation,'Visible',state)
4108 set(handles.rho_civ2,'Visible',state)
4109 set(handles.dx_civ2,'Visible',state)
4110 set(handles.dy_civ2,'Visible',state)
4111 set(handles.browse_gridciv2,'Visible',state)
4112 set(handles.get_mask_civ2,'Visible',state)
4113 set(handles.parameters,'Visible',state)
4114 set(handles.grid,'Visible',state)
4115 set(handles.parameters_text,'Visible',state)
4116 set(handles.grid_text,'Visible',state)
4117 set(handles.grid_civ2,'Visible',state)
4118 set(handles.mask_civ2,'Visible',state)
4119 set(handles.dx_civ2_title,'Visible',state)
4120 set(handles.dy_civ2_title,'Visible',state)
4121 set(handles.ibx_civ2_text,'Visible',state)
4122 set(handles.rho_civ2_title,'Visible',state)
4123 set(handles.ImaThreshold2,'Visible',state)
4124 set(handles.ImaThreshold_title2,'Visible',state)
4125 if isequal(state,'off')
4126 set(handles.MinIma2,'Visible','off')
4127 set(handles.MaxIma2,'Visible','off')
4128 set(handles.ImaThreshold2,'Value',0)
4129 if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0)
4130 set(handles.list_pair_civ2,'Visible','off')
4131 set(handles.subdir_civ2,'Visible','off')
4132 set(handles.subdir_civ2_text,'Visible','off')
4133 end
4134 else
4135 set(handles.list_pair_civ2,'Visible','on')
4136 set(handles.subdir_civ2,'Visible','on')
4137 set(handles.subdir_civ2_text,'Visible','on')
4138 end
4139
4140
4141
4142 function enable_fix2(handles)
4143 set(handles.frame_fix2,'BackgroundColor',[1 1 0])
4144 set(handles.REMOVE2,'Visible','on')
4145 set(handles.vec_Fmin2_2,'Visible','on')
4146 set(handles.vec_F4,'Visible','on')
4147 set(handles.vec_F3_2,'Visible','on')
4148 set(handles.thresh_vec2C,'Visible','on')
4149 set(handles.thresh_vec2C_text,'Visible','on')
4150 set(handles.thresh_vel2,'Visible','on')
4151 set(handles.thresh_vel2_text,'Visible','on')
4152 set(handles.mask_fix2,'Visible','on')
4153 set(handles.get_mask_fix2,'Visible','on')
4154 set(handles.list_pair_civ2,'Visible','on')
4155 set(handles.subdir_civ2,'Visible','on')
4156 set(handles.subdir_civ2_text,'Visible','on')
4157 set(handles.get_ref_fix2,'Visible','on')
4158 set(handles.ref_fix2,'Visible','on')
4159 set(handles.inf_sup2,'Visible','on')
4160 set(handles.field_ref2,'Visible','on')
4161
4162
4163 function desable_fix2(handles)
4164 set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784])
4165 set(handles.REMOVE2,'Visible','off')
4166 set(handles.vec_Fmin2_2,'Visible','off')
4167 set(handles.vec_F4,'Visible','off')
4168 set(handles.vec_F3_2,'Visible','off')
4169 set(handles.thresh_vec2C,'Visible','off')
4170 set(handles.thresh_vec2C_text,'Visible','off')
4171 set(handles.thresh_vel2,'Visible','off')
4172 set(handles.thresh_vel2_text,'Visible','off')
4173 set(handles.mask_fix2,'Visible','off')
4174 set(handles.get_mask_fix2,'Visible','off')
4175 set(handles.get_ref_fix2,'Visible','off')
4176 set(handles.ref_fix2,'Visible','off')
4177 set(handles.inf_sup2,'Visible','off')
4178 set(handles.field_ref2,'Visible','off')
4179 if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0)
4180 set(handles.list_pair_civ2,'Visible','off')
4181 set(handles.subdir_civ2,'Visible','off')
4182 set(handles.subdir_civ2_text,'Visible','off')
4183 end
4184
4185
4186 function enable_patch2(handles)
4187 set(handles.frame_patch2,'BackgroundColor',[1 1 0])
4188
4189 set(handles.rho_text2,'Visible','on')
4190 set(handles.thresh_patch2,'Visible','on')
4191 set(handles.thresh_text2,'Visible','on')
4192 set(handles.subdomain_patch2,'Visible','on')
4193 set(handles.subdomain_text2,'Visible','on')
4194 set(handles.nx_patch2,'Visible','on')
4195 set(handles.ny_patch2,'Visible','on')
4196 set(handles.nx_patch2_title,'Visible','on')
4197 set(handles.ny_patch2_title,'Visible','on')
4198 set(handles.get_gridpatch2,'Visible','on')
4199 set(handles.grid_patch2,'Visible','on')
4200 set(handles.list_pair_civ2,'Visible','on')
4201 set(handles.subdir_civ2,'Visible','on')
4202 set(handles.subdir_civ2_text,'Visible','on')
4203
4204
4205 function desable_patch2(handles)
4206 set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784])
4207 set(handles.rho_patch2,'Visible','off')
4208 set(handles.rho_text2,'Visible','off')
4209 set(handles.thresh_patch2,'Visible','off')
4210 set(handles.thresh_text2,'Visible','off')
4211 set(handles.subdomain_patch2,'Visible','off')
4212 set(handles.subdomain_text2,'Visible','off')
4213 set(handles.nx_patch2,'Visible','off')
4214 set(handles.ny_patch2,'Visible','off')
4215 set(handles.nx_patch2_title,'Visible','off')
4216 set(handles.ny_patch2_title,'Visible','off')
4217 set(handles.get_gridpatch2,'Visible','off')
4218 set(handles.grid_patch2,'Visible','off')
4219 if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0)
4220 set(handles.list_pair_civ2,'Visible','off')
4221 set(handles.subdir_civ2,'Visible','off')
4222 set(handles.subdir_civ2_text,'Visible','off')
4223 end
4224
4225
4226 function enable_pair1(handles,state)
4227 set(handles.subdir_civ1,'Visible',state)
4228 set(handles.list_subdir_civ1,'Visible',state)
4229 set(handles.SUBDIR_CIV1_txt,'Visible',state)
4230 set(handles.frame_subdirciv1,'Visible',state)
4231 set(handles.list_pair_civ1,'Visible',state)
4232 set(handles.PAIR_txt,'Visible',state)
4233 set(handles.dt_display_txt,'Visible',state)
4234 set(handles.dt_unit,'Visible',state)
4235 set(handles.PAIR_frame,'Visible',state)
4236
4237
4238 function test_interp_Callback(hObject, eventdata, handles)
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253 function par=read_param_civ1(handles,file_ima)
4254
4255 ibx_val=str2num(get(handles.ibx,'String'));
4256 par.ibx=num2str(ibx_val);
4257 iby_val=str2num(get(handles.iby,'String'));
4258 par.iby=num2str(iby_val);
4259 isx=get(handles.isx,'String');
4260 if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end;
4261 if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end
4262 isy=get(handles.isy,'String');
4263 if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;
4264 if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end
4265 par.isx=get(handles.isx,'String');
4266 par.isy=get(handles.isy,'String');
4267 par.shiftx=get(handles.shiftx,'String');
4268 par.shifty=get(handles.shifty,'String');
4269 if isempty(str2num(par.isx))
4270 par.isx='41';
4271 set(handles.isx,'String','41');
4272 end
4273 if isempty(str2num(par.isy))
4274 par.isy='41';
4275 set(handles.isy,'String','41');
4276 end;
4277 if isempty(str2num(par.shiftx))
4278 par.shiftx='0';
4279 set(handles.shiftx,'String','0');
4280 end;
4281 if isempty(str2num(par.shifty))
4282 par.shifty='0';
4283 set(handles.shifty,'String','0');
4284 end;
4285 par.rho=get(handles.rho,'String');
4286 par.dx=get(handles.dx_civ1,'String');
4287 par.dy=get(handles.dy_civ1,'String');
4288 if isequal(str2num(par.dx),[])
4289 if isempty(get(handles.grid_civ1,'String'));
4290 par.dx='0';
4291 else
4292 par.dx='20';
4293 set(handles.dx_civ1,'String','20');
4294 end
4295 end
4296 if isequal(str2num(par.dy),[])
4297 if isempty(get(handles.grid_civ1,'String'));
4298 par.dy='0';
4299 else
4300 par.dy='20';
4301 set(handles.dy_civ1_title,'String','20');
4302 end
4303 end
4304 par.pxcmx='1';
4305 par.pxcmy='1';
4306
4307 A=imread(file_ima);
4308 sizim=size(A);
4309 par.npx=num2str(sizim(2));
4310 par.npy=num2str(sizim(1));
4311 time=get(handles.displ_filebase,'UserData');
4312 par.gridname=get(handles.grid_civ1,'String');
4313 par.gridflag='y';
4314 if isequal(par.gridname,'')| isempty(par.gridname)
4315 par.gridname='nogrid';
4316 par.gridflag='n';
4317 end
4318
4319
4320 function par=read_param_civ2(handles,file_ima)
4321 par.ibx=get(handles.ibx_civ2,'String');
4322 par.iby=get(handles.iby_civ2,'String');
4323 par.rho=get(handles.rho_civ2,'String');
4324 par.decimal=int2str(get(handles.decimal,'Value'));
4325 par.deformation=int2str(get(handles.deformation,'Value'));
4326 par.dx=get(handles.dx_civ2,'String');
4327 par.dy=get(handles.dy_civ2,'String');
4328 if isequal(str2num(par.dx),[])
4329 if isempty(get(handles.grid_civ2,'String'));
4330 par.dx='0';
4331 else
4332 par.dx='20';
4333 set(handles.dx_civ2,'String','20');
4334 end
4335 end
4336 if isequal(str2num(par.dy),[])
4337 if isempty(get(handles.grid_civ2,'String'));
4338 par.dy='0';
4339 else
4340 par.dy='20';
4341 set(handles.dy_civ2,'String','20');
4342 end
4343 end
4344 par.pxcmx='1';
4345 par.pxcmy='1';
4346 A=imread(file_ima);
4347 sizim=size(A);
4348 par.npx=num2str(sizim(2));
4349 par.npy=num2str(sizim(1));
4350 time=get(handles.displ_filebase,'UserData');
4351 par.gridname=get(handles.grid_civ2,'String');
4352 par.gridflag='y';
4353 if isequal(par.gridname,'')| isempty(par.gridname)
4354 par.gridname='nogrid';
4355 par.gridflag='n';
4356 end
4357
4358
4359
4360
4361
4362 function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles)
4363
4364 global civ1_exe Civ_exe sge
4365
4366
4367
4368 if isequal(par.Dt,'0')
4369 par.Dt='1' ;
4370 end
4371
4372 textcmx={'############## CMX file';...
4373 ['FirstImage ' par.filename_ima_a];...
4374 ['LastImage ' par.filename_ima_b];...
4375 'XX' ;...
4376 ['Mask ' par.maskflag] ;...
4377 ['MaskName ' par.maskname];...
4378 ['ImageSize ' par.npx ' ' par.npy];...
4379 ['CorrelationBoxesSize ' par.ibx ' ' par.iby];...
4380 ['SearchBoxeSize ' par.isx ' ' par.isy];...
4381 ['RO ' par.rho];...
4382 ['GridSpacing ' par.dx ' ' par.dy];...
4383 'XX 1.0';...
4384 ['Dt_TO ' par.Dt ' ' par.T0];...
4385 ['PixCmXY ' par.pxcmx ' ' par.pxcmy];...
4386 'XX 1';...
4387 ['ShiftXY ' par.shiftx ' ' par.shifty];...
4388 ['Grid ' par.gridflag];...
4389 ['GridName ' par.gridname] ;...
4390 'XX 85';...
4391 'XX 1.0';...
4392 'XX 1.0';...
4393 'Hart 1';...
4394 'DecimalShift 0';...
4395 'Deformation 0';...
4396 'CorrelationMin 0';...
4397 'IntensityMin 0';...
4398 'SeuilImage n';...
4399 'SeuilImageValues 0 4096';...
4400 ['ImageToUse ' par.term_a ' ' par.term_b];...
4401 'ImageUsedBefore null null'};
4402
4403 textout=char(textcmx);
4404
4405 dlmwrite([filename '.cmx'],textout,'');
4406
4407
4408 if sge
4409 cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ];
4410 else
4411 cmd_CIV1=[civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1'];
4412 end
4413 if(isunix)
4414 [Rootbat,Filebat,extbat]=fileparts(namelog);
4415 ncName=fullfile(Rootbat,[ Filebat '.nc']);
4416 cmd_CIV1=char({cmd_CIV1 ; ['mv ' namelog ' ' namelog '.civ1.log'];['chmod g+w ' ncName]});
4417 else
4418 cmd_CIV1=char({cmd_CIV1 ; ['copy /Y ' namelog ' ' namelog '.civ1.log']});
4419 end
4420
4421
4422
4423
4424 function xml_civ1_parameters=BATCH_CIV1_Unified(filename,namelog,par,handles)
4425
4426 global civ1_exe Civ_exe
4427
4428 civ1.image1=par.filename_ima_a;
4429 civ1.image2=par.filename_ima_b;
4430 civ1.imageSize_X=par.npx;
4431 civ1.imageSize_Y=par.npy;
4432 civ1.outputFileName=[filename '.nc'];
4433 civ1.correlationBoxesSize_X=par.ibx;
4434 civ1.correlationBoxesSize_Y=par.iby;
4435 civ1.searchBoxesSize_X=par.isx;
4436 civ1.searchBoxesSize_Y=par.isy;
4437 civ1.globalShift_X=par.shiftx;
4438 civ1.globalShift_Y=par.shifty;
4439 civ1.ro=par.rho;
4440 civ1.hart='y';
4441 if isequal(par.gridflag,'y')
4442 civ1.grid=par.gridname;
4443 end
4444 civ1.gridSpacing_X=par.dx;
4445 civ1.gridSpacing_Y=par.dy;
4446 if isequal(par.maskflag,'y')
4447 civ1.mask=par.maskname;
4448 end
4449 civ1.dt=par.Dt;
4450 civ1.unit='pixel';
4451 civ1.absolut_time_T0=par.T0;
4452 civ1.pixcmx=par.pxcmx;
4453 civ1.pixcmy=par.pxcmy;
4454 civ1.convectFlow='n';
4455
4456 xml_civ1_parameters=civ1;
4457
4458
4459
4460
4461 function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par)
4462
4463 global civ2_exe sge
4464 if isequal(par.Dt,'0')
4465 par.Dt='1' ;
4466 end
4467 textcmx={'############## CMX file';...
4468 ['FirstImage ' par.filename_ima_a];...
4469 ['LastImage ' par.filename_ima_b];...
4470 'XX' ;...
4471 ['Mask ' par.maskflag];...
4472 ['MaskName ' par.maskname];...
4473 ['ImageSize ' par.npx ' ' par.npy];...
4474 ['CorrelationBoxesSize ' par.ibx ' ' par.iby];...
4475 ['SearchBoxeSize ' par.ibx ' ' par.iby];...
4476 ['RO ' par.rho];...
4477 ['GridSpacing ' par.dx ' ' par.dy];...
4478 'XX 1.0';...
4479 ['Dt_TO ' par.Dt ' ' par.T0];...
4480 ['PixCmXY ' par.pxcmx ' ' par.pxcmy];...
4481 'XX 1';...
4482 ['ShiftXY 0 0'];...
4483 ['Grid ' par.gridflag];...
4484 ['GridName ' par.gridname];...
4485 'XX 85';...
4486 'XX 1.0';...
4487 'XX 1.0';...
4488 'Hart 1';...
4489 ['DecimalShift ' par.decimal];...
4490 ['Deformation ' par.deformation];...
4491 'CorrelationMin 0';...
4492 'IntensityMin 0';...
4493 'SeuilImage n';...
4494 'SeuilImageValues 0 4096';...
4495 ['ImageToUse ' par.term_a ' ' par.term_b];...
4496 ['ImageUsedBefore ' par.filename_nc1]};
4497 textout=char(textcmx);
4498 dlmwrite([filename_cmx '2'] ,textout,'');
4499 if sge
4500 cmd_CIV2=[civ2_exe ' -f ' filename_cmx ];
4501 else
4502 cmd_CIV2=[civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1'];
4503 end
4504
4505
4506
4507 function HELP_Callback(hObject, eventdata, handles)
4508 path_to_uvmat=which ('uvmat');
4509 pathelp=fileparts(path_to_uvmat);
4510 helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
4511 if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
4512 else
4513 web([helpfile '#civ'])
4514 end
4515
4516
4517
4518
4519 function A=read_image(filename,nom_type,npx,npy,num);
4520
4521
4522 if isequal(nom_type,'avi')
4523 mov=aviread(filename,num);
4524 A=frame2im(mov(1));
4525 A=sum(double(A),3);
4526 A=uint16(A);
4527 elseif isequal(nom_type,'raw_SMD')
4528 [fid,message]=fopen(filename,'r');
4529 B=fread(fid,Inf,'int16',0,'ieee-le');
4530 A=(reshape(B,npx,npy))';
4531 A=uint16(A);
4532 fclose(fid);
4533 else
4534 A=imread(filename);
4535 siz=size(A);
4536 if length(siz)==3;
4537 A=sum(double(A),3);
4538 end
4539 A=uint16(A);
4540 end
4541
4542
4543
4544
4545 function dt_Callback(hObject, eventdata, handles)
4546
4547
4548 dt=(1/1000)*str2num(get(handles.dt,'String'));
4549 nbfield=str2num(get(handles.nb_field,'String'));
4550 time=(dt*[0:nbfield-1])';
4551
4552 set(handles.displ_filebase,'UserData',time);
4553 for index=1:min(nbfield-1,200)
4554 displ_num(1,index)=1;
4555 displ_num(2,index)=1;
4556 displ_num(3,index)=-floor(index/2);
4557 displ_num(4,index)=ceil(index/2);
4558 end
4559 set(handles.list_pair_civ1,'Value',1);
4560 set(handles.list_pair_civ1,'UserData',displ_num);
4561 set(handles.list_pair_civ2,'Value',1);
4562
4563 find_netcpair_civ1(hObject, eventdata, handles)
4564 find_netcpair_civ2(hObject, eventdata, handles)
4565
4566
4567 function ref_i_Callback(hObject, eventdata, handles)
4568 mode_list=get(handles.mode,'String');
4569 mode_value=get(handles.mode,'Value');
4570 mode=mode_list{mode_value};
4571 if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Di)')
4572 find_netcpair_civ1(hObject, eventdata, handles);
4573 end
4574 if isequal(mode,'series(Di)') | ...
4575 (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0)
4576 find_netcpair_civ2(hObject, eventdata, handles);
4577 end
4578
4579
4580 function ref_j_Callback(hObject, eventdata, handles)
4581 mode_list=get(handles.mode,'String');
4582 mode_value=get(handles.mode,'Value');
4583 mode=mode_list{mode_value};
4584 if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Dj)')
4585 find_netcpair_civ1(hObject, eventdata, handles);
4586 end
4587 if isequal(mode,'series(Dj)') | ...
4588 (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0)
4589 find_netcpair_civ2(hObject, eventdata, handles);
4590 end
4591
4592
4593 function compare_Callback(hObject, eventdata, handles)
4594 test=get(handles.compare,'Value');
4595 if test==2 || test==3
4596 filebase=get(handles.displ_filebase,'String');
4597 browse=get(handles.browse_root,'Userdata');
4598 browse.nom_type_ima1=browse.nom_type_ima;
4599 set(handles.browse_root,'UserData',browse);
4600 set(handles.sub_txt,'Visible','on')
4601 set(handles.displ_filebase2,'Visible','On');
4602 mode_store=get(handles.mode,'String');
4603 set(handles.compare,'UserData',mode_store);
4604 set(handles.mode,'Visible','off')
4605 if test==2
4606 set(handles.mode,'Visible','off')
4607 else
4608 set(handles.mode,'Visible','on')
4609 end
4610
4611
4612 ind_opening=1;
4613 browse.incr_pair=[0 0];
4614 oldfile=get(handles.displ_filebase,'String');
4615 menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
4616 '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';...
4617 '*.*', 'All Files (*.*)'};
4618 [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile);
4619 fileinput=[PathName FileName];
4620 sizf=size(fileinput);
4621 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
4622 [path,name,ext]=fileparts(fileinput);
4623 [path1]=fileparts(filebase);
4624 if ~strcmp(path1,path)
4625 msgbox_uvmat('ERROR','The two input image series must be in the same directory')
4626 return
4627 end
4628 set(handles.displ_filebase2,'String',name);
4629 [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name);
4630 browse=get(handles.browse_root,'UserData');
4631 browse.nom_type_ima_1=nom_type;
4632 set(handles.browse_root,'UserData',browse)
4633
4634
4635 if ~strcmp(ext,get(handles.ext_ima,'String'))
4636 msgbox_uvmat('ERROR','The two input image series must have the same extenion name')
4637 return
4638 end
4639
4640
4641 A=imread(fileinput);
4642 npxy=get(handles.ext_ima,'UserData');
4643 if ~isequal(npxy(1),size(A,1))|| ~isequal(npxy(2),size(A,2))
4644 msgbox_uvmat('ERROR','The two input image series must have the same size')
4645 return
4646 end
4647 else
4648 set(handles.mode,'Visible','on')
4649 set(handles.displ_filebase2,'Visible','Off');
4650 set(handles.sub_txt,'Visible','off')
4651 set(handles.displ_filebase2,'String',[]);
4652 mode_store=get(handles.compare,'UserData');
4653 set(handles.mode,'String',mode_store)
4654 set(handles.test_stereo1,'Value',0)
4655 set(handles.test_stereo2,'Value',0)
4656 end
4657 mode_Callback(hObject, eventdata, handles)
4658
4659
4660
4661 function get_ref_fix1_Callback(hObject, eventdata, handles)
4662 filebase=get(handles.displ_filebase,'String');
4663 [FileName, PathName, filterindex] = uigetfile( ...
4664 {'*.nc', ' (*.nc)';
4665 '*.nc', 'netcdf files '; ...
4666 '*.*', 'All Files (*.*)'}, ...
4667 'Pick a file',filebase);
4668
4669 fileinput=[PathName FileName];
4670 sizf=size(fileinput);
4671 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
4672
4673 [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
4674
4675
4676
4677 ref.filebase=fullfile(Path,File);
4678 ref.num_a=stra2num(str_a);
4679 ref.num_b=stra2num(str_b);
4680 ref.num1=str2num(field_count);
4681 ref.num2=str2num(str2);
4682 browse=[];
4683 if ~isequal(ref.ext,'.nc')
4684 errordlg('the reference file must be in netcdf format (*.nc)')
4685 return
4686 end
4687
4688 set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']);
4689 set(handles.ref_fix1,'UserData',ref)
4690 menu_field{1}='civ1';
4691 Data=nc2struct(fileinput,[]);
4692 if isfield(Data,'patch') & isequal(Data.patch,1)
4693 menu_field{2}='filter1';
4694 end
4695 if isfield(Data,'civ2') & isequal(Data.civ2,1)
4696 menu_field{3}='civ2';
4697 end
4698 if isfield(Data,'patch2') & isequal(Data.patch2,1)
4699 menu_field{4}='filter2';
4700 end
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711 set(handles.field_ref1,'String',menu_field);
4712 set(handles.field_ref1,'Value',length(menu_field));
4713 set(handles.inf_sup1,'Value',2);
4714 set(handles.thresh_vel,'String','1');
4715 set(handles.ref_fix1,'Enable','on')
4716
4717
4718
4719 function get_ref_fix2_Callback(hObject, eventdata, handles)
4720 if isequal(get(handles.get_ref_fix2,'Value'),1)
4721 filebase=get(handles.displ_filebase,'String');
4722 [FileName, PathName, filterindex] = uigetfile( ...
4723 {'*.nc', ' (*.nc)';
4724 '*.nc', 'netcdf files '; ...
4725 '*.*', 'All Files (*.*)'}, ...
4726 'Pick a file',filebase);
4727 fileinput=[PathName FileName];
4728 sizf=size(fileinput);
4729 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
4730
4731 [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
4732
4733
4734 ref.filebase=fullfile(Path,File);
4735 ref.num_a=stra2num(str_a);
4736 ref.num_b=stra2num(str_b);
4737 ref.num1=str2num(field_count);
4738 ref.num2=str2num(str2);
4739 browse=[];
4740 if ~isequal(ref.ext,'.nc')
4741 errordlg('the reference file must be in netcdf format (*.nc)')
4742 return
4743 end
4744
4745 set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']);
4746 set(handles.ref_fix2,'UserData',ref)
4747 menu_field{1}='civ1';
4748
4749 Data=nc2struct(fileinput,[]);
4750 if isfield(Data,'patch') & isequal(Data.patch,1)
4751 menu_field{2}='filter1';
4752 end
4753 if isfield(Data,'civ2') & isequal(Data.civ2,1)
4754 menu_field{3}='civ2';
4755 end
4756 if isfield(Data,'patch2') & isequal(Data.patch2,1)
4757 menu_field{4}='filter2';
4758 end
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769 set(handles.field_ref2,'String',menu_field);
4770 set(handles.field_ref2,'Value',length(menu_field));
4771 set(handles.inf_sup2,'Value',2);
4772 set(handles.thresh_vel2,'String','1');
4773 set(handles.ref_fix2,'Enable','on')
4774 set(handles.ref_fix2,'Visible','on')
4775 set(handles.field_ref2,'Visible','on')
4776 else
4777 set(handles.ref_fix2,'Visible','off')
4778 set(handles.field_ref2,'Visible','off')
4779 end
4780
4781
4782 function ref_fix1_Callback(hObject, eventdata, handles)
4783 set(handles.inf_sup1,'Value',1);
4784 set(handles.field_ref1,'Value',1)
4785 set(handles.field_ref1,'String',{' '})
4786 set(handles.ref_fix1,'UserData',[]);
4787 set(handles.ref_fix1,'String','');
4788 set(handles.thresh_vel1,'String','0');
4789
4790
4791
4792
4793 function ref_fix2_Callback(hObject, eventdata, handles)
4794 set(handles.inf_sup2,'Value',1);
4795 set(handles.field_ref2,'Value',1)
4796 set(handles.field_ref2,'String',{' '})
4797 set(handles.ref_fix2,'UserData',[]);
4798 set(handles.ref_fix2,'String','');
4799 set(handles.thresh_vel2,'String','0');
4800
4801
4802
4803 function inf_sup1_Callback(hObject, eventdata, handles)
4804
4805
4806
4807
4808
4809 function field_ref_Callback(hObject, eventdata, handles)
4810
4811
4812
4813
4814 function field_ref2_Callback(hObject, eventdata, handles)
4815
4816
4817
4818
4819 function numres=stra2num(str)
4820 numres=double(str)-96;
4821 if double(str) >= 48 & double(str) <= 57
4822 numres=str2num(str);
4823 end
4824
4825
4826
4827 function test_stereo1_Callback(hObject, eventdata, handles)
4828 if isequal(get(handles.test_stereo1,'Value'),0)
4829 set(handles.subdomain_patch1,'Visible','on')
4830 set(handles.rho_patch1,'Visible','on')
4831 else
4832 set(handles.subdomain_patch1,'Visible','off')
4833 set(handles.rho_patch1,'Visible','off')
4834 end
4835
4836
4837 function test_stereo2_Callback(hObject, eventdata, handles)
4838 if isequal(get(handles.test_stereo2,'Value'),0)
4839 set(handles.subdomain_patch2,'Visible','on')
4840 set(handles.rho_patch2,'Visible','on')
4841 else
4842 set(handles.subdomain_patch2,'Visible','off')
4843 set(handles.rho_patch2,'Visible','off')
4844 end
4845
4846
4847 function ImaThreshold_Callback(hObject, eventdata, handles)
4848 if isequal(get(handles.ImaThreshold,'Value'),1)
4849 set(handles.MinIma,'Visible','on')
4850 set(handles.MaxIma,'Visible','on')
4851 else
4852 set(handles.MinIma,'Visible','off')
4853 set(handles.MaxIma,'Visible','off')
4854 end
4855
4856
4857
4858 function ImaThreshold2_Callback(hObject, eventdata, handles)
4859 if isequal(get(handles.ImaThreshold2,'Value'),1)
4860 set(handles.MinIma2,'Visible','on')
4861 set(handles.MaxIma2,'Visible','on')
4862 else
4863 set(handles.MinIma2,'Visible','off')
4864 set(handles.MaxIma2,'Visible','off')
4865 end
4866
4867
4868
4869 function Experimental_Callback(hObject, eventdata, handles)
4870
4871
4872
4873 function ext_ima_1_Callback(hObject, eventdata, handles)
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883 function ext_ima_1_CreateFcn(hObject, eventdata, handles)
4884
4885
4886
4887
4888
4889
4890 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
4891 set(hObject,'BackgroundColor','white');
4892 end
4893
4894
4895
4896 function ext_ima_Callback(hObject, eventdata, handles)
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906 function ext_ima_CreateFcn(hObject, eventdata, handles)
4907
4908
4909
4910
4911
4912
4913 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
4914 set(hObject,'BackgroundColor','white');
4915 end
4916
4917