[112] | 1 | %'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch) |
---|
[2] | 2 | %------------------------------------------------------------------------ |
---|
[309] | 3 | % provides an interface for the software menucivx |
---|
[2] | 4 | % function varargout = civ(varargin) |
---|
[309] | 5 | % provides an interface for the software menucivx |
---|
[809] | 6 | |
---|
| 7 | %======================================================================= |
---|
| 8 | % Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France |
---|
| 9 | % http://www.legi.grenoble-inp.fr |
---|
| 10 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
[2] | 11 | % |
---|
[112] | 12 | % This file is part of the toolbox UVMAT. |
---|
| 13 | % |
---|
[2] | 14 | % UVMAT is free software; you can redistribute it and/or modify |
---|
[809] | 15 | % it under the terms of the GNU General Public License as published |
---|
| 16 | % by the Free Software Foundation; either version 2 of the license, |
---|
| 17 | % or (at your option) any later version. |
---|
[112] | 18 | % |
---|
[2] | 19 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[809] | 22 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
| 23 | %======================================================================= |
---|
| 24 | |
---|
[2] | 25 | function varargout = civ(varargin) |
---|
[273] | 26 | %TODO: search range |
---|
[2] | 27 | |
---|
[581] | 28 | % Last Modified by GUIDE v2.5 09-Mar-2013 22:50:23 |
---|
[2] | 29 | % Begin initialization code - DO NOT EDIT |
---|
| 30 | gui_Singleton = 1; |
---|
| 31 | gui_State = struct('gui_Name', mfilename, ... |
---|
[112] | 32 | 'gui_Singleton', gui_Singleton, ... |
---|
| 33 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
---|
| 34 | 'gui_OutputFcn', @civ_OutputFcn, ... |
---|
| 35 | 'gui_LayoutFcn', [] , ... |
---|
| 36 | 'gui_Callback', []); |
---|
[382] | 37 | if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback$','once')) |
---|
[2] | 38 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 39 | end |
---|
| 40 | |
---|
| 41 | if nargout |
---|
| 42 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 43 | else |
---|
| 44 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 45 | end |
---|
| 46 | % End initialization code - DO NOT EDIT |
---|
| 47 | |
---|
[12] | 48 | %------------------------------------------------------------------------ |
---|
[2] | 49 | % --- Executes just before civ is made visible. |
---|
[298] | 50 | function civ_OpeningFcn(hObject, eventdata, handles, fileinput) |
---|
[12] | 51 | %------------------------------------------------------------------------ |
---|
[2] | 52 | % This function has no output args, see OutputFcn. |
---|
[298] | 53 | |
---|
| 54 | %% General settings |
---|
[2] | 55 | handles.output = hObject; |
---|
[298] | 56 | guidata(hObject, handles); % Update handles structure |
---|
[309] | 57 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[252] | 58 | |
---|
[298] | 59 | %% Adjust the GUI according to the binaries available in PARAM.xml |
---|
[276] | 60 | path_civ=fileparts(which('civ')); %path to civ |
---|
[298] | 61 | addpath (path_civ) ; %add the path to civ, (useful in case of change of working directory after civ has been s opened in the working directory) |
---|
[273] | 62 | errormsg=[];%default error message |
---|
[500] | 63 | xmlfile=fullfile(path_civ,'PARAM.xml'); |
---|
[483] | 64 | test_batch=0;%default: ,no batch mode available |
---|
| 65 | sparam=[]; |
---|
[500] | 66 | if ~exist(xmlfile,'file') |
---|
[505] | 67 | [success,message]=copyfile(fullfile(path_civ,'PARAM.xml.default'),xmlfile); |
---|
[500] | 68 | end |
---|
[273] | 69 | if exist(xmlfile,'file') |
---|
| 70 | try |
---|
| 71 | t=xmltree(xmlfile); |
---|
| 72 | sparam=convert(t); |
---|
[435] | 73 | catch ME |
---|
| 74 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message}; |
---|
[483] | 75 | msgbox_uvmat('WARNING',errormsg); |
---|
[273] | 76 | end |
---|
| 77 | else |
---|
[483] | 78 | [s,w]=system('oarstat'); |
---|
| 79 | if ~isequal(s,0) |
---|
| 80 | [s,w]=system('qstat'); |
---|
| 81 | end |
---|
| 82 | if isequal(s,0) |
---|
| 83 | test_batch=1; |
---|
| 84 | end |
---|
[273] | 85 | end |
---|
| 86 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
[591] | 87 | batch_mode=sparam.BatchParam.BatchMode; |
---|
[484] | 88 | test_command=''; |
---|
[482] | 89 | switch batch_mode |
---|
| 90 | case 'sge' |
---|
| 91 | test_command='qstat'; |
---|
| 92 | case 'oar' |
---|
| 93 | test_command='oarstat'; |
---|
| 94 | end |
---|
[484] | 95 | if ~isempty(test_command) |
---|
[500] | 96 | [s,w]=system(test_command); |
---|
| 97 | if isequal(s,0) |
---|
| 98 | test_batch=1; |
---|
| 99 | end |
---|
[482] | 100 | end |
---|
[273] | 101 | end |
---|
[467] | 102 | RUNVal=get(handles.RunMode,'Value'); |
---|
[273] | 103 | if test_batch==0 |
---|
[467] | 104 | if RUNVal>2 |
---|
| 105 | set(handles.RunMode,'Value',1) |
---|
| 106 | end |
---|
| 107 | set(handles.RunMode,'String',{'local';'background'}) |
---|
| 108 | else |
---|
| 109 | set(handles.RunMode,'String',{'local';'background';'cluster'}) |
---|
[273] | 110 | end |
---|
| 111 | |
---|
[298] | 112 | %% load the list of previously browsed files in the upper bar menu Open/ |
---|
[296] | 113 | dir_perso=prefdir; % path to the directory .matlab for personal data |
---|
| 114 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab |
---|
| 115 | if exist(profil_perso,'file') |
---|
| 116 | h=load (profil_perso); |
---|
| 117 | if isfield(h,'MenuFile') |
---|
| 118 | for ifile=1:min(length(h.MenuFile),5) |
---|
| 119 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
| 120 | end |
---|
| 121 | end |
---|
[273] | 122 | end |
---|
| 123 | |
---|
[298] | 124 | %% prepare the GUI with parameters from the input file if opened from uvmat |
---|
| 125 | if exist('fileinput','var')% && isfield(param,'RootName') && ~isempty(param.RootName) |
---|
[371] | 126 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[298] | 127 | errormsg=display_file_name(handles,fileinput); |
---|
| 128 | if ~isempty(errormsg) |
---|
| 129 | msgbox_uvmat('ERROR',errormsg) |
---|
[112] | 130 | end |
---|
[371] | 131 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[2] | 132 | end |
---|
[506] | 133 | Program_Callback([],[], handles) |
---|
[2] | 134 | |
---|
[12] | 135 | %------------------------------------------------------------------------ |
---|
[2] | 136 | % --- Outputs from this function are returned to the command line. |
---|
| 137 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 138 | %------------------------------------------------------------------------ |
---|
[2] | 139 | % Get default command line output from handles structure |
---|
| 140 | varargout{1} = handles.output; |
---|
| 141 | |
---|
[307] | 142 | %------------------------------------------------------------------------ |
---|
[309] | 143 | % --- Function activated by the Open/Browse... option in the upper menu bar. |
---|
[307] | 144 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
| 145 | %------------------------------------------------------------------------ |
---|
[343] | 146 | %% get the current input root file name to initiate the browser |
---|
[371] | 147 | filebase=get(handles.RootPath,'String'); |
---|
[307] | 148 | oldfile=''; %default |
---|
[309] | 149 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored root file name |
---|
[307] | 150 | dir_perso=prefdir; |
---|
| 151 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 152 | if exist(profil_perso,'file') |
---|
| 153 | h=load (profil_perso); |
---|
| 154 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 155 | oldfile=h.filebase; |
---|
| 156 | end |
---|
| 157 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 158 | oldfile=h.RootPath; |
---|
| 159 | end |
---|
| 160 | end |
---|
| 161 | else |
---|
| 162 | oldfile=filebase; |
---|
| 163 | end |
---|
[360] | 164 | |
---|
| 165 | %% get the new input file with the browser |
---|
[307] | 166 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
[309] | 167 | '*.xml', '.xml files '; ... |
---|
| 168 | '*.civ', '.civ files '; ... |
---|
| 169 | '*.png','.png image files'; ... |
---|
| 170 | '*.jpg',' jpeg image files'; ... |
---|
| 171 | '*.tif','.tif image files'; ... |
---|
| 172 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 173 | '*.nc','.netcdf files'; ... |
---|
| 174 | '*.*', 'All Files (*.*)'}; |
---|
[307] | 175 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 176 | fileinput=[PathName FileName];%complete file name |
---|
| 177 | sizf=size(fileinput); |
---|
| 178 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 179 | |
---|
[343] | 180 | %% case of the xml file opened as input (TODO: check and see whether it is useful) |
---|
[307] | 181 | [path,name,ext]=fileparts(fileinput); |
---|
| 182 | testeditxml=0; |
---|
[360] | 183 | % if isequal(ext,'.xml') |
---|
| 184 | % testeditxml=1; |
---|
| 185 | % t_browse=xmltree(fileinput); |
---|
| 186 | % head_element=get(t_browse,1); |
---|
| 187 | % if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
| 188 | % testeditxml=0; |
---|
| 189 | % end |
---|
[343] | 190 | % end |
---|
[360] | 191 | % if testeditxml==1 || isequal(ext,'.xls') |
---|
| 192 | % heditxml=editxml({fileinput}); |
---|
| 193 | % set(heditxml,'Tag','browser') |
---|
| 194 | % waitfor(heditxml,'Tag','idle') |
---|
| 195 | % if ~ishandle(heditxml) |
---|
| 196 | % return |
---|
| 197 | % end |
---|
| 198 | % attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 199 | % set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 200 | % fileinput=get(attr,'UserData'); |
---|
| 201 | % if ~exist(fileinput,'file') |
---|
| 202 | % return |
---|
| 203 | % end |
---|
[343] | 204 | % end |
---|
[360] | 205 | [tild,tild,tild,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput); |
---|
[343] | 206 | |
---|
| 207 | %% prepare the GUI with parameters from the input file |
---|
[371] | 208 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[343] | 209 | errormsg=display_file_name(handles,fileinput); |
---|
| 210 | if ~isempty(errormsg) |
---|
| 211 | msgbox_uvmat('ERROR',erromsg) |
---|
[307] | 212 | end |
---|
[371] | 213 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[307] | 214 | |
---|
[309] | 215 | %------------------------------------------------------------------------ |
---|
[273] | 216 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
| 217 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
[12] | 218 | %------------------------------------------------------------------------ |
---|
[371] | 219 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 220 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
[298] | 221 | errormsg=display_file_name(handles,fileinput); |
---|
| 222 | if ~isempty(errormsg) |
---|
[355] | 223 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 224 | end |
---|
[371] | 225 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[273] | 226 | |
---|
| 227 | % ----------------------------------------------------------------------- |
---|
| 228 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
| 229 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 230 | %------------------------------------------------------------------------ |
---|
[371] | 231 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 232 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
[298] | 233 | errormsg=display_file_name(handles,fileinput); |
---|
| 234 | if ~isempty(errormsg) |
---|
[355] | 235 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 236 | end |
---|
[371] | 237 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[309] | 238 | |
---|
[273] | 239 | % ----------------------------------------------------------------------- |
---|
| 240 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
| 241 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 242 | %------------------------------------------------------------------------ |
---|
[371] | 243 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 244 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
[298] | 245 | errormsg=display_file_name(handles,fileinput); |
---|
| 246 | if ~isempty(errormsg) |
---|
[355] | 247 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 248 | end |
---|
[371] | 249 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[309] | 250 | |
---|
[273] | 251 | % ----------------------------------------------------------------------- |
---|
| 252 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
| 253 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 254 | %------------------------------------------------------------------------ |
---|
[371] | 255 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 256 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
[298] | 257 | errormsg=display_file_name(handles,fileinput); |
---|
| 258 | if ~isempty(errormsg) |
---|
[355] | 259 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 260 | end |
---|
[371] | 261 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[309] | 262 | |
---|
[273] | 263 | % ----------------------------------------------------------------------- |
---|
| 264 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
| 265 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 266 | %------------------------------------------------------------------------ |
---|
[371] | 267 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 268 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
[298] | 269 | errormsg=display_file_name(handles,fileinput); |
---|
| 270 | if ~isempty(errormsg) |
---|
[355] | 271 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 272 | end |
---|
[371] | 273 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[309] | 274 | |
---|
| 275 | % ----------------------------------------------------------------------- |
---|
| 276 | % ----------------------------------------------------------------------- |
---|
| 277 | % --- Open the help html file |
---|
| 278 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
| 279 | % ----------------------------------------------------------------------- |
---|
| 280 | path_civ=fileparts(which ('civ')); |
---|
| 281 | helpfile=fullfile(path_civ,'uvmat_doc','uvmat_doc.html'); |
---|
| 282 | if isempty(dir(helpfile)) |
---|
| 283 | msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
| 284 | else |
---|
| 285 | addpath (fullfile(path_civ,'uvmat_doc')) |
---|
| 286 | web([helpfile '#civ']) |
---|
| 287 | end |
---|
| 288 | |
---|
[12] | 289 | %------------------------------------------------------------------------ |
---|
[309] | 290 | % --- Function activated when a new filebase (image series) is introduced |
---|
[371] | 291 | function RootPath_Callback(hObject, eventdata, handles) |
---|
[12] | 292 | %------------------------------------------------------------------------ |
---|
[371] | 293 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
| 294 | RootPath=get(handles.RootPath,'String'); |
---|
[494] | 295 | SubDirImages=get(handles.SubDirImages,'String'); |
---|
[371] | 296 | RootFile=get(handles.RootFile,'String'); |
---|
[360] | 297 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 298 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 299 | NomType=get(handles.NomType,'String'); |
---|
| 300 | ImaExt=get(handles.ImaExt,'String'); |
---|
[494] | 301 | fileinput=fullfile_uvmat(RootPath,SubDirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j); |
---|
[360] | 302 | errormsg=display_file_name(handles,fileinput); |
---|
[298] | 303 | if ~isempty(errormsg) |
---|
[360] | 304 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 305 | end |
---|
[371] | 306 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[384] | 307 | |
---|
[273] | 308 | %------------------------------------------------------------------------ |
---|
[309] | 309 | % --- general function activated for an input file series |
---|
[298] | 310 | function errormsg=display_file_name(handles,fileinput) |
---|
[273] | 311 | %------------------------------------------------------------------------ |
---|
[282] | 312 | set(handles.ListCompareMode,'Visible','on') |
---|
[298] | 313 | errormsg='';%default empty error message |
---|
[355] | 314 | drawnow |
---|
[273] | 315 | |
---|
[298] | 316 | %% enable RUN, BATCH button and 'status' display |
---|
| 317 | set(handles.RUN, 'Enable','On') |
---|
| 318 | set(handles.RUN,'BackgroundColor',[1 0 0])%set RUN button to red color |
---|
| 319 | if isfield(handles,'status') |
---|
| 320 | set(handles.status,'Value',0); %suppress the 'status' display |
---|
| 321 | status_Callback([], [], handles) |
---|
[2] | 322 | end |
---|
| 323 | |
---|
[298] | 324 | %% determine nomenclature types and extension of the input files |
---|
[355] | 325 | [RootPath,SubDir,RootFile,i1,i2,j1,j2,ExtInput,NomTypeInput]=fileparts_uvmat(fileinput); |
---|
[360] | 326 | NomTypeNc='';%default |
---|
| 327 | |
---|
[438] | 328 | %% case of xml file as input, read the civ parameters |
---|
[355] | 329 | ind_opening=0;%default |
---|
[360] | 330 | if strcmp(ExtInput,'.xml') |
---|
[501] | 331 | %reinitialise menus |
---|
| 332 | set(handles.ListPairMode,'Value',1) |
---|
| 333 | set(handles.ListPairMode,'String',{''}) |
---|
| 334 | set(handles.ListPairCiv1,'Value',1) |
---|
| 335 | set(handles.ListPairCiv1,'String',{''}) |
---|
| 336 | set(handles.ListPairCiv2,'Value',1) |
---|
| 337 | set(handles.ListPairCiv2,'String',{''}) |
---|
| 338 | Param=xml2struct(fileinput); %read parameters from the xml input file |
---|
[611] | 339 | fill_GUI(Param,handles.civ);%fill the GUI with the parameters retrieved from the xml file |
---|
[360] | 340 | return |
---|
| 341 | end |
---|
[438] | 342 | |
---|
| 343 | %% case of netcdf file as input, get the civ processing stage and look for a coresponding image |
---|
[493] | 344 | imageinput=fileinput;%default |
---|
[360] | 345 | if strcmp(ExtInput,'.nc') |
---|
| 346 | NomTypeNc=NomTypeInput; |
---|
[494] | 347 | if isempty(regexp(NomTypeInput,'[ab|AB|-]', 'once')) |
---|
[371] | 348 | set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomencalture does not involve index pairs |
---|
[438] | 349 | set(handles.RootFile_1,'Visible','On'); |
---|
[371] | 350 | else |
---|
[438] | 351 | set(handles.ListCompareMode,'Value',1) |
---|
| 352 | set(handles.RootFile_1,'Visible','Off'); |
---|
[371] | 353 | end |
---|
[493] | 354 | imageinput=''; |
---|
[371] | 355 | Data=nc2struct(fileinput,'ListGlobalAttribute','Conventions','absolut_time_T0','CivStage','Civ2_ImageA','Civ1_ImageA','Civ2_ImageB','Civ1_ImageB','fix','patch','civ2','fix2'); |
---|
[360] | 356 | if isfield(Data,'Txt') |
---|
| 357 | errormsg=Data.Txt; |
---|
| 358 | return |
---|
| 359 | end |
---|
[438] | 360 | % settings for new civ data, |
---|
[360] | 361 | if strcmp(Data.Conventions,'uvmat/civdata')% case of new civ data, |
---|
[500] | 362 | set(handles.Program,'Value',1) %select civ/Matlab by default |
---|
[493] | 363 | Program_Callback([],[], handles) |
---|
[355] | 364 | if ~isempty(Data.CivStage)%test for civ files |
---|
| 365 | ind_opening=Data.CivStage; |
---|
[343] | 366 | end |
---|
[371] | 367 | if ~isempty(Data.Civ2_ImageB)%get the corresponding input image in the netcdf file |
---|
| 368 | imageinput=Data.Civ2_ImageB; |
---|
| 369 | [tild,ImaName,ImaExt]=fileparts(Data.Civ2_ImageA); |
---|
| 370 | set(handles.RootFile_1,'String',[ImaName ImaExt]) |
---|
| 371 | elseif ~isempty(Data.Civ1_ImageB) |
---|
| 372 | imageinput=Data.Civ1_ImageB; |
---|
| 373 | [tild,ImaName,ImaExt]=fileparts(Data.Civ1_ImageA); |
---|
| 374 | set(handles.RootFile_1,'String',[ImaName ImaExt]) |
---|
[298] | 375 | end |
---|
[438] | 376 | % settings for civx data, |
---|
[360] | 377 | elseif ~isempty(Data.absolut_time_T0')% case of civx data, |
---|
[500] | 378 | set(handles.Program,'Value',3) %select Cix by default |
---|
[476] | 379 | Program_Callback([],[], handles) |
---|
[355] | 380 | if ~isempty(Data.fix2) |
---|
| 381 | ind_opening=5; |
---|
| 382 | elseif ~isempty(Data.civ2) |
---|
| 383 | ind_opening=4; |
---|
| 384 | elseif ~isempty(Data.patch) |
---|
| 385 | ind_opening=3; |
---|
| 386 | elseif ~isempty(Data.fix) |
---|
| 387 | ind_opening=2; |
---|
| 388 | end |
---|
[360] | 389 | else |
---|
| 390 | errormsg='the input netcdf file is not civ data'; |
---|
| 391 | return |
---|
| 392 | end |
---|
[438] | 393 | % look for the corresponding input images |
---|
| 394 | check_letter=~isempty(regexp(NomTypeInput,'[ab|AB]$','once'));%detect pair label by letter |
---|
| 395 | NomTypeIma=NomTypeInput; |
---|
| 396 | if check_letter |
---|
| 397 | NomTypeIma=NomTypeInput(1:end-1); |
---|
| 398 | else |
---|
| 399 | r=regexp(NomTypeIma,'.-(?<num2>\d+)$','names'); |
---|
| 400 | if ~isempty(r) |
---|
| 401 | NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); |
---|
| 402 | end |
---|
| 403 | r=regexp(NomTypeIma,'.-(?<num2>\d+)','names'); |
---|
| 404 | if ~isempty(r) |
---|
| 405 | NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); |
---|
| 406 | end |
---|
| 407 | end |
---|
[493] | 408 | if ~exist(imageinput,'file') |
---|
[438] | 409 | imageinput=fullfile_uvmat(RootPath,regexprep(SubDir,'.civ(_?)(\d*)$',''),RootFile,'.png',NomTypeIma,i1,[],j1); |
---|
[493] | 410 | end |
---|
[360] | 411 | end |
---|
| 412 | |
---|
[469] | 413 | %% no corresponding image found, select manually with the browser |
---|
[360] | 414 | ImaExt=ExtInput; |
---|
| 415 | if ~isempty(NomTypeNc) |
---|
| 416 | %no corresponding image found, select manually with the browser |
---|
| 417 | if ~exist(imageinput,'file') |
---|
| 418 | menu={'*.png;*.jpg;*.tif;*.avi;*.AVI', '(*.png,*.jpg ,*.tif, *.avi,*.AVI)'; |
---|
| 419 | '*.png','.png image files'; ... |
---|
| 420 | '*.jpg',' jpeg image files'; ... |
---|
| 421 | '*.tif','.tif image files'; ... |
---|
| 422 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 423 | '*.*', 'All Files (*.*)'}; |
---|
| 424 | [FileName, PathName] = uigetfile( menu, 'Pick an input image file',fileparts(fileparts(fileinput))); |
---|
[493] | 425 | imageinput=[PathName FileName];%complete file name |
---|
| 426 | if ~exist(imageinput,'file') |
---|
[469] | 427 | return %abandon of the browser is cancelled |
---|
| 428 | end |
---|
[360] | 429 | end |
---|
[469] | 430 | %fileinput=imageinput; |
---|
[360] | 431 | end |
---|
[371] | 432 | |
---|
| 433 | %% scan the image file series |
---|
[493] | 434 | [FilePath,FileName,ImaExt]=fileparts(imageinput); |
---|
[398] | 435 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 436 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
[783] | 437 | [RootPath,SubDirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileInfo,MovieObject]=find_file_series(FilePath,[FileName ImaExt]); |
---|
| 438 | FileType=FileInfo.FileType; |
---|
[360] | 439 | switch FileType |
---|
[435] | 440 | case {'image','multimage','video','mmreader'} |
---|
[355] | 441 | otherwise |
---|
[360] | 442 | errormsg='invalid input file: enter an image, a movie or civ .nc file'; |
---|
| 443 | return |
---|
[2] | 444 | end |
---|
[371] | 445 | set(handles.RootPath,'String',RootPath) |
---|
[494] | 446 | set(handles.SubDirImages,'String',SubDirImages) |
---|
[371] | 447 | set(handles.RootFile,'String',RootFile) |
---|
[438] | 448 | if strcmp(ExtInput,'.nc') |
---|
[494] | 449 | SubDirCiv=regexprep(SubDir,['^' SubDirImages],'');%suppress the root SuddirImages; |
---|
[438] | 450 | else |
---|
[441] | 451 | SubDirCiv= '.civ'; |
---|
[438] | 452 | end |
---|
| 453 | set(handles.SubdirCiv1,'String',SubDirCiv) |
---|
| 454 | set(handles.SubdirCiv2,'String',SubDirCiv) |
---|
[371] | 455 | browse=get(handles.RootPath,'UserData'); |
---|
[355] | 456 | browse.incr_pair=[0 0];%default |
---|
| 457 | |
---|
[360] | 458 | %% scan the images if a civ file has been opened |
---|
[370] | 459 | MinIndex_i=min(i1_series(i1_series>0)); |
---|
| 460 | MinIndex_j=min(j1_series(j1_series>0)); |
---|
[360] | 461 | MaxIndex_i=max(i1_series(i1_series>0)); |
---|
| 462 | MaxIndex_j=max(j1_series(j1_series>0)); |
---|
[355] | 463 | |
---|
[298] | 464 | %% look for an image documentation file |
---|
[476] | 465 | XmlFileName=find_imadoc(RootPath,SubDir,RootFile,ImaExt); |
---|
[469] | 466 | if isempty(XmlFileName) |
---|
| 467 | if (strcmp(FileType,'video') || strcmp(FileType,'mmreader')) |
---|
| 468 | ext_imadoc=ImaExt;% the timing from the video movie is used |
---|
| 469 | else |
---|
| 470 | ext_imadoc=''; |
---|
| 471 | end |
---|
| 472 | else |
---|
| 473 | [tild,tild,ext_imadoc]=fileparts(XmlFileName); |
---|
[441] | 474 | end |
---|
[298] | 475 | set(handles.ImaDoc,'String',ext_imadoc)% display the extension name for the image documentation file used |
---|
[343] | 476 | |
---|
| 477 | %% read the time in the image documentation file |
---|
[298] | 478 | time=[]; |
---|
[343] | 479 | TimeUnit=''; %default |
---|
| 480 | CoordUnit='';%default |
---|
[416] | 481 | pxcm_search=1; |
---|
[469] | 482 | if ~isempty(XmlFileName) |
---|
[343] | 483 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) % set edit box to yellow cloro to indicate that the file reading is beginning |
---|
| 484 | drawnow |
---|
[469] | 485 | [XmlData,warntext]=imadoc2struct(XmlFileName); |
---|
| 486 | nom_type_read=[]; |
---|
| 487 | if isfield(XmlData,'Time') && ~isempty(XmlData.Time) |
---|
| 488 | time=XmlData.Time; |
---|
| 489 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
| 490 | if isequal(MaxIndex_i,1) && ~isequal(MaxIndex_j,1)% .Time is a line vector |
---|
| 491 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once')) |
---|
| 492 | time=time'; |
---|
| 493 | MaxIndex_i=MaxIndex_j; |
---|
| 494 | MaxIndex_j=1; |
---|
[343] | 495 | end |
---|
[469] | 496 | end |
---|
[84] | 497 | end |
---|
[582] | 498 | if isfield(XmlData,'Camera') && isfield(XmlData.Camera,'TimeUnit') |
---|
| 499 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
[468] | 500 | end |
---|
[469] | 501 | if isfield(XmlData,'GeometryCalib') |
---|
| 502 | tsai=XmlData.GeometryCalib; |
---|
| 503 | if isfield(tsai,'fx_fy') |
---|
| 504 | pxcm_search=max(tsai.fx_fy(1),tsai.fx_fy(2));%pixels:cm estimated for the search range |
---|
| 505 | end |
---|
| 506 | if isfield(tsai,'CoordUnit') |
---|
| 507 | CoordUnit=tsai.CoordUnit; |
---|
| 508 | end |
---|
| 509 | end |
---|
[2] | 510 | end |
---|
[469] | 511 | if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader')) |
---|
[494] | 512 | set(handles.ListPairMode,'Value',1); |
---|
[469] | 513 | dt=1/get(MovieObject,'FrameRate');%time interval between successive frames |
---|
[492] | 514 | if strcmp(NomTypeIma,'*') |
---|
| 515 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
| 516 | MaxIndex_i=get(MovieObject,'NumberOfFrames'); |
---|
[621] | 517 | %time=(dt*(0:MaxIndex_i-1))';%list of image times |
---|
| 518 | time=zeros(MaxIndex_i+1,2); |
---|
| 519 | time(:,2)=dt*(0:MaxIndex_i)'; |
---|
[492] | 520 | else |
---|
| 521 | set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}]) |
---|
| 522 | MaxIndex_i=max(i1_series(i1_series>0)); |
---|
[494] | 523 | MaxIndex_j=get(MovieObject,'NumberOfFrames'); |
---|
[621] | 524 | %time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j-1));%list of image times |
---|
| 525 | time=[0;dt*ones(MaxIndex_j,1)]*(0:MaxIndex_j); |
---|
[492] | 526 | enable_j(handles,'on') |
---|
[494] | 527 | end |
---|
[469] | 528 | TimeUnit='s'; |
---|
| 529 | set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter |
---|
| 530 | end |
---|
| 531 | |
---|
[298] | 532 | %% timing display |
---|
| 533 | %show the reference image edit box if relevant (not needed for movies or in the absence of time information |
---|
[343] | 534 | if numel(time)>=2 % if there are at least two time values to define dt |
---|
[621] | 535 | if size(time,1)<MaxIndex_i+1; |
---|
[589] | 536 | msgbox_uvmat('WARNING','maximum i index restricted by the timing of the xml file'); |
---|
[621] | 537 | elseif size(time,2)<MaxIndex_j+1 |
---|
[589] | 538 | msgbox_uvmat('WARNING','maximum j index restricted by the timing of the xml file'); |
---|
| 539 | end |
---|
[621] | 540 | MaxIndex_i=min(size(time,1)-1,MaxIndex_i);%possibly adjust the max index according to time data |
---|
| 541 | MaxIndex_j=min(size(time,2)-1,MaxIndex_j); |
---|
[611] | 542 | % time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices) |
---|
| 543 | % time=[zeros(1,size(time,2)); time]; %insert a horizontal line of zeros |
---|
[343] | 544 | else |
---|
| 545 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
[621] | 546 | time=(i1_series(:,1)+0:size(i1_series,3));% time=index i |
---|
| 547 | time=time'*ones(1,size(i1_series,2)+1,1); %makes a time matrix with the same time for all j indices |
---|
[343] | 548 | TimeUnit='frame'; |
---|
[2] | 549 | end |
---|
[343] | 550 | set(handles.ImaDoc,'UserData',time); %store the matrix of times |
---|
| 551 | set(handles.dt_unit,'String',['dt in m' TimeUnit]);%display dt in unit 10-3 of the time (e.g ms) |
---|
| 552 | set(handles.TimeUnit,'String',TimeUnit); |
---|
| 553 | set(handles.nb_field,'String',num2str(MaxIndex_i)); |
---|
| 554 | set(handles.nb_field2,'String',num2str(MaxIndex_j)); |
---|
[71] | 555 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[415] | 556 | set(handles.SearchRange,'UserData', pxcm_search); |
---|
[360] | 557 | set(handles.ImaExt,'String',ImaExt) |
---|
| 558 | set(handles.NomType,'String',NomTypeIma) |
---|
[370] | 559 | |
---|
[494] | 560 | %% set the reference indices from the input file indices |
---|
| 561 | num_ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 562 | num_ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 563 | % for movies don't modify except if the current ref is outside index bounds |
---|
| 564 | %if strcmp(ExtInput,'.nc')|| ~(strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader') && num_ref_i<=MaxIndex_i && num_ref_j<=MaxIndex_j) |
---|
| 565 | if ~isempty(i1)% if i1 has been selected by the input |
---|
| 566 | num_ref_i=i1;%default ref index |
---|
| 567 | if ~isempty(i2) |
---|
| 568 | num_ref_i=floor((num_ref_i+i2)/2); |
---|
| 569 | end |
---|
| 570 | if ~isempty(j1) |
---|
| 571 | num_ref_j=j1; |
---|
| 572 | if ~isempty(j2) |
---|
| 573 | num_ref_j=floor((num_ref_j+j2)/2); |
---|
| 574 | end |
---|
| 575 | end |
---|
| 576 | end |
---|
| 577 | if num_ref_i>MaxIndex_i||num_ref_i<MinIndex_i |
---|
| 578 | num_ref_i=round((MinIndex_i+MaxIndex_i)/2); |
---|
| 579 | end |
---|
| 580 | if ~isempty(num_ref_j)&&~isempty(MaxIndex_j)&& ~isempty(MinIndex_j) |
---|
| 581 | if (num_ref_j>MaxIndex_j||num_ref_j<MinIndex_j) |
---|
| 582 | num_ref_j=round((MinIndex_j+MaxIndex_j)/2); |
---|
| 583 | end |
---|
| 584 | end |
---|
| 585 | if isempty(num_ref_j) |
---|
| 586 | num_ref_j=1; |
---|
| 587 | end |
---|
| 588 | |
---|
[370] | 589 | %% update i and j index range if a nc file has been opened or pb withmin max image indices: |
---|
| 590 | % then set first and last to the inputfile index by default |
---|
| 591 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 592 | last_i=str2num(get(handles.last_i,'String')); |
---|
[494] | 593 | if isempty(first_i) || isempty(last_i)||isempty(MinIndex_i)||isempty(MaxIndex_i)||ind_opening~=0 || isempty(first_i) || isempty(last_i)|| first_i<MinIndex_i || last_i>MaxIndex_i |
---|
| 594 | first_i=num_ref_i; |
---|
| 595 | last_i=num_ref_i; |
---|
| 596 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 597 | set(handles.last_i,'String',num2str(last_i));% |
---|
[371] | 598 | end |
---|
[370] | 599 | |
---|
| 600 | %j index range |
---|
| 601 | first_j=str2num(get(handles.first_j,'String')); |
---|
[494] | 602 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 603 | if isempty(first_j) || isempty(last_j)||isempty(MinIndex_j)||isempty(MaxIndex_j)||ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j |
---|
| 604 | first_j=num_ref_j; |
---|
| 605 | last_j=num_ref_j; |
---|
| 606 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 607 | set(handles.last_j,'String',num2str(last_j));% |
---|
[370] | 608 | end |
---|
[494] | 609 | if num_ref_i>last_i || num_ref_i<first_i |
---|
| 610 | num_ref_i=round((first_i+last_i)/2); |
---|
| 611 | end |
---|
| 612 | if num_ref_j>last_j || num_ref_j<first_j |
---|
| 613 | num_ref_j=round((first_j+last_j)/2); |
---|
| 614 | end |
---|
| 615 | set(handles.ref_i,'String',num2str(num_ref_i)) |
---|
| 616 | set(handles.ref_j,'String',num2str(num_ref_j)) |
---|
[2] | 617 | |
---|
[370] | 618 | %% set the civ options depending on the input file content when a nc file has been opened |
---|
[371] | 619 | ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; |
---|
[505] | 620 | checkbox=zeros(size(ListOptions));%default |
---|
| 621 | if ind_opening==0%case of image opening, start with Civ1 |
---|
[501] | 622 | for index=1:numel(ListOptions) |
---|
| 623 | checkbox(index)=get(handles.(ListOptions{index}),'Value'); |
---|
| 624 | end |
---|
[505] | 625 | index_max=find(checkbox, 1, 'last' ); |
---|
| 626 | if isempty(index_max),index_max=1;end |
---|
| 627 | for index=1:index_max |
---|
[501] | 628 | set(handles.(ListOptions{index}),'Value',1)% select all operations starting from CIV1 |
---|
| 629 | end |
---|
| 630 | else |
---|
| 631 | for index = 1:min(ind_opening,5) |
---|
[370] | 632 | set(handles.(ListOptions{index}),'value',0) |
---|
| 633 | end |
---|
[501] | 634 | set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1) |
---|
| 635 | for index = ind_opening+2:6 |
---|
| 636 | set(handles.(ListOptions{index}),'value',0) |
---|
| 637 | end |
---|
[298] | 638 | end |
---|
[501] | 639 | %list_operation={'CheckCiv1','CheckFix1','CheckPatch1','CheckCiv2','CheckFix2','CheckPatch2'}; |
---|
| 640 | |
---|
| 641 | %set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1) |
---|
[438] | 642 | update_CivOptions(handles,ind_opening) |
---|
[298] | 643 | |
---|
[273] | 644 | %% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[362] | 645 | %check_letter=~isempty(regexp(NomTypeIma,'[ab|AB]$'));%detect pair label by letter |
---|
[371] | 646 | if isequal(NomTypeNc,'_1-2')||isempty(MaxIndex_j)|| (MaxIndex_j==1) |
---|
[282] | 647 | set(handles.ListPairMode,'Value',1) |
---|
| 648 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
[353] | 649 | elseif MaxIndex_i==1 && MaxIndex_j>1% simple series in j |
---|
[343] | 650 | set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)'}) |
---|
| 651 | if MaxIndex_j <= 10 |
---|
| 652 | set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large |
---|
| 653 | end |
---|
[492] | 654 | elseif ~(strcmp(FileType,'video') || strcmp(FileType,'mmreader')) |
---|
[282] | 655 | set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[360] | 656 | if strcmp(NomTypeNc,'_1-2_1') |
---|
| 657 | set(handles.ListPairMode,'Value',3)% advise 'series(Di)' |
---|
| 658 | elseif MaxIndex_j <= 10 |
---|
[343] | 659 | set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large |
---|
[2] | 660 | end |
---|
| 661 | end |
---|
| 662 | |
---|
[368] | 663 | %% scan files to update the subdirectory list display |
---|
[300] | 664 | listot=dir(RootPath);%directory of RootPath |
---|
[273] | 665 | idir=0; |
---|
| 666 | listdir={''};%default |
---|
[300] | 667 | % get the list of existing civ subdirectories in the path of theinput root file |
---|
[273] | 668 | for ilist=1:length(listot) |
---|
| 669 | if listot(ilist).isdir |
---|
| 670 | name=listot(ilist).name; |
---|
| 671 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 672 | idir=idir+1; |
---|
| 673 | listdir{idir,1}=listot(ilist).name; |
---|
| 674 | end |
---|
| 675 | end |
---|
| 676 | end |
---|
[368] | 677 | |
---|
[300] | 678 | %% store info |
---|
[371] | 679 | set(handles.RootPath,'UserData',browse)% store the nomenclature type |
---|
[273] | 680 | |
---|
[298] | 681 | %% list the possible index pairs, depending on the option set in ListPairMode |
---|
| 682 | ListPairMode_Callback([], [], handles) |
---|
| 683 | |
---|
| 684 | %% store the root input filename for future opening |
---|
| 685 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 686 | if exist(profil_perso,'file') |
---|
| 687 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 688 | else |
---|
| 689 | txt=ver('MATLAB'); |
---|
| 690 | Release=txt.Release; |
---|
| 691 | relnumb=str2double(Release(3:4)); |
---|
| 692 | if relnumb >= 14 |
---|
| 693 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
| 694 | else |
---|
| 695 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 696 | end |
---|
| 697 | end |
---|
[371] | 698 | set(handles.RootPath,'BackgroundColor',[1 1 1]) |
---|
[298] | 699 | |
---|
[12] | 700 | %------------------------------------------------------------------------ |
---|
[309] | 701 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
[363] | 702 | function SubdirCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 703 | %------------------------------------------------------------------------ |
---|
[363] | 704 | SubDir=get(handles.SubdirCiv1,'String'); |
---|
[309] | 705 | menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update |
---|
[343] | 706 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
[309] | 707 | if isempty(ichoice) |
---|
| 708 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
[2] | 709 | else |
---|
[309] | 710 | ilist=ichoice; |
---|
[2] | 711 | end |
---|
[309] | 712 | set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu |
---|
| 713 | if get(handles.CheckCiv1,'Value')% if Civ1 is performed |
---|
[363] | 714 | set(handles.SubdirCiv2,'String',SubDir);% set by default civ2 directory the same as civ1 |
---|
[441] | 715 | % set(handles.ListSubdirCiv2,'Value',ilist) |
---|
[309] | 716 | else % if Civ1 data already exist |
---|
[362] | 717 | errormsg=find_netcpair_civ(handles,1); %update the list of available pairs from netcdf files in the new directory |
---|
| 718 | if ~isempty(errormsg) |
---|
| 719 | msgbox_uvmat('ERROR',errormsg) |
---|
| 720 | end |
---|
[112] | 721 | end |
---|
[2] | 722 | |
---|
[12] | 723 | %------------------------------------------------------------------------ |
---|
[343] | 724 | % --- Executes on carriage return on the SubDir checkciv1 edit window |
---|
[363] | 725 | function SubdirCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 726 | %------------------------------------------------------------------------ |
---|
[363] | 727 | SubDir=get(handles.SubdirCiv1,'String'); |
---|
[309] | 728 | menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update |
---|
[343] | 729 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
[309] | 730 | if isempty(ichoice) |
---|
| 731 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
[2] | 732 | else |
---|
[309] | 733 | ilist=ichoice; |
---|
[2] | 734 | end |
---|
[309] | 735 | set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu |
---|
| 736 | %update the list of available pairs from netcdf files in the new directory |
---|
| 737 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
[362] | 738 | errormsg=find_netcpair_civ(handles,2); |
---|
| 739 | if ~isempty(errormsg) |
---|
| 740 | msgbox_uvmat('ERROR',errormsg) |
---|
| 741 | end |
---|
[2] | 742 | end |
---|
| 743 | |
---|
[309] | 744 | %------------------------------------------------------------------------ |
---|
| 745 | % --- Executes on button press in CheckCiv1. |
---|
| 746 | function CheckCiv1_Callback(hObject, eventdata, handles) |
---|
| 747 | %------------------------------------------------------------------------ |
---|
[343] | 748 | update_CivOptions(handles,0) |
---|
[2] | 749 | |
---|
[309] | 750 | %------------------------------------------------------------------------ |
---|
| 751 | % --- Executes on button press in CheckFix1. |
---|
| 752 | function CheckFix1_Callback(hObject, eventdata, handles) |
---|
| 753 | %------------------------------------------------------------------------ |
---|
[343] | 754 | update_CivOptions(handles,0) |
---|
[2] | 755 | |
---|
[309] | 756 | %------------------------------------------------------------------------ |
---|
| 757 | % --- Executes on button press in CheckPatch1. |
---|
| 758 | function CheckPatch1_Callback(hObject, eventdata, handles) |
---|
| 759 | %------------------------------------------------------------------------ |
---|
[343] | 760 | update_CivOptions(handles,0) |
---|
[2] | 761 | |
---|
[309] | 762 | %------------------------------------------------------------------------ |
---|
| 763 | % --- Executes on button press in CheckCiv2. |
---|
| 764 | function CheckCiv2_Callback(hObject, eventdata, handles) |
---|
| 765 | %------------------------------------------------------------------------ |
---|
[343] | 766 | update_CivOptions(handles,0) |
---|
[301] | 767 | |
---|
[309] | 768 | %------------------------------------------------------------------------ |
---|
| 769 | % --- Executes on button press in CheckFix2. |
---|
| 770 | function CheckFix2_Callback(hObject, eventdata, handles) |
---|
| 771 | %------------------------------------------------------------------------ |
---|
[343] | 772 | update_CivOptions(handles,0) |
---|
[301] | 773 | |
---|
[309] | 774 | %------------------------------------------------------------------------ |
---|
| 775 | % --- Executes on button press in CheckPatch2. |
---|
| 776 | function CheckPatch2_Callback(hObject, eventdata, handles) |
---|
| 777 | %------------------------------------------------------------------------ |
---|
[343] | 778 | update_CivOptions(handles,0) |
---|
[300] | 779 | |
---|
[12] | 780 | %------------------------------------------------------------------------ |
---|
[309] | 781 | % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 |
---|
[343] | 782 | function update_CivOptions(handles,opening) |
---|
[12] | 783 | %------------------------------------------------------------------------ |
---|
[309] | 784 | checkbox=zeros(1,6); |
---|
| 785 | checkbox(1)=get(handles.CheckCiv1,'Value'); |
---|
| 786 | checkbox(2)=get(handles.CheckFix1,'Value'); |
---|
| 787 | checkbox(3)=get(handles.CheckPatch1,'Value'); |
---|
| 788 | checkbox(4)=get(handles.CheckCiv2,'Value'); |
---|
| 789 | checkbox(5)=get(handles.CheckFix2,'Value'); |
---|
| 790 | checkbox(6)=get(handles.CheckPatch2,'Value'); |
---|
| 791 | ind_selected=find(checkbox,1); |
---|
| 792 | if ~isempty(ind_selected) |
---|
[371] | 793 | RootPath=get(handles.RootPath,'String'); |
---|
| 794 | if isempty(RootPath) |
---|
[362] | 795 | msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...') |
---|
| 796 | return |
---|
[270] | 797 | end |
---|
[2] | 798 | end |
---|
[309] | 799 | set(handles.PairIndices,'Visible','on') |
---|
[363] | 800 | set(handles.SubdirCiv1,'Visible','on') |
---|
[371] | 801 | set(handles.TitleSubdirCiv1,'Visible','on') |
---|
[440] | 802 | if opening==0 |
---|
[362] | 803 | errormsg=find_netcpair_civ(handles,1); % select the available netcdf files |
---|
| 804 | if ~isempty(errormsg) |
---|
| 805 | msgbox_uvmat('ERROR',errormsg) |
---|
| 806 | end |
---|
[343] | 807 | end |
---|
[309] | 808 | if max(checkbox(4:6))% case of civ2 pair choice needed |
---|
| 809 | set(handles.TitlePairCiv2,'Visible','on') |
---|
| 810 | set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[363] | 811 | set(handles.SubdirCiv2,'Visible','on') |
---|
[437] | 812 | %set(handles.ListSubdirCiv2,'Visible','on') |
---|
[309] | 813 | set(handles.ListPairCiv2,'Visible','on') |
---|
[343] | 814 | if ~opening |
---|
[362] | 815 | errormsg=find_netcpair_civ(handles,2); % select the available netcdf files |
---|
| 816 | if ~isempty(errormsg) |
---|
| 817 | msgbox_uvmat('ERROR',errormsg) |
---|
| 818 | end |
---|
[343] | 819 | end |
---|
[309] | 820 | else |
---|
| 821 | set(handles.TitleSubdirCiv2,'Visible','off') |
---|
[363] | 822 | set(handles.SubdirCiv2,'Visible','off') |
---|
[309] | 823 | set(handles.ListPairCiv2,'Visible','off') |
---|
[2] | 824 | end |
---|
[309] | 825 | options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
| 826 | for ilist=1:length(options) |
---|
| 827 | if checkbox(ilist) |
---|
| 828 | set(handles.(options{ilist}),'Visible','on') |
---|
[2] | 829 | else |
---|
[309] | 830 | set(handles.(options{ilist}),'Visible','off') |
---|
[112] | 831 | end |
---|
[2] | 832 | end |
---|
| 833 | |
---|
[12] | 834 | %------------------------------------------------------------------------ |
---|
[177] | 835 | % --- Executes on button press in RUN: processing on local computer |
---|
[67] | 836 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 837 | %------------------------------------------------------------------------ |
---|
[73] | 838 | set(handles.RUN, 'Enable','Off') |
---|
| 839 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[486] | 840 | set(handles.RUN,'UserData',now)% record the time of launch |
---|
[469] | 841 | errormsg=launch_jobs(hObject, eventdata, handles); |
---|
[73] | 842 | set(handles.RUN, 'Enable','On') |
---|
| 843 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 844 | |
---|
[371] | 845 | % display errors or start status callback to visualise results |
---|
[229] | 846 | if ~isempty(errormsg) |
---|
| 847 | display(errormsg) |
---|
| 848 | msgbox_uvmat('ERROR',errormsg) |
---|
[282] | 849 | elseif isfield(handles,'status') %&& ~isequal(get(handles.ListPairMode,'Value'),3) |
---|
[225] | 850 | set(handles.status,'Value',1);%suppress status display |
---|
| 851 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 852 | end |
---|
[177] | 853 | |
---|
[309] | 854 | %------------------------------------------------------------------- |
---|
| 855 | % --- Executes on button press in status. |
---|
| 856 | function status_Callback(hObject, eventdata, handles) |
---|
| 857 | %------------------------------------------------------------------- |
---|
| 858 | val=get(handles.status,'Value'); |
---|
| 859 | if val==0 |
---|
| 860 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
| 861 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 862 | if ~isempty(hfig) |
---|
| 863 | delete(hfig) |
---|
| 864 | end |
---|
| 865 | return |
---|
| 866 | end |
---|
| 867 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
| 868 | drawnow |
---|
| 869 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 870 | Param.CheckCiv1=get(handles.CheckCiv1,'Value'); |
---|
| 871 | Param.CheckFix1=get(handles.CheckFix1,'Value'); |
---|
| 872 | Param.CheckPatch1=get(handles.CheckPatch1,'Value'); |
---|
| 873 | Param.CheckCiv2=get(handles.CheckCiv2,'Value'); |
---|
| 874 | Param.CheckFix2=get(handles.CheckFix2,'Value'); |
---|
| 875 | Param.CheckPatch2=get(handles.CheckPatch2,'Value'); |
---|
| 876 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
| 877 | |
---|
| 878 | option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) |
---|
| 879 | filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV |
---|
| 880 | test_new=0; |
---|
| 881 | if ~isfield(filecell,'nc') |
---|
| 882 | test_new=1; |
---|
| 883 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 884 | if ~isempty(errormsg) |
---|
| 885 | msgbox_uvmat('ERROR',errormsg) |
---|
| 886 | return |
---|
| 887 | end |
---|
| 888 | filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status |
---|
| 889 | end |
---|
| 890 | if ~isequal(box_test(4:6),[0 0 0]) |
---|
| 891 | civ_files=filecell.nc.civ2;%case of civ2 operations |
---|
| 892 | else |
---|
| 893 | civ_files=filecell.nc.civ1; |
---|
| 894 | end |
---|
| 895 | [root,filename,ext]=fileparts(civ_files{1}); |
---|
[343] | 896 | [rootroot,SubDir,extdir]=fileparts(root); |
---|
[309] | 897 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 898 | if isempty(hfig) |
---|
| 899 | hfig=figure('DeleteFcn',@stop_status); |
---|
[421] | 900 | set(hfig,'MenuBar','none')% suppress the menu bar |
---|
| 901 | set(hfig,'NumberTitle','off')%suppress the fig number in the title |
---|
[309] | 902 | set(hfig,'name','civ_status') |
---|
[421] | 903 | set(hfig,'tag','civ_status') |
---|
| 904 | set(hfig,'UserData',civ_files) |
---|
[662] | 905 | hlist= uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {@open_uvmat},'tag','list'); |
---|
[309] | 906 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); |
---|
| 907 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
[591] | 908 | %uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI); |
---|
| 909 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@stop_status); |
---|
[421] | 910 | hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@refresh_GUI); |
---|
[309] | 911 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
[421] | 912 | uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
| 913 | drawnow |
---|
[309] | 914 | end |
---|
[486] | 915 | StatusData.time_ref=get(handles.RUN,'UserData');% get the time of launch |
---|
[483] | 916 | StatusData.option_civ=option_civ; |
---|
| 917 | set(hrefresh,'UserData',StatusData) |
---|
| 918 | filepath=fileparts(civ_files{1}); |
---|
[421] | 919 | set(hlist,'UserData',fileparts(filepath)) |
---|
| 920 | refresh_GUI(hrefresh,[]) |
---|
| 921 | |
---|
| 922 | %------------------------------------------------------------------------ |
---|
| 923 | % launched by refreshing the status figure |
---|
| 924 | function refresh_GUI(hObject, eventdata) |
---|
| 925 | %------------------------------------------------------------------------ |
---|
[309] | 926 | Tabchar={}; |
---|
[421] | 927 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
| 928 | hfig=get(hObject,'parent'); |
---|
[483] | 929 | StatusData=get(hObject,'UserData'); |
---|
[421] | 930 | civ_files=get(hfig,'UserData'); |
---|
[483] | 931 | [filepath,filename,ext]=fileparts(civ_files{1}); |
---|
| 932 | [tild,SubDir,extdir]=fileparts(filepath); |
---|
| 933 | SubDir=[SubDir extdir]; |
---|
| 934 | option_civ=StatusData.option_civ; |
---|
[309] | 935 | nbfiles=numel(civ_files); |
---|
[483] | 936 | testrecent=0; |
---|
[309] | 937 | count=0; |
---|
[483] | 938 | datnum=zeros(1,nbfiles); |
---|
| 939 | filefound=cell(1,nbfiles); |
---|
| 940 | for ifile=1:nbfiles |
---|
| 941 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
| 942 | option=0; |
---|
| 943 | if detect==0 |
---|
| 944 | option_str='not created'; |
---|
| 945 | else |
---|
| 946 | datfile=dir(civ_files{ifile}); |
---|
| 947 | if isfield(datfile,'datenum') |
---|
| 948 | datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
| 949 | testrecent=1; |
---|
| 950 | end |
---|
| 951 | filefound(ifile)={datfile.name}; |
---|
| 952 | |
---|
| 953 | % check the content netcdf file |
---|
| 954 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix'); |
---|
| 955 | option_list={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 956 | if ~isempty(Data.CivStage) |
---|
| 957 | option=Data.CivStage;%case of Matlab civ |
---|
[309] | 958 | else |
---|
[483] | 959 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
| 960 | option=6; |
---|
| 961 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
| 962 | option=5; |
---|
| 963 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
| 964 | option=4; |
---|
| 965 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
| 966 | option=3; |
---|
| 967 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
| 968 | option=2; |
---|
[309] | 969 | else |
---|
[483] | 970 | option=1; |
---|
[309] | 971 | end |
---|
| 972 | end |
---|
[483] | 973 | option_str=option_list{option}; |
---|
| 974 | if datnum(ifile)<StatusData.time_ref |
---|
| 975 | option_str=[option_str ' --OLD--']; |
---|
[309] | 976 | end |
---|
| 977 | end |
---|
[483] | 978 | if option >= option_civ |
---|
| 979 | count=count+1; |
---|
| 980 | end |
---|
| 981 | [filepath,filename,ext]=fileparts(civ_files{ifile}); |
---|
| 982 | Tabchar{ifile,1}=[fullfile(SubDir,filename) ext '...' option_str]; |
---|
| 983 | end |
---|
| 984 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
| 985 | if isempty(datnum) |
---|
| 986 | if testrecent |
---|
| 987 | message='no civ result created yet'; |
---|
[309] | 988 | else |
---|
[483] | 989 | message=''; |
---|
[309] | 990 | end |
---|
[483] | 991 | else |
---|
| 992 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
| 993 | [first,ind]=min(datnum); |
---|
| 994 | [last,indlast]=max(datnum); |
---|
| 995 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
| 996 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
| 997 | end |
---|
| 998 | hlist=findobj(hfig,'tag','list'); |
---|
| 999 | hmsgbox=findobj(hfig,'tag','msgbox'); |
---|
| 1000 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
| 1001 | set(hlist,'String',Tabchar) |
---|
| 1002 | set(hmsgbox,'String', message) |
---|
| 1003 | if count>0 %&& ~test_new |
---|
| 1004 | BarPosition(3)=0.9*count/nbfiles; |
---|
| 1005 | set(hwaitbar,'Position',BarPosition) |
---|
| 1006 | end |
---|
[309] | 1007 | |
---|
[483] | 1008 | |
---|
[421] | 1009 | %------------------------------------------------------------------------ |
---|
| 1010 | % launched by deleting the status figure |
---|
| 1011 | function stop_status(hObject, eventdata) |
---|
[67] | 1012 | %------------------------------------------------------------------------ |
---|
[421] | 1013 | hciv=findobj(allchild(0),'tag','civ'); |
---|
| 1014 | hhciv=guidata(hciv); |
---|
| 1015 | set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ |
---|
| 1016 | set(hhciv.status,'BackgroundColor',[0 1 0]) |
---|
| 1017 | |
---|
[591] | 1018 | % %------------------------------------------------------------------------ |
---|
| 1019 | % % launched by pressing OK on the status figure |
---|
| 1020 | % function close_GUI(hObject, eventdata) |
---|
| 1021 | % %------------------------------------------------------------------------ |
---|
| 1022 | % delete(gcbf) |
---|
[421] | 1023 | |
---|
| 1024 | |
---|
[446] | 1025 | %------------------------------------------------------------------------ |
---|
[309] | 1026 | % --- Main lauch command, called by RUN and BATCH |
---|
[469] | 1027 | function errormsg=launch_jobs(hObject, eventdata, handles) |
---|
[446] | 1028 | %------------------------------------------------------------------------ |
---|
[229] | 1029 | errormsg='';%default |
---|
[313] | 1030 | |
---|
| 1031 | %% read the input parameters from the GUI civ |
---|
[309] | 1032 | Param=read_GUI(handles.civ); |
---|
[272] | 1033 | |
---|
[133] | 1034 | %% check the selected list of operations: |
---|
[289] | 1035 | operations={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
[282] | 1036 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
[180] | 1037 | index_first=find(box_test==1,1); |
---|
| 1038 | if isempty(index_first) |
---|
[229] | 1039 | errormsg='no selected operation'; |
---|
[2] | 1040 | return |
---|
| 1041 | end |
---|
[180] | 1042 | index_last=find(box_test==1,1,'last'); |
---|
[159] | 1043 | box_used=box_test(index_first : index_last); |
---|
[2] | 1044 | [box_missing,ind_missing]=min(box_used); |
---|
[180] | 1045 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
[229] | 1046 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
[2] | 1047 | return |
---|
| 1048 | end |
---|
| 1049 | |
---|
[272] | 1050 | %% check mask if selecetd |
---|
| 1051 | %could be included in get_mask callback ? |
---|
[282] | 1052 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[384] | 1053 | maskname=get(handles.Mask,'String'); |
---|
[12] | 1054 | if ~exist(maskname,'file') |
---|
| 1055 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1056 | end |
---|
[2] | 1057 | end |
---|
[282] | 1058 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[384] | 1059 | maskname=get(handles.Mask,'String'); |
---|
[12] | 1060 | if ~exist(maskname,'file') |
---|
| 1061 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1062 | end |
---|
[2] | 1063 | end |
---|
[282] | 1064 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[384] | 1065 | maskname=get(handles.Mask,'String'); |
---|
[12] | 1066 | if ~exist(maskname,'file') |
---|
[112] | 1067 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1068 | end |
---|
[2] | 1069 | end |
---|
[282] | 1070 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[384] | 1071 | maskname=get(handles.Mask,'String'); |
---|
[12] | 1072 | if ~exist(maskname,'file') |
---|
[112] | 1073 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1074 | end |
---|
[2] | 1075 | end |
---|
| 1076 | |
---|
[177] | 1077 | %% reinitialise status callback |
---|
[178] | 1078 | if isfield(handles,'status') |
---|
[180] | 1079 | set(handles.status,'Value',0);%suppress status display |
---|
[446] | 1080 | status_Callback([], [], handles) |
---|
[178] | 1081 | end |
---|
[133] | 1082 | |
---|
[272] | 1083 | %% read the PARAM.xml file to get the binaries (and batch_mode if batch) |
---|
[276] | 1084 | path_civ=fileparts(which('civ')); %path to the source directory of uvmat |
---|
[500] | 1085 | xmlfile=fullfile(path_civ,'PARAM.xml'); |
---|
[483] | 1086 | s=[]; |
---|
[133] | 1087 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
[54] | 1088 | t=xmltree(xmlfile); |
---|
[67] | 1089 | s=convert(t); |
---|
[483] | 1090 | end% default configuration |
---|
| 1091 | if ~isfield(s,'RunParam') |
---|
[493] | 1092 | Param.xml.Civ1Bin=fullfile('bin','civ1'); |
---|
| 1093 | Param.xml.Civ2Bin=fullfile('bin','civ2'); |
---|
| 1094 | Param.xml.FixBin=fullfile('bin','fix_flag'); |
---|
| 1095 | Param.xml.PatchBin=fullfile('bin','patch_up'); |
---|
[2] | 1096 | end |
---|
[469] | 1097 | if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster |
---|
[67] | 1098 | if isfield(s,'BatchParam') |
---|
[284] | 1099 | Param.xml=s.BatchParam; |
---|
| 1100 | if isfield(Param.xml,'BatchMode') |
---|
| 1101 | batch_mode=Param.xml.BatchMode; |
---|
[257] | 1102 | if ~ismember(batch_mode,{'sge','oar'}) |
---|
| 1103 | errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; |
---|
| 1104 | return |
---|
| 1105 | end |
---|
[67] | 1106 | end |
---|
| 1107 | else |
---|
[493] | 1108 | %default configuration |
---|
| 1109 | Param.xml.Civ1Bin=fullfile('bin','civ1'); |
---|
| 1110 | Param.xml.Civ2Bin=fullfile('bin','civ2'); |
---|
| 1111 | Param.xml.FixBin=fullfile('bin','fix_flag'); |
---|
| 1112 | Param.xml.PatchBin=fullfile('bin','patch_up'); |
---|
[501] | 1113 | % Param.xml.CivmBin=fullfile('bin','civ_matlab'); |
---|
[483] | 1114 | Param.xml.BatchMode='oar';% TODO : allow choice for sge |
---|
[67] | 1115 | end |
---|
[257] | 1116 | else % run |
---|
[67] | 1117 | if isfield(s,'RunParam') |
---|
[284] | 1118 | Param.xml=s.RunParam; |
---|
[493] | 1119 | else %default configuration |
---|
| 1120 | Param.xml.Civ1Bin=fullfile('bin','civ1'); |
---|
| 1121 | Param.xml.Civ2Bin=fullfile('bin','civ2'); |
---|
| 1122 | Param.xml.FixBin=fullfile('bin','fix_flag'); |
---|
| 1123 | Param.xml.PatchBin=fullfile('bin','patch_up'); |
---|
[67] | 1124 | end |
---|
[225] | 1125 | end |
---|
[501] | 1126 | %Param.xml.CivmBin=fullfile('bin','civ_matlab'); |
---|
[238] | 1127 | |
---|
[482] | 1128 | %% check if the binaries exist : to move in civ_opening |
---|
[280] | 1129 | binary_list={}; |
---|
[469] | 1130 | switch Param.Program |
---|
[280] | 1131 | case 'CivX' |
---|
| 1132 | binary_list={'Civ1Bin','Civ2Bin','PatchBin','FixBin'}; |
---|
[371] | 1133 | case 'CivAll'% desactivated option |
---|
[289] | 1134 | binary_list={'Civ'}; |
---|
[501] | 1135 | % case 'civ_matlab.sh'% compiled version of civ_matlab |
---|
| 1136 | % binary_list={'CivmBin'}; |
---|
[225] | 1137 | end |
---|
[309] | 1138 | for bin_name=binary_list %loop on the list of binaries |
---|
| 1139 | if isfield(Param.xml,bin_name{1})% bin_name{1} =current name in the list |
---|
[494] | 1140 | if ~isunix |
---|
| 1141 | Param.xml.(bin_name{1})=[regexprep(Param.xml.(bin_name{1}),'/','\') '.exe']; |
---|
| 1142 | end |
---|
[421] | 1143 | if exist(Param.xml.(bin_name{1}),'file') |
---|
| 1144 | [path,name,ext]=fileparts(Param.xml.(bin_name{1})); |
---|
| 1145 | currentdir=pwd; |
---|
[482] | 1146 | if isempty(path) |
---|
| 1147 | path=fileparts(which('civ.m')); |
---|
| 1148 | end |
---|
[421] | 1149 | if exist(path,'dir') |
---|
| 1150 | cd(path); |
---|
| 1151 | binpath=pwd;%path of the binary |
---|
| 1152 | Param.xml.(bin_name{1})=fullfile(binpath,[name ext]); |
---|
[482] | 1153 | cd(currentdir); |
---|
[421] | 1154 | else |
---|
[501] | 1155 | errormsg=['path ' path ' for binaries specified in PARAM.xml does not exist']; |
---|
| 1156 | return |
---|
[500] | 1157 | end |
---|
[421] | 1158 | else %look for the full path if the file name has been defined with a relative path in PARAM.xm |
---|
[289] | 1159 | fullname=fullfile(path_civ,Param.xml.(bin_name{1})); |
---|
[280] | 1160 | if exist(fullname,'file') |
---|
[284] | 1161 | Param.xml.(bin_name{1})=fullname; |
---|
[280] | 1162 | else |
---|
[501] | 1163 | errormsg=['Binary ' Param.xml.(bin_name{1}) ' specified in PARAM.xml does not exist']; |
---|
| 1164 | return |
---|
[280] | 1165 | end |
---|
| 1166 | end |
---|
| 1167 | end |
---|
| 1168 | end |
---|
[501] | 1169 | if strcmp(Param.Program,'civ_matlab.sh') |
---|
| 1170 | if ~exist(fullfile(path_civ,'civ_matlab.sh'),'file') |
---|
| 1171 | errormsg=[{'no file civ_matlab.sh found'}; {'run compile_functions.m to create it by compiling civ_matlab.m'}]; |
---|
[505] | 1172 | return |
---|
[500] | 1173 | end |
---|
| 1174 | end |
---|
[2] | 1175 | |
---|
[313] | 1176 | %% set the list of files and check them |
---|
| 1177 | display('checking the files...') |
---|
| 1178 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 1179 | if ~isempty(errormsg) |
---|
| 1180 | return |
---|
| 1181 | end |
---|
[437] | 1182 | [filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,nom_type_nc,tild,tild,compare,errormsg]=... |
---|
[313] | 1183 | set_civ_filenames(handles,ref_i,ref_j,box_test); |
---|
[437] | 1184 | if ~isempty(errormsg) |
---|
| 1185 | return |
---|
| 1186 | end |
---|
[313] | 1187 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
[494] | 1188 | display('files OK, processing...') |
---|
[465] | 1189 | |
---|
| 1190 | %% create subfolders for log, cmx, nml, xml, bat |
---|
[467] | 1191 | RootBat=fileparts(filecell.nc.civ1{1,1}); |
---|
[501] | 1192 | switch(Param.Program) |
---|
| 1193 | case {'CivX','CivAll'} |
---|
| 1194 | dir_list={'0_BAT','0_CMX','0_LOG'}; |
---|
| 1195 | case {'civ_matlab','civ_matlab.sh'} |
---|
| 1196 | dir_list={'0_BAT','0_XML'}; |
---|
| 1197 | end |
---|
[465] | 1198 | for k=1:length(dir_list) |
---|
| 1199 | if ~exist(fullfile(RootBat,dir_list{k}),'dir') |
---|
| 1200 | mkdir(fullfile(RootBat,dir_list{k})); |
---|
| 1201 | end |
---|
| 1202 | end |
---|
| 1203 | |
---|
[469] | 1204 | %% get information on input images or movies |
---|
[313] | 1205 | nbfield=numel(i1_civ1); |
---|
| 1206 | nbslice=numel(j1_civ1); |
---|
[469] | 1207 | % if strcmp(Param.Program,'civ_matlab') |
---|
[389] | 1208 | if Param.CheckCiv1 |
---|
[784] | 1209 | [ImageInfoA_civ1,Param.Civ1.ImageA]=get_file_info(filecell.ima1.civ1{1}); |
---|
[783] | 1210 | Param.Civ1.FileTypeA=ImageInfoA_civ1.FileType; |
---|
[784] | 1211 | [ImageInfoB_civ1,Param.Civ1.ImageB]=get_file_info(filecell.ima2.civ1{1}); |
---|
[783] | 1212 | Param.Civ1.FileTypeB=ImageInfoB_civ1.FileType; |
---|
[389] | 1213 | end |
---|
| 1214 | if Param.CheckCiv2 |
---|
[784] | 1215 | [ImageInfoA_civ2,Param.Civ2.ImageA]=get_file_info(filecell.ima1.civ2{1}); |
---|
[783] | 1216 | Param.Civ2.FileTypeA=ImageInfoA_civ2.FileType; |
---|
[784] | 1217 | [ImageInfoB_civ2,Param.Civ2.ImageB]=get_file_info(filecell.ima2.civ2{1}); |
---|
[783] | 1218 | Param.Civ2.FileTypeB=ImageInfoB_civ2.FileType; |
---|
[389] | 1219 | end |
---|
[469] | 1220 | % end |
---|
[2] | 1221 | |
---|
[133] | 1222 | %% MAIN LOOP |
---|
[273] | 1223 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[343] | 1224 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 1225 | checkframe=strcmp(TimeUnit,'frame'); |
---|
[322] | 1226 | batch_file_list=[];%should be renamed file_list, can be used for xml or bash files |
---|
[494] | 1227 | NomTypeIma=get(handles.NomType,'String'); |
---|
[2] | 1228 | for ifile=1:nbfield |
---|
| 1229 | for j=1:nbslice |
---|
[313] | 1230 | |
---|
[272] | 1231 | % define output file name |
---|
[282] | 1232 | if Param.CheckCiv2==1 || Param.CheckFix2==1 || Param.CheckPatch2==1 |
---|
[465] | 1233 | Param.OutputFile=filecell.nc.civ2{ifile,j}; |
---|
[272] | 1234 | else |
---|
[465] | 1235 | Param.OutputFile=filecell.nc.civ1{ifile,j}; |
---|
[272] | 1236 | end |
---|
[465] | 1237 | Param.OutputFile=regexprep(Param.OutputFile,'.nc',''); |
---|
| 1238 | |
---|
[282] | 1239 | if Param.CheckCiv1 |
---|
[476] | 1240 | % read image-dependent parameters |
---|
[343] | 1241 | if ~checkframe% && size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j) |
---|
| 1242 | Param.Civ1.Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)-time(i1_civ1(ifile)+1,j1_civ1(j)+1)); |
---|
[301] | 1243 | else |
---|
| 1244 | Param.Civ1.Dt=1; |
---|
| 1245 | end |
---|
[343] | 1246 | Param.Civ1.Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2); |
---|
[469] | 1247 | if strcmp(Param.Program,'CivX') |
---|
[435] | 1248 | Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE? |
---|
| 1249 | Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);% |
---|
[399] | 1250 | end |
---|
[469] | 1251 | Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j}; |
---|
| 1252 | Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j}; |
---|
[476] | 1253 | Param.Civ1.ImageBitDepth=ImageInfoA_civ1.BitDepth; |
---|
| 1254 | Param.Civ1.ImageWidth=ImageInfoA_civ1.Width; |
---|
| 1255 | Param.Civ1.ImageHeight=ImageInfoA_civ1.Height; |
---|
[494] | 1256 | if strcmp(NomTypeIma,'*') |
---|
| 1257 | Param.Civ1.FrameIndexA=i1_civ1(ifile); |
---|
| 1258 | Param.Civ1.FrameIndexB=i2_civ1(ifile); |
---|
| 1259 | else% case of movies indexed with i, the frame index is then in j |
---|
| 1260 | Param.Civ1.FrameIndexA=j1_civ1(j); |
---|
| 1261 | Param.Civ1.FrameIndexB=j2_civ1(j); |
---|
| 1262 | end |
---|
[435] | 1263 | % read mask )parameters |
---|
[284] | 1264 | if Param.Civ1.CheckMask % the lines below should be changed with the new gui |
---|
[315] | 1265 | if ~exist(Param.Civ1.Mask,'file') |
---|
| 1266 | maskbase=[filecell.filebase '_' Param.Civ1.Mask]; % |
---|
| 1267 | nbslice_mask=str2double(Param.Civ1.Mask(1:end-4)); % |
---|
[313] | 1268 | i1_mask=mod(i1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[354] | 1269 | [RootPathMask,RootFileMask]=fileparts(maskbase); |
---|
| 1270 | Param.Civ1.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask); |
---|
[2] | 1271 | end |
---|
| 1272 | end |
---|
[313] | 1273 | % read grid parameters |
---|
[284] | 1274 | if Param.Civ1.CheckGrid |
---|
[315] | 1275 | if numel(Param.Civ1.Grid)>=4 && isequal(Param.Civ1.Grid(end-3:end),'grid') |
---|
| 1276 | nbslice_grid=str2double(Param.Civ1.Grid(1:end-4)); % |
---|
[137] | 1277 | if ~isnan(nbslice_grid) |
---|
[313] | 1278 | i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[354] | 1279 | Param.Civ1.Grid=[filecell.filebase '_' fullfile_uvmat('','',Param.Civ1.Grid,'.grid','_1',i1_grid)]; |
---|
[285] | 1280 | if ~exist(Param.Civ1.GridName,'file') |
---|
[387] | 1281 | errormsg='grid file absent for civ1'; |
---|
| 1282 | return |
---|
[2] | 1283 | end |
---|
[315] | 1284 | elseif ~exist(Param.Civ1.Grid,'file') |
---|
[387] | 1285 | errormsg='grid file absent for civ1'; |
---|
| 1286 | return |
---|
[2] | 1287 | end |
---|
| 1288 | end |
---|
| 1289 | end |
---|
[257] | 1290 | |
---|
[2] | 1291 | end |
---|
| 1292 | |
---|
[282] | 1293 | if Param.CheckCiv2==1 |
---|
[469] | 1294 | Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j}; |
---|
| 1295 | Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j}; |
---|
[343] | 1296 | if ~checkframe %&& size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j) |
---|
[372] | 1297 | Param.Civ2.Dt=time(i2_civ2(ifile)+1,j2_civ2(j)+1)-time(i1_civ2(ifile)+1,j1_civ2(j)+1); |
---|
[301] | 1298 | else |
---|
| 1299 | Param.Civ2.Dt=1; |
---|
[309] | 1300 | end |
---|
[372] | 1301 | Param.Civ2.Time=(time(i2_civ2(ifile)+1,j2_civ2(j)+1)+time(i1_civ2(ifile)+1,j1_civ2(j)+1))/2; |
---|
[469] | 1302 | if strcmp(Param.Program,'CivX') |
---|
[465] | 1303 | Param.Civ2.term_a=num2stra(j1_civ2(j),nom_type_nc); |
---|
| 1304 | Param.Civ2.term_b=num2stra(j2_civ2(j),nom_type_nc); |
---|
[399] | 1305 | end |
---|
[290] | 1306 | Param.Civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 1307 | Param.Civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
[315] | 1308 | |
---|
[465] | 1309 | % mask |
---|
[287] | 1310 | if Param.Civ2.CheckMask |
---|
[315] | 1311 | if ~exist(Param.Civ2.Mask,'file') |
---|
| 1312 | maskbase=[filecell.filebase '_' Param.Civ2.Mask]; % |
---|
| 1313 | nbslice_mask=str2double(Param.Civ2.Mask(1:end-4)); % |
---|
[313] | 1314 | i1_mask=mod(i1_civ2(ifile)-1,nbslice_mask)+1; |
---|
[354] | 1315 | [RootPathMask,RootFileMask]=fileparts(maskbase); |
---|
| 1316 | Param.Civ2.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask); |
---|
[465] | 1317 | % Param.Civ2.Mask=name_generator(maskbase,i1_mask,1,'.png','_i'); |
---|
[2] | 1318 | end |
---|
| 1319 | end |
---|
[315] | 1320 | %grid |
---|
| 1321 | if Param.Civ2.CheckGrid |
---|
| 1322 | if numel(Param.Civ2.Grid)>=4 && isequal(Param.Civ2.Grid(end-3:end),'grid') |
---|
| 1323 | nbslice_grid=str2double(Param.Civ2.Grid(1:end-4)); % |
---|
| 1324 | if ~isnan(nbslice_grid) |
---|
| 1325 | i1_grid=mod(i1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[354] | 1326 | Param.Civ2.Grid=[filecell.filebase '_' fullfile_uvmat('','',gridname,'.grid','_1',i1_grid)]; |
---|
[465] | 1327 | % Param.Civ2.Grid=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')]; |
---|
[315] | 1328 | end |
---|
[2] | 1329 | end |
---|
| 1330 | end |
---|
[469] | 1331 | |
---|
[476] | 1332 | Param.Civ2.ImageBitDepth=ImageInfoA_civ2.BitDepth; |
---|
| 1333 | Param.Civ2.ImageWidth=ImageInfoA_civ2.Width; |
---|
| 1334 | Param.Civ2.ImageHeight=ImageInfoA_civ2.Height; |
---|
[494] | 1335 | if strcmp(NomTypeIma,'*') |
---|
[498] | 1336 | Param.Civ2.FrameIndexA=i1_civ2(ifile); |
---|
| 1337 | Param.Civ2.FrameIndexB=i2_civ2(ifile); |
---|
[494] | 1338 | else% case of movies indexed with i, the frame index is then in j |
---|
[498] | 1339 | Param.Civ2.FrameIndexA=j1_civ2(j); |
---|
| 1340 | Param.Civ2.FrameIndexB=j2_civ2(j); |
---|
[494] | 1341 | end |
---|
[112] | 1342 | end |
---|
[469] | 1343 | |
---|
[465] | 1344 | % write the command and eventually the cmx, xml or nml files |
---|
[469] | 1345 | cmd=write_cmd(Param); |
---|
[465] | 1346 | write_param(Param); |
---|
[469] | 1347 | |
---|
[591] | 1348 | % create the command file name .m, .bat or .sh depending on the run option |
---|
[469] | 1349 | switch Param.Program |
---|
[482] | 1350 | case {'civ_matlab'} |
---|
[505] | 1351 | filename_bat=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_BAT$2$3.m'); |
---|
| 1352 | [BatRoot,BatFile]=fileparts(filename_bat); |
---|
| 1353 | BatFile=regexprep(BatFile,'-','__');%transform name to suppress'-' (not valid for .m files) |
---|
| 1354 | filename_bat=[fullfile(BatRoot,BatFile) '.m']; |
---|
[482] | 1355 | case {'CivX','CivAll','civ_matlab.sh'} |
---|
| 1356 | switch computer |
---|
| 1357 | case {'PCWIN','PCWIN64'} |
---|
[487] | 1358 | filename_bat=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_BAT$2$3.bat'); |
---|
[482] | 1359 | case {'GLNX86','GLNXA64','MACI64'} |
---|
[487] | 1360 | filename_bat=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_BAT$2$3.sh'); |
---|
[482] | 1361 | end |
---|
[112] | 1362 | end |
---|
| 1363 | |
---|
[486] | 1364 | % print the command in the bat file |
---|
[465] | 1365 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 1366 | if isequal(fid,-1) |
---|
| 1367 | errormsg=['creation of .bat file: ' message]; |
---|
| 1368 | return |
---|
[12] | 1369 | end |
---|
[465] | 1370 | fprintf(fid,cmd); |
---|
| 1371 | fclose(fid); |
---|
[482] | 1372 | |
---|
| 1373 | % special case for civ_matlab on cluster |
---|
| 1374 | if strcmp(Param.Program,'civ_matlab') && strcmp(Param.RunMode,'cluster') |
---|
[487] | 1375 | filename_bat2=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_BAT$2$3.sh'); |
---|
[482] | 1376 | [fid,message]=fopen(filename_bat2,'w'); |
---|
| 1377 | if isequal(fid,-1) |
---|
| 1378 | errormsg=['creation of .bat file: ' message]; |
---|
| 1379 | return |
---|
| 1380 | end |
---|
| 1381 | fprintf(fid,['#!/bin/bash \n' ... |
---|
| 1382 | '/etc/sysprofile \n'... |
---|
| 1383 | 'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n'... |
---|
| 1384 | 'addpath(''' path_civ ''');\n']); |
---|
[549] | 1385 | % for p=1:length(batch_file_list) |
---|
[482] | 1386 | fprintf(fid,['run ' filename_bat '\n']); |
---|
[549] | 1387 | % end |
---|
[547] | 1388 | fprintf(fid, 'exit\nEND_MATLAB\n'); |
---|
[482] | 1389 | fclose(fid); |
---|
| 1390 | filename_bat=filename_bat2; |
---|
[465] | 1391 | end |
---|
[309] | 1392 | |
---|
[482] | 1393 | switch computer |
---|
| 1394 | case {'GLNX86','GLNXA64','MACI64'} |
---|
| 1395 | system(['chmod +x ' filename_bat]); |
---|
| 1396 | end |
---|
| 1397 | batch_file_list{length(batch_file_list)+1}=filename_bat; |
---|
[112] | 1398 | end |
---|
[2] | 1399 | end |
---|
[134] | 1400 | |
---|
[465] | 1401 | %% start calculation |
---|
[469] | 1402 | %computation on cluster |
---|
| 1403 | %if batch ==3 |
---|
[482] | 1404 | switch Param.RunMode, |
---|
| 1405 | case 'cluster' |
---|
| 1406 | switch batch_mode |
---|
| 1407 | case 'sge' %at the moment only psmn ENS Lyon uses it |
---|
[279] | 1408 | for p=1:length(batch_file_list) |
---|
[482] | 1409 | %cmd=['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}]; |
---|
| 1410 | cmd=['!qsub -q piv1,piv2,piv3 '... |
---|
| 1411 | '-e ' regexprep(batch_file_list{p},'.bat','.errors') ' -o ' regexprep(batch_file_list{p},'.bat','.log ')... |
---|
| 1412 | ' -v ' 'LD_LIBRARY_PATH=/home/sjoubaud/matlab_sylvain/civx/lib ' batch_file_list{p}]; |
---|
| 1413 | display(cmd);eval(cmd); |
---|
| 1414 | end |
---|
| 1415 | case 'oar_old' % to remove |
---|
| 1416 | for p=1:length(batch_file_list) |
---|
[279] | 1417 | oar_command=['!oarsub -n CIVX -q nicejob '... |
---|
[482] | 1418 | '-E ' regexprep(batch_file_list{p},'.bat','.errors') ' -O ' regexprep(batch_file_list{p},'.bat','.log ')... |
---|
| 1419 | '-l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00" ' batch_file_list{p}]; |
---|
| 1420 | display(oar_command);eval(oar_command); |
---|
| 1421 | end |
---|
| 1422 | case 'oar' |
---|
| 1423 | max_walltime=3600*12; % 12h max |
---|
| 1424 | oar_modes={'oar-parexec','oar-dispatch','mpilauncher'}; |
---|
| 1425 | text={'Batch processing on servcalcul3 LEGI';... |
---|
| 1426 | 'Please choose one of the followint modes';... |
---|
| 1427 | '* oar-parexec : default and best choice';... |
---|
| 1428 | '* oar-dispatch : jobs in a container of several cores';... |
---|
| 1429 | '* mpilauncher : one single parallel mpi job using several cores';... |
---|
| 1430 | '**********************************'... |
---|
| 1431 | }; |
---|
| 1432 | [S,v]=listdlg('PromptString',text,'ListString',oar_modes,... |
---|
| 1433 | 'SelectionMode','single','ListSize',[400 100],'Name','LEGI job mode'); |
---|
| 1434 | switch oar_modes{S} |
---|
| 1435 | case 'oar-parexec' %oar-dispatch.pl |
---|
[575] | 1436 | if strcmp(Param.Program,'civ_matlab') |
---|
| 1437 | ncores=1; |
---|
| 1438 | msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing'); |
---|
| 1439 | else |
---|
[482] | 1440 | answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''}); |
---|
| 1441 | ncores=str2double(answer{1}); |
---|
| 1442 | end |
---|
[575] | 1443 | |
---|
[482] | 1444 | extra_oar=answer{2}; |
---|
| 1445 | walltime_onejob=600;%seconds |
---|
| 1446 | filename_joblist=fullfile(RootBat,'job_list.txt'); |
---|
| 1447 | fid=fopen(filename_joblist,'w'); |
---|
| 1448 | for p=1:length(batch_file_list) |
---|
| 1449 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
| 1450 | end |
---|
| 1451 | fclose(fid); |
---|
| 1452 | oar_command=['oarsub -n CIVX '... |
---|
| 1453 | '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '... |
---|
| 1454 | '-l /core=' num2str(ncores) ','... |
---|
[419] | 1455 | 'walltime=' datestr(min(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,max_walltime/86400),13) ' '... |
---|
[482] | 1456 | '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '... |
---|
| 1457 | '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '... |
---|
| 1458 | extra_oar ' '... |
---|
| 1459 | '"oar-parexec -s -f ' filename_joblist ' '... |
---|
| 1460 | '-l ' filename_joblist '.log"\n']; |
---|
| 1461 | filename_oarcommand=fullfile(RootBat,'oar_command'); |
---|
| 1462 | fid=fopen(filename_oarcommand,'w'); |
---|
| 1463 | fprintf(fid,oar_command); |
---|
| 1464 | fclose(fid); |
---|
| 1465 | fprintf(oar_command);% display in command line |
---|
| 1466 | system(oar_command); |
---|
| 1467 | % eval(['! . ' filename |
---|
| 1468 | % _oarcommand]) |
---|
| 1469 | case 'oar-dispatch' %oar-dispatch.pl |
---|
| 1470 | ncores=str2double(... |
---|
| 1471 | inputdlg('Number of cores (max 36)','oarsub parameter',1,{'6'})... |
---|
| 1472 | ); |
---|
| 1473 | walltime_onejob=600;%seconds |
---|
| 1474 | filename_joblist=fullfile(RootBat,'job_list.txt'); |
---|
| 1475 | fid=fopen(filename_joblist,'w'); |
---|
| 1476 | for p=1:length(batch_file_list) |
---|
| 1477 | oar_command=['oarsub -n CIVX '... |
---|
| 1478 | '-E ' regexprep(batch_file_list{p},'\.bat\>','.stderr') ' -O ' regexprep(batch_file_list{p},'\.bat\>','.stdout ')... |
---|
| 1479 | '-l "/core=1,walltime=' datestr(walltime_onejob/86400,13) '" ' batch_file_list{p}]; |
---|
| 1480 | fprintf(fid,[oar_command '\n']); |
---|
| 1481 | end |
---|
| 1482 | fclose(fid); |
---|
| 1483 | oar_command=['oarsub -t container -n civx-container '... |
---|
| 1484 | '-l /core=' num2str(ncores)... |
---|
| 1485 | ',walltime=' datestr(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,13) ' '... |
---|
| 1486 | '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '... |
---|
| 1487 | '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '... |
---|
| 1488 | '"oar-dispatch -f ' filename_joblist '"']; |
---|
| 1489 | filename_oarcommand=fullfile(RootBat,'oar_command'); |
---|
| 1490 | fid=fopen(filename_oarcommand,'w'); |
---|
[314] | 1491 | fprintf(fid,[oar_command '\n']); |
---|
[482] | 1492 | fclose(fid); |
---|
| 1493 | display(oar_command); |
---|
| 1494 | eval(['! . ' filename_oarcommand]) |
---|
| 1495 | case 'mpilauncher' |
---|
| 1496 | filename_joblist=fullfile(RootBat,'job_list.txt'); |
---|
| 1497 | fid=fopen(filename_joblist,'w'); |
---|
| 1498 | |
---|
| 1499 | for p=1:length(batch_file_list) |
---|
| 1500 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
| 1501 | end |
---|
| 1502 | fclose(fid) |
---|
| 1503 | text_oarscript=[... |
---|
| 1504 | '#!/bin/bash \n'... |
---|
| 1505 | '#OAR -n Mylauncher \n'... |
---|
| 1506 | '#OAR -l node=4/core=5,walltime=0:15:00 \n'... |
---|
| 1507 | '#OAR -E ' fullfile(RootBat,'stderrfile.log') ' \n'... |
---|
| 1508 | '#OAR -O ' fullfile(RootBat,'stdoutfile.log') ' \n'... |
---|
| 1509 | '# ========================================================= \n'... |
---|
| 1510 | '# This simple program launch a multinode parallel OpenMPI mpilauncher \n'... |
---|
| 1511 | '# application for coriolis PIV post-processing. \n'... |
---|
| 1512 | '# OAR uses oarshmost wrapper to propagate the user environement. \n'... |
---|
| 1513 | '# This wrapper assert that the user has the same environment on all the \n'... |
---|
| 1514 | '# allocated nodes (basic behavior needed by most MPI applications). \n'... |
---|
| 1515 | '# \n'... |
---|
| 1516 | '# REQUIREMENT: \n'... |
---|
| 1517 | '# the oarshmost wrapper should be installed in $HOME/bin directory. \n'... |
---|
| 1518 | '# If a different location is used, change the line following the comment "Bidouille" \n'... |
---|
| 1519 | '# ========================================================= \n'... |
---|
| 1520 | '# USER should only modify these 2 lines \n'... |
---|
| 1521 | 'WORKDIR=' pwd ' \n'... |
---|
| 1522 | 'COMMANDE="mpilauncher -f ' filename_joblist '" \n'... |
---|
| 1523 | '# ========================================================= \n'... |
---|
| 1524 | '# DO NOT MODIFY the FOLOWING LINES. (or be carefull) \n'... |
---|
| 1525 | 'echo "job starting on: "`hostname` \n'... |
---|
| 1526 | 'MPINODES="-host `tr [\\\\\\n] [,] <$OAR_NODEFILE |sed -e "s/,$/ /"`" \n'... |
---|
| 1527 | 'NCPUS=`cat $OAR_NODEFILE |wc -l` \n'... |
---|
| 1528 | '#========== Bidouille ============== \n'... |
---|
| 1529 | 'export OMPI_MCA_plm_rsh_agent=oar-envsh \n'...% 'cd $WORKDIR \n'... |
---|
| 1530 | 'CMD="mpirun -np $NCPUS -wdir $WORKDIR $MPINODES $COMMANDE" \n'... |
---|
| 1531 | 'echo "I run: $CMD" \n'... |
---|
| 1532 | '$CMD \n'... |
---|
| 1533 | 'echo "job ending" \n'... |
---|
| 1534 | ]; |
---|
| 1535 | % oarsub -S ./oar.sub |
---|
| 1536 | filename_oarscript=fullfile(RootBat,'oar_command'); |
---|
| 1537 | fid=fopen(filename_oarscript,'w'); |
---|
| 1538 | fprintf(fid,[text_oarscript]); |
---|
| 1539 | fclose(fid); |
---|
| 1540 | eval(['!chmod +x ' filename_oarscript]); |
---|
| 1541 | eval(['!oarsub -S ' filename_oarscript]); |
---|
[465] | 1542 | end |
---|
[482] | 1543 | end |
---|
| 1544 | case {'background','local'} |
---|
| 1545 | switch Param.Program |
---|
| 1546 | case {'civ_matlab'} |
---|
| 1547 | switch Param.RunMode |
---|
| 1548 | case 'background' |
---|
| 1549 | switch computer |
---|
| 1550 | case {'PCWIN','PCWIN64'} |
---|
| 1551 | filename_superbat=fullfile(RootBat,'job_list.bat'); |
---|
| 1552 | fid=fopen(filename_superbat,'w'); |
---|
| 1553 | if fid==-1 |
---|
| 1554 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 1555 | return |
---|
| 1556 | end |
---|
[495] | 1557 | fprintf(fid,['matlab -automation '... |
---|
| 1558 | '-r "addpath(''' regexprep(path_civ,'\\','\\\\') ''');']); |
---|
| 1559 | for p=1:length(batch_file_list) |
---|
| 1560 | fprintf(fid,['run ' regexprep(batch_file_list{p},'\\','\\\\') ';']); |
---|
| 1561 | end |
---|
| 1562 | fprintf(fid, 'exit"'); |
---|
[482] | 1563 | fclose(fid); |
---|
[495] | 1564 | dos([filename_superbat ' &']); |
---|
| 1565 | case {'GLNX86','GLNXA64','MACI64'} |
---|
[482] | 1566 | filename_superbat=fullfile(RootBat,'job_list.sh'); |
---|
| 1567 | fid=fopen(filename_superbat,'w'); |
---|
| 1568 | if fid==-1 |
---|
| 1569 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 1570 | return |
---|
| 1571 | end |
---|
| 1572 | fprintf(fid,['#!/bin/bash \n' ... |
---|
| 1573 | '/etc/sysprofile \n'... |
---|
[498] | 1574 | 'matlab -nodisplay -nosplash -nojvm -logfile <<END_MATLAB \n'... |
---|
[482] | 1575 | 'addpath(''' path_civ ''');\n']); |
---|
| 1576 | for p=1:length(batch_file_list) |
---|
| 1577 | fprintf(fid,['run ' batch_file_list{p} '\n']); |
---|
| 1578 | end |
---|
[547] | 1579 | fprintf(fid, 'exit\nEND_MATLAB\n'); |
---|
[482] | 1580 | fclose(fid); |
---|
| 1581 | system(['chmod +x ' filename_superbat]); |
---|
| 1582 | system([filename_superbat ' &']); |
---|
| 1583 | end |
---|
| 1584 | case 'local' |
---|
| 1585 | for p=1:length(batch_file_list) |
---|
| 1586 | fid=fopen(batch_file_list{p}); |
---|
| 1587 | eval(fscanf(fid,'%s')); |
---|
| 1588 | fclose(fid); |
---|
| 1589 | end |
---|
[465] | 1590 | end |
---|
[482] | 1591 | case {'CivX','CivAll','civ_matlab.sh'} |
---|
| 1592 | switch computer |
---|
| 1593 | case {'PCWIN','PCWIN64'} |
---|
| 1594 | filename_superbat=fullfile(RootBat,'job_list.bat'); |
---|
| 1595 | fid=fopen(filename_superbat,'w'); |
---|
| 1596 | if fid==-1 |
---|
| 1597 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 1598 | return |
---|
| 1599 | end |
---|
| 1600 | for p=1:length(batch_file_list) |
---|
| 1601 | fprintf(fid,['@call "' regexprep(batch_file_list{p},'\\','\\\\') '"' '\n']); |
---|
| 1602 | end |
---|
| 1603 | fclose(fid); |
---|
| 1604 | system(['chmod +x ' filename_superbat]); |
---|
| 1605 | case {'GLNX86','GLNXA64','MACI64'} |
---|
| 1606 | filename_superbat=fullfile(RootBat,'job_list.bat'); |
---|
| 1607 | fid=fopen(filename_superbat,'w'); |
---|
| 1608 | if fid==-1 |
---|
| 1609 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 1610 | return |
---|
| 1611 | end |
---|
| 1612 | for p=1:length(batch_file_list) |
---|
| 1613 | fprintf(fid,['sh ' batch_file_list{p} '\n']); |
---|
| 1614 | end |
---|
| 1615 | fclose(fid); |
---|
| 1616 | system(['chmod +x ' filename_superbat]); |
---|
| 1617 | end |
---|
| 1618 | switch Param.RunMode |
---|
| 1619 | case 'background' |
---|
| 1620 | system([filename_superbat ' &']);% execute main commmand see what it does in dos ? |
---|
| 1621 | case 'local' |
---|
| 1622 | system(filename_superbat); |
---|
[465] | 1623 | end |
---|
[482] | 1624 | end |
---|
[265] | 1625 | end |
---|
| 1626 | |
---|
[2] | 1627 | |
---|
[137] | 1628 | %% save interface state |
---|
[2] | 1629 | if isfield(filecell,'nc') |
---|
| 1630 | if isfield(filecell.nc,'civ2') |
---|
| 1631 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 1632 | else |
---|
| 1633 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 1634 | end |
---|
| 1635 | end |
---|
[343] | 1636 | [RootPath,SubDir,RootFile]=fileparts_uvmat(fileresu); |
---|
| 1637 | namedoc=fullfile(RootPath,SubDir,RootFile); |
---|
[112] | 1638 | detect=1; |
---|
[2] | 1639 | while detect==1 |
---|
| 1640 | namefigfull=[namedoc '.fig']; |
---|
| 1641 | hh=dir(namefigfull); |
---|
| 1642 | if ~isempty(hh) |
---|
| 1643 | detect=1; |
---|
| 1644 | namedoc=[namedoc '.0']; |
---|
| 1645 | else |
---|
| 1646 | detect=0; |
---|
| 1647 | end |
---|
| 1648 | end |
---|
[363] | 1649 | Param=rmfield(Param,'status'); |
---|
| 1650 | Param=rmfield(Param,'xml'); |
---|
[360] | 1651 | t=struct2xml(Param); |
---|
[437] | 1652 | t=set(t,1,'name','Civ');% set the head label |
---|
| 1653 | save(t,[namedoc '.civ.xml']); %save GUI parameters as xml file |
---|
[465] | 1654 | % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
[2] | 1655 | |
---|
[273] | 1656 | %Save info in personal profile (initiate browser next time) TODO |
---|
| 1657 | MenuFile={}; |
---|
| 1658 | dir_perso=prefdir; |
---|
| 1659 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 1660 | if exist(profil_perso,'file') |
---|
| 1661 | hh=load (profil_perso); |
---|
| 1662 | if isfield(hh,'MenuFile') |
---|
| 1663 | MenuFile=hh.MenuFile; |
---|
| 1664 | end |
---|
[289] | 1665 | if isfield(filecell.nc,'civ2') |
---|
| 1666 | MenuFile=[filecell.nc.civ2{1,1}; MenuFile]; |
---|
| 1667 | else |
---|
| 1668 | MenuFile=[filecell.nc.civ1{1,1}; MenuFile]; |
---|
| 1669 | end |
---|
[273] | 1670 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
| 1671 | else |
---|
| 1672 | MenuFile=filecell.ima1.civ1(1,1); |
---|
| 1673 | save (profil_perso,'MenuFile') |
---|
| 1674 | end |
---|
| 1675 | |
---|
[227] | 1676 | %------------------------------------------------------------------------ |
---|
| 1677 | % --- determine the list of reference indices of processing file |
---|
| 1678 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
| 1679 | %------------------------------------------------------------------------ |
---|
| 1680 | errormsg=''; %default error message |
---|
| 1681 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 1682 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 1683 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
| 1684 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 1685 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 1686 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 1687 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
| 1688 | else |
---|
| 1689 | first_j=1; |
---|
| 1690 | last_j=1; |
---|
| 1691 | incr_j=1; |
---|
| 1692 | end |
---|
| 1693 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
| 1694 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
| 1695 | if isnan(first_i)||isnan(first_j) |
---|
| 1696 | errormsg='first field number not defined'; |
---|
| 1697 | elseif isnan(last_i)||isnan(last_j) |
---|
| 1698 | errormsg='last field number not defined'; |
---|
| 1699 | elseif isnan(incr_i)||isnan(incr_j) |
---|
| 1700 | errormsg='increment in field number not defined'; |
---|
| 1701 | elseif last_i < first_i || last_j < first_j |
---|
| 1702 | errormsg='last field number must be larger than the first one'; |
---|
| 1703 | end |
---|
[134] | 1704 | |
---|
[227] | 1705 | %------------------------------------------------------------------------ |
---|
| 1706 | % --- determine the list of filenames and indices needed for launch_job |
---|
[371] | 1707 | %------------------------------------------------------------------------ |
---|
| 1708 | % OUTPUT: |
---|
| 1709 | % filecell: structure of cell arrays {ref_i,ref_j} containing all the filenames involved in the civ process |
---|
| 1710 | % the indices ref_i and ref_j correspond to the list of reference indices |
---|
| 1711 | % .filebase=fullfile(RootPath,RootFile) used to construct mask names, grid names, CivDoc xml file |
---|
| 1712 | % .ima1.civ1,.ima1.civ2: first image for civ1 and civ2 respectively (possibly different) |
---|
| 1713 | % .ima2.civ1,.ima2.civ2: second image for civ1 and civ2 respectively (possibly different) |
---|
| 1714 | % .nc.civ1,.nc.civ2: netcdf files containing civ1 and civ2 data respectively (possibly different) |
---|
| 1715 | % i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2: arrays of files indices, needed for timing records |
---|
[437] | 1716 | function [filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,NomType_nc,file_ref_fix1,file_ref_fix2,compare,errormsg]=... |
---|
[282] | 1717 | set_civ_filenames(handles,ref_i,ref_j,checkbox) |
---|
[12] | 1718 | %------------------------------------------------------------------------ |
---|
[85] | 1719 | filecell=[];%default |
---|
[437] | 1720 | errormsg=''; |
---|
[469] | 1721 | ListProgram=get(handles.Program,'String'); |
---|
| 1722 | CivMode=ListProgram{get(handles.Program,'Value')};%Program to use , CivX or Matlab |
---|
[136] | 1723 | |
---|
[371] | 1724 | %% get the root name and check dir |
---|
| 1725 | RootPath=get(handles.RootPath,'String'); |
---|
[494] | 1726 | SubDirImages=get(handles.SubDirImages,'String'); |
---|
[371] | 1727 | RootFile=get(handles.RootFile,'String'); |
---|
[494] | 1728 | filecell.filebase=fullfile(RootPath,SubDirImages,RootFile); |
---|
[371] | 1729 | if isempty(filecell.filebase) |
---|
[437] | 1730 | errormsg='please open an image with the upper menu option Open/Browse...'; |
---|
[136] | 1731 | return |
---|
| 1732 | end |
---|
[371] | 1733 | if ~exist(RootPath,'dir') |
---|
[437] | 1734 | errormsg=['path to images ' RootPath ' not found']; |
---|
[371] | 1735 | return |
---|
| 1736 | end |
---|
[388] | 1737 | [tild,message]=fileattrib(RootPath); |
---|
[371] | 1738 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[623] | 1739 | errormsg=['No writing access to ' RootPath]; |
---|
[371] | 1740 | return |
---|
| 1741 | end |
---|
| 1742 | %check result directory |
---|
[441] | 1743 | subdir_civ1=regexprep(get(handles.SubdirCiv1,'String'),'^.','');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 1744 | subdir_civ2=regexprep(get(handles.SubdirCiv2,'String'),'^.',''); |
---|
| 1745 | if isequal(subdir_civ1,''),subdir_civ1='civ'; end% put default subdir |
---|
| 1746 | % subdir_civ1=[ '.' subdir_civ1]; |
---|
| 1747 | % subdir_civ2=[ '.' subdir_civ2]; |
---|
[371] | 1748 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[494] | 1749 | subdir_civ1=[SubDirImages '.' subdir_civ1]; |
---|
| 1750 | subdir_civ2=[SubDirImages '.' subdir_civ2]; |
---|
[136] | 1751 | |
---|
[371] | 1752 | %% choose root names depending on ListCompareMode =displacement, shift, PIV or stereo PIV |
---|
| 1753 | ListCompareMode=get(handles.ListCompareMode,'String'); |
---|
| 1754 | compare=ListCompareMode{get(handles.ListCompareMode,'Value')}; |
---|
[136] | 1755 | |
---|
[371] | 1756 | % set the nomenclature type of the nc files depending on the pair mode |
---|
[360] | 1757 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
[2] | 1758 | mode='displacement'; |
---|
| 1759 | else |
---|
[282] | 1760 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 1761 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 1762 | mode=mode_list{mode_value}; |
---|
| 1763 | end |
---|
[371] | 1764 | NomType_ima2=get(handles.NomType,'String'); |
---|
| 1765 | NomType_nc=nomtype2pair(NomType_ima2,mode); |
---|
| 1766 | |
---|
| 1767 | % set the rootfile and image indexing |
---|
| 1768 | RootFile_ima2=get(handles.RootFile,'String');%root file for the second image series |
---|
| 1769 | ext_ima=get(handles.ImaExt,'String'); % image extension (the same for all images) |
---|
| 1770 | switch compare |
---|
[591] | 1771 | case {'PIV','PIV volume'} |
---|
[371] | 1772 | RootFile_ima1=RootFile_ima2;% root name of the two image series is the same |
---|
| 1773 | NomType_ima1=NomType_ima2;% the index of the first image follows the index of the second one |
---|
| 1774 | RootFile_nc=RootFile_ima2; |
---|
| 1775 | case 'displacement' |
---|
| 1776 | RootFile_ima1=get(handles.RootFile_1,'String');% root name of the first image series set by handles.RootFile_1 |
---|
| 1777 | NomType_ima1='';% no indexing of the first image, a fixed reference for the whole series |
---|
| 1778 | RootFile_nc=RootFile_ima2; |
---|
| 1779 | case 'shift' |
---|
| 1780 | RootFile_ima1=get(handles.RootFile_1,'String');% root name of the first image series set by handles.RootFile_1 |
---|
| 1781 | NomType_ima1=NomType_ima2;% the index of the first image follows the index of the second one |
---|
| 1782 | RootFile_nc=[RootFile_ima1 '-' RootFile_ima2]; |
---|
[122] | 1783 | end |
---|
[360] | 1784 | |
---|
[371] | 1785 | %determine the list of file indices involved |
---|
| 1786 | [i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2]=... |
---|
[227] | 1787 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
[371] | 1788 | |
---|
[282] | 1789 | %determine the new filebase for 'displacement' ListPairMode (comparison of two series) |
---|
[371] | 1790 | %filebase_B=filebase;% root name of the second field series for stereo |
---|
| 1791 | % filebase_A=filebase;%default |
---|
| 1792 | % if strcmp(compare,'PIV') |
---|
| 1793 | % filebase_AB=filebase; |
---|
| 1794 | % else |
---|
| 1795 | % [Path2,Name2]=fileparts(filebase_B); |
---|
| 1796 | % Name1=RootFile_ima1; |
---|
| 1797 | % filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 1798 | % end |
---|
| 1799 | % [RootPath_AB,RootFile_AB]=fileparts(filebase_AB); |
---|
| 1800 | % % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_B); |
---|
| 1801 | % [RootPath_ima2,RootFile_ima2]=fileparts(filebase_B); |
---|
| 1802 | % [RootPath_nc,RootFile_nc]=fileparts(filebase_B);%default |
---|
| 1803 | % if strcmp(compare,'displacement') |
---|
| 1804 | % % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_B); |
---|
| 1805 | % % [RootPath_ima2,RootFile_ima2]=fileparts(filebase_B); |
---|
| 1806 | % [RootPath_nc,RootFile_nc]=fileparts(filebase_B); |
---|
| 1807 | % elseif strcmp(compare,'shift') |
---|
| 1808 | % RootPath_nc=RootPath_AB; |
---|
| 1809 | % RootFile_nc=RootFile_AB; |
---|
| 1810 | % end |
---|
| 1811 | % else |
---|
| 1812 | % filebase_ima1=filebase_B; |
---|
| 1813 | % filebase_ima2=filebase_B; |
---|
| 1814 | % filebase_nc=filebase_B; |
---|
| 1815 | % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_ima1); |
---|
| 1816 | % [RootPath_ima2,RootFile_ima2]=fileparts(filebase_ima2); |
---|
| 1817 | % [RootPath_nc,RootFile_nc]=fileparts(filebase_nc); |
---|
| 1818 | % [RootPath_A,RootFile_A]=fileparts(filebase_A); |
---|
| 1819 | |
---|
[353] | 1820 | |
---|
[371] | 1821 | %% determine reference files for fix: |
---|
[2] | 1822 | file_ref_fix1={};%default |
---|
| 1823 | file_ref_fix2={}; |
---|
[371] | 1824 | nbfield=length(i1_civ1); |
---|
| 1825 | nbslice=length(j1_civ1); |
---|
[282] | 1826 | if checkbox(2)==1% fix1 performed |
---|
[2] | 1827 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 1828 | if ~isempty(ref) |
---|
[137] | 1829 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1830 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1831 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 1832 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1833 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1834 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 1835 | num_i_ref=first_i:incr_i:last_i; |
---|
| 1836 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 1837 | if isequal(mode,'displacement') |
---|
| 1838 | num_i1=num_i_ref; |
---|
[371] | 1839 | num_i2=num_i_ref; |
---|
[2] | 1840 | num_j1=num_j_ref; |
---|
| 1841 | num_j2=num_j_ref; |
---|
| 1842 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 1843 | num_i1=num_i_ref; |
---|
| 1844 | num_i2=num_i1; |
---|
| 1845 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 1846 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 1847 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 1848 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 1849 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 1850 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 1851 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 1852 | if isempty(ref.num_a) |
---|
| 1853 | ref.num_a=1; |
---|
| 1854 | end |
---|
| 1855 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 1856 | num_j2=num_j1; |
---|
| 1857 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 1858 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 1859 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 1860 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 1861 | num_i2=num_i1; |
---|
| 1862 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 1863 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 1864 | end |
---|
| 1865 | for ifile=1:nbfield |
---|
| 1866 | for j=1:nbslice |
---|
[371] | 1867 | [RootPathRef,RootFile]=fileparts(ref.filebase); |
---|
| 1868 | file_ref=fullfile_uvmat(RootPathRef,ref.subdir,RootFile,'.nc',ref.NomType,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j)); |
---|
[2] | 1869 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 1870 | if ~exist(file_ref,'file') |
---|
[437] | 1871 | errormsg=['reference file ' file_ref ' not found for fix1']; |
---|
[2] | 1872 | return |
---|
| 1873 | end |
---|
| 1874 | end |
---|
| 1875 | end |
---|
| 1876 | end |
---|
| 1877 | end |
---|
| 1878 | |
---|
[371] | 1879 | %% determine reference files for fix2: |
---|
[282] | 1880 | if checkbox(5)==1% fix2 performed |
---|
[2] | 1881 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 1882 | if ~isempty(ref) |
---|
[127] | 1883 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1884 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1885 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 1886 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1887 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1888 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[229] | 1889 | num_i_ref=first_i:incr_i:last_i; |
---|
| 1890 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 1891 | if isequal(mode,'displacement') |
---|
| 1892 | num_i1=num_i_ref; |
---|
| 1893 | num_i2=num_i_ref; |
---|
| 1894 | num_j1=num_j_ref; |
---|
| 1895 | num_j2=num_j_ref; |
---|
| 1896 | elseif isequal(mode,'pair j1-j2') |
---|
| 1897 | num_i1=num_i_ref; |
---|
| 1898 | num_i2=num_i1; |
---|
| 1899 | num_j1=ref.num_a; |
---|
| 1900 | num_j2=ref.num_b; |
---|
| 1901 | elseif isequal(mode,'series(Di)') |
---|
| 1902 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 1903 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 1904 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 1905 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 1906 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 1907 | num_j2=num_j1; |
---|
| 1908 | elseif isequal(mode,'series(Dj)') |
---|
| 1909 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 1910 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 1911 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 1912 | num_i2=num_i1; |
---|
| 1913 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 1914 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 1915 | end |
---|
| 1916 | for ifile=1:nbfield |
---|
| 1917 | for j=1:nbslice |
---|
[371] | 1918 | [RootPathRef,RootFile]=fileparts(ref.filebase); |
---|
| 1919 | file_ref=fullfile_uvmat(RootPathRef,ref.subdir,RootFile,'.nc',ref.NomType,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j)); |
---|
[2] | 1920 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 1921 | if ~exist(file_ref,'file') |
---|
[437] | 1922 | errormsg=['reference file ' file_ref ' not found for fix2']; |
---|
[2] | 1923 | return |
---|
| 1924 | end |
---|
| 1925 | end |
---|
| 1926 | end |
---|
| 1927 | end |
---|
| 1928 | end |
---|
| 1929 | |
---|
[371] | 1930 | %% check the existence of the netcdf and image files involved |
---|
[282] | 1931 | % %%%%%%%%%%%% case CheckCiv1 activated %%%%%%%%%%%%% |
---|
| 1932 | if checkbox(1)==1; |
---|
[112] | 1933 | detect=1; |
---|
[127] | 1934 | vers=0; |
---|
| 1935 | subdir_civ1_new=subdir_civ1; |
---|
[482] | 1936 | answer='No'; |
---|
[153] | 1937 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[122] | 1938 | for ifile=1:nbfield |
---|
[112] | 1939 | for j=1:nbslice |
---|
[371] | 1940 | filename=fullfile_uvmat(RootPath,subdir_civ1_new,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); |
---|
[112] | 1941 | detect=exist(filename,'file')==2; |
---|
| 1942 | if detect% if a netcdf file already exists |
---|
[482] | 1943 | if strcmp(answer,'No') |
---|
| 1944 | answer=msgbox_uvmat('INPUT_Y-N',['overwrite existing civ files in ' subdir_civ1_new]); |
---|
| 1945 | end |
---|
[452] | 1946 | if strcmp(answer,'Yes') |
---|
| 1947 | detect=0; |
---|
| 1948 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 1949 | else |
---|
[446] | 1950 | r=regexp(subdir_civ1_new,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number |
---|
| 1951 | if isempty(r) |
---|
| 1952 | r(1).root=[subdir_civ1_new '_']; |
---|
| 1953 | r(1).num1='0'; |
---|
| 1954 | end |
---|
| 1955 | subdir_civ1_new=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 |
---|
| 1956 | subdir_civ2=subdir_civ1_new; |
---|
[127] | 1957 | end |
---|
[112] | 1958 | break |
---|
| 1959 | end |
---|
| 1960 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 1961 | end |
---|
| 1962 | if detect% if a netcdf file already exists |
---|
| 1963 | break |
---|
| 1964 | end |
---|
| 1965 | end |
---|
[134] | 1966 | |
---|
[363] | 1967 | %create the new SubdirCiv1 |
---|
[371] | 1968 | if ~exist(fullfile(RootPath,subdir_civ1_new),'dir') |
---|
| 1969 | [xx,msg1]=mkdir(fullfile(RootPath,subdir_civ1_new)); |
---|
[128] | 1970 | if ~strcmp(msg1,'') |
---|
[437] | 1971 | errormsg=['cannot create ' subdir_civ1_new ': ' msg1];%error message for directory creation |
---|
[122] | 1972 | return |
---|
[163] | 1973 | elseif isunix |
---|
[371] | 1974 | [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 1975 | if ~strcmp(msg2,'') |
---|
[437] | 1976 | errormsg=['pb of permission for ' fullfile(RootPath,subdir_civ1_new) ': ' msg2];%error message for directory creation |
---|
[128] | 1977 | return |
---|
| 1978 | end |
---|
[112] | 1979 | end |
---|
| 1980 | end |
---|
| 1981 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 1982 | for ifile=1:nbfield |
---|
| 1983 | for j=1:nbslice |
---|
[371] | 1984 | filename=fullfile_uvmat(RootPath,subdir_civ1_new,RootFile_A,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); |
---|
[112] | 1985 | detect=exist(filename,'file')==2; |
---|
[2] | 1986 | if detect% if a netcdf file already exists |
---|
[137] | 1987 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 1988 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 1989 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 1990 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 1991 | else |
---|
| 1992 | vers=vers+1; |
---|
[137] | 1993 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 1994 | end |
---|
| 1995 | subdir_civ2=subdir_civ1; |
---|
| 1996 | break |
---|
[2] | 1997 | end |
---|
[112] | 1998 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 1999 | end |
---|
| 2000 | if detect% if a netcdf file already exists |
---|
| 2001 | break |
---|
| 2002 | end |
---|
| 2003 | end |
---|
[363] | 2004 | %create the new SubdirCiv1 |
---|
[371] | 2005 | if ~exist(fullfile(RootPath,subdir_civ1_new),'dir') |
---|
| 2006 | [xx,msg1]=mkdir(fullfile(RootPath,subdir_civ1_new)); |
---|
[252] | 2007 | if ~strcmp(msg1,'') |
---|
[437] | 2008 | errormsg=['cannot create ' subdir_civ1_new ': ' msg1]; |
---|
[122] | 2009 | return |
---|
[623] | 2010 | elseif isunix |
---|
[371] | 2011 | [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 2012 | if ~strcmp(msg2,'') |
---|
[437] | 2013 | errormsg=['pb of permission for ' subdir_civ1_new ': ' msg2];%error message for directory creation |
---|
[128] | 2014 | return |
---|
| 2015 | end |
---|
[112] | 2016 | end |
---|
| 2017 | end |
---|
| 2018 | end |
---|
| 2019 | end |
---|
[127] | 2020 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 2021 | % get image names |
---|
| 2022 | for ifile=1:nbfield |
---|
[112] | 2023 | for j=1:nbslice |
---|
[494] | 2024 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j)); |
---|
[2] | 2025 | idetect(j)=exist(filename,'file')==2; |
---|
| 2026 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
[494] | 2027 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j)); |
---|
[2] | 2028 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2029 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 2030 | end |
---|
| 2031 | [idetectmin,indexj]=min(idetect); |
---|
| 2032 | if idetectmin==0, |
---|
[437] | 2033 | errormsg=[filecell.ima1.civ1{ifile,indexj} ' not found']; |
---|
[112] | 2034 | return |
---|
| 2035 | end |
---|
| 2036 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2037 | if idetectmin==0, |
---|
[437] | 2038 | errormsg=[filecell.ima2.civ1{ifile,indexj} ' not found']; |
---|
[112] | 2039 | return |
---|
| 2040 | end |
---|
| 2041 | end |
---|
| 2042 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2043 | for ifile=1:nbfield |
---|
| 2044 | for j=1:nbslice |
---|
[371] | 2045 | filename=fullfile_uvmat(RootPath,'',RootFile_A,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j)); |
---|
[112] | 2046 | idetect(j)=exist(filename,'file')==2; |
---|
| 2047 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
[371] | 2048 | filename=fullfile_uvmat(RootPath,'',RootFile_A,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j)); |
---|
[112] | 2049 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2050 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2051 | end |
---|
[2] | 2052 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2053 | if idetectmin==0, |
---|
[437] | 2054 | errormsg=[filecell.imaA1.civ1{ifile,indexj} ' not found']; |
---|
[2] | 2055 | return |
---|
[112] | 2056 | end |
---|
[2] | 2057 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2058 | if idetectmin==0, |
---|
[437] | 2059 | errormsg=[filecell.imaA2.civ1{ifile,indexj} ' not found']; |
---|
[2] | 2060 | return |
---|
[112] | 2061 | end |
---|
| 2062 | end |
---|
[2] | 2063 | end |
---|
[112] | 2064 | |
---|
[282] | 2065 | %%%%%%%%%%%%% checkfix1 or checkpatch1 activated but no checkciv1 %%%%%%%%%%%%% |
---|
| 2066 | elseif (checkbox(2)==1 || checkbox(3)==1); |
---|
[2] | 2067 | for ifile=1:nbfield |
---|
| 2068 | for j=1:nbslice |
---|
[371] | 2069 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); |
---|
[112] | 2070 | detect=exist(filename,'file')==2; |
---|
[122] | 2071 | if detect==0 |
---|
[437] | 2072 | errormsg=[filename ' not found']; |
---|
[122] | 2073 | return |
---|
| 2074 | end |
---|
[2] | 2075 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2076 | end |
---|
| 2077 | end |
---|
| 2078 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2079 | for ifile=1:nbfield |
---|
| 2080 | for j=1:nbslice |
---|
[371] | 2081 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_A,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); |
---|
[112] | 2082 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2083 | if ~exist(filename,'file') |
---|
[437] | 2084 | errormsg=['input file ' filename ' not found']; |
---|
[112] | 2085 | return |
---|
[2] | 2086 | end |
---|
| 2087 | end |
---|
[112] | 2088 | end |
---|
[2] | 2089 | end |
---|
| 2090 | end |
---|
| 2091 | |
---|
[282] | 2092 | %%%%%%%%%%%%% if checkciv2 performed with pairs different than checkciv1 %%%%%%%%%%%%% |
---|
[2] | 2093 | testdiff=0; |
---|
[282] | 2094 | if (checkbox(4)==1)&&... |
---|
| 2095 | ((get(handles.ListPairCiv1,'Value')~=get(handles.ListPairCiv2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2096 | testdiff=1; |
---|
[112] | 2097 | detect=1; |
---|
[127] | 2098 | vers=0; |
---|
| 2099 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2100 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2101 | for ifile=1:nbfield |
---|
| 2102 | for j=1:nbslice |
---|
[371] | 2103 | filename=fullfile_uvmat(RootPath,subdir_civ2_new,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[112] | 2104 | detect=exist(filename,'file')==2; |
---|
| 2105 | if detect% if a netcdf file already exists |
---|
[127] | 2106 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2107 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2108 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2109 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2110 | else |
---|
| 2111 | vers=vers+1; |
---|
| 2112 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2113 | end |
---|
[112] | 2114 | break |
---|
| 2115 | end |
---|
| 2116 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2117 | end |
---|
| 2118 | if detect% if a netcdf file already exists |
---|
| 2119 | break |
---|
| 2120 | end |
---|
| 2121 | end |
---|
[128] | 2122 | %create the new subdir_civ2_new |
---|
[371] | 2123 | if ~exist(fullfile(RootPath,subdir_civ2_new),'dir') |
---|
| 2124 | [xx,m2]=mkdir(fullfile(RootPath,subdir_civ2_new)); |
---|
[623] | 2125 | if isunix |
---|
[371] | 2126 | [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2127 | if ~isequal(m2,'') |
---|
[437] | 2128 | errormsg=['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2]; |
---|
[122] | 2129 | return |
---|
[112] | 2130 | end |
---|
[623] | 2131 | end |
---|
[112] | 2132 | end |
---|
| 2133 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2134 | for ifile=1:nbfield |
---|
| 2135 | for j=1:nbslice |
---|
[371] | 2136 | filename=fullfile_uvmat(RootPath,subdir_civ2_new,RootFile_A,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[112] | 2137 | detect=exist(filename,'file')==2; |
---|
[2] | 2138 | if detect% if a netcdf file already exists |
---|
[127] | 2139 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2140 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2141 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2142 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2143 | else |
---|
| 2144 | vers=vers+1; |
---|
| 2145 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2146 | end |
---|
[112] | 2147 | break |
---|
[2] | 2148 | end |
---|
[112] | 2149 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2150 | end |
---|
| 2151 | if detect% if a netcdf file already exists |
---|
| 2152 | break |
---|
| 2153 | end |
---|
| 2154 | end |
---|
[122] | 2155 | subdir_civ2=subdir_civ2_new; |
---|
[363] | 2156 | %create the new SubdirCiv1 |
---|
[371] | 2157 | if ~exist(fullfile(RootPath,subdir_civ2_new),'dir') |
---|
[127] | 2158 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
[623] | 2159 | if isunix |
---|
[371] | 2160 | [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2161 | if ~isequal(m2,'') |
---|
[437] | 2162 | errormsg= ['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2];%error message for directory creation |
---|
[122] | 2163 | return |
---|
[112] | 2164 | end |
---|
[623] | 2165 | end |
---|
[112] | 2166 | end |
---|
| 2167 | end |
---|
| 2168 | end |
---|
[127] | 2169 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2170 | end |
---|
| 2171 | |
---|
[282] | 2172 | %%%%%%%%%%%%% if checkciv2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2173 | if checkbox(4)==1 || checkbox(5)==1 || checkbox(6)==1 %civ2 |
---|
| 2174 | %check source netcdf file of checkciv1 estimates |
---|
| 2175 | if checkbox(1)==0; %no civ1 performed |
---|
[2] | 2176 | for ifile=1:nbfield |
---|
| 2177 | for j=1:nbslice |
---|
[371] | 2178 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j));% |
---|
[2] | 2179 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2180 | if ~exist(filename,'file') |
---|
[437] | 2181 | errormsg=['input file ' filename ' not found']; |
---|
[2] | 2182 | return |
---|
| 2183 | end |
---|
| 2184 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
[282] | 2185 | if checkbox(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
[248] | 2186 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
[364] | 2187 | if isfield(Data,'Txt') |
---|
[437] | 2188 | errormsg=Data.Txt; |
---|
[364] | 2189 | return |
---|
| 2190 | elseif ~isempty(Data.CivStage)% case of new civ files |
---|
| 2191 | if Data.CivStage<4 %test for civ files |
---|
[437] | 2192 | errormsg=['no civ2 data in ' filename]; |
---|
[2] | 2193 | return |
---|
[364] | 2194 | end |
---|
[248] | 2195 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[437] | 2196 | errormsg=['no civ2 data in ' filename]; |
---|
[248] | 2197 | return |
---|
[112] | 2198 | end |
---|
[282] | 2199 | elseif checkbox(3)==0; %check the existence of patch if it is not calculated |
---|
[275] | 2200 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch'); |
---|
[437] | 2201 | if isfield(Data,'Txt') |
---|
| 2202 | errormsg=Data.Txt; |
---|
| 2203 | return |
---|
| 2204 | elseif ~isempty(Data.CivStage) |
---|
[248] | 2205 | if Data.CivStage<3 %test for civ files |
---|
[437] | 2206 | errormsg=['no patch data in ' filename]; |
---|
[248] | 2207 | return |
---|
| 2208 | end |
---|
| 2209 | elseif isempty(Data.patch)||isequal(Data.patch,0) |
---|
[437] | 2210 | errormsg=['no patch data in ' filename]; |
---|
[2] | 2211 | return |
---|
| 2212 | end |
---|
[112] | 2213 | end |
---|
[2] | 2214 | end |
---|
| 2215 | end |
---|
| 2216 | end |
---|
| 2217 | if strcmp(compare,'stereo PIV') |
---|
| 2218 | for ifile=1:nbfield |
---|
| 2219 | for j=1:nbslice |
---|
[371] | 2220 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_A,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[2] | 2221 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2222 | if ~exist(filename,'file') |
---|
[437] | 2223 | errormsg=['input file ' filename ' not found']; |
---|
[2] | 2224 | return |
---|
| 2225 | end |
---|
| 2226 | end |
---|
| 2227 | end |
---|
| 2228 | end |
---|
| 2229 | end |
---|
[112] | 2230 | |
---|
| 2231 | detect=1; |
---|
[282] | 2232 | % while detect==1%creates a new subdir if the netcdf files already contain checkciv2 data |
---|
[112] | 2233 | for ifile=1:nbfield |
---|
| 2234 | for j=1:nbslice |
---|
[371] | 2235 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[112] | 2236 | detect=exist(filename,'file')==2; |
---|
| 2237 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2238 | end |
---|
[112] | 2239 | end |
---|
[282] | 2240 | %get first image names for checkciv2 |
---|
[371] | 2241 | if checkbox(1)==1 && isequal(i1_civ1,i1_civ2) && isequal(j1_civ1,j1_civ2) |
---|
[2] | 2242 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
[282] | 2243 | elseif checkbox(4)==1 |
---|
[2] | 2244 | for ifile=1:nbfield |
---|
| 2245 | for j=1:nbslice |
---|
[494] | 2246 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ2(ifile),[],j1_civ2(j)); |
---|
[2] | 2247 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2248 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2249 | end |
---|
[112] | 2250 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2251 | if idetectmin==0, |
---|
[437] | 2252 | errormsg=['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']; |
---|
[112] | 2253 | return |
---|
[2] | 2254 | end |
---|
| 2255 | end |
---|
| 2256 | end |
---|
| 2257 | |
---|
[282] | 2258 | %get second image names for checkciv2 |
---|
[371] | 2259 | if checkbox(1)==1 && isequal(i2_civ1,i2_civ2) && isequal(j2_civ1,j2_civ2) |
---|
[2] | 2260 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
[282] | 2261 | elseif checkbox(4)==1 |
---|
[2] | 2262 | for ifile=1:nbfield |
---|
| 2263 | for j=1:nbslice |
---|
[494] | 2264 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ2(ifile),[],j2_civ2(j)); |
---|
[2] | 2265 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2266 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2267 | end |
---|
[112] | 2268 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2269 | if idetectmin==0, |
---|
[437] | 2270 | errormsg=['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']; |
---|
[112] | 2271 | return |
---|
[2] | 2272 | end |
---|
| 2273 | end |
---|
| 2274 | end |
---|
| 2275 | end |
---|
[282] | 2276 | if (checkbox(5) || checkbox(6)) && ~checkbox(4) % need to read an existing netcdf civ2 file |
---|
[2] | 2277 | if ~testdiff |
---|
| 2278 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2279 | else % check the civ2 files |
---|
[2] | 2280 | for ifile=1:nbfield |
---|
| 2281 | for j=1:nbslice |
---|
[371] | 2282 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[2] | 2283 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2284 | if ~exist(filename,'file') |
---|
[437] | 2285 | errormsg=['input file ' filename ' not found']; |
---|
[2] | 2286 | return |
---|
| 2287 | else |
---|
[248] | 2288 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2289 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
[437] | 2290 | errormsg=['no civ2 data in ' filename]; |
---|
[248] | 2291 | return |
---|
| 2292 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[437] | 2293 | errormsg=['no civ2 data in ' filename]; |
---|
[2] | 2294 | return |
---|
| 2295 | end |
---|
| 2296 | end |
---|
| 2297 | end |
---|
| 2298 | end |
---|
| 2299 | end |
---|
| 2300 | end |
---|
| 2301 | |
---|
| 2302 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2303 | if strcmp(compare,'stereo PIV') |
---|
[282] | 2304 | if checkbox(3) && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2305 | for ifile=1:nbfield |
---|
| 2306 | for j=1:nbslice |
---|
[371] | 2307 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_AB,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); |
---|
[2] | 2308 | filecell.st(ifile,j)={filename}; |
---|
| 2309 | end |
---|
| 2310 | end |
---|
| 2311 | end |
---|
[282] | 2312 | if checkbox(6) && isequal(get(handles.CheckStereo,'Value'),1) |
---|
[2] | 2313 | for ifile=1:nbfield |
---|
| 2314 | for j=1:nbslice |
---|
[371] | 2315 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_AB,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[2] | 2316 | filecell.st(ifile,j)={filename}; |
---|
| 2317 | end |
---|
| 2318 | end |
---|
[112] | 2319 | end |
---|
[2] | 2320 | end |
---|
[494] | 2321 | set(handles.SubdirCiv1,'String',regexprep(subdir_civ1,['^' SubDirImages],''));%suppress the root SuddirImages;);%update the edit box |
---|
| 2322 | set(handles.SubdirCiv2,'String',regexprep(subdir_civ2,['^' SubDirImages],''));%update the edit box |
---|
[2] | 2323 | |
---|
[388] | 2324 | % For CivX COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
| 2325 | if strcmp(CivMode,'CivX') |
---|
[494] | 2326 | NomType_imanew1=NomType_ima1; |
---|
| 2327 | NomType_imanew2=NomType_ima2; |
---|
[388] | 2328 | if ~isequal(ext_ima,'.png') |
---|
[494] | 2329 | if checkbox(1) %if civ1 is performed |
---|
[784] | 2330 | [FileInfo,MovieObject]=get_file_info(filecell.ima1.civ1{1}); |
---|
[783] | 2331 | FileType=FileInfo.FileType; |
---|
[494] | 2332 | check_j=0; |
---|
| 2333 | if strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader')||strcmp(FileType,'multimage') |
---|
| 2334 | if max(j1_civ1)>1 |
---|
| 2335 | check_j=1; |
---|
| 2336 | NomType_imanew1='_1_1'; |
---|
[388] | 2337 | else |
---|
[494] | 2338 | NomType_imanew1='_1'; |
---|
[388] | 2339 | end |
---|
| 2340 | end |
---|
| 2341 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
| 2342 | for ifile=1:nbfield |
---|
| 2343 | waitbar(ifile/nbfield); |
---|
| 2344 | for j=1:nbslice |
---|
[494] | 2345 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j)); |
---|
[388] | 2346 | if ~exist(filename,'file') |
---|
[494] | 2347 | if check_j |
---|
| 2348 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ1(j)); |
---|
| 2349 | else |
---|
| 2350 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ1(ifile)); |
---|
| 2351 | end |
---|
| 2352 | imwrite(uint16(sum(A,3)),filename,'BitDepth',16); |
---|
[388] | 2353 | end |
---|
| 2354 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
[494] | 2355 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,'.png',NomType_imanew1,i2_civ1(ifile),[],j2_civ1(j)); |
---|
[388] | 2356 | if ~exist(filename,'file') |
---|
[494] | 2357 | if check_j |
---|
| 2358 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j2_civ1(j)); |
---|
| 2359 | else |
---|
| 2360 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i2_civ1(ifile)); |
---|
| 2361 | end |
---|
| 2362 | imwrite(uint16(sum(A,3)),filename,'BitDepth',16); |
---|
[388] | 2363 | end |
---|
| 2364 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[112] | 2365 | end |
---|
[2] | 2366 | end |
---|
[388] | 2367 | close(h) |
---|
[2] | 2368 | end |
---|
[388] | 2369 | if checkbox(4) %if civ2 is performed |
---|
[784] | 2370 | [FileInfo,MovieObject]=get_file_info(filecell.ima1.civ2{1}); |
---|
[783] | 2371 | FileType=FileInfo.FileType; |
---|
[494] | 2372 | check_j=0; |
---|
| 2373 | if strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader')||strcmp(FileType,'multimage') |
---|
| 2374 | if max(j1_civ2)>1 |
---|
| 2375 | check_j=1; |
---|
| 2376 | NomType_imanew1='_1_1'; |
---|
| 2377 | else |
---|
| 2378 | NomType_imanew1='_1'; |
---|
| 2379 | end |
---|
| 2380 | end |
---|
[388] | 2381 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
| 2382 | for ifile=1:nbfield |
---|
| 2383 | waitbar(ifile/nbfield); |
---|
| 2384 | for j=1:nbslice |
---|
[494] | 2385 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j)); |
---|
[388] | 2386 | if ~exist(filename,'file') |
---|
[494] | 2387 | if check_j |
---|
| 2388 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ2(j)); |
---|
| 2389 | else |
---|
| 2390 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ2(ifile)); |
---|
| 2391 | end |
---|
| 2392 | imwrite(uint16(sum(A,3)),filename,'BitDepth',16); |
---|
[388] | 2393 | end |
---|
| 2394 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
[494] | 2395 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j)); |
---|
[388] | 2396 | if ~exist(filename,'file') |
---|
[494] | 2397 | if check_j |
---|
| 2398 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ2(j)); |
---|
| 2399 | else |
---|
| 2400 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ2(ifile)); |
---|
| 2401 | end |
---|
| 2402 | imwrite(uint16(sum(A,3)),filename,'BitDepth',16); |
---|
[388] | 2403 | end |
---|
| 2404 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[112] | 2405 | end |
---|
[2] | 2406 | end |
---|
[388] | 2407 | close(h); |
---|
[2] | 2408 | end |
---|
| 2409 | end |
---|
| 2410 | end |
---|
| 2411 | |
---|
[12] | 2412 | %------------------------------------------------------------------------ |
---|
[227] | 2413 | % --- determine the list of index pairs of processing file |
---|
[494] | 2414 | function [i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2]=... |
---|
[227] | 2415 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
| 2416 | %------------------------------------------------------------------------ |
---|
| 2417 | |
---|
[282] | 2418 | list_civ1=get(handles.ListPairCiv1,'String'); |
---|
| 2419 | index_civ1=get(handles.ListPairCiv1,'Value'); |
---|
[227] | 2420 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
| 2421 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 2422 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 2423 | return |
---|
| 2424 | end |
---|
[282] | 2425 | list_civ2=get(handles.ListPairCiv2,'String'); |
---|
| 2426 | index_civ2=get(handles.ListPairCiv2,'Value'); |
---|
[227] | 2427 | if index_civ2>length(list_civ2) |
---|
| 2428 | list_civ2=list_civ1; |
---|
| 2429 | index_civ2=index_civ1; |
---|
| 2430 | end |
---|
| 2431 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 2432 | |
---|
| 2433 | if isequal (mode,'series(Di)') |
---|
| 2434 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
[494] | 2435 | i1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
| 2436 | i2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
| 2437 | j1_civ1=ref_j; |
---|
| 2438 | j2_civ1=ref_j; |
---|
| 2439 | i1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
| 2440 | i2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
| 2441 | j1_civ2=ref_j; |
---|
| 2442 | j2_civ2=ref_j; |
---|
[227] | 2443 | |
---|
| 2444 | % adjust the first and last field number |
---|
| 2445 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2446 | if isnan(lastfield) |
---|
[494] | 2447 | indsel=find((i1_civ1 >= 1)&(i1_civ2 >= 1)); |
---|
[227] | 2448 | else |
---|
[494] | 2449 | indsel=find((i2_civ1 <= lastfield)&(i2_civ2 <= lastfield)&(i1_civ1 >= 1)&(i1_civ2 >= 1)); |
---|
[227] | 2450 | end |
---|
| 2451 | if length(indsel)>=1 |
---|
| 2452 | firstind=indsel(1); |
---|
| 2453 | lastind=indsel(end); |
---|
| 2454 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
| 2455 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
| 2456 | ref_i=ref_i(indsel); |
---|
[494] | 2457 | i1_civ1=i1_civ1(indsel); |
---|
| 2458 | i1_civ2=i1_civ2(indsel); |
---|
| 2459 | i2_civ1=i2_civ1(indsel); |
---|
| 2460 | i2_civ2=i2_civ2(indsel); |
---|
[227] | 2461 | end |
---|
| 2462 | elseif isequal (mode,'series(Dj)') |
---|
| 2463 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
[494] | 2464 | i1_civ1=ref_i;% set of first image numbers |
---|
| 2465 | i2_civ1=ref_i; |
---|
| 2466 | j1_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
| 2467 | j2_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
| 2468 | i1_civ2=ref_i; |
---|
| 2469 | i2_civ2=ref_i; |
---|
| 2470 | j1_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
| 2471 | j2_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
[227] | 2472 | % adjust the first and last field number |
---|
| 2473 | if isnan(lastfield_j) |
---|
[494] | 2474 | indsel=find((j1_civ1 >= 1)&(j1_civ2 >= 1)); |
---|
[227] | 2475 | else |
---|
[494] | 2476 | indsel=find((j2_civ1 <= lastfield_j)&(j2_civ2 <= lastfield_j)&(j1_civ1 >= 1)&(j1_civ2 >= 1)); |
---|
[227] | 2477 | end |
---|
| 2478 | if length(indsel)>=1 |
---|
| 2479 | firstind=indsel(1); |
---|
| 2480 | lastind=indsel(end); |
---|
| 2481 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
| 2482 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
| 2483 | ref_j=ref_j(indsel); |
---|
[494] | 2484 | j1_civ1=j1_civ1(indsel); |
---|
| 2485 | j2_civ1=j2_civ1(indsel); |
---|
| 2486 | j1_civ2=j1_civ2(indsel); |
---|
| 2487 | j2_civ2=j2_civ2(indsel); |
---|
[227] | 2488 | end |
---|
| 2489 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[282] | 2490 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[494] | 2491 | i1_civ1=ref_i; |
---|
| 2492 | i2_civ1=ref_i; |
---|
| 2493 | j1_civ1=displ_num(1,index_civ1); |
---|
| 2494 | j2_civ1=displ_num(2,index_civ1); |
---|
| 2495 | i1_civ2=ref_i; |
---|
| 2496 | i2_civ2=ref_i; |
---|
| 2497 | j1_civ2=displ_num(1,index_civ2); |
---|
| 2498 | j2_civ2=displ_num(2,index_civ2); |
---|
[227] | 2499 | elseif isequal(mode,'displacement') |
---|
[494] | 2500 | i1_civ1=ref_i; |
---|
| 2501 | i2_civ1=ref_i; |
---|
| 2502 | j1_civ1=ref_j; |
---|
| 2503 | j2_civ1=ref_j; |
---|
| 2504 | i1_civ2=ref_i; |
---|
| 2505 | i2_civ2=ref_i; |
---|
| 2506 | j1_civ2=ref_j; |
---|
| 2507 | j2_civ2=ref_j; |
---|
[227] | 2508 | end |
---|
| 2509 | |
---|
| 2510 | %------------------------------------------------------------------------ |
---|
[309] | 2511 | % --- Executes on button press in ListCompareMode. |
---|
| 2512 | function ListCompareMode_Callback(hObject, eventdata, handles) |
---|
[12] | 2513 | %------------------------------------------------------------------------ |
---|
[371] | 2514 | ListCompareMode=get(handles.ListCompareMode,'String'); |
---|
| 2515 | option=ListCompareMode{get(handles.ListCompareMode,'Value')}; |
---|
[591] | 2516 | switch option |
---|
| 2517 | case 'PIV' |
---|
| 2518 | set(handles.RootFile_1,'Visible','Off'); |
---|
| 2519 | set(handles.sub_txt,'Visible','off') |
---|
| 2520 | set(handles.RootFile_1,'String',[]); |
---|
| 2521 | mode_store=get(handles.ListCompareMode,'UserData'); |
---|
| 2522 | set(handles.ListPairMode,'Visible','on') |
---|
| 2523 | set(handles.ListPairMode,'Value',1) |
---|
| 2524 | set(handles.ListPairMode,'String',mode_store) |
---|
| 2525 | set(handles.CheckStereo,'Value',0) |
---|
| 2526 | case 'PIV volume' |
---|
| 2527 | set(handles.RootFile_1,'Visible','Off'); |
---|
| 2528 | set(handles.sub_txt,'Visible','off') |
---|
| 2529 | set(handles.RootFile_1,'String',[]); |
---|
| 2530 | mode_store=get(handles.ListCompareMode,'UserData'); |
---|
| 2531 | set(handles.ListPairMode,'Visible','on') |
---|
| 2532 | set(handles.ListPairMode,'Value',1) |
---|
| 2533 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
| 2534 | set(handles.CheckStereo,'Value',0) |
---|
| 2535 | set(handles.last_j,'String',get(handles.nb_field2,'String'))% select the whole volume scan by default |
---|
| 2536 | set(handles.incr_i,'String',num2str(2))% |
---|
| 2537 | otherwise |
---|
| 2538 | filebase=get(handles.RootPath,'String'); |
---|
| 2539 | set(handles.sub_txt,'Visible','on') |
---|
| 2540 | set(handles.RootFile_1,'Visible','On');%mkes the second file input window visible |
---|
| 2541 | mode_store=get(handles.ListPairMode,'String');%get the present 'mode' |
---|
| 2542 | set(handles.ListCompareMode,'UserData',mode_store);%store the mode display |
---|
| 2543 | set(handles.ListPairMode,'Visible','off') |
---|
| 2544 | |
---|
| 2545 | %% open an image file with the browser |
---|
| 2546 | ind_opening=1;%default |
---|
| 2547 | browse.incr_pair=[0 0]; %default |
---|
| 2548 | oldfile=get(handles.RootPath,'String'); |
---|
| 2549 | menu={'*.png;*.jpg;*.tif;*.avi;*.AVI;', ' (*.png,*.jpg ,.tif, *.avi,*.AVI)'; |
---|
| 2550 | '*.png','.png image files'; ... |
---|
| 2551 | '*.jpg',' jpeg image files'; ... |
---|
| 2552 | '*.tif','.tif image files'; ... |
---|
| 2553 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 2554 | '*.*', 'All Files (*.*)'}; |
---|
| 2555 | if strcmp(option,'displacement') |
---|
| 2556 | comment='Pick the reference file for displacements'; |
---|
| 2557 | else |
---|
| 2558 | comment='Pick a file of the second series'; |
---|
[371] | 2559 | end |
---|
[591] | 2560 | [FileName, PathName] = uigetfile( menu, comment,oldfile); |
---|
| 2561 | fileinput=[PathName FileName];%complete file name |
---|
| 2562 | sizf=size(fileinput); |
---|
| 2563 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 2564 | [path,name,ext]=fileparts(fileinput); |
---|
| 2565 | [path1]=fileparts(filebase); |
---|
| 2566 | if isunix |
---|
| 2567 | [status,path]=system(['readlink ' path]); |
---|
| 2568 | [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths |
---|
| 2569 | end |
---|
| 2570 | if ~strcmp(path1,path) |
---|
| 2571 | msgbox_uvmat('ERROR','The second image or series must be in the same directory as the first one') |
---|
| 2572 | return |
---|
| 2573 | end |
---|
| 2574 | if strcmp(option,'displacement') |
---|
| 2575 | [tild,RootFile_1]=fileparts(name); |
---|
| 2576 | else |
---|
| 2577 | [FilePath,FileName,Ext]=fileparts(fileinput); |
---|
| 2578 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 2579 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
[783] | 2580 | [RootPath,SubDir,RootFile_1,i1_series,i2_series,j1_series,j2_series,nom_type_1,FileInfo,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName Ext]); |
---|
| 2581 | FileType=FileInfo.FileType; |
---|
[591] | 2582 | %check image nom type |
---|
| 2583 | if ~strcmp(nom_type_1,get(handles.NomType,'String')) |
---|
| 2584 | msgbox_uvmat('ERROR','The second image series must have the same indexing type as the first one, or use the option displacement for a fixed image') |
---|
| 2585 | return |
---|
| 2586 | end |
---|
| 2587 | end |
---|
| 2588 | %check image extension |
---|
| 2589 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
| 2590 | msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one') |
---|
| 2591 | return |
---|
| 2592 | end |
---|
| 2593 | set(handles.RootFile_1,'String',RootFile_1); |
---|
| 2594 | |
---|
[309] | 2595 | end |
---|
[319] | 2596 | ListPairMode_Callback(hObject, eventdata, handles) |
---|
[2] | 2597 | |
---|
[309] | 2598 | |
---|
| 2599 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 2600 | % Callbacks in the uipanel Pair Indices |
---|
| 2601 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[12] | 2602 | %------------------------------------------------------------------------ |
---|
[309] | 2603 | % --- Executes on button press in ListPairMode. |
---|
| 2604 | function ListPairMode_Callback(hObject, eventdata, handles) |
---|
[12] | 2605 | %------------------------------------------------------------------------ |
---|
[309] | 2606 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 2607 | val=get(handles.ListCompareMode,'Value'); |
---|
| 2608 | compare=compare_list{val}; |
---|
[360] | 2609 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
[309] | 2610 | mode='displacement'; |
---|
| 2611 | else |
---|
| 2612 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2613 | if ischar(mode_list) |
---|
| 2614 | mode_list={mode_list}; |
---|
| 2615 | end |
---|
| 2616 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2617 | mode=mode_list{mode_value}; |
---|
| 2618 | end |
---|
| 2619 | displ_num=[];%default |
---|
| 2620 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 2621 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 2622 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[343] | 2623 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 2624 | checkframe=strcmp(TimeUnit,'frame'); |
---|
[309] | 2625 | siztime=size(time); |
---|
[343] | 2626 | nbfield=siztime(1)-1; |
---|
| 2627 | nbfield2=siztime(2)-1; |
---|
[309] | 2628 | indchosen=1; %%first pair selected by default |
---|
| 2629 | %displ_num used to define the indices of the civ pairs |
---|
| 2630 | % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices |
---|
| 2631 | % are relative to the reference indices ref_i and ref_j respectively. |
---|
| 2632 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 2633 | dt=1; |
---|
| 2634 | displ=''; |
---|
| 2635 | index=0; |
---|
| 2636 | numlist_a=[]; |
---|
| 2637 | numlist_B=[]; |
---|
| 2638 | %get all the time intervals in bursts |
---|
| 2639 | displ_dt=1;%default |
---|
| 2640 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 2641 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 2642 | for numod_b=(numod_a+1):nbfield2 |
---|
| 2643 | index=index+1; |
---|
| 2644 | numlist_a(index)=numod_a; |
---|
| 2645 | numlist_b(index)=numod_b; |
---|
[343] | 2646 | if size(time,2)>1 && ~checkframe |
---|
| 2647 | dt(numod_a,numod_b)=time(ref_i+1,numod_b+1)-time(ref_i+1,numod_a+1);%first time interval dt |
---|
[309] | 2648 | displ_dt(index)=dt(numod_a,numod_b); |
---|
| 2649 | else |
---|
| 2650 | displ_dt(index)=1; |
---|
| 2651 | end |
---|
| 2652 | end |
---|
| 2653 | end |
---|
| 2654 | [dtsort,indsort]=sort(displ_dt); |
---|
| 2655 | if ~isempty(numlist_a) |
---|
| 2656 | displ_num(1,:)=numlist_a(indsort); |
---|
| 2657 | displ_num(2,:)=numlist_b(indsort); |
---|
| 2658 | end |
---|
| 2659 | displ_num(3,:)=0; |
---|
| 2660 | displ_num(4,:)=0; |
---|
[360] | 2661 | enable_j(handles, 'off') |
---|
[309] | 2662 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
| 2663 | index=1:200; |
---|
| 2664 | displ_num(1,index)=-floor(index/2); |
---|
| 2665 | displ_num(2,index)=ceil(index/2); |
---|
| 2666 | displ_num(3:4,index)=zeros(2,200); |
---|
[360] | 2667 | enable_j(handles, 'on') |
---|
[309] | 2668 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 2669 | index=1:200; |
---|
| 2670 | displ_num(1:2,index)=zeros(2,200); |
---|
| 2671 | displ_num(3,index)=-floor(index/2); |
---|
| 2672 | displ_num(4,index)=ceil(index/2); |
---|
[360] | 2673 | enable_i(handles, 'on') |
---|
[309] | 2674 | if nbfield2 > 1 |
---|
[360] | 2675 | enable_j(handles, 'on') |
---|
[309] | 2676 | else |
---|
[360] | 2677 | enable_j(handles, 'off') |
---|
[309] | 2678 | end |
---|
| 2679 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
| 2680 | displ_num(1,1)=0; |
---|
| 2681 | displ_num(2,1)=0; |
---|
| 2682 | displ_num(3,1)=0; |
---|
| 2683 | displ_num(4,1)=0; |
---|
[319] | 2684 | if nbfield > 1 || nbfield==0 |
---|
[360] | 2685 | enable_i(handles, 'on') |
---|
[309] | 2686 | else |
---|
[360] | 2687 | enable_j(handles, 'off') |
---|
[309] | 2688 | end |
---|
| 2689 | if nbfield2 > 1 |
---|
[360] | 2690 | enable_j(handles, 'on') |
---|
[309] | 2691 | else |
---|
[360] | 2692 | enable_j(handles, 'off') |
---|
[309] | 2693 | end |
---|
| 2694 | end |
---|
| 2695 | set(handles.ListPairCiv1,'UserData',displ_num); |
---|
[362] | 2696 | errormsg=find_netcpair_civ( handles,1); |
---|
| 2697 | if ~isempty(errormsg) |
---|
| 2698 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2699 | end |
---|
[360] | 2700 | % find_netcpair_civ2(handles) |
---|
[2] | 2701 | |
---|
[360] | 2702 | function enable_i(handles, state) |
---|
| 2703 | set(handles.itext,'Visible',state) |
---|
| 2704 | set(handles.first_i,'Visible',state) |
---|
| 2705 | set(handles.last_i,'Visible',state) |
---|
| 2706 | set(handles.incr_i,'Visible',state) |
---|
| 2707 | set(handles.nb_field,'Visible',state) |
---|
| 2708 | set(handles.ref_i,'Visible',state) |
---|
| 2709 | |
---|
| 2710 | function enable_j(handles, state) |
---|
| 2711 | set(handles.jtext,'Visible',state) |
---|
| 2712 | set(handles.first_j,'Visible',state) |
---|
| 2713 | set(handles.last_j,'Visible',state) |
---|
| 2714 | set(handles.incr_j,'Visible',state) |
---|
| 2715 | set(handles.nb_field2,'Visible',state) |
---|
| 2716 | set(handles.ref_j,'Visible',state) |
---|
| 2717 | |
---|
| 2718 | |
---|
[12] | 2719 | %------------------------------------------------------------------------ |
---|
[309] | 2720 | % --- Executes on selection change in ListPairCiv1. |
---|
| 2721 | function ListPairCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 2722 | %------------------------------------------------------------------------ |
---|
[309] | 2723 | %reproduce by default the chosen pair in the checkciv2 menu |
---|
| 2724 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
| 2725 | index_pair=get(handles.ListPairCiv1,'Value'); |
---|
| 2726 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
| 2727 | list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs |
---|
| 2728 | if index_pair<=length(list_pair2) |
---|
| 2729 | set(handles.ListPairCiv2,'Value',index_pair); |
---|
| 2730 | end |
---|
[2] | 2731 | |
---|
[309] | 2732 | %update first_i and last_i according to the chosen image pairs |
---|
| 2733 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2734 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2735 | mode=mode_list{mode_value}; |
---|
| 2736 | if isequal(mode,'series(Di)') |
---|
| 2737 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2738 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2739 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[582] | 2740 | num_i=first_i:incr_i:last_i; |
---|
[309] | 2741 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2742 | if ~isnan(lastfield) |
---|
[582] | 2743 | test_find=(num_i-floor(index_pair/2)*ones(size(num_i))>0)& ... |
---|
| 2744 | (num_i+ceil(index_pair/2)*ones(size(num_i))<=lastfield); |
---|
| 2745 | num_i=num_i(test_find); |
---|
[309] | 2746 | end |
---|
[582] | 2747 | set(handles.first_i,'String',num2str(num_i(1))); |
---|
| 2748 | set(handles.last_i,'String',num2str(num_i(end))); |
---|
[309] | 2749 | elseif isequal(mode,'series(Dj)') |
---|
| 2750 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2751 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2752 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 2753 | num_j=first_j:incr_j:last_j; |
---|
| 2754 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 2755 | if ~isnan(lastfield2) |
---|
| 2756 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 2757 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
[582] | 2758 | num_j=num_j(test_find); |
---|
[309] | 2759 | end |
---|
[582] | 2760 | set(handles.first_j,'String',num2str(num_j(1))); |
---|
| 2761 | set(handles.last_j,'String',num2str(num_j(end))); |
---|
[309] | 2762 | end |
---|
| 2763 | |
---|
[12] | 2764 | %------------------------------------------------------------------------ |
---|
[309] | 2765 | % --- Executes on selection change in ListPairCiv2. |
---|
| 2766 | function ListPairCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 2767 | %------------------------------------------------------------------------ |
---|
[309] | 2768 | index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu |
---|
[2] | 2769 | |
---|
[309] | 2770 | %update first_i and last_i according to the chosen image pairs |
---|
| 2771 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2772 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2773 | mode=mode_list{mode_value}; |
---|
| 2774 | if isequal(mode,'series(Di)') |
---|
| 2775 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2776 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2777 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[582] | 2778 | num_i=first_i:incr_i:last_i; |
---|
[309] | 2779 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2780 | if ~isnan(lastfield) |
---|
[582] | 2781 | test_find=(num_i-floor(index_pair/2)*ones(size(num_i))>0)& ... |
---|
| 2782 | (num_i+ceil(index_pair/2)*ones(size(num_i))<=lastfield); |
---|
| 2783 | num_i=num_i(test_find); |
---|
[309] | 2784 | end |
---|
[582] | 2785 | set(handles.first_i,'String',num2str(num_i(1))); |
---|
| 2786 | set(handles.last_i,'String',num2str(num_i(end))); |
---|
[309] | 2787 | elseif isequal(mode,'series(Dj)') |
---|
| 2788 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2789 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2790 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 2791 | num_j=first_j:incr_j:last_j; |
---|
| 2792 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 2793 | if ~isnan(lastfield2) |
---|
| 2794 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 2795 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
[582] | 2796 | num_j=num_j(test_find); |
---|
[309] | 2797 | end |
---|
[582] | 2798 | set(handles.first_j,'String',num2str(num_j(1))); |
---|
| 2799 | set(handles.last_j,'String',num2str(num_j(end))); |
---|
[309] | 2800 | end |
---|
| 2801 | |
---|
[12] | 2802 | %------------------------------------------------------------------------ |
---|
[309] | 2803 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 2804 | %------------------------------------------------------------------------ |
---|
[309] | 2805 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2806 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2807 | mode=mode_list{mode_value}; |
---|
[362] | 2808 | errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files |
---|
[309] | 2809 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
| 2810 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
[362] | 2811 | errormsg=find_netcpair_civ( handles,2); |
---|
[309] | 2812 | end |
---|
[362] | 2813 | if ~isempty(errormsg) |
---|
| 2814 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2815 | end |
---|
[2] | 2816 | |
---|
[12] | 2817 | %------------------------------------------------------------------------ |
---|
[309] | 2818 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 2819 | %------------------------------------------------------------------------ |
---|
[309] | 2820 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2821 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2822 | mode=mode_list{mode_value}; |
---|
| 2823 | if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[362] | 2824 | errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files |
---|
[309] | 2825 | end |
---|
| 2826 | if isequal(mode,'series(Dj)') || ... |
---|
| 2827 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
[362] | 2828 | errormsg=find_netcpair_civ(handles,2); |
---|
[309] | 2829 | end |
---|
[362] | 2830 | if ~isempty(errormsg) |
---|
| 2831 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2832 | end |
---|
[360] | 2833 | |
---|
[12] | 2834 | %------------------------------------------------------------------------ |
---|
[309] | 2835 | % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of |
---|
| 2836 | % the field series set by first_i, incr, last_i |
---|
[389] | 2837 | % index=1: look for pairs for civ1 |
---|
| 2838 | % index=2: look for pairs for civ2 |
---|
[362] | 2839 | function errormsg=find_netcpair_civ(handles,index) |
---|
[12] | 2840 | %------------------------------------------------------------------------ |
---|
[362] | 2841 | set(gcf,'Pointer','watch')% set the mouse pointer to 'watch' (clock) |
---|
| 2842 | |
---|
| 2843 | %% initialisation |
---|
| 2844 | errormsg=''; |
---|
[371] | 2845 | browse=get(handles.RootPath,'UserData'); |
---|
[309] | 2846 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 2847 | val=get(handles.ListCompareMode,'Value'); |
---|
| 2848 | compare=compare_list{val}; |
---|
[371] | 2849 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
[309] | 2850 | mode='displacement'; |
---|
| 2851 | else |
---|
| 2852 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2853 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2854 | if isempty(mode_list) |
---|
| 2855 | return |
---|
| 2856 | end |
---|
| 2857 | mode=mode_list{mode_value}; |
---|
| 2858 | end |
---|
[360] | 2859 | nom_type_ima=get(handles.NomType,'String'); |
---|
[289] | 2860 | |
---|
[360] | 2861 | %% determine nom_type_nc, nomenclature type of the .nc files: |
---|
[389] | 2862 | [nom_type_nc]=nomtype2pair(nom_type_ima,mode); |
---|
[309] | 2863 | |
---|
[362] | 2864 | %% reads .nc subdirectoy and image numbers from the interface |
---|
[494] | 2865 | SubDirImages=get(handles.SubDirImages,'String'); |
---|
[493] | 2866 | subdir_civ1=[SubDirImages get(handles.SubdirCiv1,'String')];%subdirectory subdir_civ1 for the netcdf data |
---|
| 2867 | subdir_civ2=[SubDirImages get(handles.SubdirCiv2,'String')];%subdirectory subdir_civ2 for the netcdf data |
---|
[309] | 2868 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[494] | 2869 | ref_j=[]; |
---|
[309] | 2870 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 2871 | ref_j=0; |
---|
[494] | 2872 | elseif strcmp(get(handles.ref_j,'Visible'),'on') |
---|
[309] | 2873 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 2874 | end |
---|
[494] | 2875 | if isempty(ref_j) |
---|
| 2876 | ref_j=1; |
---|
| 2877 | end |
---|
[309] | 2878 | time=get(handles.ImaDoc,'UserData');%get the set of times |
---|
[343] | 2879 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 2880 | checkframe=strcmp(TimeUnit,'frame'); |
---|
[309] | 2881 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
| 2882 | |
---|
[362] | 2883 | %% eliminate the first pairs inconsistent with the position |
---|
[309] | 2884 | if isempty(displ_num) |
---|
| 2885 | nbpair=0; |
---|
| 2886 | else |
---|
| 2887 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 2888 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 2889 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 2890 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 2891 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 2892 | end |
---|
| 2893 | end |
---|
| 2894 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 2895 | |
---|
[362] | 2896 | %% case with no Civ1 operation, netcdf files need to exist for reading |
---|
[309] | 2897 | displ_pair={''}; |
---|
| 2898 | select=ones(size(1:nbpair));%flag for displayed pairs =1 for display |
---|
| 2899 | testpair=0; |
---|
[371] | 2900 | RootPath=get(handles.RootPath,'String'); |
---|
| 2901 | RootFile=get(handles.RootFile,'String'); |
---|
[360] | 2902 | if index==1 % case civ1 |
---|
[362] | 2903 | if ~get(handles.CheckCiv1,'Value') % |
---|
[371] | 2904 | if ~exist(fullfile(RootPath,subdir_civ1),'dir') |
---|
[362] | 2905 | errormsg=['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']; |
---|
| 2906 | set(handles.ListPairCiv1,'String',{}); |
---|
| 2907 | return |
---|
| 2908 | end |
---|
| 2909 | for ipair=1:nbpair |
---|
| 2910 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,... |
---|
| 2911 | ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair)); |
---|
| 2912 | select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist |
---|
| 2913 | end |
---|
| 2914 | % case of no displayed pair |
---|
| 2915 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 2916 | if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0]) |
---|
| 2917 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 2918 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 2919 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 2920 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 2921 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2); |
---|
| 2922 | select(1)=exist(filename,'file')==2; |
---|
| 2923 | testpair=1; |
---|
[309] | 2924 | else |
---|
[494] | 2925 | % if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 2926 | % errormsg=['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]; |
---|
| 2927 | % else |
---|
[389] | 2928 | errormsg=['no civ1 file available for the selected reference indices (i,j)= ' num2str(ref_i) ', ' num2str(ref_j) ' and subdirectory ' subdir_civ1]; |
---|
[494] | 2929 | % end |
---|
[362] | 2930 | set(handles.ListPairCiv1,'String',{''}); |
---|
| 2931 | %COMPLETER CAS STEREO |
---|
| 2932 | return |
---|
[309] | 2933 | end |
---|
| 2934 | end |
---|
| 2935 | end |
---|
[362] | 2936 | else %case civ2 alone |
---|
| 2937 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
[438] | 2938 | if ~exist(fullfile(RootPath,subdir_civ2),'dir') |
---|
| 2939 | msgbox_uvmat('ERROR',['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
[360] | 2940 | set(handles.ListPairCiv2,'Value',1); |
---|
| 2941 | set(handles.ListPairCiv2,'String',{''}); |
---|
| 2942 | return |
---|
| 2943 | end |
---|
[362] | 2944 | for ipair=1:nbpair |
---|
| 2945 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,... |
---|
| 2946 | ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair)); |
---|
| 2947 | select(ipair)=exist(filename,'file')==2; |
---|
| 2948 | end |
---|
| 2949 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 2950 | if isfield(browse,'incr_pair') |
---|
| 2951 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 2952 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 2953 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 2954 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 2955 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2); |
---|
| 2956 | select(1)=exist(filename,'file')==2; |
---|
| 2957 | else |
---|
| 2958 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 2959 | errormsg=['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]; |
---|
| 2960 | else |
---|
| 2961 | errormsg=['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]; |
---|
| 2962 | end |
---|
| 2963 | set(handles.ListPairCiv2,'Value',1); |
---|
| 2964 | set(handles.ListPairCiv2,'String',{''}); |
---|
| 2965 | return |
---|
| 2966 | end |
---|
| 2967 | end |
---|
[360] | 2968 | end |
---|
| 2969 | end |
---|
[309] | 2970 | |
---|
| 2971 | %% determine the menu display in .ListPairCiv1 |
---|
| 2972 | % the menu depends on the mode defined in ListPairMode_callback through the array displ_num: |
---|
| 2973 | % displ_num(1,:)=indices j1 |
---|
| 2974 | % displ_num(2,:)=indices j2 |
---|
| 2975 | % displ_num(3,:)=indices i1 |
---|
| 2976 | % displ_num(4,:)=indices i2 |
---|
| 2977 | % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices |
---|
| 2978 | % are relative to the reference indices ref_i and ref_j respectively. |
---|
| 2979 | if isequal(mode,'series(Di)') |
---|
| 2980 | if testpair |
---|
| 2981 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 2982 | else |
---|
| 2983 | for ipair=1:nbpair |
---|
| 2984 | if select(ipair) |
---|
| 2985 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
[389] | 2986 | %if ~checkframe && size(time,1)>=ref_i+1+displ_num(4,ipair) && size(time,2)>=ref_j+1+displ_num(2,ipair)&&displ_num(2,ipair)>=1 &&displ_num(1,ipair)>=1 |
---|
| 2987 | % dt=time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%time interval dt |
---|
| 2988 | if ~checkframe && size(time,1)>=ref_i+1+ceil(ipair/2) && size(time,2)>=ref_j+1&& ref_i-floor(ipair/2)>=0 && ref_j>=0 |
---|
| 2989 | dt=time(ref_i+1+ceil(ipair/2),ref_j+1)-time(ref_i+1-floor(ipair/2),ref_j+1);%time interval dtref_j+1 |
---|
[343] | 2990 | else |
---|
| 2991 | dt=1; |
---|
[309] | 2992 | end |
---|
[343] | 2993 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
[309] | 2994 | else |
---|
| 2995 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 2996 | end |
---|
| 2997 | end |
---|
| 2998 | end |
---|
| 2999 | elseif isequal(mode,'series(Dj)') |
---|
| 3000 | if testpair |
---|
| 3001 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 3002 | else |
---|
| 3003 | for ipair=1:nbpair |
---|
| 3004 | if select(ipair) |
---|
| 3005 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
[343] | 3006 | if ~checkframe && size(time,1)>=ref_i+1+displ_num(4,ipair) && size(time,2)>=ref_j+1+displ_num(2,ipair) |
---|
| 3007 | dt=time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%time interval dt |
---|
[309] | 3008 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
| 3009 | end |
---|
| 3010 | else |
---|
| 3011 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 3012 | end |
---|
| 3013 | end |
---|
| 3014 | end |
---|
| 3015 | elseif isequal(mode,'pair j1-j2')%case of pairs |
---|
| 3016 | for ipair=1:nbpair |
---|
| 3017 | if select(ipair) |
---|
[343] | 3018 | if ~checkframe && size(time,2)>1 |
---|
| 3019 | dt=time(ref_i+1+displ_num(4,ipair),displ_num(2,ipair)+1)-time(ref_i+1+displ_num(3,ipair),displ_num(1,ipair)+1);%time interval dt |
---|
| 3020 | else % time set by default to i index |
---|
| 3021 | dt=1; |
---|
| 3022 | end |
---|
[309] | 3023 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 3024 | ' :dt= ' num2str(dt*1000)]; |
---|
| 3025 | else |
---|
| 3026 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 3027 | end |
---|
| 3028 | end |
---|
| 3029 | elseif isequal(mode,'displacement') |
---|
| 3030 | displ_pair={'Di=Dj=0'}; |
---|
| 3031 | end |
---|
[362] | 3032 | if index==1 |
---|
[309] | 3033 | set(handles.ListPairCiv1,'String',displ_pair'); |
---|
[362] | 3034 | end |
---|
[309] | 3035 | |
---|
| 3036 | %% determine the default selection in the pair menu |
---|
| 3037 | ichoice=find(select,1);% index of selected pair |
---|
| 3038 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 3039 | initial=get(handles.ListPairCiv1,'Value');%initial choice of pair |
---|
| 3040 | if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1)) |
---|
| 3041 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 3042 | end |
---|
| 3043 | initial=get(handles.ListPairCiv2,'Value'); |
---|
| 3044 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 3045 | if ichoice <= length(displ_pair') |
---|
| 3046 | set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 3047 | else |
---|
| 3048 | set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2 |
---|
| 3049 | end |
---|
| 3050 | end |
---|
| 3051 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
| 3052 | set(gcf,'Pointer','arrow') |
---|
| 3053 | |
---|
[415] | 3054 | |
---|
[315] | 3055 | |
---|
[415] | 3056 | % %------------------------------------------------------------------------ |
---|
| 3057 | % % call 'view_field.fig' to display the field selected in the list of 'status' |
---|
| 3058 | % function open_view_field(hObject, eventdata) |
---|
| 3059 | % %------------------------------------------------------------------------ |
---|
| 3060 | % list=get(hObject,'String'); |
---|
| 3061 | % index=get(hObject,'Value'); |
---|
| 3062 | % rootroot=get(hObject,'UserData'); |
---|
| 3063 | % filename=list{index}; |
---|
| 3064 | % ind_dot=strfind(filename,'...'); |
---|
| 3065 | % filename=filename(1:ind_dot-1); |
---|
| 3066 | % filename=fullfile(rootroot,filename); |
---|
| 3067 | % delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
| 3068 | % if exist(filename,'file')%visualise the vel field if it exists |
---|
| 3069 | % uvmat(filename) |
---|
| 3070 | % set(gcbo,'Value',1) |
---|
| 3071 | % end |
---|
[309] | 3072 | |
---|
| 3073 | |
---|
| 3074 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3075 | % Callbacks in the uipanel Reference Indices |
---|
| 3076 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[12] | 3077 | %------------------------------------------------------------------------ |
---|
| 3078 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3079 | %------------------------------------------------------------------------ |
---|
[137] | 3080 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3081 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
| 3082 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3083 | |
---|
[12] | 3084 | %------------------------------------------------------------------------ |
---|
| 3085 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3086 | %------------------------------------------------------------------------ |
---|
| 3087 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3088 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3089 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3090 | |
---|
[309] | 3091 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3092 | % Callbacks in the uipanel Civ1 |
---|
| 3093 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[12] | 3094 | %------------------------------------------------------------------------ |
---|
[437] | 3095 | % --- Executes on button press in SearchRange: determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 |
---|
[273] | 3096 | function SearchRange_Callback(hObject, eventdata, handles) |
---|
[12] | 3097 | %------------------------------------------------------------------------ |
---|
[2] | 3098 | %determine pair numbers |
---|
[415] | 3099 | if strcmp(get(handles.num_UMin,'Visible'),'off') |
---|
[273] | 3100 | set(handles.u_title,'Visible','on') |
---|
| 3101 | set(handles.v_title,'Visible','on') |
---|
[415] | 3102 | set(handles.num_UMin,'Visible','on') |
---|
| 3103 | set(handles.num_UMax,'Visible','on') |
---|
| 3104 | set(handles.num_VMin,'Visible','on') |
---|
| 3105 | set(handles.num_VMax,'Visible','on') |
---|
[273] | 3106 | set(handles.CoordUnit,'Visible','on') |
---|
| 3107 | set(handles.TimeUnit,'Visible','on') |
---|
| 3108 | set(handles.slash_title,'Visible','on') |
---|
| 3109 | set(handles.min_title,'Visible','on') |
---|
| 3110 | set(handles.max_title,'Visible','on') |
---|
| 3111 | set(handles.unit_title,'Visible','on') |
---|
| 3112 | else |
---|
| 3113 | get_search_range(hObject, eventdata, handles) |
---|
[2] | 3114 | end |
---|
| 3115 | |
---|
[12] | 3116 | %------------------------------------------------------------------------ |
---|
[437] | 3117 | % --- determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 and shift |
---|
[273] | 3118 | function get_search_range(hObject, eventdata, handles) |
---|
[415] | 3119 | %------------------------------------------------------------------------ |
---|
| 3120 | param_civ1=read_GUI(handles.Civ1); |
---|
| 3121 | umin=param_civ1.UMin; |
---|
| 3122 | umax=param_civ1.UMax; |
---|
| 3123 | vmin=param_civ1.VMin; |
---|
| 3124 | vmax=param_civ1.VMax; |
---|
[273] | 3125 | %switch min_title and max_title in case of error |
---|
| 3126 | if umax<=umin |
---|
| 3127 | umin_old=umin; |
---|
| 3128 | umin=umax; |
---|
| 3129 | umax=umin_old; |
---|
[415] | 3130 | set(handles.num_UMin,'String', num2str(umin)) |
---|
| 3131 | set(handles.num_UMax,'String', num2str(umax)) |
---|
[273] | 3132 | end |
---|
| 3133 | if vmax<=vmin |
---|
| 3134 | vmin_old=vmin; |
---|
| 3135 | vmin=vmax; |
---|
| 3136 | vmax=vmin_old; |
---|
[415] | 3137 | set(handles.num_VMin,'String', num2str(vmin)) |
---|
| 3138 | set(handles.num_VMax,'String', num2str(vmax)) |
---|
[273] | 3139 | end |
---|
[415] | 3140 | if ~(isempty(umin)||isempty(umax)||isempty(vmin)||isempty(vmax)) |
---|
[282] | 3141 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
| 3142 | index=get(handles.ListPairCiv1,'Value'); |
---|
[415] | 3143 | pair_string=list_pair{index}; |
---|
[273] | 3144 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[415] | 3145 | pxcm=get(handles.SearchRange,'UserData'); |
---|
[282] | 3146 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 3147 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[415] | 3148 | mode=mode_list{mode_value}; |
---|
[273] | 3149 | if isequal (mode, 'series(Di)' ) |
---|
| 3150 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3151 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3152 | num2=ref_i+ceil(index/2); |
---|
| 3153 | num_a=1; |
---|
| 3154 | num_b=1; |
---|
| 3155 | elseif isequal (mode, 'series(Dj)') |
---|
| 3156 | num1=1; |
---|
| 3157 | num2=1; |
---|
| 3158 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 3159 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3160 | num_b=ref_j+ceil(index/2); |
---|
[415] | 3161 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[273] | 3162 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3163 | num1=ref_i; |
---|
| 3164 | num2=ref_i; |
---|
[415] | 3165 | r=regexp(pair_string,'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
| 3166 | if isempty(r) |
---|
| 3167 | r=regexp(pair_string,'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names'); |
---|
| 3168 | end |
---|
| 3169 | num_a=str2num(r.num1); |
---|
| 3170 | num_b=str2num(r.num2); |
---|
[273] | 3171 | end |
---|
[415] | 3172 | dt=time(num2+1,num_b+1)-time(num1+1,num_a+1); |
---|
[437] | 3173 | ibx=str2double(get(handles.num_CorrBoxSize_1,'String')); |
---|
| 3174 | iby=str2double(get(handles.num_CorrBoxSize_2,'String')); |
---|
[415] | 3175 | umin=dt*pxcm*umin; |
---|
| 3176 | umax=dt*pxcm*umax; |
---|
| 3177 | vmin=dt*pxcm*vmin; |
---|
| 3178 | vmax=dt*pxcm*vmax; |
---|
[273] | 3179 | shiftx=round((umin+umax)/2); |
---|
| 3180 | shifty=round((vmin+vmax)/2); |
---|
[415] | 3181 | isx=(umax+2-shiftx)*2+param_civ1.Bx; |
---|
[273] | 3182 | isx=2*ceil(isx/2)+1; |
---|
[415] | 3183 | isy=(vmax+2-shifty)*2+param_civ1.Bx; |
---|
[273] | 3184 | isy=2*ceil(isy/2)+1; |
---|
[437] | 3185 | set(handles.num_SearchBoxShift_1,'String',num2str(shiftx)); |
---|
| 3186 | set(handles.num_SearchBoxShift_2,'String',num2str(shifty)); |
---|
| 3187 | set(handles.num_SearchBoxSize_1,'String',num2str(isx)); |
---|
| 3188 | set(handles.num_SearchBoxSize_2,'String',num2str(isy)); |
---|
[273] | 3189 | end |
---|
| 3190 | |
---|
[315] | 3191 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3192 | % Callbacks in the uipanel Fix1 |
---|
| 3193 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[12] | 3194 | %------------------------------------------------------------------------ |
---|
[282] | 3195 | % --- Executes on button press in CheckMask. |
---|
[2] | 3196 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3197 | %------------------------------------------------------------------------ |
---|
[282] | 3198 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3199 | if isequal(maskval,0) |
---|
[384] | 3200 | set(handles.Mask,'String','') |
---|
[2] | 3201 | else |
---|
[112] | 3202 | mask_displ='no mask'; %default |
---|
[371] | 3203 | filebase=get(handles.RootPath,'String'); |
---|
[112] | 3204 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3205 | if isequal(flag_mask,1) |
---|
| 3206 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3207 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[371] | 3208 | filebase_a=get(handles.RootFile_1,'String'); |
---|
[2] | 3209 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3210 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3211 | mask_displ='no mask'; |
---|
| 3212 | end |
---|
[112] | 3213 | end |
---|
| 3214 | if isequal(mask_displ,'no mask') |
---|
| 3215 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3216 | {'*.png', ' (*.png)'; |
---|
[12] | 3217 | '*.png', '.png files '; ... |
---|
| 3218 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3219 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3220 | mask_displ=fullfile(PathName,FileName); |
---|
| 3221 | if ~exist(mask_displ,'file') |
---|
| 3222 | mask_displ='no mask'; |
---|
| 3223 | end |
---|
[12] | 3224 | end |
---|
[112] | 3225 | if isequal(mask_displ,'no mask') |
---|
[282] | 3226 | set(handles.CheckMask,'Value',0) |
---|
| 3227 | set(handles.CheckMask,'Value',0) |
---|
| 3228 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3229 | else |
---|
[282] | 3230 | %set(handles.CheckMask,'Value',1) |
---|
| 3231 | set(handles.CheckMask,'Value',1) |
---|
[112] | 3232 | end |
---|
[384] | 3233 | set(handles.Mask,'String',mask_displ) |
---|
| 3234 | set(handles.Mask,'String',mask_displ) |
---|
| 3235 | set(handles.Mask,'String',mask_displ) |
---|
[12] | 3236 | end |
---|
| 3237 | |
---|
| 3238 | %------------------------------------------------------------------------ |
---|
[282] | 3239 | % --- Executes on button press in CheckMask: select box for mask option |
---|
[2] | 3240 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3241 | %------------------------------------------------------------------------ |
---|
[282] | 3242 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3243 | if isequal(maskval,0) |
---|
[384] | 3244 | set(handles.Mask,'String','') |
---|
[2] | 3245 | else |
---|
[112] | 3246 | mask_displ='no mask'; %default |
---|
[371] | 3247 | filebase=get(handles.RootPath,'String'); |
---|
[112] | 3248 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3249 | if isequal(flag_mask,1) |
---|
| 3250 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3251 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[371] | 3252 | filebase_a=get(handles.RootFile_1,'String'); |
---|
[2] | 3253 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3254 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3255 | mask_displ='no mask'; |
---|
| 3256 | end |
---|
[112] | 3257 | end |
---|
| 3258 | if isequal(mask_displ,'no mask') |
---|
| 3259 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3260 | {'*.png', ' (*.png)'; |
---|
[12] | 3261 | '*.png', '.png files '; ... |
---|
| 3262 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3263 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3264 | mask_displ=fullfile(PathName,FileName); |
---|
| 3265 | if ~exist(mask_displ,'file') |
---|
| 3266 | mask_displ='no mask'; |
---|
| 3267 | end |
---|
[12] | 3268 | end |
---|
[112] | 3269 | if isequal(mask_displ,'no mask') |
---|
[282] | 3270 | set(handles.CheckMask,'Value',0) |
---|
| 3271 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3272 | else |
---|
[282] | 3273 | set(handles.CheckMask,'Value',1) |
---|
[112] | 3274 | end |
---|
[384] | 3275 | set(handles.Mask,'String',mask_displ) |
---|
| 3276 | set(handles.Mask,'String',mask_displ) |
---|
[12] | 3277 | end |
---|
| 3278 | |
---|
| 3279 | %------------------------------------------------------------------------ |
---|
[282] | 3280 | % --- Executes on button press in CheckMask. |
---|
[2] | 3281 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3282 | %------------------------------------------------------------------------ |
---|
[282] | 3283 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3284 | if isequal(maskval,0) |
---|
[384] | 3285 | set(handles.Mask,'String','') |
---|
[2] | 3286 | else |
---|
[12] | 3287 | mask_displ='no mask'; %default |
---|
[371] | 3288 | filebase=get(handles.RootPath,'String'); |
---|
[12] | 3289 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3290 | if isequal(flag_mask,1) |
---|
[112] | 3291 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3292 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[371] | 3293 | filebase_a=get(handles.RootFile_1,'String'); |
---|
[112] | 3294 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3295 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[112] | 3296 | mask_displ='no mask'; |
---|
| 3297 | end |
---|
[12] | 3298 | end |
---|
| 3299 | if isequal(mask_displ,'no mask') |
---|
| 3300 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3301 | {'*.png', ' (*.png)'; |
---|
| 3302 | '*.png', '.png files '; ... |
---|
| 3303 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3304 | 'Pick a mask file *.png',filebase); |
---|
| 3305 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3306 | if ~exist(mask_displ,'file') |
---|
[2] | 3307 | mask_displ='no mask'; |
---|
| 3308 | end |
---|
[12] | 3309 | end |
---|
| 3310 | if isequal(mask_displ,'no mask') |
---|
[282] | 3311 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3312 | end |
---|
[384] | 3313 | set(handles.Mask,'String',mask_displ) |
---|
[2] | 3314 | end |
---|
| 3315 | |
---|
[12] | 3316 | %------------------------------------------------------------------------ |
---|
| 3317 | % --- function called to look for mask files |
---|
[2] | 3318 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3319 | %------------------------------------------------------------------------ |
---|
[112] | 3320 | %detect mask files, images with appropriate file base |
---|
[2] | 3321 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3322 | %flag_mask=1 indicates detection |
---|
| 3323 | |
---|
| 3324 | flag_mask=0;%default |
---|
| 3325 | nbslice=1; |
---|
| 3326 | |
---|
[363] | 3327 | % subdir=get(handles.SubdirCiv1,'String'); |
---|
[2] | 3328 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3329 | if ~isdir(Path) |
---|
| 3330 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3331 | return |
---|
| 3332 | end |
---|
[272] | 3333 | % currentdir=pwd; |
---|
| 3334 | % cd(Path);%move in the dir of the root name filebase |
---|
| 3335 | maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files |
---|
| 3336 | % cd(currentdir);%come back to the current working directory |
---|
[12] | 3337 | if ~isempty(maskfiles) |
---|
[112] | 3338 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3339 | % else |
---|
[2] | 3340 | flag_mask=1; |
---|
| 3341 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3342 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3343 | Namedouble=double(Name); |
---|
| 3344 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3345 | ind_mask=findstr('mask',Name); |
---|
| 3346 | i=ind_mask-1; |
---|
[137] | 3347 | while val(i)==0 && i>0 |
---|
[112] | 3348 | i=i-1; |
---|
[2] | 3349 | end |
---|
[137] | 3350 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3351 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3352 | flag_mask=1; |
---|
[2] | 3353 | else |
---|
[112] | 3354 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3355 | return |
---|
| 3356 | nbslice=1; |
---|
[2] | 3357 | end |
---|
[112] | 3358 | end |
---|
[2] | 3359 | |
---|
[12] | 3360 | %------------------------------------------------------------------------ |
---|
| 3361 | % --- function called to look for grid files |
---|
[576] | 3362 | function [nbslice, flag_grid]=get_grid(filebase,handles) |
---|
[12] | 3363 | %------------------------------------------------------------------------ |
---|
[576] | 3364 | flag_grid=0;%default |
---|
[2] | 3365 | nbslice=1; |
---|
| 3366 | [Path,Name]=fileparts(filebase); |
---|
| 3367 | currentdir=pwd; |
---|
| 3368 | cd(Path);%move in the dir of the root name filebase |
---|
[576] | 3369 | gridfiles=dir([Name '_*grid_*.grid']);%look for grid files |
---|
[2] | 3370 | cd(currentdir);%come back to the current working directory |
---|
[576] | 3371 | if ~isempty(gridfiles) |
---|
| 3372 | flag_grid=1; |
---|
| 3373 | gridname=gridfiles(1).name;% take the first grid file in the list |
---|
| 3374 | [Path2,Name,ext]=fileparts(gridname); |
---|
[2] | 3375 | Namedouble=double(Name); |
---|
| 3376 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
[576] | 3377 | ind_grid=findstr('grid',Name); |
---|
| 3378 | i=ind_grid-1; |
---|
[137] | 3379 | while val(i)==0 && i>0 |
---|
[112] | 3380 | i=i-1; |
---|
[2] | 3381 | end |
---|
[576] | 3382 | nbslice=str2double(Name(i+1:ind_grid-1)); |
---|
[137] | 3383 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[576] | 3384 | flag_grid=1; |
---|
[2] | 3385 | else |
---|
[112] | 3386 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3387 | return |
---|
| 3388 | nbslice=1; |
---|
[2] | 3389 | end |
---|
[12] | 3390 | end |
---|
[2] | 3391 | |
---|
[12] | 3392 | %------------------------------------------------------------------------ |
---|
| 3393 | % --- transform numbers to letters |
---|
[122] | 3394 | function str=num2stra(num,nom_type) |
---|
[12] | 3395 | %------------------------------------------------------------------------ |
---|
[122] | 3396 | if isempty(nom_type) |
---|
| 3397 | str=''; |
---|
| 3398 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3399 | str=char(96+num); |
---|
[122] | 3400 | elseif strcmp(nom_type(end),'A') |
---|
| 3401 | str=char(96+num); |
---|
| 3402 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3403 | str=''; |
---|
| 3404 | else |
---|
| 3405 | str=num2str(num); |
---|
| 3406 | end |
---|
[12] | 3407 | |
---|
[441] | 3408 | % %------------------------------------------------------------------------ |
---|
| 3409 | % % --- Executes on button press in ListSubdirCiv1. |
---|
| 3410 | % function ListSubdirCiv1_Callback(hObject, eventdata, handles) |
---|
| 3411 | % %------------------------------------------------------------------------ |
---|
| 3412 | % list_subdir_civ1=get(handles.ListSubdirCiv1,'String'); |
---|
| 3413 | % val=get(handles.ListSubdirCiv1,'Value'); |
---|
| 3414 | % SubDir=list_subdir_civ1{val}; |
---|
| 3415 | % if strcmp(SubDir,'new...') |
---|
| 3416 | % if get(handles.CheckCiv1,'Value') |
---|
| 3417 | % SubDir='CIV'; %default subdirectory |
---|
| 3418 | % else |
---|
| 3419 | % msgbox_uvmat('ERROR','select CheckCiv1 to perform a new Civ operation') |
---|
| 3420 | % return |
---|
| 3421 | % end |
---|
| 3422 | % end |
---|
| 3423 | % set(handles.SubdirCiv1,'String',SubDir); |
---|
| 3424 | % errormsg=find_netcpair_civ(handles,1); |
---|
| 3425 | % if ~isempty(errormsg) |
---|
| 3426 | % msgbox_uvmat('ERROR',errormsg) |
---|
| 3427 | % end |
---|
| 3428 | % |
---|
[12] | 3429 | %------------------------------------------------------------------------ |
---|
[441] | 3430 | % % --- Executes on button press in ListSubdirCiv2. |
---|
| 3431 | % function ListSubdirCiv2_Callback(hObject, eventdata, handles) |
---|
| 3432 | % %------------------------------------------------------------------------ |
---|
| 3433 | % list_subdir_civ2=get(handles.ListSubdirCiv2,'String'); |
---|
| 3434 | % val=get(handles.ListSubdirCiv2,'Value'); |
---|
| 3435 | % SubDir=list_subdir_civ2{val}; |
---|
| 3436 | % if strcmp(SubDir,'new...') |
---|
| 3437 | % if get(handles.CheckCiv2,'Value') |
---|
| 3438 | % SubDir='CIV'; %default subdirectory |
---|
| 3439 | % else |
---|
| 3440 | % msgbox_uvmat('ERROR','select CheckCiv2 to perform a new Civ operation') |
---|
| 3441 | % return |
---|
| 3442 | % end |
---|
| 3443 | % end |
---|
| 3444 | % set(handles.SubdirCiv2,'String',SubDir); |
---|
[2] | 3445 | |
---|
[12] | 3446 | %------------------------------------------------------------------------ |
---|
[282] | 3447 | % --- Executes on button press in CheckGrid. |
---|
| 3448 | function CheckGrid_Callback(hObject, eventdata, handles) |
---|
[12] | 3449 | %------------------------------------------------------------------------ |
---|
[276] | 3450 | value=get(hObject,'Value'); |
---|
[576] | 3451 | hparent=get(hObject,'parent');%handles of the parent panel |
---|
[276] | 3452 | hchildren=get(hparent,'children'); |
---|
[576] | 3453 | handle_txtbox=findobj(hchildren,'tag','Grid');% look for the grid name box in the same panel |
---|
[276] | 3454 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 3455 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
[315] | 3456 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
| 3457 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
[2] | 3458 | testgrid=0; |
---|
[276] | 3459 | filegrid=''; |
---|
[2] | 3460 | if value |
---|
[371] | 3461 | filebase=get(handles.RootPath,'String'); |
---|
[276] | 3462 | [nbslice, flag_grid]=get_grid(filebase,handles);% look for a grid with appropriate name |
---|
[2] | 3463 | if isequal(flag_grid,1) |
---|
[112] | 3464 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3465 | testgrid=1; |
---|
[276] | 3466 | else % browse for a grid |
---|
| 3467 | filegrid=get(hObject,'UserData');%look for previous grid name stored as UserData |
---|
| 3468 | if exist(filegrid,'file') |
---|
| 3469 | filebase=filegrid; |
---|
| 3470 | end |
---|
[576] | 3471 | [FileName, PathName] = uigetfile( ... |
---|
[112] | 3472 | {'*.grid', ' (*.grid)'; |
---|
| 3473 | '*.grid', '.grid files '; ... |
---|
| 3474 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3475 | 'Pick a file',filebase); |
---|
[2] | 3476 | filegrid=fullfile(PathName,FileName); |
---|
[276] | 3477 | set(hObject,'UserData',filegrid);%store for future use |
---|
[2] | 3478 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3479 | testgrid=1; |
---|
| 3480 | end |
---|
[112] | 3481 | end |
---|
[2] | 3482 | end |
---|
| 3483 | if testgrid |
---|
[276] | 3484 | set(handle_dx,'Visible','off'); |
---|
| 3485 | set(handle_dy,'Visible','off'); |
---|
[315] | 3486 | set(handle_title_dy,'Visible','off'); |
---|
| 3487 | set(handle_title_dx,'Visible','off'); |
---|
[276] | 3488 | set(handle_txtbox,'Visible','on') |
---|
| 3489 | set(handle_txtbox,'String',filegrid) |
---|
[112] | 3490 | else |
---|
[276] | 3491 | set(hObject,'Value',0); |
---|
[315] | 3492 | set(handle_dx,'Visible','on'); |
---|
[276] | 3493 | set(handle_dy,'Visible','on'); |
---|
[315] | 3494 | set(handle_title_dy,'Visible','on'); |
---|
| 3495 | set(handle_title_dx,'Visible','on'); |
---|
[276] | 3496 | set(handle_txtbox,'Visible','off') |
---|
[2] | 3497 | end |
---|
| 3498 | |
---|
[282] | 3499 | %% if hObject is on the checkciv1 frame, duplicate action for checkciv2 frame |
---|
[319] | 3500 | PanelName=get(hparent,'tag'); |
---|
[315] | 3501 | if strcmp(PanelName,'Civ1') |
---|
[282] | 3502 | hchildren=get(handles.Civ2,'children'); |
---|
[315] | 3503 | handle_checkbox=findobj(hchildren,'tag','CheckGrid'); |
---|
[576] | 3504 | handle_txtbox=findobj(hchildren,'tag','Grid'); |
---|
[276] | 3505 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 3506 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
[315] | 3507 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
| 3508 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
[276] | 3509 | set(handle_checkbox,'UserData',filegrid);%store for future use |
---|
| 3510 | if testgrid |
---|
| 3511 | set(handle_checkbox,'Value',1); |
---|
| 3512 | set(handle_dx,'Visible','off'); |
---|
| 3513 | set(handle_dy,'Visible','off'); |
---|
[315] | 3514 | set(handle_title_dx,'Visible','off'); |
---|
| 3515 | set(handle_title_dy,'Visible','off'); |
---|
[276] | 3516 | set(handle_txtbox,'Visible','on') |
---|
| 3517 | set(handle_txtbox,'String',filegrid) |
---|
| 3518 | end |
---|
| 3519 | end |
---|
[387] | 3520 | |
---|
[12] | 3521 | %------------------------------------------------------------------------ |
---|
[387] | 3522 | % --- Executes on button press in CheckMask: common to all panels (civ1, Civ2..) |
---|
[282] | 3523 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
[276] | 3524 | %------------------------------------------------------------------------ |
---|
| 3525 | value=get(hObject,'Value'); |
---|
[315] | 3526 | hparent=get(hObject,'parent'); |
---|
| 3527 | parent_tag=get(hparent,'Tag'); |
---|
| 3528 | hchildren=get(hparent,'children'); |
---|
[387] | 3529 | handle_txtbox=findobj(hchildren,'tag','Mask');% look for the mask name box in the same panel |
---|
[276] | 3530 | testmask=0; |
---|
| 3531 | if value |
---|
[371] | 3532 | filebase=get(handles.RootPath,'String'); |
---|
[276] | 3533 | [nbslice, flag_mask]=get_mask(filebase,handles);% look for a mask with appropriate name |
---|
| 3534 | if isequal(flag_mask,1) |
---|
| 3535 | filemask=[num2str(nbslice) 'mask']; |
---|
| 3536 | testmask=1; |
---|
| 3537 | else % browse for a mask |
---|
[315] | 3538 | filemask=get(hObject,'UserData');%look for previous mask name stored as UserData |
---|
[276] | 3539 | if exist(filemask,'file') |
---|
| 3540 | filebase=filemask; |
---|
| 3541 | end |
---|
[315] | 3542 | [FileName, PathName] = uigetfile( ... |
---|
[276] | 3543 | {'*.png', ' (*.png)'; |
---|
| 3544 | '*.png', '.png files '; ... |
---|
| 3545 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3546 | 'Pick a mask file *.png',filebase); |
---|
| 3547 | filemask=fullfile(PathName,FileName); |
---|
[315] | 3548 | set(hObject,'UserData',filemask);%store for future use |
---|
[276] | 3549 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filemask,'file')) |
---|
| 3550 | testmask=1; |
---|
| 3551 | end |
---|
| 3552 | end |
---|
| 3553 | end |
---|
| 3554 | if testmask |
---|
[316] | 3555 | if strcmp(parent_tag,'Civ1') |
---|
[387] | 3556 | set(handles.Mask,'Visible','on') |
---|
[384] | 3557 | set(handles.Mask,'String',filemask) |
---|
[316] | 3558 | set(handles.CheckMask,'Value',1) |
---|
[315] | 3559 | end |
---|
[276] | 3560 | else |
---|
[315] | 3561 | set(hObject,'Value',0); |
---|
| 3562 | set(handle_txtbox,'Visible','off') |
---|
[276] | 3563 | end |
---|
| 3564 | |
---|
[576] | 3565 | %------------------------------------------------------------------------ |
---|
[2] | 3566 | % --- Executes on button press in get_gridpatch1. |
---|
| 3567 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
[576] | 3568 | %------------------------------------------------------------------------ |
---|
[371] | 3569 | filebase=get(handles.RootPath,'String'); |
---|
[2] | 3570 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3571 | {'*.grid', ' (*.grid)'; |
---|
| 3572 | '*.grid', '.grid files '; ... |
---|
| 3573 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3574 | 'Pick a file',filebase); |
---|
[2] | 3575 | filegrid=fullfile(PathName,FileName); |
---|
| 3576 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3577 | |
---|
[371] | 3578 | |
---|
[12] | 3579 | %------------------------------------------------------------------------ |
---|
[2] | 3580 | % --- Executes on button press in get_gridpatch2. |
---|
| 3581 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3582 | %------------------------------------------------------------------------ |
---|
[2] | 3583 | |
---|
| 3584 | |
---|
[12] | 3585 | %------------------------------------------------------------------------ |
---|
[309] | 3586 | % --- STEREO Interp |
---|
| 3587 | function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) |
---|
[12] | 3588 | %------------------------------------------------------------------------ |
---|
[309] | 3589 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
| 3590 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
| 3591 | ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB ' -xy x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
[273] | 3592 | |
---|
[494] | 3593 | % %------------------------------------------------------------------------ |
---|
| 3594 | % %--read images and convert them to the uint16 format used for PIV |
---|
| 3595 | % function A=read_image(filename,type_ima,num,movieobject) |
---|
| 3596 | % %------------------------------------------------------------------------ |
---|
| 3597 | % %num is the view number needed for an avi movie |
---|
| 3598 | % switch type_ima |
---|
| 3599 | % case 'movie' |
---|
| 3600 | % A=read(movieobject,num); |
---|
| 3601 | % case 'avi' |
---|
| 3602 | % mov=aviread(filename,num); |
---|
| 3603 | % A=frame2im(mov(1)); |
---|
| 3604 | % case 'multimage' |
---|
| 3605 | % A=imread(filename,num); |
---|
| 3606 | % case 'image' |
---|
| 3607 | % A=imread(filename); |
---|
| 3608 | % end |
---|
| 3609 | % siz=size(A); |
---|
| 3610 | % if length(siz)==3;%color images |
---|
| 3611 | % A=sum(double(A),3); |
---|
| 3612 | % A=uint16(A); |
---|
| 3613 | % end |
---|
[2] | 3614 | |
---|
| 3615 | |
---|
[12] | 3616 | %------------------------------------------------------------------------ |
---|
[2] | 3617 | % --- Executes on button press in get_ref_fix1. |
---|
| 3618 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3619 | %------------------------------------------------------------------------ |
---|
[371] | 3620 | filebase=get(handles.RootPath,'String'); |
---|
[2] | 3621 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3622 | {'*.nc', ' (*.nc)'; |
---|
| 3623 | '*.nc', 'netcdf files '; ... |
---|
| 3624 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3625 | 'Pick a file',filebase); |
---|
| 3626 | |
---|
[2] | 3627 | fileinput=[PathName FileName]; |
---|
| 3628 | sizf=size(fileinput); |
---|
[122] | 3629 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[343] | 3630 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 3631 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
[2] | 3632 | ref.filebase=fullfile(Path,File); |
---|
[343] | 3633 | % ref.num_a=stra2num(str_a); |
---|
| 3634 | % ref.num_b=stra2num(str_b); |
---|
| 3635 | % ref.num1=str2double(field_count); |
---|
| 3636 | % ref.num2=str2double(str2); |
---|
[2] | 3637 | browse=[];%initialisation |
---|
| 3638 | if ~isequal(ref.ext,'.nc') |
---|
| 3639 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 3640 | return |
---|
| 3641 | end |
---|
| 3642 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 3643 | set(handles.ref_fix1,'UserData',ref) |
---|
| 3644 | menu_field{1}='civ1'; |
---|
| 3645 | Data=nc2struct(fileinput,[]); |
---|
[45] | 3646 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 3647 | menu_field{2}='filter1'; |
---|
| 3648 | end |
---|
[45] | 3649 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 3650 | menu_field{3}='civ2'; |
---|
| 3651 | end |
---|
[45] | 3652 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 3653 | menu_field{4}='filter2'; |
---|
| 3654 | end |
---|
| 3655 | set(handles.field_ref1,'String',menu_field); |
---|
| 3656 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
[287] | 3657 | set(handles.num_MinVel,'Value',2); |
---|
| 3658 | set(handles.num_MinVel,'String','1');%default threshold |
---|
[2] | 3659 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 3660 | |
---|
| 3661 | %------------------------------------------------------------------------ |
---|
[2] | 3662 | % --- Executes on button press in get_ref_fix2. |
---|
| 3663 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3664 | %------------------------------------------------------------------------ |
---|
[2] | 3665 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
[371] | 3666 | filebase=get(handles.RootPath,'String'); |
---|
[2] | 3667 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3668 | {'*.nc', ' (*.nc)'; |
---|
| 3669 | '*.nc', 'netcdf files '; ... |
---|
| 3670 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3671 | 'Pick a file',filebase); |
---|
[2] | 3672 | fileinput=[PathName FileName]; |
---|
| 3673 | sizf=size(fileinput); |
---|
[45] | 3674 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[343] | 3675 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 3676 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
[2] | 3677 | ref.filebase=fullfile(Path,File); |
---|
[343] | 3678 | % ref.num_a=stra2num(str_a); |
---|
| 3679 | % ref.num_b=stra2num(str_b); |
---|
| 3680 | % ref.num1=str2num(field_count); |
---|
| 3681 | % ref.num2=str2num(str2); |
---|
[2] | 3682 | browse=[];%initialisation |
---|
| 3683 | if ~isequal(ref.ext,'.nc') |
---|
| 3684 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 3685 | return |
---|
| 3686 | end |
---|
| 3687 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
[112] | 3688 | set(handles.ref_fix2,'UserData',ref) |
---|
[2] | 3689 | menu_field{1}='civ1'; |
---|
| 3690 | Data=nc2struct(fileinput,[]); |
---|
[301] | 3691 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 3692 | menu_field{2}='filter1'; |
---|
| 3693 | end |
---|
[301] | 3694 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 3695 | menu_field{3}='civ2'; |
---|
| 3696 | end |
---|
[301] | 3697 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 3698 | menu_field{4}='filter2'; |
---|
| 3699 | end |
---|
| 3700 | set(handles.field_ref2,'String',menu_field); |
---|
| 3701 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
[287] | 3702 | set(handles.num_MinVel,'Value',2); |
---|
| 3703 | set(handles.num_MinVel,'String','1');%default threshold |
---|
[2] | 3704 | set(handles.ref_fix2,'Enable','on') |
---|
| 3705 | set(handles.ref_fix2,'Visible','on') |
---|
| 3706 | set(handles.field_ref2,'Visible','on') |
---|
| 3707 | else |
---|
| 3708 | set(handles.ref_fix2,'Visible','off') |
---|
| 3709 | set(handles.field_ref2,'Visible','off') |
---|
| 3710 | end |
---|
| 3711 | |
---|
[12] | 3712 | %------------------------------------------------------------------------ |
---|
[2] | 3713 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3714 | %------------------------------------------------------------------------ |
---|
[287] | 3715 | set(handles.num_MinVel,'Value',1); |
---|
[12] | 3716 | set(handles.field_ref1,'Value',1) |
---|
| 3717 | set(handles.field_ref1,'String',{' '}) |
---|
| 3718 | set(handles.ref_fix1,'UserData',[]); |
---|
| 3719 | set(handles.ref_fix1,'String',''); |
---|
| 3720 | set(handles.thresh_vel1,'String','0'); |
---|
[112] | 3721 | |
---|
[12] | 3722 | %------------------------------------------------------------------------ |
---|
[2] | 3723 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3724 | %------------------------------------------------------------------------ |
---|
[287] | 3725 | set(handles.num_MinVel,'Value',1); |
---|
[12] | 3726 | set(handles.field_ref2,'Value',1) |
---|
| 3727 | set(handles.field_ref2,'String',{' '}) |
---|
| 3728 | set(handles.ref_fix2,'UserData',[]); |
---|
| 3729 | set(handles.ref_fix2,'String',''); |
---|
[287] | 3730 | set(handles.num_MinVel,'String','0'); |
---|
[2] | 3731 | |
---|
[12] | 3732 | %------------------------------------------------------------------------ |
---|
[371] | 3733 | % --- TO ABANDON Executes on button press in test_stereo1. |
---|
| 3734 | function CheckStereo_Callback(hObject, eventdata, handles) |
---|
[12] | 3735 | %------------------------------------------------------------------------ |
---|
[371] | 3736 | hparent=get(hObject,'parent'); |
---|
| 3737 | parent_tag=get(hparent,'Tag'); |
---|
| 3738 | hchildren=get(hparent,'children'); |
---|
| 3739 | handle_txtbox=findobj(hchildren,'tag','txt_Mask'); |
---|
| 3740 | if isequal(get(hObject,'Value'),0) |
---|
[581] | 3741 | set(handles.num_SubDomainSize,'Visible','on') |
---|
[437] | 3742 | set(handles.num_FieldSmooth,'Visible','on') |
---|
[2] | 3743 | else |
---|
[581] | 3744 | set(handles.num_SubDomainSize,'Visible','off') |
---|
[437] | 3745 | set(handles.num_FieldSmooth,'Visible','off') |
---|
[2] | 3746 | end |
---|
| 3747 | |
---|
[371] | 3748 | % %------------------------------------------------------------------------ |
---|
| 3749 | % % --- Executes on button press in CheckStereo. |
---|
| 3750 | % function StereoCheck_Callback(hObject, eventdata, handles) |
---|
| 3751 | % %------------------------------------------------------------------------ |
---|
| 3752 | % if isequal(get(handles.CheckStereo,'Value'),0) |
---|
[581] | 3753 | % set(handles.num_subdomainsize,'Visible','on') |
---|
[437] | 3754 | % set(handles.num_FieldSmooth,'Visible','on') |
---|
[371] | 3755 | % else |
---|
[581] | 3756 | % set(handles.num_subdomainsize,'Visible','off') |
---|
[437] | 3757 | % set(handles.num_FieldSmooth,'Visible','off') |
---|
[371] | 3758 | % end |
---|
| 3759 | |
---|
[12] | 3760 | %------------------------------------------------------------------------ |
---|
[413] | 3761 | % --- Executes on button press in TestCiv1: prepare the image correlation function |
---|
| 3762 | % activated by mouse motion |
---|
[150] | 3763 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
[224] | 3764 | %------------------------------------------------------------------------ |
---|
[233] | 3765 | drawnow |
---|
[309] | 3766 | if get(handles.TestCiv1,'Value') |
---|
[413] | 3767 | set(handles.TestCiv1,'BackgroundColor',[0.7 0.7 0.7])% paint TestCiv1 button to grey to confirm civ launch |
---|
| 3768 | ref_i=str2double(get(handles.ref_i,'String'));% read reference i index |
---|
[227] | 3769 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
[413] | 3770 | ref_j=str2double(get(handles.ref_j,'String'));% read reference j index if relevant |
---|
[227] | 3771 | else |
---|
[413] | 3772 | ref_j=1;%default j index |
---|
[227] | 3773 | end |
---|
[437] | 3774 | [filecell,i1,i2]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);% get the corresponding file name and indices |
---|
[224] | 3775 | Data.ListVarName={'ny','nx','A'}; |
---|
[315] | 3776 | Data.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
[444] | 3777 | |
---|
[413] | 3778 | Data.A=imread(filecell.ima1.civ1{1}); % read the first image |
---|
[387] | 3779 | if ndims(Data.A)==3 %case of color image |
---|
| 3780 | Data.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; |
---|
| 3781 | end |
---|
[224] | 3782 | Data.ny=[size(Data.A,1) 1]; |
---|
| 3783 | Data.nx=[1 size(Data.A,2)]; |
---|
[413] | 3784 | Data.CoordUnit='pixel';% used to set equal scaling for x and y in image dispaly |
---|
[309] | 3785 | par_civ1=read_GUI(handles.Civ1); |
---|
[784] | 3786 | FileInfo=get_file_info(filecell.ima1.civ1{1}); |
---|
[783] | 3787 | par_civ1.FileTypeA=FileInfo.FileType; |
---|
[388] | 3788 | par_civ1.ImageWidth=size(Data.A,2); |
---|
| 3789 | par_civ1.ImageHeight=size(Data.A,1); |
---|
[315] | 3790 | par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation |
---|
[435] | 3791 | par_civ1.FrameIndexA=num2str(i1); |
---|
| 3792 | par_civ1.FrameIndexB=num2str(i2); |
---|
[246] | 3793 | Param.Civ1=par_civ1; |
---|
[315] | 3794 | Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV |
---|
[387] | 3795 | hview_field=view_field(Data); %view the image in the GUI view_field |
---|
[231] | 3796 | set(0,'CurrentFigure',hview_field) |
---|
| 3797 | hhview_field=guihandles(hview_field); |
---|
[548] | 3798 | set(hview_field,'CurrentAxes',hhview_field.PlotAxes) |
---|
[231] | 3799 | ViewData=get(hview_field,'UserData'); |
---|
| 3800 | ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field |
---|
[548] | 3801 | ViewData.PlotAxes.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field |
---|
| 3802 | ViewData.PlotAxes.X=Grid.Civ1_X; %keep the set of points in memeory |
---|
| 3803 | ViewData.PlotAxes.Y=Grid.Civ1_Y; |
---|
[231] | 3804 | set(hview_field,'UserData',ViewData) |
---|
[224] | 3805 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 3806 | if isempty(corrfig) |
---|
| 3807 | corrfig=figure; |
---|
| 3808 | set(corrfig,'tag','corrfig') |
---|
| 3809 | set(corrfig,'name','image correlation') |
---|
| 3810 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
| 3811 | end |
---|
[233] | 3812 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
[224] | 3813 | else |
---|
[413] | 3814 | set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red |
---|
[224] | 3815 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 3816 | if ~isempty(corrfig) |
---|
| 3817 | delete(corrfig) |
---|
| 3818 | end |
---|
| 3819 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 3820 | if ~isempty(hview_field) |
---|
| 3821 | delete(hview_field) |
---|
| 3822 | end |
---|
[150] | 3823 | end |
---|
[71] | 3824 | |
---|
[415] | 3825 | %------------------------------------------------------------------------ |
---|
| 3826 | %----function introduced for the correlation window figure, activated by deleting this window |
---|
| 3827 | function closeview_field(gcbo,eventdata) |
---|
| 3828 | %------------------------------------------------------------------------ |
---|
| 3829 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 3830 | if ~isempty(hview_field) |
---|
| 3831 | delete(hview_field) |
---|
| 3832 | end |
---|
[150] | 3833 | |
---|
[252] | 3834 | %------------------------------------------------------------------------ |
---|
[315] | 3835 | % --- Executes on button press in CheckThreshold. |
---|
| 3836 | function CheckThreshold_Callback(hObject, eventdata, handles) |
---|
[252] | 3837 | %------------------------------------------------------------------------ |
---|
[315] | 3838 | huipanel=get(hObject,'parent'); |
---|
| 3839 | obj(1)=findobj(huipanel,'Tag','num_MinIma'); |
---|
| 3840 | obj(2)=findobj(huipanel,'Tag','num_MaxIma'); |
---|
| 3841 | obj(3)=findobj(huipanel,'Tag','title_Threshold'); |
---|
| 3842 | if get(hObject,'Value') |
---|
| 3843 | set(obj,'Visible','on') |
---|
| 3844 | else |
---|
| 3845 | set(obj,'Visible','off') |
---|
| 3846 | end |
---|
[220] | 3847 | |
---|
[465] | 3848 | |
---|
| 3849 | |
---|
| 3850 | |
---|
| 3851 | %'nomtype2pair': creates nomencalture for index pairs knowing the image nomenclature |
---|
| 3852 | %--------------------------------------------------------------------- |
---|
| 3853 | function NomTypeNc=nomtype2pair(NomTypeIma,mode) |
---|
| 3854 | %--------------------------------------------------------------------- |
---|
| 3855 | % OUTPUT: |
---|
| 3856 | % NomTypeNc |
---|
| 3857 | %--------------------------------------------------------------------- |
---|
| 3858 | % INPUT: |
---|
| 3859 | % 'NomTypeIma': string defining the kind of nomenclature used for images |
---|
| 3860 | |
---|
| 3861 | NomTypeNc=NomTypeIma;%default |
---|
| 3862 | switch mode |
---|
| 3863 | case 'pair j1-j2' |
---|
| 3864 | if ~isempty(regexp(NomTypeIma,'a$')) |
---|
| 3865 | NomTypeNc=[NomTypeIma 'b']; |
---|
| 3866 | elseif ~isempty(regexp(NomTypeIma,'A$')) |
---|
| 3867 | NomTypeNc=[NomTypeIma 'B']; |
---|
| 3868 | else |
---|
| 3869 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
| 3870 | if ~isempty(r) |
---|
| 3871 | NomTypeNc='_1_1-2'; |
---|
| 3872 | end |
---|
| 3873 | end |
---|
| 3874 | case 'series(Dj)' |
---|
[492] | 3875 | % r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
| 3876 | % if ~isempty(r) |
---|
[465] | 3877 | NomTypeNc='_1_1-2'; |
---|
[492] | 3878 | % end |
---|
[465] | 3879 | case 'series(Di)' |
---|
| 3880 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
| 3881 | if ~isempty(r) |
---|
| 3882 | NomTypeNc='_1-2_1'; |
---|
| 3883 | else |
---|
| 3884 | NomTypeNc='_1-2'; |
---|
| 3885 | end |
---|
| 3886 | end |
---|
| 3887 | |
---|
| 3888 | function NomType_Callback(hObject, eventdata, handles) |
---|
| 3889 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
| 3890 | RootPath=get(handles.RootPath,'String'); |
---|
| 3891 | RootFile=get(handles.RootFile,'String'); |
---|
[494] | 3892 | SubDirImages=get(handles.SubDirImages,'String'); |
---|
[465] | 3893 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3894 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 3895 | NomType=get(handles.NomType,'String'); |
---|
| 3896 | ImaExt=get(handles.ImaExt,'String'); |
---|
[494] | 3897 | fileinput=fullfile_uvmat(RootPath,SubDirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j); |
---|
[465] | 3898 | errormsg=display_file_name(handles,fileinput); |
---|
| 3899 | if ~isempty(errormsg) |
---|
| 3900 | msgbox_uvmat('ERROR',errormsg) |
---|
| 3901 | end |
---|
| 3902 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
| 3903 | |
---|
[469] | 3904 | % --- Executes on selection change in Program. |
---|
| 3905 | function Program_Callback(hObject, eventdata, handles) |
---|
| 3906 | ListProgram=get(handles.Program,'String'); |
---|
| 3907 | Program=ListProgram{get(handles.Program,'value')}; |
---|
[465] | 3908 | switch Program |
---|
| 3909 | case 'CivX' |
---|
| 3910 | set(handles.num_MaxDiff,'Visible','off') |
---|
| 3911 | set(handles.num_MaxVel,'Visible','off') |
---|
| 3912 | set(handles.title_MaxVel,'Visible','off') |
---|
| 3913 | set(handles.num_Nx,'Visible','on') |
---|
| 3914 | set(handles.num_Ny,'Visible','on') |
---|
| 3915 | set(handles.title_Nx,'Visible','on') |
---|
| 3916 | set(handles.title_Ny,'Visible','on') |
---|
| 3917 | set(handles.title_MaxDiff,'Visible','off') |
---|
| 3918 | set(handles.num_CorrSmooth,'Style','edit') |
---|
| 3919 | set(handles.num_CorrSmooth,'String','1') |
---|
| 3920 | set(handles.BATCH,'Enable','on') |
---|
| 3921 | set(handles.CheckThreshold,'Visible','off') |
---|
| 3922 | set(handles.CheckDeformation,'Value',1) |
---|
| 3923 | set(handles.CheckDecimal,'Value',1) |
---|
[469] | 3924 | case {'civ_matlab','civ_matlab.sh'} |
---|
[465] | 3925 | set(handles.num_MaxDiff,'Visible','on') |
---|
| 3926 | set(handles.num_MaxVel,'Visible','on') |
---|
| 3927 | set(handles.title_MaxVel,'Visible','on') |
---|
| 3928 | set(handles.title_MaxDiff,'Visible','on') |
---|
| 3929 | set(handles.num_Nx,'Visible','off') |
---|
| 3930 | set(handles.num_Ny,'Visible','off') |
---|
| 3931 | set(handles.title_Nx,'Visible','off') |
---|
| 3932 | set(handles.title_Ny,'Visible','off') |
---|
| 3933 | set(handles.num_CorrSmooth,'Style','popupmenu') |
---|
| 3934 | set(handles.num_CorrSmooth,'Value',1) |
---|
| 3935 | set(handles.num_CorrSmooth,'String',{'1';'2'}) |
---|
| 3936 | set(handles.CheckThreshold,'Visible','on') |
---|
| 3937 | set(handles.CheckDeformation,'Value',0)% desactivate (work in progress) |
---|
| 3938 | set(handles.CheckDecimal,'Value',0)% desactivate (work in progress) |
---|
| 3939 | end |
---|
| 3940 | |
---|
| 3941 | % --- Executes on button press in TestPatch1. |
---|
| 3942 | function TestPatch1_Callback(hObject, eventdata, handles) |
---|
| 3943 | set(handles.TestPatch1,'BackgroundColor',[1 1 0]) |
---|
| 3944 | drawnow |
---|
| 3945 | if get(handles.TestPatch1,'Value') |
---|
| 3946 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3947 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
| 3948 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 3949 | else |
---|
| 3950 | ref_j=1;%default |
---|
| 3951 | end |
---|
| 3952 | filecell=set_civ_filenames(handles,ref_i,ref_j,[0 0 1 0 0 0]); |
---|
| 3953 | Data.ListVarName={'ny','nx','A'}; |
---|
| 3954 | Data.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
| 3955 | param_patch1=read_GUI(handles.Patch1); |
---|
| 3956 | param_patch1.CivFile=filecell.nc.civ1{1}; |
---|
| 3957 | Param.Patch1=param_patch1; |
---|
| 3958 | for irho=1:7 |
---|
| 3959 | [Data,errormsg]=civ_matlab(Param);% get the grid of x, y positions set for PIV |
---|
| 3960 | if ~isempty(errormsg) |
---|
| 3961 | msgbox_uvmat('ERROR',errormsg) |
---|
| 3962 | return |
---|
| 3963 | end |
---|
| 3964 | SmoothingParam(irho)=Param.Patch1.FieldSmooth; |
---|
| 3965 | Data.Civ1_U_Diff=Data.Civ1_U_Diff(Data.Civ1_FF==0); |
---|
| 3966 | Data.Civ1_V_Diff=Data.Civ1_V_Diff(Data.Civ1_FF==0); |
---|
| 3967 | DiffVel(irho)=sqrt(mean(Data.Civ1_U_Diff.*Data.Civ1_U_Diff+Data.Civ1_V_Diff.*Data.Civ1_V_Diff)) |
---|
| 3968 | NbSites(irho,:)=Data.Civ1_NbSites*numel(Data.Civ1_NbSites)/numel(Data.Civ1_U_Diff); |
---|
| 3969 | Param.Patch1.SmoothingParam=2*Param.Patch1.FieldSmooth; |
---|
| 3970 | end |
---|
| 3971 | figure |
---|
| 3972 | plot(SmoothingParam,DiffVel,'b',SmoothingParam,NbSites,'r') |
---|
| 3973 | set(handles.TestPatch1,'BackgroundColor',[1 0 0]) |
---|
| 3974 | else |
---|
| 3975 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 3976 | if ~isempty(corrfig) |
---|
| 3977 | delete(corrfig) |
---|
| 3978 | end |
---|
| 3979 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 3980 | if ~isempty(hview_field) |
---|
| 3981 | delete(hview_field) |
---|
| 3982 | end |
---|
| 3983 | end |
---|
| 3984 | |
---|
| 3985 | |
---|
| 3986 | % --- Executes on button press in TestCiv2. |
---|
| 3987 | function TestCiv2_Callback(hObject, eventdata, handles) |
---|
| 3988 | |
---|
| 3989 | function RootFile_Callback(hObject, eventdata, handles) |
---|
| 3990 | |
---|
[494] | 3991 | function SubDirImages_Callback(hObject, eventdata, handles) |
---|
[465] | 3992 | |
---|
| 3993 | |
---|
| 3994 | |
---|
| 3995 | function errormsg=write_param(Param) |
---|
[252] | 3996 | %------------------------------------------------------------------------ |
---|
[284] | 3997 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 3998 | %changes : filename_cmx -> filename ( no extension ) |
---|
[465] | 3999 | errormsg=''; |
---|
[469] | 4000 | switch Param.Program |
---|
[465] | 4001 | case 'CivX' |
---|
| 4002 | if Param.CheckCiv1 |
---|
[487] | 4003 | filename=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_CMX$2$3.civ1.cmx'); |
---|
[465] | 4004 | if isequal(Param.Civ1.Dt,0) |
---|
| 4005 | Param.Civ1.Dt=1 ;%case of 'displacement' mode |
---|
| 4006 | end |
---|
| 4007 | Param.Civ1.ImageA=regexprep(Param.Civ1.ImageA,'.png',''); |
---|
| 4008 | Param.Civ1.ImageB=regexprep(Param.Civ1.ImageB,'.png',''); |
---|
| 4009 | [fid,errormsg]=fopen(filename,'w'); |
---|
| 4010 | if isequal(fid,-1) |
---|
| 4011 | errormsg=['cmd file ' filename ' cannot be created: ' errormsg]; |
---|
| 4012 | return |
---|
| 4013 | end |
---|
| 4014 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4015 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ1.ImageA,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4016 | fprintf(fid, ['LastImage ' regexprep(Param.Civ1.ImageB,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4017 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4018 | if isfield(Param.Civ1,'Mask') |
---|
| 4019 | fprintf(fid, ['Mask ' 'y' '\n' ]); |
---|
| 4020 | fprintf(fid, ['MaskName ' regexprep(Param.Civ1.Mask,'\\','\\\\') '\n' ]); |
---|
| 4021 | else |
---|
| 4022 | fprintf(fid, ['Mask ' 'n' '\n' ]); |
---|
| 4023 | fprintf(fid, ['MaskName ' 'noFile use default' '\n' ]); |
---|
| 4024 | end |
---|
| 4025 | fprintf(fid, ['ImageSize ' num2str(Param.Civ1.ImageWidth) ' ' num2str(Param.Civ1.ImageHeight) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4026 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ1.CorrBoxSize(1)) ' ' num2str(Param.Civ1.CorrBoxSize(2)) '\n' ]); |
---|
| 4027 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ1.SearchBoxSize(1)) ' ' num2str(Param.Civ1.SearchBoxSize(2)) '\n' ]); |
---|
| 4028 | fprintf(fid, ['RO ' num2str(Param.Civ1.CorrSmooth) '\n' ]); |
---|
| 4029 | if isfield(Param.Civ1,'Grid') |
---|
| 4030 | fprintf(fid, ['GridSpacing ' '25' ' ' '25' '\n' ]); |
---|
| 4031 | else |
---|
| 4032 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ1.Dx) ' ' num2str(Param.Civ1.Dy) '\n' ]); |
---|
| 4033 | end |
---|
| 4034 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4035 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ1.Dt) ' ' num2str(Param.Civ1.Time) '\n' ]); |
---|
| 4036 | fprintf(fid, ['PixCmXY ' '1' ' ' '1' '\n' ]); |
---|
| 4037 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4038 | fprintf(fid, ['ShiftXY ' num2str(Param.Civ1.SearchBoxShift(1)) ' ' num2str(Param.Civ1.SearchBoxShift(2)) '\n' ]); |
---|
| 4039 | if isfield(Param.Civ1,'Grid') |
---|
| 4040 | fprintf(fid, ['Grid ' 'y' '\n' ]); |
---|
| 4041 | fprintf(fid, ['GridName ' regexprep(Param.Civ1.Grid,'\\','\\\\') '\n' ]); |
---|
| 4042 | else |
---|
| 4043 | fprintf(fid, ['Grid ' 'n' '\n' ]); |
---|
| 4044 | fprintf(fid, ['GridName ' 'noFile use default' '\n' ]); |
---|
| 4045 | end |
---|
| 4046 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4047 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4048 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4049 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4050 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4051 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4052 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4053 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4054 | if ~isfield(Param.Civ1,'MinIma')% Image threshold not activated |
---|
| 4055 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4056 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]);%not used in principle |
---|
| 4057 | else% Image threshold activated |
---|
| 4058 | if isempty(Param.Civ1.MaxIma)||isnan(Param.Civ1.MaxIma) |
---|
| 4059 | Param.Civ1.MaxIma=2^Param.Civ1.ImageBitDepth;%take the max image value as upper bound by default |
---|
| 4060 | end |
---|
| 4061 | fprintf(fid, ['SeuilImage y' '\n' ]); |
---|
| 4062 | fprintf(fid, ['SeuilImageValues ' num2str(Param.Civ1.MinIma) ' ' num2str(Param.Civ1.MaxIma) '\n' ]); |
---|
| 4063 | end |
---|
| 4064 | fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? |
---|
| 4065 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 4066 | fclose(fid); |
---|
| 4067 | end |
---|
| 4068 | |
---|
| 4069 | if Param.CheckCiv2 |
---|
[487] | 4070 | filename=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_CMX$2$3.civ2.cmx'); |
---|
[465] | 4071 | |
---|
| 4072 | if isequal(Param.Civ2.Dt,'0') |
---|
| 4073 | Param.Civ2.Dt='1' ;%case of 'displacement' mode |
---|
| 4074 | end |
---|
| 4075 | Param.Civ2.ImageA=regexprep(Param.Civ2.ImageA,'.png',''); |
---|
| 4076 | Param.Civ2.ImageB=regexprep(Param.Civ2.ImageB,'.png','');% bug : .png appears two times ? |
---|
| 4077 | [fid,errormsg]=fopen(filename,'w'); |
---|
| 4078 | if isequal(fid,-1) |
---|
| 4079 | return |
---|
| 4080 | end |
---|
| 4081 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4082 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ2.ImageA,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4083 | fprintf(fid, ['LastImage ' regexprep(Param.Civ2.ImageB,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4084 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4085 | if isfield(Param.Civ2,'Mask') |
---|
| 4086 | fprintf(fid, ['Mask ' 'y' '\n' ]); |
---|
|
---|