[435] | 1 | |
---|
[112] | 2 | %'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch) |
---|
[2] | 3 | %------------------------------------------------------------------------ |
---|
[309] | 4 | % provides an interface for the software menucivx |
---|
[2] | 5 | % function varargout = civ(varargin) |
---|
[309] | 6 | % provides an interface for the software menucivx |
---|
[2] | 7 | % |
---|
| 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
[282] | 9 | % Copyright Joel Sommeria, 2011, LEGI / CNRS-UJF-INPG, sommeria@legi.grenoble-inp.fr |
---|
[2] | 10 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
[112] | 11 | % This file is part of the toolbox UVMAT. |
---|
| 12 | % |
---|
[2] | 13 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 14 | % it under the terms of the GNU General Public License as published by |
---|
| 15 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 16 | % (at your option) any later version. |
---|
[112] | 17 | % |
---|
[2] | 18 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 21 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 22 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 23 | function varargout = civ(varargin) |
---|
[273] | 24 | %TODO: search range |
---|
[2] | 25 | |
---|
[500] | 26 | % Last Modified by GUIDE v2.5 24-Jul-2012 13:14:00 |
---|
[2] | 27 | % Begin initialization code - DO NOT EDIT |
---|
| 28 | gui_Singleton = 1; |
---|
| 29 | gui_State = struct('gui_Name', mfilename, ... |
---|
[112] | 30 | 'gui_Singleton', gui_Singleton, ... |
---|
| 31 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
---|
| 32 | 'gui_OutputFcn', @civ_OutputFcn, ... |
---|
| 33 | 'gui_LayoutFcn', [] , ... |
---|
| 34 | 'gui_Callback', []); |
---|
[382] | 35 | if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback$','once')) |
---|
[2] | 36 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 37 | end |
---|
| 38 | |
---|
| 39 | if nargout |
---|
| 40 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 41 | else |
---|
| 42 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 43 | end |
---|
| 44 | % End initialization code - DO NOT EDIT |
---|
| 45 | |
---|
[12] | 46 | %------------------------------------------------------------------------ |
---|
[2] | 47 | % --- Executes just before civ is made visible. |
---|
[298] | 48 | function civ_OpeningFcn(hObject, eventdata, handles, fileinput) |
---|
[12] | 49 | %------------------------------------------------------------------------ |
---|
[2] | 50 | % This function has no output args, see OutputFcn. |
---|
[298] | 51 | |
---|
| 52 | %% General settings |
---|
[2] | 53 | handles.output = hObject; |
---|
[298] | 54 | guidata(hObject, handles); % Update handles structure |
---|
[309] | 55 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[252] | 56 | |
---|
[298] | 57 | %% Adjust the GUI according to the binaries available in PARAM.xml |
---|
[276] | 58 | path_civ=fileparts(which('civ')); %path to civ |
---|
[298] | 59 | 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] | 60 | errormsg=[];%default error message |
---|
[500] | 61 | xmlfile=fullfile(path_civ,'PARAM.xml'); |
---|
[483] | 62 | test_batch=0;%default: ,no batch mode available |
---|
| 63 | sparam=[]; |
---|
[500] | 64 | if ~exist(xmlfile,'file') |
---|
[505] | 65 | [success,message]=copyfile(fullfile(path_civ,'PARAM.xml.default'),xmlfile); |
---|
[500] | 66 | end |
---|
[273] | 67 | if exist(xmlfile,'file') |
---|
| 68 | try |
---|
| 69 | t=xmltree(xmlfile); |
---|
| 70 | sparam=convert(t); |
---|
[435] | 71 | catch ME |
---|
| 72 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message}; |
---|
[483] | 73 | msgbox_uvmat('WARNING',errormsg); |
---|
[273] | 74 | end |
---|
| 75 | else |
---|
[483] | 76 | [s,w]=system('oarstat'); |
---|
| 77 | if ~isequal(s,0) |
---|
| 78 | [s,w]=system('qstat'); |
---|
| 79 | end |
---|
| 80 | if isequal(s,0) |
---|
| 81 | test_batch=1; |
---|
| 82 | end |
---|
[273] | 83 | end |
---|
| 84 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
[482] | 85 | batch_mode=sparam.BatchParam.BatchMode; %sge is currently the only implemented batch mod |
---|
[484] | 86 | test_command=''; |
---|
[482] | 87 | switch batch_mode |
---|
| 88 | case 'sge' |
---|
| 89 | test_command='qstat'; |
---|
| 90 | case 'oar' |
---|
| 91 | test_command='oarstat'; |
---|
| 92 | end |
---|
[484] | 93 | if ~isempty(test_command) |
---|
[500] | 94 | [s,w]=system(test_command); |
---|
| 95 | if isequal(s,0) |
---|
| 96 | test_batch=1; |
---|
| 97 | end |
---|
[482] | 98 | end |
---|
[273] | 99 | end |
---|
[467] | 100 | RUNVal=get(handles.RunMode,'Value'); |
---|
[273] | 101 | if test_batch==0 |
---|
[467] | 102 | if RUNVal>2 |
---|
| 103 | set(handles.RunMode,'Value',1) |
---|
| 104 | end |
---|
| 105 | set(handles.RunMode,'String',{'local';'background'}) |
---|
| 106 | else |
---|
| 107 | set(handles.RunMode,'String',{'local';'background';'cluster'}) |
---|
[273] | 108 | end |
---|
| 109 | |
---|
[298] | 110 | %% load the list of previously browsed files in the upper bar menu Open/ |
---|
[296] | 111 | dir_perso=prefdir; % path to the directory .matlab for personal data |
---|
| 112 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab |
---|
| 113 | if exist(profil_perso,'file') |
---|
| 114 | h=load (profil_perso); |
---|
| 115 | if isfield(h,'MenuFile') |
---|
| 116 | for ifile=1:min(length(h.MenuFile),5) |
---|
| 117 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
| 118 | end |
---|
| 119 | end |
---|
[273] | 120 | end |
---|
| 121 | |
---|
[298] | 122 | %% prepare the GUI with parameters from the input file if opened from uvmat |
---|
| 123 | if exist('fileinput','var')% && isfield(param,'RootName') && ~isempty(param.RootName) |
---|
[371] | 124 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[298] | 125 | errormsg=display_file_name(handles,fileinput); |
---|
| 126 | if ~isempty(errormsg) |
---|
| 127 | msgbox_uvmat('ERROR',errormsg) |
---|
[112] | 128 | end |
---|
[371] | 129 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[2] | 130 | end |
---|
[506] | 131 | Program_Callback([],[], handles) |
---|
[2] | 132 | |
---|
[12] | 133 | %------------------------------------------------------------------------ |
---|
[2] | 134 | % --- Outputs from this function are returned to the command line. |
---|
| 135 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 136 | %------------------------------------------------------------------------ |
---|
[2] | 137 | % Get default command line output from handles structure |
---|
| 138 | varargout{1} = handles.output; |
---|
| 139 | |
---|
[307] | 140 | %------------------------------------------------------------------------ |
---|
[309] | 141 | % --- Function activated by the Open/Browse... option in the upper menu bar. |
---|
[307] | 142 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
| 143 | %------------------------------------------------------------------------ |
---|
[343] | 144 | %% get the current input root file name to initiate the browser |
---|
[371] | 145 | filebase=get(handles.RootPath,'String'); |
---|
[307] | 146 | oldfile=''; %default |
---|
[309] | 147 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored root file name |
---|
[307] | 148 | dir_perso=prefdir; |
---|
| 149 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 150 | if exist(profil_perso,'file') |
---|
| 151 | h=load (profil_perso); |
---|
| 152 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 153 | oldfile=h.filebase; |
---|
| 154 | end |
---|
| 155 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 156 | oldfile=h.RootPath; |
---|
| 157 | end |
---|
| 158 | end |
---|
| 159 | else |
---|
| 160 | oldfile=filebase; |
---|
| 161 | end |
---|
[360] | 162 | |
---|
| 163 | %% get the new input file with the browser |
---|
[307] | 164 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
[309] | 165 | '*.xml', '.xml files '; ... |
---|
| 166 | '*.civ', '.civ files '; ... |
---|
| 167 | '*.png','.png image files'; ... |
---|
| 168 | '*.jpg',' jpeg image files'; ... |
---|
| 169 | '*.tif','.tif image files'; ... |
---|
| 170 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 171 | '*.nc','.netcdf files'; ... |
---|
| 172 | '*.*', 'All Files (*.*)'}; |
---|
[307] | 173 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 174 | fileinput=[PathName FileName];%complete file name |
---|
| 175 | sizf=size(fileinput); |
---|
| 176 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 177 | |
---|
[343] | 178 | %% case of the xml file opened as input (TODO: check and see whether it is useful) |
---|
[307] | 179 | [path,name,ext]=fileparts(fileinput); |
---|
| 180 | testeditxml=0; |
---|
[360] | 181 | % if isequal(ext,'.xml') |
---|
| 182 | % testeditxml=1; |
---|
| 183 | % t_browse=xmltree(fileinput); |
---|
| 184 | % head_element=get(t_browse,1); |
---|
| 185 | % if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
| 186 | % testeditxml=0; |
---|
| 187 | % end |
---|
[343] | 188 | % end |
---|
[360] | 189 | % if testeditxml==1 || isequal(ext,'.xls') |
---|
| 190 | % heditxml=editxml({fileinput}); |
---|
| 191 | % set(heditxml,'Tag','browser') |
---|
| 192 | % waitfor(heditxml,'Tag','idle') |
---|
| 193 | % if ~ishandle(heditxml) |
---|
| 194 | % return |
---|
| 195 | % end |
---|
| 196 | % attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 197 | % set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 198 | % fileinput=get(attr,'UserData'); |
---|
| 199 | % if ~exist(fileinput,'file') |
---|
| 200 | % return |
---|
| 201 | % end |
---|
[343] | 202 | % end |
---|
[360] | 203 | [tild,tild,tild,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput); |
---|
[343] | 204 | |
---|
| 205 | %% prepare the GUI with parameters from the input file |
---|
[371] | 206 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[343] | 207 | errormsg=display_file_name(handles,fileinput); |
---|
| 208 | if ~isempty(errormsg) |
---|
| 209 | msgbox_uvmat('ERROR',erromsg) |
---|
[307] | 210 | end |
---|
[371] | 211 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[307] | 212 | |
---|
[309] | 213 | %------------------------------------------------------------------------ |
---|
[273] | 214 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
| 215 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
[12] | 216 | %------------------------------------------------------------------------ |
---|
[371] | 217 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 218 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
[298] | 219 | errormsg=display_file_name(handles,fileinput); |
---|
| 220 | if ~isempty(errormsg) |
---|
[355] | 221 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 222 | end |
---|
[371] | 223 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[273] | 224 | |
---|
| 225 | % ----------------------------------------------------------------------- |
---|
| 226 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
| 227 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 228 | %------------------------------------------------------------------------ |
---|
[371] | 229 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 230 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
[298] | 231 | errormsg=display_file_name(handles,fileinput); |
---|
| 232 | if ~isempty(errormsg) |
---|
[355] | 233 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 234 | end |
---|
[371] | 235 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[309] | 236 | |
---|
[273] | 237 | % ----------------------------------------------------------------------- |
---|
| 238 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
| 239 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 240 | %------------------------------------------------------------------------ |
---|
[371] | 241 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 242 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
[298] | 243 | errormsg=display_file_name(handles,fileinput); |
---|
| 244 | if ~isempty(errormsg) |
---|
[355] | 245 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 246 | end |
---|
[371] | 247 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[309] | 248 | |
---|
[273] | 249 | % ----------------------------------------------------------------------- |
---|
| 250 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
| 251 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 252 | %------------------------------------------------------------------------ |
---|
[371] | 253 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 254 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
[298] | 255 | errormsg=display_file_name(handles,fileinput); |
---|
| 256 | if ~isempty(errormsg) |
---|
[355] | 257 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 258 | end |
---|
[371] | 259 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[309] | 260 | |
---|
[273] | 261 | % ----------------------------------------------------------------------- |
---|
| 262 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
| 263 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 264 | %------------------------------------------------------------------------ |
---|
[371] | 265 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 266 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
[298] | 267 | errormsg=display_file_name(handles,fileinput); |
---|
| 268 | if ~isempty(errormsg) |
---|
[355] | 269 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 270 | end |
---|
[371] | 271 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[309] | 272 | |
---|
| 273 | % ----------------------------------------------------------------------- |
---|
| 274 | % ----------------------------------------------------------------------- |
---|
| 275 | % --- Open the help html file |
---|
| 276 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
| 277 | % ----------------------------------------------------------------------- |
---|
| 278 | path_civ=fileparts(which ('civ')); |
---|
| 279 | helpfile=fullfile(path_civ,'uvmat_doc','uvmat_doc.html'); |
---|
| 280 | if isempty(dir(helpfile)) |
---|
| 281 | msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
| 282 | else |
---|
| 283 | addpath (fullfile(path_civ,'uvmat_doc')) |
---|
| 284 | web([helpfile '#civ']) |
---|
| 285 | end |
---|
| 286 | |
---|
[12] | 287 | %------------------------------------------------------------------------ |
---|
[309] | 288 | % --- Function activated when a new filebase (image series) is introduced |
---|
[371] | 289 | function RootPath_Callback(hObject, eventdata, handles) |
---|
[12] | 290 | %------------------------------------------------------------------------ |
---|
[371] | 291 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
| 292 | RootPath=get(handles.RootPath,'String'); |
---|
[494] | 293 | SubDirImages=get(handles.SubDirImages,'String'); |
---|
[371] | 294 | RootFile=get(handles.RootFile,'String'); |
---|
[360] | 295 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 296 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 297 | NomType=get(handles.NomType,'String'); |
---|
| 298 | ImaExt=get(handles.ImaExt,'String'); |
---|
[494] | 299 | fileinput=fullfile_uvmat(RootPath,SubDirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j); |
---|
[360] | 300 | errormsg=display_file_name(handles,fileinput); |
---|
[298] | 301 | if ~isempty(errormsg) |
---|
[360] | 302 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 303 | end |
---|
[371] | 304 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[384] | 305 | |
---|
[273] | 306 | %------------------------------------------------------------------------ |
---|
[309] | 307 | % --- general function activated for an input file series |
---|
[298] | 308 | function errormsg=display_file_name(handles,fileinput) |
---|
[273] | 309 | %------------------------------------------------------------------------ |
---|
[282] | 310 | set(handles.ListCompareMode,'Visible','on') |
---|
[298] | 311 | errormsg='';%default empty error message |
---|
[355] | 312 | drawnow |
---|
[273] | 313 | |
---|
[298] | 314 | %% enable RUN, BATCH button and 'status' display |
---|
| 315 | set(handles.RUN, 'Enable','On') |
---|
| 316 | set(handles.RUN,'BackgroundColor',[1 0 0])%set RUN button to red color |
---|
| 317 | if isfield(handles,'status') |
---|
| 318 | set(handles.status,'Value',0); %suppress the 'status' display |
---|
| 319 | status_Callback([], [], handles) |
---|
[2] | 320 | end |
---|
| 321 | |
---|
[298] | 322 | %% determine nomenclature types and extension of the input files |
---|
[355] | 323 | [RootPath,SubDir,RootFile,i1,i2,j1,j2,ExtInput,NomTypeInput]=fileparts_uvmat(fileinput); |
---|
[360] | 324 | NomTypeNc='';%default |
---|
| 325 | |
---|
[438] | 326 | %% case of xml file as input, read the civ parameters |
---|
[355] | 327 | ind_opening=0;%default |
---|
[360] | 328 | if strcmp(ExtInput,'.xml') |
---|
[501] | 329 | %reinitialise menus |
---|
| 330 | set(handles.ListPairMode,'Value',1) |
---|
| 331 | set(handles.ListPairMode,'String',{''}) |
---|
| 332 | set(handles.ListPairCiv1,'Value',1) |
---|
| 333 | set(handles.ListPairCiv1,'String',{''}) |
---|
| 334 | set(handles.ListPairCiv2,'Value',1) |
---|
| 335 | set(handles.ListPairCiv2,'String',{''}) |
---|
| 336 | Param=xml2struct(fileinput); %read parameters from the xml input file |
---|
[360] | 337 | fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file |
---|
| 338 | return |
---|
| 339 | end |
---|
[438] | 340 | |
---|
| 341 | %% case of netcdf file as input, get the civ processing stage and look for a coresponding image |
---|
[493] | 342 | imageinput=fileinput;%default |
---|
[360] | 343 | if strcmp(ExtInput,'.nc') |
---|
| 344 | NomTypeNc=NomTypeInput; |
---|
[494] | 345 | if isempty(regexp(NomTypeInput,'[ab|AB|-]', 'once')) |
---|
[371] | 346 | set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomencalture does not involve index pairs |
---|
[438] | 347 | set(handles.RootFile_1,'Visible','On'); |
---|
[371] | 348 | else |
---|
[438] | 349 | set(handles.ListCompareMode,'Value',1) |
---|
| 350 | set(handles.RootFile_1,'Visible','Off'); |
---|
[371] | 351 | end |
---|
[493] | 352 | imageinput=''; |
---|
[371] | 353 | Data=nc2struct(fileinput,'ListGlobalAttribute','Conventions','absolut_time_T0','CivStage','Civ2_ImageA','Civ1_ImageA','Civ2_ImageB','Civ1_ImageB','fix','patch','civ2','fix2'); |
---|
[360] | 354 | if isfield(Data,'Txt') |
---|
| 355 | errormsg=Data.Txt; |
---|
| 356 | return |
---|
| 357 | end |
---|
[438] | 358 | % settings for new civ data, |
---|
[360] | 359 | if strcmp(Data.Conventions,'uvmat/civdata')% case of new civ data, |
---|
[500] | 360 | set(handles.Program,'Value',1) %select civ/Matlab by default |
---|
[493] | 361 | Program_Callback([],[], handles) |
---|
[355] | 362 | if ~isempty(Data.CivStage)%test for civ files |
---|
| 363 | ind_opening=Data.CivStage; |
---|
[343] | 364 | end |
---|
[371] | 365 | if ~isempty(Data.Civ2_ImageB)%get the corresponding input image in the netcdf file |
---|
| 366 | imageinput=Data.Civ2_ImageB; |
---|
| 367 | [tild,ImaName,ImaExt]=fileparts(Data.Civ2_ImageA); |
---|
| 368 | set(handles.RootFile_1,'String',[ImaName ImaExt]) |
---|
| 369 | elseif ~isempty(Data.Civ1_ImageB) |
---|
| 370 | imageinput=Data.Civ1_ImageB; |
---|
| 371 | [tild,ImaName,ImaExt]=fileparts(Data.Civ1_ImageA); |
---|
| 372 | set(handles.RootFile_1,'String',[ImaName ImaExt]) |
---|
[298] | 373 | end |
---|
[438] | 374 | % settings for civx data, |
---|
[360] | 375 | elseif ~isempty(Data.absolut_time_T0')% case of civx data, |
---|
[500] | 376 | set(handles.Program,'Value',3) %select Cix by default |
---|
[476] | 377 | Program_Callback([],[], handles) |
---|
[355] | 378 | if ~isempty(Data.fix2) |
---|
| 379 | ind_opening=5; |
---|
| 380 | elseif ~isempty(Data.civ2) |
---|
| 381 | ind_opening=4; |
---|
| 382 | elseif ~isempty(Data.patch) |
---|
| 383 | ind_opening=3; |
---|
| 384 | elseif ~isempty(Data.fix) |
---|
| 385 | ind_opening=2; |
---|
| 386 | end |
---|
[360] | 387 | else |
---|
| 388 | errormsg='the input netcdf file is not civ data'; |
---|
| 389 | return |
---|
| 390 | end |
---|
[438] | 391 | % look for the corresponding input images |
---|
| 392 | check_letter=~isempty(regexp(NomTypeInput,'[ab|AB]$','once'));%detect pair label by letter |
---|
| 393 | NomTypeIma=NomTypeInput; |
---|
| 394 | if check_letter |
---|
| 395 | NomTypeIma=NomTypeInput(1:end-1); |
---|
| 396 | else |
---|
| 397 | r=regexp(NomTypeIma,'.-(?<num2>\d+)$','names'); |
---|
| 398 | if ~isempty(r) |
---|
| 399 | NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); |
---|
| 400 | end |
---|
| 401 | r=regexp(NomTypeIma,'.-(?<num2>\d+)','names'); |
---|
| 402 | if ~isempty(r) |
---|
| 403 | NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); |
---|
| 404 | end |
---|
| 405 | end |
---|
[493] | 406 | if ~exist(imageinput,'file') |
---|
[438] | 407 | imageinput=fullfile_uvmat(RootPath,regexprep(SubDir,'.civ(_?)(\d*)$',''),RootFile,'.png',NomTypeIma,i1,[],j1); |
---|
[493] | 408 | end |
---|
[360] | 409 | end |
---|
| 410 | |
---|
[469] | 411 | %% no corresponding image found, select manually with the browser |
---|
[360] | 412 | ImaExt=ExtInput; |
---|
| 413 | if ~isempty(NomTypeNc) |
---|
| 414 | %no corresponding image found, select manually with the browser |
---|
| 415 | if ~exist(imageinput,'file') |
---|
| 416 | menu={'*.png;*.jpg;*.tif;*.avi;*.AVI', '(*.png,*.jpg ,*.tif, *.avi,*.AVI)'; |
---|
| 417 | '*.png','.png image files'; ... |
---|
| 418 | '*.jpg',' jpeg image files'; ... |
---|
| 419 | '*.tif','.tif image files'; ... |
---|
| 420 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 421 | '*.*', 'All Files (*.*)'}; |
---|
| 422 | [FileName, PathName] = uigetfile( menu, 'Pick an input image file',fileparts(fileparts(fileinput))); |
---|
[493] | 423 | imageinput=[PathName FileName];%complete file name |
---|
| 424 | if ~exist(imageinput,'file') |
---|
[469] | 425 | return %abandon of the browser is cancelled |
---|
| 426 | end |
---|
[360] | 427 | end |
---|
[469] | 428 | %fileinput=imageinput; |
---|
[360] | 429 | end |
---|
[371] | 430 | |
---|
| 431 | %% scan the image file series |
---|
[493] | 432 | [FilePath,FileName,ImaExt]=fileparts(imageinput); |
---|
[398] | 433 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 434 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
[494] | 435 | [RootPath,SubDirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]); |
---|
[360] | 436 | switch FileType |
---|
[435] | 437 | case {'image','multimage','video','mmreader'} |
---|
[355] | 438 | otherwise |
---|
[360] | 439 | errormsg='invalid input file: enter an image, a movie or civ .nc file'; |
---|
| 440 | return |
---|
[2] | 441 | end |
---|
[371] | 442 | set(handles.RootPath,'String',RootPath) |
---|
[494] | 443 | set(handles.SubDirImages,'String',SubDirImages) |
---|
[371] | 444 | set(handles.RootFile,'String',RootFile) |
---|
[438] | 445 | if strcmp(ExtInput,'.nc') |
---|
[494] | 446 | SubDirCiv=regexprep(SubDir,['^' SubDirImages],'');%suppress the root SuddirImages; |
---|
[438] | 447 | else |
---|
[441] | 448 | SubDirCiv= '.civ'; |
---|
[438] | 449 | end |
---|
| 450 | set(handles.SubdirCiv1,'String',SubDirCiv) |
---|
| 451 | set(handles.SubdirCiv2,'String',SubDirCiv) |
---|
[371] | 452 | browse=get(handles.RootPath,'UserData'); |
---|
[355] | 453 | browse.incr_pair=[0 0];%default |
---|
| 454 | |
---|
[360] | 455 | %% scan the images if a civ file has been opened |
---|
[370] | 456 | MinIndex_i=min(i1_series(i1_series>0)); |
---|
| 457 | MinIndex_j=min(j1_series(j1_series>0)); |
---|
[360] | 458 | MaxIndex_i=max(i1_series(i1_series>0)); |
---|
| 459 | MaxIndex_j=max(j1_series(j1_series>0)); |
---|
[355] | 460 | |
---|
[298] | 461 | %% look for an image documentation file |
---|
[476] | 462 | XmlFileName=find_imadoc(RootPath,SubDir,RootFile,ImaExt); |
---|
[469] | 463 | if isempty(XmlFileName) |
---|
| 464 | if (strcmp(FileType,'video') || strcmp(FileType,'mmreader')) |
---|
| 465 | ext_imadoc=ImaExt;% the timing from the video movie is used |
---|
| 466 | else |
---|
| 467 | ext_imadoc=''; |
---|
| 468 | end |
---|
| 469 | else |
---|
| 470 | [tild,tild,ext_imadoc]=fileparts(XmlFileName); |
---|
[441] | 471 | end |
---|
[298] | 472 | set(handles.ImaDoc,'String',ext_imadoc)% display the extension name for the image documentation file used |
---|
[343] | 473 | |
---|
| 474 | %% read the time in the image documentation file |
---|
[298] | 475 | time=[]; |
---|
[343] | 476 | TimeUnit=''; %default |
---|
| 477 | CoordUnit='';%default |
---|
[416] | 478 | pxcm_search=1; |
---|
[469] | 479 | if ~isempty(XmlFileName) |
---|
[343] | 480 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) % set edit box to yellow cloro to indicate that the file reading is beginning |
---|
| 481 | drawnow |
---|
[469] | 482 | [XmlData,warntext]=imadoc2struct(XmlFileName); |
---|
| 483 | nom_type_read=[]; |
---|
| 484 | if isfield(XmlData,'Time') && ~isempty(XmlData.Time) |
---|
| 485 | time=XmlData.Time; |
---|
| 486 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
| 487 | if isequal(MaxIndex_i,1) && ~isequal(MaxIndex_j,1)% .Time is a line vector |
---|
| 488 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once')) |
---|
| 489 | time=time'; |
---|
| 490 | MaxIndex_i=MaxIndex_j; |
---|
| 491 | MaxIndex_j=1; |
---|
[343] | 492 | end |
---|
[469] | 493 | end |
---|
[84] | 494 | end |
---|
[469] | 495 | if isfield(XmlData,'TimeUnit') |
---|
| 496 | TimeUnit=XmlData.TimeUnit; |
---|
[468] | 497 | end |
---|
[469] | 498 | if isfield(XmlData,'GeometryCalib') |
---|
| 499 | tsai=XmlData.GeometryCalib; |
---|
| 500 | if isfield(tsai,'fx_fy') |
---|
| 501 | pxcm_search=max(tsai.fx_fy(1),tsai.fx_fy(2));%pixels:cm estimated for the search range |
---|
| 502 | end |
---|
| 503 | if isfield(tsai,'CoordUnit') |
---|
| 504 | CoordUnit=tsai.CoordUnit; |
---|
| 505 | end |
---|
| 506 | end |
---|
[2] | 507 | end |
---|
[469] | 508 | if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader')) |
---|
[494] | 509 | set(handles.ListPairMode,'Value',1); |
---|
[469] | 510 | dt=1/get(MovieObject,'FrameRate');%time interval between successive frames |
---|
[492] | 511 | if strcmp(NomTypeIma,'*') |
---|
| 512 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
| 513 | MaxIndex_i=get(MovieObject,'NumberOfFrames'); |
---|
| 514 | time=(dt*(0:MaxIndex_i-1))';%list of image times |
---|
| 515 | else |
---|
| 516 | set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}]) |
---|
| 517 | MaxIndex_i=max(i1_series(i1_series>0)); |
---|
[494] | 518 | MaxIndex_j=get(MovieObject,'NumberOfFrames'); |
---|
[492] | 519 | time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j-1));%list of image times |
---|
| 520 | enable_j(handles,'on') |
---|
[494] | 521 | end |
---|
[469] | 522 | TimeUnit='s'; |
---|
| 523 | set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter |
---|
| 524 | end |
---|
| 525 | |
---|
[298] | 526 | %% timing display |
---|
| 527 | %show the reference image edit box if relevant (not needed for movies or in the absence of time information |
---|
[343] | 528 | if numel(time)>=2 % if there are at least two time values to define dt |
---|
[494] | 529 | MaxIndex_i=min(size(time,1),MaxIndex_i);%possibly adjust the max index according to time data |
---|
[343] | 530 | MaxIndex_j=min(size(time,2),MaxIndex_j); |
---|
| 531 | time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices) |
---|
| 532 | time=[zeros(1,size(time,2)); time]; %insert a horizontal line of zeros |
---|
| 533 | else |
---|
| 534 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
[512] | 535 | time=(i1_series(:,1)+0:size(i1_series,3)-1);% time=index i |
---|
[343] | 536 | time=time'*ones(1,size(i1_series,2),1); %makes a time matrix with the same time for all j indices |
---|
| 537 | TimeUnit='frame'; |
---|
[2] | 538 | end |
---|
[343] | 539 | set(handles.ImaDoc,'UserData',time); %store the matrix of times |
---|
| 540 | set(handles.dt_unit,'String',['dt in m' TimeUnit]);%display dt in unit 10-3 of the time (e.g ms) |
---|
| 541 | set(handles.TimeUnit,'String',TimeUnit); |
---|
| 542 | set(handles.nb_field,'String',num2str(MaxIndex_i)); |
---|
| 543 | set(handles.nb_field2,'String',num2str(MaxIndex_j)); |
---|
[71] | 544 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[415] | 545 | set(handles.SearchRange,'UserData', pxcm_search); |
---|
[360] | 546 | set(handles.ImaExt,'String',ImaExt) |
---|
| 547 | set(handles.NomType,'String',NomTypeIma) |
---|
[370] | 548 | |
---|
[494] | 549 | %% set the reference indices from the input file indices |
---|
| 550 | num_ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 551 | num_ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 552 | % for movies don't modify except if the current ref is outside index bounds |
---|
| 553 | %if strcmp(ExtInput,'.nc')|| ~(strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader') && num_ref_i<=MaxIndex_i && num_ref_j<=MaxIndex_j) |
---|
| 554 | if ~isempty(i1)% if i1 has been selected by the input |
---|
| 555 | num_ref_i=i1;%default ref index |
---|
| 556 | if ~isempty(i2) |
---|
| 557 | num_ref_i=floor((num_ref_i+i2)/2); |
---|
| 558 | end |
---|
| 559 | if ~isempty(j1) |
---|
| 560 | num_ref_j=j1; |
---|
| 561 | if ~isempty(j2) |
---|
| 562 | num_ref_j=floor((num_ref_j+j2)/2); |
---|
| 563 | end |
---|
| 564 | end |
---|
| 565 | end |
---|
| 566 | if num_ref_i>MaxIndex_i||num_ref_i<MinIndex_i |
---|
| 567 | num_ref_i=round((MinIndex_i+MaxIndex_i)/2); |
---|
| 568 | end |
---|
| 569 | if ~isempty(num_ref_j)&&~isempty(MaxIndex_j)&& ~isempty(MinIndex_j) |
---|
| 570 | if (num_ref_j>MaxIndex_j||num_ref_j<MinIndex_j) |
---|
| 571 | num_ref_j=round((MinIndex_j+MaxIndex_j)/2); |
---|
| 572 | end |
---|
| 573 | end |
---|
| 574 | if isempty(num_ref_j) |
---|
| 575 | num_ref_j=1; |
---|
| 576 | end |
---|
| 577 | |
---|
[370] | 578 | %% update i and j index range if a nc file has been opened or pb withmin max image indices: |
---|
| 579 | % then set first and last to the inputfile index by default |
---|
| 580 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 581 | last_i=str2num(get(handles.last_i,'String')); |
---|
[494] | 582 | 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 |
---|
| 583 | first_i=num_ref_i; |
---|
| 584 | last_i=num_ref_i; |
---|
| 585 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 586 | set(handles.last_i,'String',num2str(last_i));% |
---|
[371] | 587 | end |
---|
[370] | 588 | |
---|
| 589 | %j index range |
---|
| 590 | first_j=str2num(get(handles.first_j,'String')); |
---|
[494] | 591 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 592 | if isempty(first_j) || isempty(last_j)||isempty(MinIndex_j)||isempty(MaxIndex_j)||ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j |
---|
| 593 | first_j=num_ref_j; |
---|
| 594 | last_j=num_ref_j; |
---|
| 595 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 596 | set(handles.last_j,'String',num2str(last_j));% |
---|
[370] | 597 | end |
---|
[494] | 598 | if num_ref_i>last_i || num_ref_i<first_i |
---|
| 599 | num_ref_i=round((first_i+last_i)/2); |
---|
| 600 | end |
---|
| 601 | if num_ref_j>last_j || num_ref_j<first_j |
---|
| 602 | num_ref_j=round((first_j+last_j)/2); |
---|
| 603 | end |
---|
| 604 | set(handles.ref_i,'String',num2str(num_ref_i)) |
---|
| 605 | set(handles.ref_j,'String',num2str(num_ref_j)) |
---|
[2] | 606 | |
---|
[370] | 607 | %% set the civ options depending on the input file content when a nc file has been opened |
---|
[371] | 608 | ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; |
---|
[505] | 609 | checkbox=zeros(size(ListOptions));%default |
---|
| 610 | if ind_opening==0%case of image opening, start with Civ1 |
---|
[501] | 611 | for index=1:numel(ListOptions) |
---|
| 612 | checkbox(index)=get(handles.(ListOptions{index}),'Value'); |
---|
| 613 | end |
---|
[505] | 614 | index_max=find(checkbox, 1, 'last' ); |
---|
| 615 | if isempty(index_max),index_max=1;end |
---|
| 616 | for index=1:index_max |
---|
[501] | 617 | set(handles.(ListOptions{index}),'Value',1)% select all operations starting from CIV1 |
---|
| 618 | end |
---|
| 619 | else |
---|
| 620 | for index = 1:min(ind_opening,5) |
---|
[370] | 621 | set(handles.(ListOptions{index}),'value',0) |
---|
| 622 | end |
---|
[501] | 623 | set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1) |
---|
| 624 | for index = ind_opening+2:6 |
---|
| 625 | set(handles.(ListOptions{index}),'value',0) |
---|
| 626 | end |
---|
[298] | 627 | end |
---|
[501] | 628 | %list_operation={'CheckCiv1','CheckFix1','CheckPatch1','CheckCiv2','CheckFix2','CheckPatch2'}; |
---|
| 629 | |
---|
| 630 | %set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1) |
---|
[438] | 631 | update_CivOptions(handles,ind_opening) |
---|
[298] | 632 | |
---|
[273] | 633 | %% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[362] | 634 | %check_letter=~isempty(regexp(NomTypeIma,'[ab|AB]$'));%detect pair label by letter |
---|
[371] | 635 | if isequal(NomTypeNc,'_1-2')||isempty(MaxIndex_j)|| (MaxIndex_j==1) |
---|
[282] | 636 | set(handles.ListPairMode,'Value',1) |
---|
| 637 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
[353] | 638 | elseif MaxIndex_i==1 && MaxIndex_j>1% simple series in j |
---|
[343] | 639 | set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)'}) |
---|
| 640 | if MaxIndex_j <= 10 |
---|
| 641 | set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large |
---|
| 642 | end |
---|
[492] | 643 | elseif ~(strcmp(FileType,'video') || strcmp(FileType,'mmreader')) |
---|
[282] | 644 | set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[360] | 645 | if strcmp(NomTypeNc,'_1-2_1') |
---|
| 646 | set(handles.ListPairMode,'Value',3)% advise 'series(Di)' |
---|
| 647 | elseif MaxIndex_j <= 10 |
---|
[343] | 648 | set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large |
---|
[2] | 649 | end |
---|
| 650 | end |
---|
| 651 | |
---|
[368] | 652 | %% scan files to update the subdirectory list display |
---|
[300] | 653 | listot=dir(RootPath);%directory of RootPath |
---|
[273] | 654 | idir=0; |
---|
| 655 | listdir={''};%default |
---|
[300] | 656 | % get the list of existing civ subdirectories in the path of theinput root file |
---|
[273] | 657 | for ilist=1:length(listot) |
---|
| 658 | if listot(ilist).isdir |
---|
| 659 | name=listot(ilist).name; |
---|
| 660 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 661 | idir=idir+1; |
---|
| 662 | listdir{idir,1}=listot(ilist).name; |
---|
| 663 | end |
---|
| 664 | end |
---|
| 665 | end |
---|
[368] | 666 | |
---|
[300] | 667 | %% store info |
---|
[371] | 668 | set(handles.RootPath,'UserData',browse)% store the nomenclature type |
---|
[273] | 669 | |
---|
[298] | 670 | %% list the possible index pairs, depending on the option set in ListPairMode |
---|
| 671 | ListPairMode_Callback([], [], handles) |
---|
| 672 | |
---|
| 673 | %% store the root input filename for future opening |
---|
| 674 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 675 | if exist(profil_perso,'file') |
---|
| 676 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 677 | else |
---|
| 678 | txt=ver('MATLAB'); |
---|
| 679 | Release=txt.Release; |
---|
| 680 | relnumb=str2double(Release(3:4)); |
---|
| 681 | if relnumb >= 14 |
---|
| 682 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
| 683 | else |
---|
| 684 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 685 | end |
---|
| 686 | end |
---|
[371] | 687 | set(handles.RootPath,'BackgroundColor',[1 1 1]) |
---|
[298] | 688 | |
---|
[12] | 689 | %------------------------------------------------------------------------ |
---|
[309] | 690 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
[363] | 691 | function SubdirCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 692 | %------------------------------------------------------------------------ |
---|
[363] | 693 | SubDir=get(handles.SubdirCiv1,'String'); |
---|
[309] | 694 | menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update |
---|
[343] | 695 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
[309] | 696 | if isempty(ichoice) |
---|
| 697 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
[2] | 698 | else |
---|
[309] | 699 | ilist=ichoice; |
---|
[2] | 700 | end |
---|
[309] | 701 | set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu |
---|
| 702 | if get(handles.CheckCiv1,'Value')% if Civ1 is performed |
---|
[363] | 703 | set(handles.SubdirCiv2,'String',SubDir);% set by default civ2 directory the same as civ1 |
---|
[441] | 704 | % set(handles.ListSubdirCiv2,'Value',ilist) |
---|
[309] | 705 | else % if Civ1 data already exist |
---|
[362] | 706 | errormsg=find_netcpair_civ(handles,1); %update the list of available pairs from netcdf files in the new directory |
---|
| 707 | if ~isempty(errormsg) |
---|
| 708 | msgbox_uvmat('ERROR',errormsg) |
---|
| 709 | end |
---|
[112] | 710 | end |
---|
[2] | 711 | |
---|
[12] | 712 | %------------------------------------------------------------------------ |
---|
[343] | 713 | % --- Executes on carriage return on the SubDir checkciv1 edit window |
---|
[363] | 714 | function SubdirCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 715 | %------------------------------------------------------------------------ |
---|
[363] | 716 | SubDir=get(handles.SubdirCiv1,'String'); |
---|
[309] | 717 | menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update |
---|
[343] | 718 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
[309] | 719 | if isempty(ichoice) |
---|
| 720 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
[2] | 721 | else |
---|
[309] | 722 | ilist=ichoice; |
---|
[2] | 723 | end |
---|
[309] | 724 | set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu |
---|
| 725 | %update the list of available pairs from netcdf files in the new directory |
---|
| 726 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
[362] | 727 | errormsg=find_netcpair_civ(handles,2); |
---|
| 728 | if ~isempty(errormsg) |
---|
| 729 | msgbox_uvmat('ERROR',errormsg) |
---|
| 730 | end |
---|
[2] | 731 | end |
---|
| 732 | |
---|
[309] | 733 | %------------------------------------------------------------------------ |
---|
| 734 | % --- Executes on button press in CheckCiv1. |
---|
| 735 | function CheckCiv1_Callback(hObject, eventdata, handles) |
---|
| 736 | %------------------------------------------------------------------------ |
---|
[343] | 737 | update_CivOptions(handles,0) |
---|
[2] | 738 | |
---|
[309] | 739 | %------------------------------------------------------------------------ |
---|
| 740 | % --- Executes on button press in CheckFix1. |
---|
| 741 | function CheckFix1_Callback(hObject, eventdata, handles) |
---|
| 742 | %------------------------------------------------------------------------ |
---|
[343] | 743 | update_CivOptions(handles,0) |
---|
[2] | 744 | |
---|
[309] | 745 | %------------------------------------------------------------------------ |
---|
| 746 | % --- Executes on button press in CheckPatch1. |
---|
| 747 | function CheckPatch1_Callback(hObject, eventdata, handles) |
---|
| 748 | %------------------------------------------------------------------------ |
---|
[343] | 749 | update_CivOptions(handles,0) |
---|
[2] | 750 | |
---|
[309] | 751 | %------------------------------------------------------------------------ |
---|
| 752 | % --- Executes on button press in CheckCiv2. |
---|
| 753 | function CheckCiv2_Callback(hObject, eventdata, handles) |
---|
| 754 | %------------------------------------------------------------------------ |
---|
[343] | 755 | update_CivOptions(handles,0) |
---|
[301] | 756 | |
---|
[309] | 757 | %------------------------------------------------------------------------ |
---|
| 758 | % --- Executes on button press in CheckFix2. |
---|
| 759 | function CheckFix2_Callback(hObject, eventdata, handles) |
---|
| 760 | %------------------------------------------------------------------------ |
---|
[343] | 761 | update_CivOptions(handles,0) |
---|
[301] | 762 | |
---|
[309] | 763 | %------------------------------------------------------------------------ |
---|
| 764 | % --- Executes on button press in CheckPatch2. |
---|
| 765 | function CheckPatch2_Callback(hObject, eventdata, handles) |
---|
| 766 | %------------------------------------------------------------------------ |
---|
[343] | 767 | update_CivOptions(handles,0) |
---|
[300] | 768 | |
---|
[12] | 769 | %------------------------------------------------------------------------ |
---|
[309] | 770 | % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 |
---|
[343] | 771 | function update_CivOptions(handles,opening) |
---|
[12] | 772 | %------------------------------------------------------------------------ |
---|
[309] | 773 | checkbox=zeros(1,6); |
---|
| 774 | checkbox(1)=get(handles.CheckCiv1,'Value'); |
---|
| 775 | checkbox(2)=get(handles.CheckFix1,'Value'); |
---|
| 776 | checkbox(3)=get(handles.CheckPatch1,'Value'); |
---|
| 777 | checkbox(4)=get(handles.CheckCiv2,'Value'); |
---|
| 778 | checkbox(5)=get(handles.CheckFix2,'Value'); |
---|
| 779 | checkbox(6)=get(handles.CheckPatch2,'Value'); |
---|
| 780 | ind_selected=find(checkbox,1); |
---|
| 781 | if ~isempty(ind_selected) |
---|
[371] | 782 | RootPath=get(handles.RootPath,'String'); |
---|
| 783 | if isempty(RootPath) |
---|
[362] | 784 | msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...') |
---|
| 785 | return |
---|
[270] | 786 | end |
---|
[2] | 787 | end |
---|
[309] | 788 | set(handles.PairIndices,'Visible','on') |
---|
[363] | 789 | set(handles.SubdirCiv1,'Visible','on') |
---|
[371] | 790 | set(handles.TitleSubdirCiv1,'Visible','on') |
---|
[440] | 791 | if opening==0 |
---|
[362] | 792 | errormsg=find_netcpair_civ(handles,1); % select the available netcdf files |
---|
| 793 | if ~isempty(errormsg) |
---|
| 794 | msgbox_uvmat('ERROR',errormsg) |
---|
| 795 | end |
---|
[343] | 796 | end |
---|
[309] | 797 | if max(checkbox(4:6))% case of civ2 pair choice needed |
---|
| 798 | set(handles.TitlePairCiv2,'Visible','on') |
---|
| 799 | set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[363] | 800 | set(handles.SubdirCiv2,'Visible','on') |
---|
[437] | 801 | %set(handles.ListSubdirCiv2,'Visible','on') |
---|
[309] | 802 | set(handles.ListPairCiv2,'Visible','on') |
---|
[343] | 803 | if ~opening |
---|
[362] | 804 | errormsg=find_netcpair_civ(handles,2); % select the available netcdf files |
---|
| 805 | if ~isempty(errormsg) |
---|
| 806 | msgbox_uvmat('ERROR',errormsg) |
---|
| 807 | end |
---|
[343] | 808 | end |
---|
[309] | 809 | else |
---|
| 810 | set(handles.TitleSubdirCiv2,'Visible','off') |
---|
[363] | 811 | set(handles.SubdirCiv2,'Visible','off') |
---|
[309] | 812 | set(handles.ListPairCiv2,'Visible','off') |
---|
[2] | 813 | end |
---|
[309] | 814 | options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
| 815 | for ilist=1:length(options) |
---|
| 816 | if checkbox(ilist) |
---|
| 817 | set(handles.(options{ilist}),'Visible','on') |
---|
[2] | 818 | else |
---|
[309] | 819 | set(handles.(options{ilist}),'Visible','off') |
---|
[112] | 820 | end |
---|
[2] | 821 | end |
---|
| 822 | |
---|
[12] | 823 | %------------------------------------------------------------------------ |
---|
[177] | 824 | % --- Executes on button press in RUN: processing on local computer |
---|
[67] | 825 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 826 | %------------------------------------------------------------------------ |
---|
[73] | 827 | set(handles.RUN, 'Enable','Off') |
---|
| 828 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[486] | 829 | set(handles.RUN,'UserData',now)% record the time of launch |
---|
[469] | 830 | errormsg=launch_jobs(hObject, eventdata, handles); |
---|
[73] | 831 | set(handles.RUN, 'Enable','On') |
---|
| 832 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 833 | |
---|
[371] | 834 | % display errors or start status callback to visualise results |
---|
[229] | 835 | if ~isempty(errormsg) |
---|
| 836 | display(errormsg) |
---|
| 837 | msgbox_uvmat('ERROR',errormsg) |
---|
[282] | 838 | elseif isfield(handles,'status') %&& ~isequal(get(handles.ListPairMode,'Value'),3) |
---|
[225] | 839 | set(handles.status,'Value',1);%suppress status display |
---|
| 840 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 841 | end |
---|
[177] | 842 | |
---|
[309] | 843 | %------------------------------------------------------------------- |
---|
| 844 | % --- Executes on button press in status. |
---|
| 845 | function status_Callback(hObject, eventdata, handles) |
---|
| 846 | %------------------------------------------------------------------- |
---|
| 847 | val=get(handles.status,'Value'); |
---|
| 848 | if val==0 |
---|
| 849 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
| 850 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 851 | if ~isempty(hfig) |
---|
| 852 | delete(hfig) |
---|
| 853 | end |
---|
| 854 | return |
---|
| 855 | end |
---|
| 856 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
| 857 | drawnow |
---|
| 858 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 859 | Param.CheckCiv1=get(handles.CheckCiv1,'Value'); |
---|
| 860 | Param.CheckFix1=get(handles.CheckFix1,'Value'); |
---|
| 861 | Param.CheckPatch1=get(handles.CheckPatch1,'Value'); |
---|
| 862 | Param.CheckCiv2=get(handles.CheckCiv2,'Value'); |
---|
| 863 | Param.CheckFix2=get(handles.CheckFix2,'Value'); |
---|
| 864 | Param.CheckPatch2=get(handles.CheckPatch2,'Value'); |
---|
| 865 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
| 866 | |
---|
| 867 | option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) |
---|
| 868 | filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV |
---|
| 869 | test_new=0; |
---|
| 870 | if ~isfield(filecell,'nc') |
---|
| 871 | test_new=1; |
---|
| 872 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 873 | if ~isempty(errormsg) |
---|
| 874 | msgbox_uvmat('ERROR',errormsg) |
---|
| 875 | return |
---|
| 876 | end |
---|
| 877 | filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status |
---|
| 878 | end |
---|
| 879 | if ~isequal(box_test(4:6),[0 0 0]) |
---|
| 880 | civ_files=filecell.nc.civ2;%case of civ2 operations |
---|
| 881 | else |
---|
| 882 | civ_files=filecell.nc.civ1; |
---|
| 883 | end |
---|
| 884 | [root,filename,ext]=fileparts(civ_files{1}); |
---|
[343] | 885 | [rootroot,SubDir,extdir]=fileparts(root); |
---|
[309] | 886 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 887 | if isempty(hfig) |
---|
| 888 | hfig=figure('DeleteFcn',@stop_status); |
---|
[421] | 889 | set(hfig,'MenuBar','none')% suppress the menu bar |
---|
| 890 | set(hfig,'NumberTitle','off')%suppress the fig number in the title |
---|
[309] | 891 | set(hfig,'name','civ_status') |
---|
[421] | 892 | set(hfig,'tag','civ_status') |
---|
| 893 | set(hfig,'UserData',civ_files) |
---|
| 894 | hlist= uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list'); |
---|
[309] | 895 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); |
---|
| 896 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
[421] | 897 | 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); |
---|
| 898 | 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] | 899 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
[421] | 900 | uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
| 901 | drawnow |
---|
[309] | 902 | end |
---|
[486] | 903 | StatusData.time_ref=get(handles.RUN,'UserData');% get the time of launch |
---|
[483] | 904 | StatusData.option_civ=option_civ; |
---|
| 905 | set(hrefresh,'UserData',StatusData) |
---|
| 906 | filepath=fileparts(civ_files{1}); |
---|
[421] | 907 | set(hlist,'UserData',fileparts(filepath)) |
---|
| 908 | refresh_GUI(hrefresh,[]) |
---|
| 909 | |
---|
| 910 | %------------------------------------------------------------------------ |
---|
| 911 | % launched by refreshing the status figure |
---|
| 912 | function refresh_GUI(hObject, eventdata) |
---|
| 913 | %------------------------------------------------------------------------ |
---|
[309] | 914 | Tabchar={}; |
---|
[421] | 915 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
| 916 | hfig=get(hObject,'parent'); |
---|
[483] | 917 | StatusData=get(hObject,'UserData'); |
---|
[421] | 918 | civ_files=get(hfig,'UserData'); |
---|
[483] | 919 | [filepath,filename,ext]=fileparts(civ_files{1}); |
---|
| 920 | [tild,SubDir,extdir]=fileparts(filepath); |
---|
| 921 | SubDir=[SubDir extdir]; |
---|
| 922 | option_civ=StatusData.option_civ; |
---|
[309] | 923 | nbfiles=numel(civ_files); |
---|
[483] | 924 | testrecent=0; |
---|
[309] | 925 | count=0; |
---|
[483] | 926 | datnum=zeros(1,nbfiles); |
---|
| 927 | filefound=cell(1,nbfiles); |
---|
| 928 | for ifile=1:nbfiles |
---|
| 929 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
| 930 | option=0; |
---|
| 931 | if detect==0 |
---|
| 932 | option_str='not created'; |
---|
| 933 | else |
---|
| 934 | datfile=dir(civ_files{ifile}); |
---|
| 935 | if isfield(datfile,'datenum') |
---|
| 936 | datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
| 937 | testrecent=1; |
---|
| 938 | end |
---|
| 939 | filefound(ifile)={datfile.name}; |
---|
| 940 | |
---|
| 941 | % check the content netcdf file |
---|
| 942 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix'); |
---|
| 943 | option_list={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 944 | if ~isempty(Data.CivStage) |
---|
| 945 | option=Data.CivStage;%case of Matlab civ |
---|
[309] | 946 | else |
---|
[483] | 947 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
| 948 | option=6; |
---|
| 949 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
| 950 | option=5; |
---|
| 951 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
| 952 | option=4; |
---|
| 953 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
| 954 | option=3; |
---|
| 955 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
| 956 | option=2; |
---|
[309] | 957 | else |
---|
[483] | 958 | option=1; |
---|
[309] | 959 | end |
---|
| 960 | end |
---|
[483] | 961 | option_str=option_list{option}; |
---|
| 962 | if datnum(ifile)<StatusData.time_ref |
---|
| 963 | option_str=[option_str ' --OLD--']; |
---|
[309] | 964 | end |
---|
| 965 | end |
---|
[483] | 966 | if option >= option_civ |
---|
| 967 | count=count+1; |
---|
| 968 | end |
---|
| 969 | [filepath,filename,ext]=fileparts(civ_files{ifile}); |
---|
| 970 | Tabchar{ifile,1}=[fullfile(SubDir,filename) ext '...' option_str]; |
---|
| 971 | end |
---|
| 972 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
| 973 | if isempty(datnum) |
---|
| 974 | if testrecent |
---|
| 975 | message='no civ result created yet'; |
---|
[309] | 976 | else |
---|
[483] | 977 | message=''; |
---|
[309] | 978 | end |
---|
[483] | 979 | else |
---|
| 980 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
| 981 | [first,ind]=min(datnum); |
---|
| 982 | [last,indlast]=max(datnum); |
---|
| 983 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
| 984 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
| 985 | end |
---|
| 986 | hlist=findobj(hfig,'tag','list'); |
---|
| 987 | hmsgbox=findobj(hfig,'tag','msgbox'); |
---|
| 988 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
| 989 | set(hlist,'String',Tabchar) |
---|
| 990 | set(hmsgbox,'String', message) |
---|
| 991 | if count>0 %&& ~test_new |
---|
| 992 | BarPosition(3)=0.9*count/nbfiles; |
---|
| 993 | set(hwaitbar,'Position',BarPosition) |
---|
| 994 | end |
---|
[309] | 995 | |
---|
[483] | 996 | |
---|
[421] | 997 | %------------------------------------------------------------------------ |
---|
| 998 | % launched by deleting the status figure |
---|
| 999 | function stop_status(hObject, eventdata) |
---|
[67] | 1000 | %------------------------------------------------------------------------ |
---|
[421] | 1001 | hciv=findobj(allchild(0),'tag','civ'); |
---|
| 1002 | hhciv=guidata(hciv); |
---|
| 1003 | set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ |
---|
| 1004 | set(hhciv.status,'BackgroundColor',[0 1 0]) |
---|
| 1005 | |
---|
| 1006 | %------------------------------------------------------------------------ |
---|
| 1007 | % launched by pressing OK on the status figure |
---|
| 1008 | function close_GUI(hObject, eventdata) |
---|
| 1009 | %------------------------------------------------------------------------ |
---|
| 1010 | delete(gcbf) |
---|
| 1011 | |
---|
| 1012 | |
---|
[446] | 1013 | %------------------------------------------------------------------------ |
---|
[309] | 1014 | % --- Main lauch command, called by RUN and BATCH |
---|
[469] | 1015 | function errormsg=launch_jobs(hObject, eventdata, handles) |
---|
[446] | 1016 | %------------------------------------------------------------------------ |
---|
[229] | 1017 | errormsg='';%default |
---|
[313] | 1018 | |
---|
| 1019 | %% read the input parameters from the GUI civ |
---|
[309] | 1020 | Param=read_GUI(handles.civ); |
---|
[272] | 1021 | |
---|
[133] | 1022 | %% check the selected list of operations: |
---|
[289] | 1023 | operations={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
[282] | 1024 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
[180] | 1025 | index_first=find(box_test==1,1); |
---|
| 1026 | if isempty(index_first) |
---|
[229] | 1027 | errormsg='no selected operation'; |
---|
[2] | 1028 | return |
---|
| 1029 | end |
---|
[180] | 1030 | index_last=find(box_test==1,1,'last'); |
---|
[159] | 1031 | box_used=box_test(index_first : index_last); |
---|
[2] | 1032 | [box_missing,ind_missing]=min(box_used); |
---|
[180] | 1033 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
[229] | 1034 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
[2] | 1035 | return |
---|
| 1036 | end |
---|
| 1037 | |
---|
[272] | 1038 | %% check mask if selecetd |
---|
| 1039 | %could be included in get_mask callback ? |
---|
[282] | 1040 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[384] | 1041 | maskname=get(handles.Mask,'String'); |
---|
[12] | 1042 | if ~exist(maskname,'file') |
---|
| 1043 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1044 | end |
---|
[2] | 1045 | end |
---|
[282] | 1046 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[384] | 1047 | maskname=get(handles.Mask,'String'); |
---|
[12] | 1048 | if ~exist(maskname,'file') |
---|
| 1049 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1050 | end |
---|
[2] | 1051 | end |
---|
[282] | 1052 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[384] | 1053 | maskname=get(handles.Mask,'String'); |
---|
[12] | 1054 | if ~exist(maskname,'file') |
---|
[112] | 1055 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 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') |
---|
[112] | 1061 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1062 | end |
---|
[2] | 1063 | end |
---|
| 1064 | |
---|
[177] | 1065 | %% reinitialise status callback |
---|
[178] | 1066 | if isfield(handles,'status') |
---|
[180] | 1067 | set(handles.status,'Value',0);%suppress status display |
---|
[446] | 1068 | status_Callback([], [], handles) |
---|
[178] | 1069 | end |
---|
[133] | 1070 | |
---|
[272] | 1071 | %% read the PARAM.xml file to get the binaries (and batch_mode if batch) |
---|
[276] | 1072 | path_civ=fileparts(which('civ')); %path to the source directory of uvmat |
---|
[500] | 1073 | xmlfile=fullfile(path_civ,'PARAM.xml'); |
---|
[483] | 1074 | s=[]; |
---|
[133] | 1075 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
[54] | 1076 | t=xmltree(xmlfile); |
---|
[67] | 1077 | s=convert(t); |
---|
[483] | 1078 | end% default configuration |
---|
| 1079 | if ~isfield(s,'RunParam') |
---|
[493] | 1080 | Param.xml.Civ1Bin=fullfile('bin','civ1'); |
---|
| 1081 | Param.xml.Civ2Bin=fullfile('bin','civ2'); |
---|
| 1082 | Param.xml.FixBin=fullfile('bin','fix_flag'); |
---|
| 1083 | Param.xml.PatchBin=fullfile('bin','patch_up'); |
---|
[2] | 1084 | end |
---|
[469] | 1085 | if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster |
---|
[67] | 1086 | if isfield(s,'BatchParam') |
---|
[284] | 1087 | Param.xml=s.BatchParam; |
---|
| 1088 | if isfield(Param.xml,'BatchMode') |
---|
| 1089 | batch_mode=Param.xml.BatchMode; |
---|
[257] | 1090 | if ~ismember(batch_mode,{'sge','oar'}) |
---|
| 1091 | errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; |
---|
| 1092 | return |
---|
| 1093 | end |
---|
[67] | 1094 | end |
---|
| 1095 | else |
---|
[493] | 1096 | %default configuration |
---|
| 1097 | Param.xml.Civ1Bin=fullfile('bin','civ1'); |
---|
| 1098 | Param.xml.Civ2Bin=fullfile('bin','civ2'); |
---|
| 1099 | Param.xml.FixBin=fullfile('bin','fix_flag'); |
---|
| 1100 | Param.xml.PatchBin=fullfile('bin','patch_up'); |
---|
[501] | 1101 | % Param.xml.CivmBin=fullfile('bin','civ_matlab'); |
---|
[483] | 1102 | Param.xml.BatchMode='oar';% TODO : allow choice for sge |
---|
[67] | 1103 | end |
---|
[257] | 1104 | else % run |
---|
[67] | 1105 | if isfield(s,'RunParam') |
---|
[284] | 1106 | Param.xml=s.RunParam; |
---|
[493] | 1107 | else %default configuration |
---|
| 1108 | Param.xml.Civ1Bin=fullfile('bin','civ1'); |
---|
| 1109 | Param.xml.Civ2Bin=fullfile('bin','civ2'); |
---|
| 1110 | Param.xml.FixBin=fullfile('bin','fix_flag'); |
---|
| 1111 | Param.xml.PatchBin=fullfile('bin','patch_up'); |
---|
[67] | 1112 | end |
---|
[225] | 1113 | end |
---|
[501] | 1114 | %Param.xml.CivmBin=fullfile('bin','civ_matlab'); |
---|
[238] | 1115 | |
---|
[482] | 1116 | %% check if the binaries exist : to move in civ_opening |
---|
[280] | 1117 | binary_list={}; |
---|
[469] | 1118 | switch Param.Program |
---|
[280] | 1119 | case 'CivX' |
---|
| 1120 | binary_list={'Civ1Bin','Civ2Bin','PatchBin','FixBin'}; |
---|
[371] | 1121 | case 'CivAll'% desactivated option |
---|
[289] | 1122 | binary_list={'Civ'}; |
---|
[501] | 1123 | % case 'civ_matlab.sh'% compiled version of civ_matlab |
---|
| 1124 | % binary_list={'CivmBin'}; |
---|
[225] | 1125 | end |
---|
[309] | 1126 | for bin_name=binary_list %loop on the list of binaries |
---|
| 1127 | if isfield(Param.xml,bin_name{1})% bin_name{1} =current name in the list |
---|
[494] | 1128 | if ~isunix |
---|
| 1129 | Param.xml.(bin_name{1})=[regexprep(Param.xml.(bin_name{1}),'/','\') '.exe']; |
---|
| 1130 | end |
---|
[421] | 1131 | if exist(Param.xml.(bin_name{1}),'file') |
---|
| 1132 | [path,name,ext]=fileparts(Param.xml.(bin_name{1})); |
---|
| 1133 | currentdir=pwd; |
---|
[482] | 1134 | if isempty(path) |
---|
| 1135 | path=fileparts(which('civ.m')); |
---|
| 1136 | end |
---|
[421] | 1137 | if exist(path,'dir') |
---|
| 1138 | cd(path); |
---|
| 1139 | binpath=pwd;%path of the binary |
---|
| 1140 | Param.xml.(bin_name{1})=fullfile(binpath,[name ext]); |
---|
[482] | 1141 | cd(currentdir); |
---|
[421] | 1142 | else |
---|
[501] | 1143 | errormsg=['path ' path ' for binaries specified in PARAM.xml does not exist']; |
---|
| 1144 | return |
---|
[500] | 1145 | end |
---|
[421] | 1146 | else %look for the full path if the file name has been defined with a relative path in PARAM.xm |
---|
[289] | 1147 | fullname=fullfile(path_civ,Param.xml.(bin_name{1})); |
---|
[280] | 1148 | if exist(fullname,'file') |
---|
[284] | 1149 | Param.xml.(bin_name{1})=fullname; |
---|
[280] | 1150 | else |
---|
[501] | 1151 | errormsg=['Binary ' Param.xml.(bin_name{1}) ' specified in PARAM.xml does not exist']; |
---|
| 1152 | return |
---|
[280] | 1153 | end |
---|
| 1154 | end |
---|
| 1155 | end |
---|
| 1156 | end |
---|
[501] | 1157 | if strcmp(Param.Program,'civ_matlab.sh') |
---|
| 1158 | if ~exist(fullfile(path_civ,'civ_matlab.sh'),'file') |
---|
| 1159 | errormsg=[{'no file civ_matlab.sh found'}; {'run compile_functions.m to create it by compiling civ_matlab.m'}]; |
---|
[505] | 1160 | return |
---|
[500] | 1161 | end |
---|
| 1162 | end |
---|
[2] | 1163 | |
---|
[313] | 1164 | %% set the list of files and check them |
---|
| 1165 | display('checking the files...') |
---|
| 1166 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 1167 | if ~isempty(errormsg) |
---|
| 1168 | return |
---|
| 1169 | end |
---|
[437] | 1170 | [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] | 1171 | set_civ_filenames(handles,ref_i,ref_j,box_test); |
---|
[437] | 1172 | if ~isempty(errormsg) |
---|
| 1173 | return |
---|
| 1174 | end |
---|
[313] | 1175 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
[494] | 1176 | display('files OK, processing...') |
---|
[465] | 1177 | |
---|
| 1178 | %% create subfolders for log, cmx, nml, xml, bat |
---|
[467] | 1179 | RootBat=fileparts(filecell.nc.civ1{1,1}); |
---|
[501] | 1180 | switch(Param.Program) |
---|
| 1181 | case {'CivX','CivAll'} |
---|
| 1182 | dir_list={'0_BAT','0_CMX','0_LOG'}; |
---|
| 1183 | case {'civ_matlab','civ_matlab.sh'} |
---|
| 1184 | dir_list={'0_BAT','0_XML'}; |
---|
| 1185 | end |
---|
[465] | 1186 | for k=1:length(dir_list) |
---|
| 1187 | if ~exist(fullfile(RootBat,dir_list{k}),'dir') |
---|
| 1188 | mkdir(fullfile(RootBat,dir_list{k})); |
---|
| 1189 | end |
---|
| 1190 | end |
---|
| 1191 | |
---|
[469] | 1192 | %% get information on input images or movies |
---|
[313] | 1193 | nbfield=numel(i1_civ1); |
---|
| 1194 | nbslice=numel(j1_civ1); |
---|
[469] | 1195 | % if strcmp(Param.Program,'civ_matlab') |
---|
[389] | 1196 | if Param.CheckCiv1 |
---|
[469] | 1197 | [Param.Civ1.FileTypeA,ImageInfoA_civ1,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1}); |
---|
| 1198 | [Param.Civ1.FileTypeB,ImageInfoB_civ1,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1}); |
---|
[389] | 1199 | end |
---|
| 1200 | if Param.CheckCiv2 |
---|
[476] | 1201 | [Param.Civ2.FileTypeA,ImageInfoA_civ2,Param.Civ2.ImageA]=get_file_type(filecell.ima1.civ2{1}); |
---|
| 1202 | [Param.Civ2.FileTypeB,ImageInfoB_civ2,Param.Civ2.ImageB]=get_file_type(filecell.ima2.civ2{1}); |
---|
[389] | 1203 | end |
---|
[469] | 1204 | % end |
---|
[2] | 1205 | |
---|
[133] | 1206 | %% MAIN LOOP |
---|
[273] | 1207 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[343] | 1208 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 1209 | checkframe=strcmp(TimeUnit,'frame'); |
---|
[322] | 1210 | batch_file_list=[];%should be renamed file_list, can be used for xml or bash files |
---|
[494] | 1211 | NomTypeIma=get(handles.NomType,'String'); |
---|
[2] | 1212 | for ifile=1:nbfield |
---|
| 1213 | for j=1:nbslice |
---|
[313] | 1214 | |
---|
[272] | 1215 | % define output file name |
---|
[282] | 1216 | if Param.CheckCiv2==1 || Param.CheckFix2==1 || Param.CheckPatch2==1 |
---|
[465] | 1217 | Param.OutputFile=filecell.nc.civ2{ifile,j}; |
---|
[272] | 1218 | else |
---|
[465] | 1219 | Param.OutputFile=filecell.nc.civ1{ifile,j}; |
---|
[272] | 1220 | end |
---|
[465] | 1221 | Param.OutputFile=regexprep(Param.OutputFile,'.nc',''); |
---|
| 1222 | |
---|
[282] | 1223 | if Param.CheckCiv1 |
---|
[476] | 1224 | % read image-dependent parameters |
---|
[343] | 1225 | if ~checkframe% && size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j) |
---|
| 1226 | Param.Civ1.Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)-time(i1_civ1(ifile)+1,j1_civ1(j)+1)); |
---|
[301] | 1227 | else |
---|
| 1228 | Param.Civ1.Dt=1; |
---|
| 1229 | end |
---|
[343] | 1230 | Param.Civ1.Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2); |
---|
[469] | 1231 | if strcmp(Param.Program,'CivX') |
---|
[435] | 1232 | Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE? |
---|
| 1233 | Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);% |
---|
[399] | 1234 | end |
---|
[469] | 1235 | Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j}; |
---|
| 1236 | Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j}; |
---|
[476] | 1237 | Param.Civ1.ImageBitDepth=ImageInfoA_civ1.BitDepth; |
---|
| 1238 | Param.Civ1.ImageWidth=ImageInfoA_civ1.Width; |
---|
| 1239 | Param.Civ1.ImageHeight=ImageInfoA_civ1.Height; |
---|
[494] | 1240 | if strcmp(NomTypeIma,'*') |
---|
| 1241 | Param.Civ1.FrameIndexA=i1_civ1(ifile); |
---|
| 1242 | Param.Civ1.FrameIndexB=i2_civ1(ifile); |
---|
| 1243 | else% case of movies indexed with i, the frame index is then in j |
---|
| 1244 | Param.Civ1.FrameIndexA=j1_civ1(j); |
---|
| 1245 | Param.Civ1.FrameIndexB=j2_civ1(j); |
---|
| 1246 | end |
---|
[435] | 1247 | % read mask )parameters |
---|
[284] | 1248 | if Param.Civ1.CheckMask % the lines below should be changed with the new gui |
---|
[315] | 1249 | if ~exist(Param.Civ1.Mask,'file') |
---|
| 1250 | maskbase=[filecell.filebase '_' Param.Civ1.Mask]; % |
---|
| 1251 | nbslice_mask=str2double(Param.Civ1.Mask(1:end-4)); % |
---|
[313] | 1252 | i1_mask=mod(i1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[354] | 1253 | [RootPathMask,RootFileMask]=fileparts(maskbase); |
---|
| 1254 | Param.Civ1.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask); |
---|
[2] | 1255 | end |
---|
| 1256 | end |
---|
[313] | 1257 | % read grid parameters |
---|
[284] | 1258 | if Param.Civ1.CheckGrid |
---|
[315] | 1259 | if numel(Param.Civ1.Grid)>=4 && isequal(Param.Civ1.Grid(end-3:end),'grid') |
---|
| 1260 | nbslice_grid=str2double(Param.Civ1.Grid(1:end-4)); % |
---|
[137] | 1261 | if ~isnan(nbslice_grid) |
---|
[313] | 1262 | i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[354] | 1263 | Param.Civ1.Grid=[filecell.filebase '_' fullfile_uvmat('','',Param.Civ1.Grid,'.grid','_1',i1_grid)]; |
---|
[285] | 1264 | if ~exist(Param.Civ1.GridName,'file') |
---|
[387] | 1265 | errormsg='grid file absent for civ1'; |
---|
| 1266 | return |
---|
[2] | 1267 | end |
---|
[315] | 1268 | elseif ~exist(Param.Civ1.Grid,'file') |
---|
[387] | 1269 | errormsg='grid file absent for civ1'; |
---|
| 1270 | return |
---|
[2] | 1271 | end |
---|
| 1272 | end |
---|
| 1273 | end |
---|
[257] | 1274 | |
---|
[2] | 1275 | end |
---|
| 1276 | |
---|
[282] | 1277 | if Param.CheckCiv2==1 |
---|
[469] | 1278 | Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j}; |
---|
| 1279 | Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j}; |
---|
[343] | 1280 | if ~checkframe %&& size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j) |
---|
[372] | 1281 | Param.Civ2.Dt=time(i2_civ2(ifile)+1,j2_civ2(j)+1)-time(i1_civ2(ifile)+1,j1_civ2(j)+1); |
---|
[301] | 1282 | else |
---|
| 1283 | Param.Civ2.Dt=1; |
---|
[309] | 1284 | end |
---|
[372] | 1285 | Param.Civ2.Time=(time(i2_civ2(ifile)+1,j2_civ2(j)+1)+time(i1_civ2(ifile)+1,j1_civ2(j)+1))/2; |
---|
[469] | 1286 | if strcmp(Param.Program,'CivX') |
---|
[465] | 1287 | Param.Civ2.term_a=num2stra(j1_civ2(j),nom_type_nc); |
---|
| 1288 | Param.Civ2.term_b=num2stra(j2_civ2(j),nom_type_nc); |
---|
[399] | 1289 | end |
---|
[290] | 1290 | Param.Civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 1291 | Param.Civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
[315] | 1292 | |
---|
[465] | 1293 | % mask |
---|
[287] | 1294 | if Param.Civ2.CheckMask |
---|
[315] | 1295 | if ~exist(Param.Civ2.Mask,'file') |
---|
| 1296 | maskbase=[filecell.filebase '_' Param.Civ2.Mask]; % |
---|
| 1297 | nbslice_mask=str2double(Param.Civ2.Mask(1:end-4)); % |
---|
[313] | 1298 | i1_mask=mod(i1_civ2(ifile)-1,nbslice_mask)+1; |
---|
[354] | 1299 | [RootPathMask,RootFileMask]=fileparts(maskbase); |
---|
| 1300 | Param.Civ2.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask); |
---|
[465] | 1301 | % Param.Civ2.Mask=name_generator(maskbase,i1_mask,1,'.png','_i'); |
---|
[2] | 1302 | end |
---|
| 1303 | end |
---|
[315] | 1304 | %grid |
---|
| 1305 | if Param.Civ2.CheckGrid |
---|
| 1306 | if numel(Param.Civ2.Grid)>=4 && isequal(Param.Civ2.Grid(end-3:end),'grid') |
---|
| 1307 | nbslice_grid=str2double(Param.Civ2.Grid(1:end-4)); % |
---|
| 1308 | if ~isnan(nbslice_grid) |
---|
| 1309 | i1_grid=mod(i1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[354] | 1310 | Param.Civ2.Grid=[filecell.filebase '_' fullfile_uvmat('','',gridname,'.grid','_1',i1_grid)]; |
---|
[465] | 1311 | % Param.Civ2.Grid=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')]; |
---|
[315] | 1312 | end |
---|
[2] | 1313 | end |
---|
| 1314 | end |
---|
[469] | 1315 | |
---|
[476] | 1316 | Param.Civ2.ImageBitDepth=ImageInfoA_civ2.BitDepth; |
---|
| 1317 | Param.Civ2.ImageWidth=ImageInfoA_civ2.Width; |
---|
| 1318 | Param.Civ2.ImageHeight=ImageInfoA_civ2.Height; |
---|
[494] | 1319 | if strcmp(NomTypeIma,'*') |
---|
[498] | 1320 | Param.Civ2.FrameIndexA=i1_civ2(ifile); |
---|
| 1321 | Param.Civ2.FrameIndexB=i2_civ2(ifile); |
---|
[494] | 1322 | else% case of movies indexed with i, the frame index is then in j |
---|
[498] | 1323 | Param.Civ2.FrameIndexA=j1_civ2(j); |
---|
| 1324 | Param.Civ2.FrameIndexB=j2_civ2(j); |
---|
[494] | 1325 | end |
---|
[112] | 1326 | end |
---|
[469] | 1327 | |
---|
[465] | 1328 | % write the command and eventually the cmx, xml or nml files |
---|
[469] | 1329 | cmd=write_cmd(Param); |
---|
[465] | 1330 | write_param(Param); |
---|
[469] | 1331 | |
---|
[465] | 1332 | % create the file used in run or batch |
---|
[469] | 1333 | switch Param.Program |
---|
[482] | 1334 | case {'civ_matlab'} |
---|
[505] | 1335 | filename_bat=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_BAT$2$3.m'); |
---|
| 1336 | [BatRoot,BatFile]=fileparts(filename_bat); |
---|
| 1337 | BatFile=regexprep(BatFile,'-','__');%transform name to suppress'-' (not valid for .m files) |
---|
| 1338 | filename_bat=[fullfile(BatRoot,BatFile) '.m']; |
---|
[482] | 1339 | case {'CivX','CivAll','civ_matlab.sh'} |
---|
| 1340 | switch computer |
---|
| 1341 | case {'PCWIN','PCWIN64'} |
---|
[487] | 1342 | filename_bat=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_BAT$2$3.bat'); |
---|
[482] | 1343 | case {'GLNX86','GLNXA64','MACI64'} |
---|
[487] | 1344 | filename_bat=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_BAT$2$3.sh'); |
---|
[482] | 1345 | end |
---|
[112] | 1346 | end |
---|
| 1347 | |
---|
[486] | 1348 | % print the command in the bat file |
---|
[465] | 1349 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 1350 | if isequal(fid,-1) |
---|
| 1351 | errormsg=['creation of .bat file: ' message]; |
---|
| 1352 | return |
---|
[12] | 1353 | end |
---|
[465] | 1354 | fprintf(fid,cmd); |
---|
| 1355 | fclose(fid); |
---|
[482] | 1356 | |
---|
| 1357 | % special case for civ_matlab on cluster |
---|
| 1358 | if strcmp(Param.Program,'civ_matlab') && strcmp(Param.RunMode,'cluster') |
---|
[487] | 1359 | filename_bat2=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_BAT$2$3.sh'); |
---|
[482] | 1360 | [fid,message]=fopen(filename_bat2,'w'); |
---|
| 1361 | if isequal(fid,-1) |
---|
| 1362 | errormsg=['creation of .bat file: ' message]; |
---|
| 1363 | return |
---|
| 1364 | end |
---|
| 1365 | fprintf(fid,['#!/bin/bash \n' ... |
---|
| 1366 | '/etc/sysprofile \n'... |
---|
| 1367 | 'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n'... |
---|
| 1368 | 'addpath(''' path_civ ''');\n']); |
---|
| 1369 | for p=1:length(batch_file_list) |
---|
| 1370 | fprintf(fid,['run ' filename_bat '\n']); |
---|
| 1371 | end |
---|
| 1372 | fprintf(fid, 'exit \n END_MATLAB \n'); |
---|
| 1373 | fclose(fid); |
---|
| 1374 | filename_bat=filename_bat2; |
---|
[465] | 1375 | end |
---|
[309] | 1376 | |
---|
[482] | 1377 | switch computer |
---|
| 1378 | case {'GLNX86','GLNXA64','MACI64'} |
---|
| 1379 | system(['chmod +x ' filename_bat]); |
---|
| 1380 | end |
---|
| 1381 | batch_file_list{length(batch_file_list)+1}=filename_bat; |
---|
[112] | 1382 | end |
---|
[2] | 1383 | end |
---|
[134] | 1384 | |
---|
[465] | 1385 | %% start calculation |
---|
[469] | 1386 | %computation on cluster |
---|
| 1387 | %if batch ==3 |
---|
[482] | 1388 | switch Param.RunMode, |
---|
| 1389 | case 'cluster' |
---|
| 1390 | switch batch_mode |
---|
| 1391 | case 'sge' %at the moment only psmn ENS Lyon uses it |
---|
[279] | 1392 | for p=1:length(batch_file_list) |
---|
[482] | 1393 | %cmd=['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}]; |
---|
| 1394 | cmd=['!qsub -q piv1,piv2,piv3 '... |
---|
| 1395 | '-e ' regexprep(batch_file_list{p},'.bat','.errors') ' -o ' regexprep(batch_file_list{p},'.bat','.log ')... |
---|
| 1396 | ' -v ' 'LD_LIBRARY_PATH=/home/sjoubaud/matlab_sylvain/civx/lib ' batch_file_list{p}]; |
---|
| 1397 | display(cmd);eval(cmd); |
---|
| 1398 | end |
---|
| 1399 | case 'oar_old' % to remove |
---|
| 1400 | for p=1:length(batch_file_list) |
---|
[279] | 1401 | oar_command=['!oarsub -n CIVX -q nicejob '... |
---|
[482] | 1402 | '-E ' regexprep(batch_file_list{p},'.bat','.errors') ' -O ' regexprep(batch_file_list{p},'.bat','.log ')... |
---|
| 1403 | '-l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00" ' batch_file_list{p}]; |
---|
| 1404 | display(oar_command);eval(oar_command); |
---|
| 1405 | end |
---|
| 1406 | case 'oar' |
---|
| 1407 | max_walltime=3600*12; % 12h max |
---|
| 1408 | oar_modes={'oar-parexec','oar-dispatch','mpilauncher'}; |
---|
| 1409 | text={'Batch processing on servcalcul3 LEGI';... |
---|
| 1410 | 'Please choose one of the followint modes';... |
---|
| 1411 | '* oar-parexec : default and best choice';... |
---|
| 1412 | '* oar-dispatch : jobs in a container of several cores';... |
---|
| 1413 | '* mpilauncher : one single parallel mpi job using several cores';... |
---|
| 1414 | '**********************************'... |
---|
| 1415 | }; |
---|
| 1416 | [S,v]=listdlg('PromptString',text,'ListString',oar_modes,... |
---|
| 1417 | 'SelectionMode','single','ListSize',[400 100],'Name','LEGI job mode'); |
---|
| 1418 | switch oar_modes{S} |
---|
| 1419 | case 'oar-parexec' %oar-dispatch.pl |
---|
| 1420 | answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''}); |
---|
| 1421 | ncores=str2double(answer{1}); |
---|
| 1422 | if strcmp(Param.Program,'civ_matlab') |
---|
| 1423 | ncores=1; |
---|
| 1424 | end |
---|
| 1425 | extra_oar=answer{2}; |
---|
| 1426 | walltime_onejob=600;%seconds |
---|
| 1427 | filename_joblist=fullfile(RootBat,'job_list.txt'); |
---|
| 1428 | fid=fopen(filename_joblist,'w'); |
---|
| 1429 | for p=1:length(batch_file_list) |
---|
| 1430 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
| 1431 | end |
---|
| 1432 | fclose(fid); |
---|
| 1433 | oar_command=['oarsub -n CIVX '... |
---|
| 1434 | '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '... |
---|
| 1435 | '-l /core=' num2str(ncores) ','... |
---|
[419] | 1436 | 'walltime=' datestr(min(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,max_walltime/86400),13) ' '... |
---|
[482] | 1437 | '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '... |
---|
| 1438 | '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '... |
---|
| 1439 | extra_oar ' '... |
---|
| 1440 | '"oar-parexec -s -f ' filename_joblist ' '... |
---|
| 1441 | '-l ' filename_joblist '.log"\n']; |
---|
| 1442 | filename_oarcommand=fullfile(RootBat,'oar_command'); |
---|
| 1443 | fid=fopen(filename_oarcommand,'w'); |
---|
| 1444 | fprintf(fid,oar_command); |
---|
| 1445 | fclose(fid); |
---|
| 1446 | fprintf(oar_command);% display in command line |
---|
| 1447 | system(oar_command); |
---|
| 1448 | % eval(['! . ' filename |
---|
| 1449 | % _oarcommand]) |
---|
| 1450 | case 'oar-dispatch' %oar-dispatch.pl |
---|
| 1451 | ncores=str2double(... |
---|
| 1452 | inputdlg('Number of cores (max 36)','oarsub parameter',1,{'6'})... |
---|
| 1453 | ); |
---|
| 1454 | walltime_onejob=600;%seconds |
---|
| 1455 | filename_joblist=fullfile(RootBat,'job_list.txt'); |
---|
| 1456 | fid=fopen(filename_joblist,'w'); |
---|
| 1457 | for p=1:length(batch_file_list) |
---|
| 1458 | oar_command=['oarsub -n CIVX '... |
---|
| 1459 | '-E ' regexprep(batch_file_list{p},'\.bat\>','.stderr') ' -O ' regexprep(batch_file_list{p},'\.bat\>','.stdout ')... |
---|
| 1460 | '-l "/core=1,walltime=' datestr(walltime_onejob/86400,13) '" ' batch_file_list{p}]; |
---|
| 1461 | fprintf(fid,[oar_command '\n']); |
---|
| 1462 | end |
---|
| 1463 | fclose(fid); |
---|
| 1464 | oar_command=['oarsub -t container -n civx-container '... |
---|
| 1465 | '-l /core=' num2str(ncores)... |
---|
| 1466 | ',walltime=' datestr(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,13) ' '... |
---|
| 1467 | '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '... |
---|
| 1468 | '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '... |
---|
| 1469 | '"oar-dispatch -f ' filename_joblist '"']; |
---|
| 1470 | filename_oarcommand=fullfile(RootBat,'oar_command'); |
---|
| 1471 | fid=fopen(filename_oarcommand,'w'); |
---|
[314] | 1472 | fprintf(fid,[oar_command '\n']); |
---|
[482] | 1473 | fclose(fid); |
---|
| 1474 | display(oar_command); |
---|
| 1475 | eval(['! . ' filename_oarcommand]) |
---|
| 1476 | case 'mpilauncher' |
---|
| 1477 | filename_joblist=fullfile(RootBat,'job_list.txt'); |
---|
| 1478 | fid=fopen(filename_joblist,'w'); |
---|
| 1479 | |
---|
| 1480 | for p=1:length(batch_file_list) |
---|
| 1481 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
| 1482 | end |
---|
| 1483 | fclose(fid) |
---|
| 1484 | text_oarscript=[... |
---|
| 1485 | '#!/bin/bash \n'... |
---|
| 1486 | '#OAR -n Mylauncher \n'... |
---|
| 1487 | '#OAR -l node=4/core=5,walltime=0:15:00 \n'... |
---|
| 1488 | '#OAR -E ' fullfile(RootBat,'stderrfile.log') ' \n'... |
---|
| 1489 | '#OAR -O ' fullfile(RootBat,'stdoutfile.log') ' \n'... |
---|
| 1490 | '# ========================================================= \n'... |
---|
| 1491 | '# This simple program launch a multinode parallel OpenMPI mpilauncher \n'... |
---|
| 1492 | '# application for coriolis PIV post-processing. \n'... |
---|
| 1493 | '# OAR uses oarshmost wrapper to propagate the user environement. \n'... |
---|
| 1494 | '# This wrapper assert that the user has the same environment on all the \n'... |
---|
| 1495 | '# allocated nodes (basic behavior needed by most MPI applications). \n'... |
---|
| 1496 | '# \n'... |
---|
| 1497 | '# REQUIREMENT: \n'... |
---|
| 1498 | '# the oarshmost wrapper should be installed in $HOME/bin directory. \n'... |
---|
| 1499 | '# If a different location is used, change the line following the comment "Bidouille" \n'... |
---|
| 1500 | '# ========================================================= \n'... |
---|
| 1501 | '# USER should only modify these 2 lines \n'... |
---|
| 1502 | 'WORKDIR=' pwd ' \n'... |
---|
| 1503 | 'COMMANDE="mpilauncher -f ' filename_joblist '" \n'... |
---|
| 1504 | '# ========================================================= \n'... |
---|
| 1505 | '# DO NOT MODIFY the FOLOWING LINES. (or be carefull) \n'... |
---|
| 1506 | 'echo "job starting on: "`hostname` \n'... |
---|
| 1507 | 'MPINODES="-host `tr [\\\\\\n] [,] <$OAR_NODEFILE |sed -e "s/,$/ /"`" \n'... |
---|
| 1508 | 'NCPUS=`cat $OAR_NODEFILE |wc -l` \n'... |
---|
| 1509 | '#========== Bidouille ============== \n'... |
---|
| 1510 | 'export OMPI_MCA_plm_rsh_agent=oar-envsh \n'...% 'cd $WORKDIR \n'... |
---|
| 1511 | 'CMD="mpirun -np $NCPUS -wdir $WORKDIR $MPINODES $COMMANDE" \n'... |
---|
| 1512 | 'echo "I run: $CMD" \n'... |
---|
| 1513 | '$CMD \n'... |
---|
| 1514 | 'echo "job ending" \n'... |
---|
| 1515 | ]; |
---|
| 1516 | % oarsub -S ./oar.sub |
---|
| 1517 | filename_oarscript=fullfile(RootBat,'oar_command'); |
---|
| 1518 | fid=fopen(filename_oarscript,'w'); |
---|
| 1519 | fprintf(fid,[text_oarscript]); |
---|
| 1520 | fclose(fid); |
---|
| 1521 | eval(['!chmod +x ' filename_oarscript]); |
---|
| 1522 | eval(['!oarsub -S ' filename_oarscript]); |
---|
[465] | 1523 | end |
---|
[482] | 1524 | end |
---|
| 1525 | case {'background','local'} |
---|
| 1526 | switch Param.Program |
---|
| 1527 | case {'civ_matlab'} |
---|
| 1528 | switch Param.RunMode |
---|
| 1529 | case 'background' |
---|
| 1530 | switch computer |
---|
| 1531 | case {'PCWIN','PCWIN64'} |
---|
| 1532 | filename_superbat=fullfile(RootBat,'job_list.bat'); |
---|
| 1533 | fid=fopen(filename_superbat,'w'); |
---|
| 1534 | if fid==-1 |
---|
| 1535 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 1536 | return |
---|
| 1537 | end |
---|
[495] | 1538 | fprintf(fid,['matlab -automation '... |
---|
| 1539 | '-r "addpath(''' regexprep(path_civ,'\\','\\\\') ''');']); |
---|
| 1540 | for p=1:length(batch_file_list) |
---|
| 1541 | fprintf(fid,['run ' regexprep(batch_file_list{p},'\\','\\\\') ';']); |
---|
| 1542 | end |
---|
| 1543 | fprintf(fid, 'exit"'); |
---|
[482] | 1544 | fclose(fid); |
---|
[495] | 1545 | dos([filename_superbat ' &']); |
---|
| 1546 | case {'GLNX86','GLNXA64','MACI64'} |
---|
[482] | 1547 | filename_superbat=fullfile(RootBat,'job_list.sh'); |
---|
| 1548 | fid=fopen(filename_superbat,'w'); |
---|
| 1549 | if fid==-1 |
---|
| 1550 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 1551 | return |
---|
| 1552 | end |
---|
| 1553 | fprintf(fid,['#!/bin/bash \n' ... |
---|
| 1554 | '/etc/sysprofile \n'... |
---|
[498] | 1555 | 'matlab -nodisplay -nosplash -nojvm -logfile <<END_MATLAB \n'... |
---|
[482] | 1556 | 'addpath(''' path_civ ''');\n']); |
---|
| 1557 | for p=1:length(batch_file_list) |
---|
| 1558 | fprintf(fid,['run ' batch_file_list{p} '\n']); |
---|
| 1559 | end |
---|
| 1560 | fprintf(fid, 'exit \n END_MATLAB \n'); |
---|
| 1561 | fclose(fid); |
---|
| 1562 | system(['chmod +x ' filename_superbat]); |
---|
| 1563 | system([filename_superbat ' &']); |
---|
| 1564 | end |
---|
| 1565 | case 'local' |
---|
| 1566 | for p=1:length(batch_file_list) |
---|
| 1567 | fid=fopen(batch_file_list{p}); |
---|
| 1568 | eval(fscanf(fid,'%s')); |
---|
| 1569 | fclose(fid); |
---|
| 1570 | end |
---|
[465] | 1571 | end |
---|
[482] | 1572 | case {'CivX','CivAll','civ_matlab.sh'} |
---|
| 1573 | switch computer |
---|
| 1574 | case {'PCWIN','PCWIN64'} |
---|
| 1575 | filename_superbat=fullfile(RootBat,'job_list.bat'); |
---|
| 1576 | fid=fopen(filename_superbat,'w'); |
---|
| 1577 | if fid==-1 |
---|
| 1578 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 1579 | return |
---|
| 1580 | end |
---|
| 1581 | for p=1:length(batch_file_list) |
---|
| 1582 | fprintf(fid,['@call "' regexprep(batch_file_list{p},'\\','\\\\') '"' '\n']); |
---|
| 1583 | end |
---|
| 1584 | fclose(fid); |
---|
| 1585 | system(['chmod +x ' filename_superbat]); |
---|
| 1586 | case {'GLNX86','GLNXA64','MACI64'} |
---|
| 1587 | filename_superbat=fullfile(RootBat,'job_list.bat'); |
---|
| 1588 | fid=fopen(filename_superbat,'w'); |
---|
| 1589 | if fid==-1 |
---|
| 1590 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 1591 | return |
---|
| 1592 | end |
---|
| 1593 | for p=1:length(batch_file_list) |
---|
| 1594 | fprintf(fid,['sh ' batch_file_list{p} '\n']); |
---|
| 1595 | end |
---|
| 1596 | fclose(fid); |
---|
| 1597 | system(['chmod +x ' filename_superbat]); |
---|
| 1598 | end |
---|
| 1599 | switch Param.RunMode |
---|
| 1600 | case 'background' |
---|
| 1601 | system([filename_superbat ' &']);% execute main commmand see what it does in dos ? |
---|
| 1602 | case 'local' |
---|
| 1603 | system(filename_superbat); |
---|
[465] | 1604 | end |
---|
[482] | 1605 | end |
---|
[265] | 1606 | end |
---|
| 1607 | |
---|
[2] | 1608 | |
---|
[137] | 1609 | %% save interface state |
---|
[2] | 1610 | if isfield(filecell,'nc') |
---|
| 1611 | if isfield(filecell.nc,'civ2') |
---|
| 1612 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 1613 | else |
---|
| 1614 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 1615 | end |
---|
| 1616 | end |
---|
[343] | 1617 | [RootPath,SubDir,RootFile]=fileparts_uvmat(fileresu); |
---|
| 1618 | namedoc=fullfile(RootPath,SubDir,RootFile); |
---|
[112] | 1619 | detect=1; |
---|
[2] | 1620 | while detect==1 |
---|
| 1621 | namefigfull=[namedoc '.fig']; |
---|
| 1622 | hh=dir(namefigfull); |
---|
| 1623 | if ~isempty(hh) |
---|
| 1624 | detect=1; |
---|
| 1625 | namedoc=[namedoc '.0']; |
---|
| 1626 | else |
---|
| 1627 | detect=0; |
---|
| 1628 | end |
---|
| 1629 | end |
---|
[363] | 1630 | Param=rmfield(Param,'status'); |
---|
| 1631 | Param=rmfield(Param,'xml'); |
---|
[360] | 1632 | t=struct2xml(Param); |
---|
[437] | 1633 | t=set(t,1,'name','Civ');% set the head label |
---|
| 1634 | save(t,[namedoc '.civ.xml']); %save GUI parameters as xml file |
---|
[465] | 1635 | % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
[2] | 1636 | |
---|
[273] | 1637 | %Save info in personal profile (initiate browser next time) TODO |
---|
| 1638 | MenuFile={}; |
---|
| 1639 | dir_perso=prefdir; |
---|
| 1640 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 1641 | if exist(profil_perso,'file') |
---|
| 1642 | hh=load (profil_perso); |
---|
| 1643 | if isfield(hh,'MenuFile') |
---|
| 1644 | MenuFile=hh.MenuFile; |
---|
| 1645 | end |
---|
[289] | 1646 | if isfield(filecell.nc,'civ2') |
---|
| 1647 | MenuFile=[filecell.nc.civ2{1,1}; MenuFile]; |
---|
| 1648 | else |
---|
| 1649 | MenuFile=[filecell.nc.civ1{1,1}; MenuFile]; |
---|
| 1650 | end |
---|
[273] | 1651 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
| 1652 | else |
---|
| 1653 | MenuFile=filecell.ima1.civ1(1,1); |
---|
| 1654 | save (profil_perso,'MenuFile') |
---|
| 1655 | end |
---|
| 1656 | |
---|
[227] | 1657 | %------------------------------------------------------------------------ |
---|
| 1658 | % --- determine the list of reference indices of processing file |
---|
| 1659 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
| 1660 | %------------------------------------------------------------------------ |
---|
| 1661 | errormsg=''; %default error message |
---|
| 1662 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 1663 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 1664 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
| 1665 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 1666 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 1667 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 1668 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
| 1669 | else |
---|
| 1670 | first_j=1; |
---|
| 1671 | last_j=1; |
---|
| 1672 | incr_j=1; |
---|
| 1673 | end |
---|
| 1674 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
| 1675 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
| 1676 | if isnan(first_i)||isnan(first_j) |
---|
| 1677 | errormsg='first field number not defined'; |
---|
| 1678 | elseif isnan(last_i)||isnan(last_j) |
---|
| 1679 | errormsg='last field number not defined'; |
---|
| 1680 | elseif isnan(incr_i)||isnan(incr_j) |
---|
| 1681 | errormsg='increment in field number not defined'; |
---|
| 1682 | elseif last_i < first_i || last_j < first_j |
---|
| 1683 | errormsg='last field number must be larger than the first one'; |
---|
| 1684 | end |
---|
[134] | 1685 | |
---|
[227] | 1686 | %------------------------------------------------------------------------ |
---|
| 1687 | % --- determine the list of filenames and indices needed for launch_job |
---|
[371] | 1688 | %------------------------------------------------------------------------ |
---|
| 1689 | % OUTPUT: |
---|
| 1690 | % filecell: structure of cell arrays {ref_i,ref_j} containing all the filenames involved in the civ process |
---|
| 1691 | % the indices ref_i and ref_j correspond to the list of reference indices |
---|
| 1692 | % .filebase=fullfile(RootPath,RootFile) used to construct mask names, grid names, CivDoc xml file |
---|
| 1693 | % .ima1.civ1,.ima1.civ2: first image for civ1 and civ2 respectively (possibly different) |
---|
| 1694 | % .ima2.civ1,.ima2.civ2: second image for civ1 and civ2 respectively (possibly different) |
---|
| 1695 | % .nc.civ1,.nc.civ2: netcdf files containing civ1 and civ2 data respectively (possibly different) |
---|
| 1696 | % 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] | 1697 | 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] | 1698 | set_civ_filenames(handles,ref_i,ref_j,checkbox) |
---|
[12] | 1699 | %------------------------------------------------------------------------ |
---|
[85] | 1700 | filecell=[];%default |
---|
[437] | 1701 | errormsg=''; |
---|
[469] | 1702 | ListProgram=get(handles.Program,'String'); |
---|
| 1703 | CivMode=ListProgram{get(handles.Program,'Value')};%Program to use , CivX or Matlab |
---|
[136] | 1704 | |
---|
[371] | 1705 | %% get the root name and check dir |
---|
| 1706 | RootPath=get(handles.RootPath,'String'); |
---|
[494] | 1707 | SubDirImages=get(handles.SubDirImages,'String'); |
---|
[371] | 1708 | RootFile=get(handles.RootFile,'String'); |
---|
[494] | 1709 | filecell.filebase=fullfile(RootPath,SubDirImages,RootFile); |
---|
[371] | 1710 | if isempty(filecell.filebase) |
---|
[437] | 1711 | errormsg='please open an image with the upper menu option Open/Browse...'; |
---|
[136] | 1712 | return |
---|
| 1713 | end |
---|
[371] | 1714 | if ~exist(RootPath,'dir') |
---|
[437] | 1715 | errormsg=['path to images ' RootPath ' not found']; |
---|
[371] | 1716 | return |
---|
| 1717 | end |
---|
[388] | 1718 | [tild,message]=fileattrib(RootPath); |
---|
[371] | 1719 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[437] | 1720 | errormsg=['No writting access to ' RootPath]; |
---|
[371] | 1721 | return |
---|
| 1722 | end |
---|
| 1723 | %check result directory |
---|
[441] | 1724 | subdir_civ1=regexprep(get(handles.SubdirCiv1,'String'),'^.','');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 1725 | subdir_civ2=regexprep(get(handles.SubdirCiv2,'String'),'^.',''); |
---|
| 1726 | if isequal(subdir_civ1,''),subdir_civ1='civ'; end% put default subdir |
---|
| 1727 | % subdir_civ1=[ '.' subdir_civ1]; |
---|
| 1728 | % subdir_civ2=[ '.' subdir_civ2]; |
---|
[371] | 1729 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[494] | 1730 | subdir_civ1=[SubDirImages '.' subdir_civ1]; |
---|
| 1731 | subdir_civ2=[SubDirImages '.' subdir_civ2]; |
---|
[136] | 1732 | |
---|
[371] | 1733 | %% choose root names depending on ListCompareMode =displacement, shift, PIV or stereo PIV |
---|
| 1734 | ListCompareMode=get(handles.ListCompareMode,'String'); |
---|
| 1735 | compare=ListCompareMode{get(handles.ListCompareMode,'Value')}; |
---|
[136] | 1736 | |
---|
[371] | 1737 | % set the nomenclature type of the nc files depending on the pair mode |
---|
[360] | 1738 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
[2] | 1739 | mode='displacement'; |
---|
| 1740 | else |
---|
[282] | 1741 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 1742 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 1743 | mode=mode_list{mode_value}; |
---|
| 1744 | end |
---|
[371] | 1745 | NomType_ima2=get(handles.NomType,'String'); |
---|
| 1746 | NomType_nc=nomtype2pair(NomType_ima2,mode); |
---|
| 1747 | |
---|
| 1748 | % set the rootfile and image indexing |
---|
| 1749 | RootFile_ima2=get(handles.RootFile,'String');%root file for the second image series |
---|
| 1750 | ext_ima=get(handles.ImaExt,'String'); % image extension (the same for all images) |
---|
| 1751 | switch compare |
---|
| 1752 | case 'PIV' |
---|
| 1753 | RootFile_ima1=RootFile_ima2;% root name of the two image series is the same |
---|
| 1754 | NomType_ima1=NomType_ima2;% the index of the first image follows the index of the second one |
---|
| 1755 | RootFile_nc=RootFile_ima2; |
---|
| 1756 | case 'displacement' |
---|
| 1757 | RootFile_ima1=get(handles.RootFile_1,'String');% root name of the first image series set by handles.RootFile_1 |
---|
| 1758 | NomType_ima1='';% no indexing of the first image, a fixed reference for the whole series |
---|
| 1759 | RootFile_nc=RootFile_ima2; |
---|
| 1760 | case 'shift' |
---|
| 1761 | RootFile_ima1=get(handles.RootFile_1,'String');% root name of the first image series set by handles.RootFile_1 |
---|
| 1762 | NomType_ima1=NomType_ima2;% the index of the first image follows the index of the second one |
---|
| 1763 | RootFile_nc=[RootFile_ima1 '-' RootFile_ima2]; |
---|
[122] | 1764 | end |
---|
[360] | 1765 | |
---|
[371] | 1766 | %determine the list of file indices involved |
---|
| 1767 | [i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2]=... |
---|
[227] | 1768 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
[371] | 1769 | |
---|
[282] | 1770 | %determine the new filebase for 'displacement' ListPairMode (comparison of two series) |
---|
[371] | 1771 | %filebase_B=filebase;% root name of the second field series for stereo |
---|
| 1772 | % filebase_A=filebase;%default |
---|
| 1773 | % if strcmp(compare,'PIV') |
---|
| 1774 | % filebase_AB=filebase; |
---|
| 1775 | % else |
---|
| 1776 | % [Path2,Name2]=fileparts(filebase_B); |
---|
| 1777 | % Name1=RootFile_ima1; |
---|
| 1778 | % filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 1779 | % end |
---|
| 1780 | % [RootPath_AB,RootFile_AB]=fileparts(filebase_AB); |
---|
| 1781 | % % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_B); |
---|
| 1782 | % [RootPath_ima2,RootFile_ima2]=fileparts(filebase_B); |
---|
| 1783 | % [RootPath_nc,RootFile_nc]=fileparts(filebase_B);%default |
---|
| 1784 | % if strcmp(compare,'displacement') |
---|
| 1785 | % % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_B); |
---|
| 1786 | % % [RootPath_ima2,RootFile_ima2]=fileparts(filebase_B); |
---|
| 1787 | % [RootPath_nc,RootFile_nc]=fileparts(filebase_B); |
---|
| 1788 | % elseif strcmp(compare,'shift') |
---|
| 1789 | % RootPath_nc=RootPath_AB; |
---|
| 1790 | % RootFile_nc=RootFile_AB; |
---|
| 1791 | % end |
---|
| 1792 | % else |
---|
| 1793 | % filebase_ima1=filebase_B; |
---|
| 1794 | % filebase_ima2=filebase_B; |
---|
| 1795 | % filebase_nc=filebase_B; |
---|
| 1796 | % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_ima1); |
---|
| 1797 | % [RootPath_ima2,RootFile_ima2]=fileparts(filebase_ima2); |
---|
| 1798 | % [RootPath_nc,RootFile_nc]=fileparts(filebase_nc); |
---|
| 1799 | % [RootPath_A,RootFile_A]=fileparts(filebase_A); |
---|
| 1800 | |
---|
[353] | 1801 | |
---|
[371] | 1802 | %% determine reference files for fix: |
---|
[2] | 1803 | file_ref_fix1={};%default |
---|
| 1804 | file_ref_fix2={}; |
---|
[371] | 1805 | nbfield=length(i1_civ1); |
---|
| 1806 | nbslice=length(j1_civ1); |
---|
[282] | 1807 | if checkbox(2)==1% fix1 performed |
---|
[2] | 1808 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 1809 | if ~isempty(ref) |
---|
[137] | 1810 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1811 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1812 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 1813 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1814 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1815 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 1816 | num_i_ref=first_i:incr_i:last_i; |
---|
| 1817 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 1818 | if isequal(mode,'displacement') |
---|
| 1819 | num_i1=num_i_ref; |
---|
[371] | 1820 | num_i2=num_i_ref; |
---|
[2] | 1821 | num_j1=num_j_ref; |
---|
| 1822 | num_j2=num_j_ref; |
---|
| 1823 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 1824 | num_i1=num_i_ref; |
---|
| 1825 | num_i2=num_i1; |
---|
| 1826 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 1827 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 1828 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 1829 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 1830 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 1831 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 1832 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 1833 | if isempty(ref.num_a) |
---|
| 1834 | ref.num_a=1; |
---|
| 1835 | end |
---|
| 1836 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 1837 | num_j2=num_j1; |
---|
| 1838 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 1839 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 1840 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 1841 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 1842 | num_i2=num_i1; |
---|
| 1843 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 1844 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 1845 | end |
---|
| 1846 | for ifile=1:nbfield |
---|
| 1847 | for j=1:nbslice |
---|
[371] | 1848 | [RootPathRef,RootFile]=fileparts(ref.filebase); |
---|
| 1849 | file_ref=fullfile_uvmat(RootPathRef,ref.subdir,RootFile,'.nc',ref.NomType,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j)); |
---|
[2] | 1850 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 1851 | if ~exist(file_ref,'file') |
---|
[437] | 1852 | errormsg=['reference file ' file_ref ' not found for fix1']; |
---|
[2] | 1853 | return |
---|
| 1854 | end |
---|
| 1855 | end |
---|
| 1856 | end |
---|
| 1857 | end |
---|
| 1858 | end |
---|
| 1859 | |
---|
[371] | 1860 | %% determine reference files for fix2: |
---|
[282] | 1861 | if checkbox(5)==1% fix2 performed |
---|
[2] | 1862 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 1863 | if ~isempty(ref) |
---|
[127] | 1864 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1865 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1866 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 1867 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1868 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1869 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[229] | 1870 | num_i_ref=first_i:incr_i:last_i; |
---|
| 1871 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 1872 | if isequal(mode,'displacement') |
---|
| 1873 | num_i1=num_i_ref; |
---|
| 1874 | num_i2=num_i_ref; |
---|
| 1875 | num_j1=num_j_ref; |
---|
| 1876 | num_j2=num_j_ref; |
---|
| 1877 | elseif isequal(mode,'pair j1-j2') |
---|
| 1878 | num_i1=num_i_ref; |
---|
| 1879 | num_i2=num_i1; |
---|
| 1880 | num_j1=ref.num_a; |
---|
| 1881 | num_j2=ref.num_b; |
---|
| 1882 | elseif isequal(mode,'series(Di)') |
---|
| 1883 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 1884 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 1885 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 1886 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 1887 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 1888 | num_j2=num_j1; |
---|
| 1889 | elseif isequal(mode,'series(Dj)') |
---|
| 1890 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 1891 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 1892 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 1893 | num_i2=num_i1; |
---|
| 1894 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 1895 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 1896 | end |
---|
| 1897 | for ifile=1:nbfield |
---|
| 1898 | for j=1:nbslice |
---|
[371] | 1899 | [RootPathRef,RootFile]=fileparts(ref.filebase); |
---|
| 1900 | file_ref=fullfile_uvmat(RootPathRef,ref.subdir,RootFile,'.nc',ref.NomType,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j)); |
---|
[2] | 1901 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 1902 | if ~exist(file_ref,'file') |
---|
[437] | 1903 | errormsg=['reference file ' file_ref ' not found for fix2']; |
---|
[2] | 1904 | return |
---|
| 1905 | end |
---|
| 1906 | end |
---|
| 1907 | end |
---|
| 1908 | end |
---|
| 1909 | end |
---|
| 1910 | |
---|
[371] | 1911 | %% check the existence of the netcdf and image files involved |
---|
[282] | 1912 | % %%%%%%%%%%%% case CheckCiv1 activated %%%%%%%%%%%%% |
---|
| 1913 | if checkbox(1)==1; |
---|
[112] | 1914 | detect=1; |
---|
[127] | 1915 | vers=0; |
---|
| 1916 | subdir_civ1_new=subdir_civ1; |
---|
[482] | 1917 | answer='No'; |
---|
[153] | 1918 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[122] | 1919 | for ifile=1:nbfield |
---|
[112] | 1920 | for j=1:nbslice |
---|
[371] | 1921 | 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] | 1922 | detect=exist(filename,'file')==2; |
---|
| 1923 | if detect% if a netcdf file already exists |
---|
[482] | 1924 | if strcmp(answer,'No') |
---|
| 1925 | answer=msgbox_uvmat('INPUT_Y-N',['overwrite existing civ files in ' subdir_civ1_new]); |
---|
| 1926 | end |
---|
[452] | 1927 | if strcmp(answer,'Yes') |
---|
| 1928 | detect=0; |
---|
| 1929 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 1930 | else |
---|
[446] | 1931 | r=regexp(subdir_civ1_new,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number |
---|
| 1932 | if isempty(r) |
---|
| 1933 | r(1).root=[subdir_civ1_new '_']; |
---|
| 1934 | r(1).num1='0'; |
---|
| 1935 | end |
---|
| 1936 | subdir_civ1_new=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 |
---|
| 1937 | subdir_civ2=subdir_civ1_new; |
---|
[127] | 1938 | end |
---|
[112] | 1939 | break |
---|
| 1940 | end |
---|
| 1941 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 1942 | end |
---|
| 1943 | if detect% if a netcdf file already exists |
---|
| 1944 | break |
---|
| 1945 | end |
---|
| 1946 | end |
---|
[134] | 1947 | |
---|
[363] | 1948 | %create the new SubdirCiv1 |
---|
[371] | 1949 | if ~exist(fullfile(RootPath,subdir_civ1_new),'dir') |
---|
| 1950 | [xx,msg1]=mkdir(fullfile(RootPath,subdir_civ1_new)); |
---|
[128] | 1951 | if ~strcmp(msg1,'') |
---|
[437] | 1952 | errormsg=['cannot create ' subdir_civ1_new ': ' msg1];%error message for directory creation |
---|
[122] | 1953 | return |
---|
[163] | 1954 | elseif isunix |
---|
[371] | 1955 | [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 1956 | if ~strcmp(msg2,'') |
---|
[437] | 1957 | errormsg=['pb of permission for ' fullfile(RootPath,subdir_civ1_new) ': ' msg2];%error message for directory creation |
---|
[128] | 1958 | return |
---|
| 1959 | end |
---|
[112] | 1960 | end |
---|
| 1961 | end |
---|
| 1962 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 1963 | for ifile=1:nbfield |
---|
| 1964 | for j=1:nbslice |
---|
[371] | 1965 | 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] | 1966 | detect=exist(filename,'file')==2; |
---|
[2] | 1967 | if detect% if a netcdf file already exists |
---|
[137] | 1968 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 1969 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 1970 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 1971 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 1972 | else |
---|
| 1973 | vers=vers+1; |
---|
[137] | 1974 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 1975 | end |
---|
| 1976 | subdir_civ2=subdir_civ1; |
---|
| 1977 | break |
---|
[2] | 1978 | end |
---|
[112] | 1979 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 1980 | end |
---|
| 1981 | if detect% if a netcdf file already exists |
---|
| 1982 | break |
---|
| 1983 | end |
---|
| 1984 | end |
---|
[363] | 1985 | %create the new SubdirCiv1 |
---|
[371] | 1986 | if ~exist(fullfile(RootPath,subdir_civ1_new),'dir') |
---|
| 1987 | [xx,msg1]=mkdir(fullfile(RootPath,subdir_civ1_new)); |
---|
[252] | 1988 | if ~strcmp(msg1,'') |
---|
[437] | 1989 | errormsg=['cannot create ' subdir_civ1_new ': ' msg1]; |
---|
[122] | 1990 | return |
---|
[128] | 1991 | else |
---|
[371] | 1992 | [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 1993 | if ~strcmp(msg2,'') |
---|
[437] | 1994 | errormsg=['pb of permission for ' subdir_civ1_new ': ' msg2];%error message for directory creation |
---|
[128] | 1995 | return |
---|
| 1996 | end |
---|
[112] | 1997 | end |
---|
| 1998 | end |
---|
| 1999 | end |
---|
| 2000 | end |
---|
[127] | 2001 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 2002 | % get image names |
---|
| 2003 | for ifile=1:nbfield |
---|
[112] | 2004 | for j=1:nbslice |
---|
[494] | 2005 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j)); |
---|
[2] | 2006 | idetect(j)=exist(filename,'file')==2; |
---|
| 2007 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
[494] | 2008 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j)); |
---|
[2] | 2009 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2010 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 2011 | end |
---|
| 2012 | [idetectmin,indexj]=min(idetect); |
---|
| 2013 | if idetectmin==0, |
---|
[437] | 2014 | errormsg=[filecell.ima1.civ1{ifile,indexj} ' not found']; |
---|
[112] | 2015 | return |
---|
| 2016 | end |
---|
| 2017 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2018 | if idetectmin==0, |
---|
[437] | 2019 | errormsg=[filecell.ima2.civ1{ifile,indexj} ' not found']; |
---|
[112] | 2020 | return |
---|
| 2021 | end |
---|
| 2022 | end |
---|
| 2023 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2024 | for ifile=1:nbfield |
---|
| 2025 | for j=1:nbslice |
---|
[371] | 2026 | filename=fullfile_uvmat(RootPath,'',RootFile_A,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j)); |
---|
[112] | 2027 | idetect(j)=exist(filename,'file')==2; |
---|
| 2028 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
[371] | 2029 | filename=fullfile_uvmat(RootPath,'',RootFile_A,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j)); |
---|
[112] | 2030 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2031 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2032 | end |
---|
[2] | 2033 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2034 | if idetectmin==0, |
---|
[437] | 2035 | errormsg=[filecell.imaA1.civ1{ifile,indexj} ' not found']; |
---|
[2] | 2036 | return |
---|
[112] | 2037 | end |
---|
[2] | 2038 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2039 | if idetectmin==0, |
---|
[437] | 2040 | errormsg=[filecell.imaA2.civ1{ifile,indexj} ' not found']; |
---|
[2] | 2041 | return |
---|
[112] | 2042 | end |
---|
| 2043 | end |
---|
[2] | 2044 | end |
---|
[112] | 2045 | |
---|
[282] | 2046 | %%%%%%%%%%%%% checkfix1 or checkpatch1 activated but no checkciv1 %%%%%%%%%%%%% |
---|
| 2047 | elseif (checkbox(2)==1 || checkbox(3)==1); |
---|
[2] | 2048 | for ifile=1:nbfield |
---|
| 2049 | for j=1:nbslice |
---|
[371] | 2050 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); |
---|
[112] | 2051 | detect=exist(filename,'file')==2; |
---|
[122] | 2052 | if detect==0 |
---|
[437] | 2053 | errormsg=[filename ' not found']; |
---|
[122] | 2054 | return |
---|
| 2055 | end |
---|
[2] | 2056 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2057 | end |
---|
| 2058 | end |
---|
| 2059 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2060 | for ifile=1:nbfield |
---|
| 2061 | for j=1:nbslice |
---|
[371] | 2062 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_A,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); |
---|
[112] | 2063 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2064 | if ~exist(filename,'file') |
---|
[437] | 2065 | errormsg=['input file ' filename ' not found']; |
---|
[112] | 2066 | return |
---|
[2] | 2067 | end |
---|
| 2068 | end |
---|
[112] | 2069 | end |
---|
[2] | 2070 | end |
---|
| 2071 | end |
---|
| 2072 | |
---|
[282] | 2073 | %%%%%%%%%%%%% if checkciv2 performed with pairs different than checkciv1 %%%%%%%%%%%%% |
---|
[2] | 2074 | testdiff=0; |
---|
[282] | 2075 | if (checkbox(4)==1)&&... |
---|
| 2076 | ((get(handles.ListPairCiv1,'Value')~=get(handles.ListPairCiv2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2077 | testdiff=1; |
---|
[112] | 2078 | detect=1; |
---|
[127] | 2079 | vers=0; |
---|
| 2080 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2081 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2082 | for ifile=1:nbfield |
---|
| 2083 | for j=1:nbslice |
---|
[371] | 2084 | 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] | 2085 | detect=exist(filename,'file')==2; |
---|
| 2086 | if detect% if a netcdf file already exists |
---|
[127] | 2087 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2088 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2089 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2090 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2091 | else |
---|
| 2092 | vers=vers+1; |
---|
| 2093 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2094 | end |
---|
[112] | 2095 | break |
---|
| 2096 | end |
---|
| 2097 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2098 | end |
---|
| 2099 | if detect% if a netcdf file already exists |
---|
| 2100 | break |
---|
| 2101 | end |
---|
| 2102 | end |
---|
[128] | 2103 | %create the new subdir_civ2_new |
---|
[371] | 2104 | if ~exist(fullfile(RootPath,subdir_civ2_new),'dir') |
---|
| 2105 | [xx,m2]=mkdir(fullfile(RootPath,subdir_civ2_new)); |
---|
| 2106 | [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2107 | if ~isequal(m2,'') |
---|
[437] | 2108 | errormsg=['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2]; |
---|
[122] | 2109 | return |
---|
[112] | 2110 | end |
---|
| 2111 | end |
---|
| 2112 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2113 | for ifile=1:nbfield |
---|
| 2114 | for j=1:nbslice |
---|
[371] | 2115 | 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] | 2116 | detect=exist(filename,'file')==2; |
---|
[2] | 2117 | if detect% if a netcdf file already exists |
---|
[127] | 2118 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2119 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2120 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2121 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2122 | else |
---|
| 2123 | vers=vers+1; |
---|
| 2124 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2125 | end |
---|
[112] | 2126 | break |
---|
[2] | 2127 | end |
---|
[112] | 2128 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2129 | end |
---|
| 2130 | if detect% if a netcdf file already exists |
---|
| 2131 | break |
---|
| 2132 | end |
---|
| 2133 | end |
---|
[122] | 2134 | subdir_civ2=subdir_civ2_new; |
---|
[363] | 2135 | %create the new SubdirCiv1 |
---|
[371] | 2136 | if ~exist(fullfile(RootPath,subdir_civ2_new),'dir') |
---|
[127] | 2137 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
[371] | 2138 | [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2139 | if ~isequal(m2,'') |
---|
[437] | 2140 | errormsg= ['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2];%error message for directory creation |
---|
[122] | 2141 | return |
---|
[112] | 2142 | end |
---|
| 2143 | end |
---|
| 2144 | end |
---|
| 2145 | end |
---|
[127] | 2146 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2147 | end |
---|
| 2148 | |
---|
[282] | 2149 | %%%%%%%%%%%%% if checkciv2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2150 | if checkbox(4)==1 || checkbox(5)==1 || checkbox(6)==1 %civ2 |
---|
| 2151 | %check source netcdf file of checkciv1 estimates |
---|
| 2152 | if checkbox(1)==0; %no civ1 performed |
---|
[2] | 2153 | for ifile=1:nbfield |
---|
| 2154 | for j=1:nbslice |
---|
[371] | 2155 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j));% |
---|
[2] | 2156 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2157 | if ~exist(filename,'file') |
---|
[437] | 2158 | errormsg=['input file ' filename ' not found']; |
---|
[2] | 2159 | return |
---|
| 2160 | end |
---|
| 2161 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
[282] | 2162 | if checkbox(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
[248] | 2163 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
[364] | 2164 | if isfield(Data,'Txt') |
---|
[437] | 2165 | errormsg=Data.Txt; |
---|
[364] | 2166 | return |
---|
| 2167 | elseif ~isempty(Data.CivStage)% case of new civ files |
---|
| 2168 | if Data.CivStage<4 %test for civ files |
---|
[437] | 2169 | errormsg=['no civ2 data in ' filename]; |
---|
[2] | 2170 | return |
---|
[364] | 2171 | end |
---|
[248] | 2172 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[437] | 2173 | errormsg=['no civ2 data in ' filename]; |
---|
[248] | 2174 | return |
---|
[112] | 2175 | end |
---|
[282] | 2176 | elseif checkbox(3)==0; %check the existence of patch if it is not calculated |
---|
[275] | 2177 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch'); |
---|
[437] | 2178 | if isfield(Data,'Txt') |
---|
| 2179 | errormsg=Data.Txt; |
---|
| 2180 | return |
---|
| 2181 | elseif ~isempty(Data.CivStage) |
---|
[248] | 2182 | if Data.CivStage<3 %test for civ files |
---|
[437] | 2183 | errormsg=['no patch data in ' filename]; |
---|
[248] | 2184 | return |
---|
| 2185 | end |
---|
| 2186 | elseif isempty(Data.patch)||isequal(Data.patch,0) |
---|
[437] | 2187 | errormsg=['no patch data in ' filename]; |
---|
[2] | 2188 | return |
---|
| 2189 | end |
---|
[112] | 2190 | end |
---|
[2] | 2191 | end |
---|
| 2192 | end |
---|
| 2193 | end |
---|
| 2194 | if strcmp(compare,'stereo PIV') |
---|
| 2195 | for ifile=1:nbfield |
---|
| 2196 | for j=1:nbslice |
---|
[371] | 2197 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_A,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[2] | 2198 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2199 | if ~exist(filename,'file') |
---|
[437] | 2200 | errormsg=['input file ' filename ' not found']; |
---|
[2] | 2201 | return |
---|
| 2202 | end |
---|
| 2203 | end |
---|
| 2204 | end |
---|
| 2205 | end |
---|
| 2206 | end |
---|
[112] | 2207 | |
---|
| 2208 | detect=1; |
---|
[282] | 2209 | % while detect==1%creates a new subdir if the netcdf files already contain checkciv2 data |
---|
[112] | 2210 | for ifile=1:nbfield |
---|
| 2211 | for j=1:nbslice |
---|
[371] | 2212 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[112] | 2213 | detect=exist(filename,'file')==2; |
---|
| 2214 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2215 | end |
---|
[112] | 2216 | end |
---|
[282] | 2217 | %get first image names for checkciv2 |
---|
[371] | 2218 | if checkbox(1)==1 && isequal(i1_civ1,i1_civ2) && isequal(j1_civ1,j1_civ2) |
---|
[2] | 2219 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
[282] | 2220 | elseif checkbox(4)==1 |
---|
[2] | 2221 | for ifile=1:nbfield |
---|
| 2222 | for j=1:nbslice |
---|
[494] | 2223 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ2(ifile),[],j1_civ2(j)); |
---|
[2] | 2224 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2225 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2226 | end |
---|
[112] | 2227 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2228 | if idetectmin==0, |
---|
[437] | 2229 | errormsg=['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']; |
---|
[112] | 2230 | return |
---|
[2] | 2231 | end |
---|
| 2232 | end |
---|
| 2233 | end |
---|
| 2234 | |
---|
[282] | 2235 | %get second image names for checkciv2 |
---|
[371] | 2236 | if checkbox(1)==1 && isequal(i2_civ1,i2_civ2) && isequal(j2_civ1,j2_civ2) |
---|
[2] | 2237 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
[282] | 2238 | elseif checkbox(4)==1 |
---|
[2] | 2239 | for ifile=1:nbfield |
---|
| 2240 | for j=1:nbslice |
---|
[494] | 2241 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ2(ifile),[],j2_civ2(j)); |
---|
[2] | 2242 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2243 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2244 | end |
---|
[112] | 2245 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2246 | if idetectmin==0, |
---|
[437] | 2247 | errormsg=['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']; |
---|
[112] | 2248 | return |
---|
[2] | 2249 | end |
---|
| 2250 | end |
---|
| 2251 | end |
---|
| 2252 | end |
---|
[282] | 2253 | if (checkbox(5) || checkbox(6)) && ~checkbox(4) % need to read an existing netcdf civ2 file |
---|
[2] | 2254 | if ~testdiff |
---|
| 2255 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2256 | else % check the civ2 files |
---|
[2] | 2257 | for ifile=1:nbfield |
---|
| 2258 | for j=1:nbslice |
---|
[371] | 2259 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[2] | 2260 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2261 | if ~exist(filename,'file') |
---|
[437] | 2262 | errormsg=['input file ' filename ' not found']; |
---|
[2] | 2263 | return |
---|
| 2264 | else |
---|
[248] | 2265 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2266 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
[437] | 2267 | errormsg=['no civ2 data in ' filename]; |
---|
[248] | 2268 | return |
---|
| 2269 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[437] | 2270 | errormsg=['no civ2 data in ' filename]; |
---|
[2] | 2271 | return |
---|
| 2272 | end |
---|
| 2273 | end |
---|
| 2274 | end |
---|
| 2275 | end |
---|
| 2276 | end |
---|
| 2277 | end |
---|
| 2278 | |
---|
| 2279 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2280 | if strcmp(compare,'stereo PIV') |
---|
[282] | 2281 | if checkbox(3) && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2282 | for ifile=1:nbfield |
---|
| 2283 | for j=1:nbslice |
---|
[371] | 2284 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_AB,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); |
---|
[2] | 2285 | filecell.st(ifile,j)={filename}; |
---|
| 2286 | end |
---|
| 2287 | end |
---|
| 2288 | end |
---|
[282] | 2289 | if checkbox(6) && isequal(get(handles.CheckStereo,'Value'),1) |
---|
[2] | 2290 | for ifile=1:nbfield |
---|
| 2291 | for j=1:nbslice |
---|
[371] | 2292 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_AB,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[2] | 2293 | filecell.st(ifile,j)={filename}; |
---|
| 2294 | end |
---|
| 2295 | end |
---|
[112] | 2296 | end |
---|
[2] | 2297 | end |
---|
[494] | 2298 | set(handles.SubdirCiv1,'String',regexprep(subdir_civ1,['^' SubDirImages],''));%suppress the root SuddirImages;);%update the edit box |
---|
| 2299 | set(handles.SubdirCiv2,'String',regexprep(subdir_civ2,['^' SubDirImages],''));%update the edit box |
---|
[2] | 2300 | |
---|
[388] | 2301 | % For CivX COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
| 2302 | if strcmp(CivMode,'CivX') |
---|
[494] | 2303 | NomType_imanew1=NomType_ima1; |
---|
| 2304 | NomType_imanew2=NomType_ima2; |
---|
[388] | 2305 | if ~isequal(ext_ima,'.png') |
---|
[494] | 2306 | if checkbox(1) %if civ1 is performed |
---|
| 2307 | [FileType,FileInfo,MovieObject]=get_file_type(filecell.ima1.civ1{1}); |
---|
| 2308 | check_j=0; |
---|
| 2309 | if strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader')||strcmp(FileType,'multimage') |
---|
| 2310 | if max(j1_civ1)>1 |
---|
| 2311 | check_j=1; |
---|
| 2312 | NomType_imanew1='_1_1'; |
---|
[388] | 2313 | else |
---|
[494] | 2314 | NomType_imanew1='_1'; |
---|
[388] | 2315 | end |
---|
| 2316 | end |
---|
| 2317 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
| 2318 | for ifile=1:nbfield |
---|
| 2319 | waitbar(ifile/nbfield); |
---|
| 2320 | for j=1:nbslice |
---|
[494] | 2321 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j)); |
---|
[388] | 2322 | if ~exist(filename,'file') |
---|
[494] | 2323 | if check_j |
---|
| 2324 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ1(j)); |
---|
| 2325 | else |
---|
| 2326 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ1(ifile)); |
---|
| 2327 | end |
---|
| 2328 | imwrite(uint16(sum(A,3)),filename,'BitDepth',16); |
---|
[388] | 2329 | end |
---|
| 2330 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
[494] | 2331 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,'.png',NomType_imanew1,i2_civ1(ifile),[],j2_civ1(j)); |
---|
[388] | 2332 | if ~exist(filename,'file') |
---|
[494] | 2333 | if check_j |
---|
| 2334 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j2_civ1(j)); |
---|
| 2335 | else |
---|
| 2336 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i2_civ1(ifile)); |
---|
| 2337 | end |
---|
| 2338 | imwrite(uint16(sum(A,3)),filename,'BitDepth',16); |
---|
[388] | 2339 | end |
---|
| 2340 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[112] | 2341 | end |
---|
[2] | 2342 | end |
---|
[388] | 2343 | close(h) |
---|
[2] | 2344 | end |
---|
[388] | 2345 | if checkbox(4) %if civ2 is performed |
---|
[494] | 2346 | [FileType,FileInfo,MovieObject]=get_file_type(filecell.ima1.civ2{1}); |
---|
| 2347 | check_j=0; |
---|
| 2348 | if strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader')||strcmp(FileType,'multimage') |
---|
| 2349 | if max(j1_civ2)>1 |
---|
| 2350 | check_j=1; |
---|
| 2351 | NomType_imanew1='_1_1'; |
---|
| 2352 | else |
---|
| 2353 | NomType_imanew1='_1'; |
---|
| 2354 | end |
---|
| 2355 | end |
---|
[388] | 2356 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
| 2357 | for ifile=1:nbfield |
---|
| 2358 | waitbar(ifile/nbfield); |
---|
| 2359 | for j=1:nbslice |
---|
[494] | 2360 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j)); |
---|
[388] | 2361 | if ~exist(filename,'file') |
---|
[494] | 2362 | if check_j |
---|
| 2363 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ2(j)); |
---|
| 2364 | else |
---|
| 2365 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ2(ifile)); |
---|
| 2366 | end |
---|
| 2367 | imwrite(uint16(sum(A,3)),filename,'BitDepth',16); |
---|
[388] | 2368 | end |
---|
| 2369 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
[494] | 2370 | filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j)); |
---|
[388] | 2371 | if ~exist(filename,'file') |
---|
[494] | 2372 | if check_j |
---|
| 2373 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ2(j)); |
---|
| 2374 | else |
---|
| 2375 | A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ2(ifile)); |
---|
| 2376 | end |
---|
| 2377 | imwrite(uint16(sum(A,3)),filename,'BitDepth',16); |
---|
[388] | 2378 | end |
---|
| 2379 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[112] | 2380 | end |
---|
[2] | 2381 | end |
---|
[388] | 2382 | close(h); |
---|
[2] | 2383 | end |
---|
| 2384 | end |
---|
| 2385 | end |
---|
| 2386 | |
---|
[12] | 2387 | %------------------------------------------------------------------------ |
---|
[227] | 2388 | % --- determine the list of index pairs of processing file |
---|
[494] | 2389 | function [i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2]=... |
---|
[227] | 2390 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
| 2391 | %------------------------------------------------------------------------ |
---|
| 2392 | |
---|
[282] | 2393 | list_civ1=get(handles.ListPairCiv1,'String'); |
---|
| 2394 | index_civ1=get(handles.ListPairCiv1,'Value'); |
---|
[227] | 2395 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
| 2396 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 2397 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 2398 | return |
---|
| 2399 | end |
---|
[282] | 2400 | list_civ2=get(handles.ListPairCiv2,'String'); |
---|
| 2401 | index_civ2=get(handles.ListPairCiv2,'Value'); |
---|
[227] | 2402 | if index_civ2>length(list_civ2) |
---|
| 2403 | list_civ2=list_civ1; |
---|
| 2404 | index_civ2=index_civ1; |
---|
| 2405 | end |
---|
| 2406 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 2407 | |
---|
| 2408 | if isequal (mode,'series(Di)') |
---|
| 2409 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
[494] | 2410 | i1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
| 2411 | i2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
| 2412 | j1_civ1=ref_j; |
---|
| 2413 | j2_civ1=ref_j; |
---|
| 2414 | i1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
| 2415 | i2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
| 2416 | j1_civ2=ref_j; |
---|
| 2417 | j2_civ2=ref_j; |
---|
[227] | 2418 | |
---|
| 2419 | % adjust the first and last field number |
---|
| 2420 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2421 | if isnan(lastfield) |
---|
[494] | 2422 | indsel=find((i1_civ1 >= 1)&(i1_civ2 >= 1)); |
---|
[227] | 2423 | else |
---|
[494] | 2424 | indsel=find((i2_civ1 <= lastfield)&(i2_civ2 <= lastfield)&(i1_civ1 >= 1)&(i1_civ2 >= 1)); |
---|
[227] | 2425 | end |
---|
| 2426 | if length(indsel)>=1 |
---|
| 2427 | firstind=indsel(1); |
---|
| 2428 | lastind=indsel(end); |
---|
| 2429 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
| 2430 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
| 2431 | ref_i=ref_i(indsel); |
---|
[494] | 2432 | i1_civ1=i1_civ1(indsel); |
---|
| 2433 | i1_civ2=i1_civ2(indsel); |
---|
| 2434 | i2_civ1=i2_civ1(indsel); |
---|
| 2435 | i2_civ2=i2_civ2(indsel); |
---|
[227] | 2436 | end |
---|
| 2437 | elseif isequal (mode,'series(Dj)') |
---|
| 2438 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
[494] | 2439 | i1_civ1=ref_i;% set of first image numbers |
---|
| 2440 | i2_civ1=ref_i; |
---|
| 2441 | j1_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
| 2442 | j2_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
| 2443 | i1_civ2=ref_i; |
---|
| 2444 | i2_civ2=ref_i; |
---|
| 2445 | j1_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
| 2446 | j2_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
[227] | 2447 | % adjust the first and last field number |
---|
| 2448 | if isnan(lastfield_j) |
---|
[494] | 2449 | indsel=find((j1_civ1 >= 1)&(j1_civ2 >= 1)); |
---|
[227] | 2450 | else |
---|
[494] | 2451 | indsel=find((j2_civ1 <= lastfield_j)&(j2_civ2 <= lastfield_j)&(j1_civ1 >= 1)&(j1_civ2 >= 1)); |
---|
[227] | 2452 | end |
---|
| 2453 | if length(indsel)>=1 |
---|
| 2454 | firstind=indsel(1); |
---|
| 2455 | lastind=indsel(end); |
---|
| 2456 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
| 2457 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
| 2458 | ref_j=ref_j(indsel); |
---|
[494] | 2459 | j1_civ1=j1_civ1(indsel); |
---|
| 2460 | j2_civ1=j2_civ1(indsel); |
---|
| 2461 | j1_civ2=j1_civ2(indsel); |
---|
| 2462 | j2_civ2=j2_civ2(indsel); |
---|
[227] | 2463 | end |
---|
| 2464 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[282] | 2465 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[494] | 2466 | i1_civ1=ref_i; |
---|
| 2467 | i2_civ1=ref_i; |
---|
| 2468 | j1_civ1=displ_num(1,index_civ1); |
---|
| 2469 | j2_civ1=displ_num(2,index_civ1); |
---|
| 2470 | i1_civ2=ref_i; |
---|
| 2471 | i2_civ2=ref_i; |
---|
| 2472 | j1_civ2=displ_num(1,index_civ2); |
---|
| 2473 | j2_civ2=displ_num(2,index_civ2); |
---|
[227] | 2474 | elseif isequal(mode,'displacement') |
---|
[494] | 2475 | i1_civ1=ref_i; |
---|
| 2476 | i2_civ1=ref_i; |
---|
| 2477 | j1_civ1=ref_j; |
---|
| 2478 | j2_civ1=ref_j; |
---|
| 2479 | i1_civ2=ref_i; |
---|
| 2480 | i2_civ2=ref_i; |
---|
| 2481 | j1_civ2=ref_j; |
---|
| 2482 | j2_civ2=ref_j; |
---|
[227] | 2483 | end |
---|
| 2484 | |
---|
| 2485 | %------------------------------------------------------------------------ |
---|
[309] | 2486 | % --- Executes on button press in ListCompareMode. |
---|
| 2487 | function ListCompareMode_Callback(hObject, eventdata, handles) |
---|
[12] | 2488 | %------------------------------------------------------------------------ |
---|
[371] | 2489 | ListCompareMode=get(handles.ListCompareMode,'String'); |
---|
| 2490 | option=ListCompareMode{get(handles.ListCompareMode,'Value')}; |
---|
[360] | 2491 | if ~strcmp(option,'PIV') % case 'displacement' or 'stereo PIV' |
---|
[371] | 2492 | filebase=get(handles.RootPath,'String'); |
---|
[309] | 2493 | set(handles.sub_txt,'Visible','on') |
---|
[371] | 2494 | set(handles.RootFile_1,'Visible','On');%mkes the second file input window visible |
---|
[309] | 2495 | mode_store=get(handles.ListPairMode,'String');%get the present 'mode' |
---|
| 2496 | set(handles.ListCompareMode,'UserData',mode_store);%store the mode display |
---|
| 2497 | set(handles.ListPairMode,'Visible','off') |
---|
| 2498 | |
---|
[371] | 2499 | %% open an image file with the browser |
---|
[309] | 2500 | ind_opening=1;%default |
---|
| 2501 | browse.incr_pair=[0 0]; %default |
---|
[371] | 2502 | oldfile=get(handles.RootPath,'String'); |
---|
| 2503 | menu={'*.png;*.jpg;*.tif;*.avi;*.AVI;', ' (*.png,*.jpg ,.tif, *.avi,*.AVI)'; |
---|
[309] | 2504 | '*.png','.png image files'; ... |
---|
| 2505 | '*.jpg',' jpeg image files'; ... |
---|
| 2506 | '*.tif','.tif image files'; ... |
---|
| 2507 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 2508 | '*.*', 'All Files (*.*)'}; |
---|
[371] | 2509 | if strcmp(option,'displacement') |
---|
| 2510 | comment='Pick the reference file for displacements'; |
---|
| 2511 | else |
---|
| 2512 | comment='Pick a file of the second series'; |
---|
| 2513 | end |
---|
| 2514 | [FileName, PathName] = uigetfile( menu, comment,oldfile); |
---|
[309] | 2515 | fileinput=[PathName FileName];%complete file name |
---|
| 2516 | sizf=size(fileinput); |
---|
| 2517 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 2518 | [path,name,ext]=fileparts(fileinput); |
---|
| 2519 | [path1]=fileparts(filebase); |
---|
| 2520 | if isunix |
---|
| 2521 | [status,path]=system(['readlink ' path]); |
---|
| 2522 | [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths |
---|
| 2523 | end |
---|
| 2524 | if ~strcmp(path1,path) |
---|
[371] | 2525 | msgbox_uvmat('ERROR','The second image or series must be in the same directory as the first one') |
---|
[309] | 2526 | return |
---|
[360] | 2527 | end |
---|
[371] | 2528 | if strcmp(option,'displacement') |
---|
| 2529 | [tild,RootFile_1]=fileparts(name); |
---|
| 2530 | else |
---|
[398] | 2531 | [FilePath,FileName,Ext]=fileparts(fileinput); |
---|
| 2532 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 2533 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
| 2534 | [RootPath,SubDir,RootFile_1,i1_series,i2_series,j1_series,j2_series,nom_type_1,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName Ext]); |
---|
[512] | 2535 | |
---|
[371] | 2536 | %check image nom type |
---|
| 2537 | if ~strcmp(nom_type_1,get(handles.NomType,'String')) |
---|
| 2538 | 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') |
---|
| 2539 | return |
---|
| 2540 | end |
---|
| 2541 | end |
---|
| 2542 | %check image extension |
---|
[309] | 2543 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
| 2544 | msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one') |
---|
| 2545 | return |
---|
[371] | 2546 | end |
---|
| 2547 | set(handles.RootFile_1,'String',RootFile_1); |
---|
[309] | 2548 | else |
---|
| 2549 | set(handles.ListPairMode,'Visible','on') |
---|
[371] | 2550 | set(handles.RootFile_1,'Visible','Off'); |
---|
[309] | 2551 | set(handles.sub_txt,'Visible','off') |
---|
[371] | 2552 | set(handles.RootFile_1,'String',[]); |
---|
[309] | 2553 | mode_store=get(handles.ListCompareMode,'UserData'); |
---|
| 2554 | set(handles.ListPairMode,'Value',1) |
---|
| 2555 | set(handles.ListPairMode,'String',mode_store) |
---|
| 2556 | set(handles.CheckStereo,'Value',0) |
---|
| 2557 | set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default |
---|
| 2558 | end |
---|
[319] | 2559 | ListPairMode_Callback(hObject, eventdata, handles) |
---|
[2] | 2560 | |
---|
[309] | 2561 | |
---|
| 2562 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 2563 | % Callbacks in the uipanel Pair Indices |
---|
| 2564 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[12] | 2565 | %------------------------------------------------------------------------ |
---|
[309] | 2566 | % --- Executes on button press in ListPairMode. |
---|
| 2567 | function ListPairMode_Callback(hObject, eventdata, handles) |
---|
[12] | 2568 | %------------------------------------------------------------------------ |
---|
[309] | 2569 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 2570 | val=get(handles.ListCompareMode,'Value'); |
---|
| 2571 | compare=compare_list{val}; |
---|
[360] | 2572 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
[309] | 2573 | mode='displacement'; |
---|
| 2574 | else |
---|
| 2575 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2576 | if ischar(mode_list) |
---|
| 2577 | mode_list={mode_list}; |
---|
| 2578 | end |
---|
| 2579 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2580 | mode=mode_list{mode_value}; |
---|
| 2581 | end |
---|
| 2582 | displ_num=[];%default |
---|
| 2583 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 2584 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 2585 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[343] | 2586 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 2587 | checkframe=strcmp(TimeUnit,'frame'); |
---|
[309] | 2588 | siztime=size(time); |
---|
[343] | 2589 | nbfield=siztime(1)-1; |
---|
| 2590 | nbfield2=siztime(2)-1; |
---|
[309] | 2591 | indchosen=1; %%first pair selected by default |
---|
| 2592 | %displ_num used to define the indices of the civ pairs |
---|
| 2593 | % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices |
---|
| 2594 | % are relative to the reference indices ref_i and ref_j respectively. |
---|
| 2595 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 2596 | dt=1; |
---|
| 2597 | displ=''; |
---|
| 2598 | index=0; |
---|
| 2599 | numlist_a=[]; |
---|
| 2600 | numlist_B=[]; |
---|
| 2601 | %get all the time intervals in bursts |
---|
| 2602 | displ_dt=1;%default |
---|
| 2603 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 2604 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 2605 | for numod_b=(numod_a+1):nbfield2 |
---|
| 2606 | index=index+1; |
---|
| 2607 | numlist_a(index)=numod_a; |
---|
| 2608 | numlist_b(index)=numod_b; |
---|
[343] | 2609 | if size(time,2)>1 && ~checkframe |
---|
| 2610 | dt(numod_a,numod_b)=time(ref_i+1,numod_b+1)-time(ref_i+1,numod_a+1);%first time interval dt |
---|
[309] | 2611 | displ_dt(index)=dt(numod_a,numod_b); |
---|
| 2612 | else |
---|
| 2613 | displ_dt(index)=1; |
---|
| 2614 | end |
---|
| 2615 | end |
---|
| 2616 | end |
---|
| 2617 | [dtsort,indsort]=sort(displ_dt); |
---|
| 2618 | if ~isempty(numlist_a) |
---|
| 2619 | displ_num(1,:)=numlist_a(indsort); |
---|
| 2620 | displ_num(2,:)=numlist_b(indsort); |
---|
| 2621 | end |
---|
| 2622 | displ_num(3,:)=0; |
---|
| 2623 | displ_num(4,:)=0; |
---|
[360] | 2624 | enable_j(handles, 'off') |
---|
[309] | 2625 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
| 2626 | index=1:200; |
---|
| 2627 | displ_num(1,index)=-floor(index/2); |
---|
| 2628 | displ_num(2,index)=ceil(index/2); |
---|
| 2629 | displ_num(3:4,index)=zeros(2,200); |
---|
[360] | 2630 | enable_j(handles, 'on') |
---|
[309] | 2631 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 2632 | index=1:200; |
---|
| 2633 | displ_num(1:2,index)=zeros(2,200); |
---|
| 2634 | displ_num(3,index)=-floor(index/2); |
---|
| 2635 | displ_num(4,index)=ceil(index/2); |
---|
[360] | 2636 | enable_i(handles, 'on') |
---|
[309] | 2637 | if nbfield2 > 1 |
---|
[360] | 2638 | enable_j(handles, 'on') |
---|
[309] | 2639 | else |
---|
[360] | 2640 | enable_j(handles, 'off') |
---|
[309] | 2641 | end |
---|
| 2642 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
| 2643 | displ_num(1,1)=0; |
---|
| 2644 | displ_num(2,1)=0; |
---|
| 2645 | displ_num(3,1)=0; |
---|
| 2646 | displ_num(4,1)=0; |
---|
[319] | 2647 | if nbfield > 1 || nbfield==0 |
---|
[360] | 2648 | enable_i(handles, 'on') |
---|
[309] | 2649 | else |
---|
[360] | 2650 | enable_j(handles, 'off') |
---|
[309] | 2651 | end |
---|
| 2652 | if nbfield2 > 1 |
---|
[360] | 2653 | enable_j(handles, 'on') |
---|
[309] | 2654 | else |
---|
[360] | 2655 | enable_j(handles, 'off') |
---|
[309] | 2656 | end |
---|
| 2657 | end |
---|
| 2658 | set(handles.ListPairCiv1,'UserData',displ_num); |
---|
[362] | 2659 | errormsg=find_netcpair_civ( handles,1); |
---|
| 2660 | if ~isempty(errormsg) |
---|
| 2661 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2662 | end |
---|
[360] | 2663 | % find_netcpair_civ2(handles) |
---|
[2] | 2664 | |
---|
[360] | 2665 | function enable_i(handles, state) |
---|
| 2666 | set(handles.itext,'Visible',state) |
---|
| 2667 | set(handles.first_i,'Visible',state) |
---|
| 2668 | set(handles.last_i,'Visible',state) |
---|
| 2669 | set(handles.incr_i,'Visible',state) |
---|
| 2670 | set(handles.nb_field,'Visible',state) |
---|
| 2671 | set(handles.ref_i,'Visible',state) |
---|
| 2672 | |
---|
| 2673 | function enable_j(handles, state) |
---|
| 2674 | set(handles.jtext,'Visible',state) |
---|
| 2675 | set(handles.first_j,'Visible',state) |
---|
| 2676 | set(handles.last_j,'Visible',state) |
---|
| 2677 | set(handles.incr_j,'Visible',state) |
---|
| 2678 | set(handles.nb_field2,'Visible',state) |
---|
| 2679 | set(handles.ref_j,'Visible',state) |
---|
| 2680 | |
---|
| 2681 | |
---|
[12] | 2682 | %------------------------------------------------------------------------ |
---|
[309] | 2683 | % --- Executes on selection change in ListPairCiv1. |
---|
| 2684 | function ListPairCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 2685 | %------------------------------------------------------------------------ |
---|
[309] | 2686 | %reproduce by default the chosen pair in the checkciv2 menu |
---|
| 2687 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
| 2688 | index_pair=get(handles.ListPairCiv1,'Value'); |
---|
| 2689 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
| 2690 | list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs |
---|
| 2691 | if index_pair<=length(list_pair2) |
---|
| 2692 | set(handles.ListPairCiv2,'Value',index_pair); |
---|
| 2693 | end |
---|
[2] | 2694 | |
---|
[309] | 2695 | %update first_i and last_i according to the chosen image pairs |
---|
| 2696 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2697 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2698 | mode=mode_list{mode_value}; |
---|
| 2699 | if isequal(mode,'series(Di)') |
---|
| 2700 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2701 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2702 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2703 | num1=first_i:incr_i:last_i; |
---|
| 2704 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2705 | if ~isnan(lastfield) |
---|
| 2706 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 2707 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 2708 | num1=num1(test_find); |
---|
| 2709 | end |
---|
| 2710 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 2711 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 2712 | elseif isequal(mode,'series(Dj)') |
---|
| 2713 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2714 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2715 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 2716 | num_j=first_j:incr_j:last_j; |
---|
| 2717 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 2718 | if ~isnan(lastfield2) |
---|
| 2719 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 2720 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 2721 | num1=num_j(test_find); |
---|
| 2722 | end |
---|
| 2723 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 2724 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 2725 | end |
---|
| 2726 | |
---|
[12] | 2727 | %------------------------------------------------------------------------ |
---|
[309] | 2728 | % --- Executes on selection change in ListPairCiv2. |
---|
| 2729 | function ListPairCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 2730 | %------------------------------------------------------------------------ |
---|
[309] | 2731 | index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu |
---|
[2] | 2732 | |
---|
[309] | 2733 | %update first_i and last_i according to the chosen image pairs |
---|
| 2734 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2735 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2736 | mode=mode_list{mode_value}; |
---|
| 2737 | if isequal(mode,'series(Di)') |
---|
| 2738 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2739 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2740 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2741 | num1=first_i:incr_i:last_i; |
---|
| 2742 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2743 | if ~isnan(lastfield) |
---|
| 2744 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 2745 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 2746 | num1=num1(test_find); |
---|
| 2747 | end |
---|
| 2748 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 2749 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 2750 | elseif isequal(mode,'series(Dj)') |
---|
| 2751 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2752 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2753 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 2754 | num_j=first_j:incr_j:last_j; |
---|
| 2755 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 2756 | if ~isnan(lastfield2) |
---|
| 2757 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 2758 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 2759 | num1=num_j(test_find); |
---|
| 2760 | end |
---|
| 2761 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 2762 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 2763 | end |
---|
| 2764 | |
---|
[12] | 2765 | %------------------------------------------------------------------------ |
---|
[309] | 2766 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 2767 | %------------------------------------------------------------------------ |
---|
[309] | 2768 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2769 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2770 | mode=mode_list{mode_value}; |
---|
[362] | 2771 | errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files |
---|
[309] | 2772 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
| 2773 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
[362] | 2774 | errormsg=find_netcpair_civ( handles,2); |
---|
[309] | 2775 | end |
---|
[362] | 2776 | if ~isempty(errormsg) |
---|
| 2777 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2778 | end |
---|
[2] | 2779 | |
---|
[12] | 2780 | %------------------------------------------------------------------------ |
---|
[309] | 2781 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 2782 | %------------------------------------------------------------------------ |
---|
[309] | 2783 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2784 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2785 | mode=mode_list{mode_value}; |
---|
| 2786 | if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[362] | 2787 | errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files |
---|
[309] | 2788 | end |
---|
| 2789 | if isequal(mode,'series(Dj)') || ... |
---|
| 2790 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
[362] | 2791 | errormsg=find_netcpair_civ(handles,2); |
---|
[309] | 2792 | end |
---|
[362] | 2793 | if ~isempty(errormsg) |
---|
| 2794 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2795 | end |
---|
[360] | 2796 | |
---|
[12] | 2797 | %------------------------------------------------------------------------ |
---|
[309] | 2798 | % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of |
---|
| 2799 | % the field series set by first_i, incr, last_i |
---|
[389] | 2800 | % index=1: look for pairs for civ1 |
---|
| 2801 | % index=2: look for pairs for civ2 |
---|
[362] | 2802 | function errormsg=find_netcpair_civ(handles,index) |
---|
[12] | 2803 | %------------------------------------------------------------------------ |
---|
[362] | 2804 | set(gcf,'Pointer','watch')% set the mouse pointer to 'watch' (clock) |
---|
| 2805 | |
---|
| 2806 | %% initialisation |
---|
| 2807 | errormsg=''; |
---|
[371] | 2808 | browse=get(handles.RootPath,'UserData'); |
---|
[309] | 2809 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 2810 | val=get(handles.ListCompareMode,'Value'); |
---|
| 2811 | compare=compare_list{val}; |
---|
[371] | 2812 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
[309] | 2813 | mode='displacement'; |
---|
| 2814 | else |
---|
| 2815 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2816 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2817 | if isempty(mode_list) |
---|
| 2818 | return |
---|
| 2819 | end |
---|
| 2820 | mode=mode_list{mode_value}; |
---|
| 2821 | end |
---|
[360] | 2822 | nom_type_ima=get(handles.NomType,'String'); |
---|
[289] | 2823 | |
---|
[360] | 2824 | %% determine nom_type_nc, nomenclature type of the .nc files: |
---|
[389] | 2825 | [nom_type_nc]=nomtype2pair(nom_type_ima,mode); |
---|
[309] | 2826 | |
---|
[362] | 2827 | %% reads .nc subdirectoy and image numbers from the interface |
---|
[494] | 2828 | SubDirImages=get(handles.SubDirImages,'String'); |
---|
[493] | 2829 | subdir_civ1=[SubDirImages get(handles.SubdirCiv1,'String')];%subdirectory subdir_civ1 for the netcdf data |
---|
| 2830 | subdir_civ2=[SubDirImages get(handles.SubdirCiv2,'String')];%subdirectory subdir_civ2 for the netcdf data |
---|
[309] | 2831 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[494] | 2832 | ref_j=[]; |
---|
[309] | 2833 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 2834 | ref_j=0; |
---|
[494] | 2835 | elseif strcmp(get(handles.ref_j,'Visible'),'on') |
---|
[309] | 2836 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 2837 | end |
---|
[494] | 2838 | if isempty(ref_j) |
---|
| 2839 | ref_j=1; |
---|
| 2840 | end |
---|
[309] | 2841 | time=get(handles.ImaDoc,'UserData');%get the set of times |
---|
[343] | 2842 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 2843 | checkframe=strcmp(TimeUnit,'frame'); |
---|
[309] | 2844 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
| 2845 | |
---|
[362] | 2846 | %% eliminate the first pairs inconsistent with the position |
---|
[309] | 2847 | if isempty(displ_num) |
---|
| 2848 | nbpair=0; |
---|
| 2849 | else |
---|
| 2850 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 2851 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 2852 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 2853 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 2854 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 2855 | end |
---|
| 2856 | end |
---|
| 2857 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 2858 | |
---|
[362] | 2859 | %% case with no Civ1 operation, netcdf files need to exist for reading |
---|
[309] | 2860 | displ_pair={''}; |
---|
| 2861 | select=ones(size(1:nbpair));%flag for displayed pairs =1 for display |
---|
| 2862 | testpair=0; |
---|
[371] | 2863 | RootPath=get(handles.RootPath,'String'); |
---|
| 2864 | RootFile=get(handles.RootFile,'String'); |
---|
[360] | 2865 | if index==1 % case civ1 |
---|
[362] | 2866 | if ~get(handles.CheckCiv1,'Value') % |
---|
[371] | 2867 | if ~exist(fullfile(RootPath,subdir_civ1),'dir') |
---|
[362] | 2868 | errormsg=['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']; |
---|
| 2869 | set(handles.ListPairCiv1,'String',{}); |
---|
| 2870 | return |
---|
| 2871 | end |
---|
| 2872 | for ipair=1:nbpair |
---|
| 2873 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,... |
---|
| 2874 | ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair)); |
---|
| 2875 | select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist |
---|
| 2876 | end |
---|
| 2877 | % case of no displayed pair |
---|
| 2878 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 2879 | if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0]) |
---|
| 2880 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 2881 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 2882 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 2883 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 2884 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2); |
---|
| 2885 | select(1)=exist(filename,'file')==2; |
---|
| 2886 | testpair=1; |
---|
[309] | 2887 | else |
---|
[494] | 2888 | % if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 2889 | % errormsg=['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]; |
---|
| 2890 | % else |
---|
[389] | 2891 | errormsg=['no civ1 file available for the selected reference indices (i,j)= ' num2str(ref_i) ', ' num2str(ref_j) ' and subdirectory ' subdir_civ1]; |
---|
[494] | 2892 | % end |
---|
[362] | 2893 | set(handles.ListPairCiv1,'String',{''}); |
---|
| 2894 | %COMPLETER CAS STEREO |
---|
| 2895 | return |
---|
[309] | 2896 | end |
---|
| 2897 | end |
---|
| 2898 | end |
---|
[362] | 2899 | else %case civ2 alone |
---|
| 2900 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
[438] | 2901 | if ~exist(fullfile(RootPath,subdir_civ2),'dir') |
---|
| 2902 | msgbox_uvmat('ERROR',['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
[360] | 2903 | set(handles.ListPairCiv2,'Value',1); |
---|
| 2904 | set(handles.ListPairCiv2,'String',{''}); |
---|
| 2905 | return |
---|
| 2906 | end |
---|
[362] | 2907 | for ipair=1:nbpair |
---|
| 2908 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,... |
---|
| 2909 | ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair)); |
---|
| 2910 | select(ipair)=exist(filename,'file')==2; |
---|
| 2911 | end |
---|
| 2912 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 2913 | if isfield(browse,'incr_pair') |
---|
| 2914 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 2915 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 2916 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 2917 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 2918 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2); |
---|
| 2919 | select(1)=exist(filename,'file')==2; |
---|
| 2920 | else |
---|
| 2921 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 2922 | errormsg=['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]; |
---|
| 2923 | else |
---|
| 2924 | errormsg=['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]; |
---|
| 2925 | end |
---|
| 2926 | set(handles.ListPairCiv2,'Value',1); |
---|
| 2927 | set(handles.ListPairCiv2,'String',{''}); |
---|
| 2928 | return |
---|
| 2929 | end |
---|
| 2930 | end |
---|
[360] | 2931 | end |
---|
| 2932 | end |
---|
[309] | 2933 | |
---|
| 2934 | %% determine the menu display in .ListPairCiv1 |
---|
| 2935 | % the menu depends on the mode defined in ListPairMode_callback through the array displ_num: |
---|
| 2936 | % displ_num(1,:)=indices j1 |
---|
| 2937 | % displ_num(2,:)=indices j2 |
---|
| 2938 | % displ_num(3,:)=indices i1 |
---|
| 2939 | % displ_num(4,:)=indices i2 |
---|
| 2940 | % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices |
---|
| 2941 | % are relative to the reference indices ref_i and ref_j respectively. |
---|
| 2942 | if isequal(mode,'series(Di)') |
---|
| 2943 | if testpair |
---|
| 2944 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 2945 | else |
---|
| 2946 | for ipair=1:nbpair |
---|
| 2947 | if select(ipair) |
---|
| 2948 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
[389] | 2949 | %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 |
---|
| 2950 | % 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 |
---|
| 2951 | 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 |
---|
| 2952 | 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] | 2953 | else |
---|
| 2954 | dt=1; |
---|
[309] | 2955 | end |
---|
[343] | 2956 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
[309] | 2957 | else |
---|
| 2958 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 2959 | end |
---|
| 2960 | end |
---|
| 2961 | end |
---|
| 2962 | elseif isequal(mode,'series(Dj)') |
---|
| 2963 | if testpair |
---|
| 2964 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 2965 | else |
---|
| 2966 | for ipair=1:nbpair |
---|
| 2967 | if select(ipair) |
---|
| 2968 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
[343] | 2969 | if ~checkframe && size(time,1)>=ref_i+1+displ_num(4,ipair) && size(time,2)>=ref_j+1+displ_num(2,ipair) |
---|
| 2970 | 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] | 2971 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
| 2972 | end |
---|
| 2973 | else |
---|
| 2974 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 2975 | end |
---|
| 2976 | end |
---|
| 2977 | end |
---|
| 2978 | elseif isequal(mode,'pair j1-j2')%case of pairs |
---|
| 2979 | for ipair=1:nbpair |
---|
| 2980 | if select(ipair) |
---|
[343] | 2981 | if ~checkframe && size(time,2)>1 |
---|
| 2982 | 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 |
---|
| 2983 | else % time set by default to i index |
---|
| 2984 | dt=1; |
---|
| 2985 | end |
---|
[309] | 2986 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 2987 | ' :dt= ' num2str(dt*1000)]; |
---|
| 2988 | else |
---|
| 2989 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 2990 | end |
---|
| 2991 | end |
---|
| 2992 | elseif isequal(mode,'displacement') |
---|
| 2993 | displ_pair={'Di=Dj=0'}; |
---|
| 2994 | end |
---|
[362] | 2995 | if index==1 |
---|
[309] | 2996 | set(handles.ListPairCiv1,'String',displ_pair'); |
---|
[362] | 2997 | end |
---|
[309] | 2998 | |
---|
| 2999 | %% determine the default selection in the pair menu |
---|
| 3000 | ichoice=find(select,1);% index of selected pair |
---|
| 3001 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 3002 | initial=get(handles.ListPairCiv1,'Value');%initial choice of pair |
---|
| 3003 | if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1)) |
---|
| 3004 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 3005 | end |
---|
| 3006 | initial=get(handles.ListPairCiv2,'Value'); |
---|
| 3007 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 3008 | if ichoice <= length(displ_pair') |
---|
| 3009 | set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 3010 | else |
---|
| 3011 | set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2 |
---|
| 3012 | end |
---|
| 3013 | end |
---|
| 3014 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
| 3015 | set(gcf,'Pointer','arrow') |
---|
| 3016 | |
---|
[415] | 3017 | |
---|
[315] | 3018 | |
---|
[415] | 3019 | % %------------------------------------------------------------------------ |
---|
| 3020 | % % call 'view_field.fig' to display the field selected in the list of 'status' |
---|
| 3021 | % function open_view_field(hObject, eventdata) |
---|
| 3022 | % %------------------------------------------------------------------------ |
---|
| 3023 | % list=get(hObject,'String'); |
---|
| 3024 | % index=get(hObject,'Value'); |
---|
| 3025 | % rootroot=get(hObject,'UserData'); |
---|
| 3026 | % filename=list{index}; |
---|
| 3027 | % ind_dot=strfind(filename,'...'); |
---|
| 3028 | % filename=filename(1:ind_dot-1); |
---|
| 3029 | % filename=fullfile(rootroot,filename); |
---|
| 3030 | % delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
| 3031 | % if exist(filename,'file')%visualise the vel field if it exists |
---|
| 3032 | % uvmat(filename) |
---|
| 3033 | % set(gcbo,'Value',1) |
---|
| 3034 | % end |
---|
[309] | 3035 | |
---|
| 3036 | |
---|
| 3037 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3038 | % Callbacks in the uipanel Reference Indices |
---|
| 3039 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[12] | 3040 | %------------------------------------------------------------------------ |
---|
| 3041 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3042 | %------------------------------------------------------------------------ |
---|
[137] | 3043 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3044 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
| 3045 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3046 | |
---|
[12] | 3047 | %------------------------------------------------------------------------ |
---|
| 3048 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3049 | %------------------------------------------------------------------------ |
---|
| 3050 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3051 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3052 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3053 | |
---|
[309] | 3054 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3055 | % Callbacks in the uipanel Civ1 |
---|
| 3056 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[12] | 3057 | %------------------------------------------------------------------------ |
---|
[437] | 3058 | % --- Executes on button press in SearchRange: determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 |
---|
[273] | 3059 | function SearchRange_Callback(hObject, eventdata, handles) |
---|
[12] | 3060 | %------------------------------------------------------------------------ |
---|
[2] | 3061 | %determine pair numbers |
---|
[415] | 3062 | if strcmp(get(handles.num_UMin,'Visible'),'off') |
---|
[273] | 3063 | set(handles.u_title,'Visible','on') |
---|
| 3064 | set(handles.v_title,'Visible','on') |
---|
[415] | 3065 | set(handles.num_UMin,'Visible','on') |
---|
| 3066 | set(handles.num_UMax,'Visible','on') |
---|
| 3067 | set(handles.num_VMin,'Visible','on') |
---|
| 3068 | set(handles.num_VMax,'Visible','on') |
---|
[273] | 3069 | set(handles.CoordUnit,'Visible','on') |
---|
| 3070 | set(handles.TimeUnit,'Visible','on') |
---|
| 3071 | set(handles.slash_title,'Visible','on') |
---|
| 3072 | set(handles.min_title,'Visible','on') |
---|
| 3073 | set(handles.max_title,'Visible','on') |
---|
| 3074 | set(handles.unit_title,'Visible','on') |
---|
| 3075 | else |
---|
| 3076 | get_search_range(hObject, eventdata, handles) |
---|
[2] | 3077 | end |
---|
| 3078 | |
---|
[12] | 3079 | %------------------------------------------------------------------------ |
---|
[437] | 3080 | % --- determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 and shift |
---|
[273] | 3081 | function get_search_range(hObject, eventdata, handles) |
---|
[415] | 3082 | %------------------------------------------------------------------------ |
---|
| 3083 | param_civ1=read_GUI(handles.Civ1); |
---|
| 3084 | umin=param_civ1.UMin; |
---|
| 3085 | umax=param_civ1.UMax; |
---|
| 3086 | vmin=param_civ1.VMin; |
---|
| 3087 | vmax=param_civ1.VMax; |
---|
[273] | 3088 | %switch min_title and max_title in case of error |
---|
| 3089 | if umax<=umin |
---|
| 3090 | umin_old=umin; |
---|
| 3091 | umin=umax; |
---|
| 3092 | umax=umin_old; |
---|
[415] | 3093 | set(handles.num_UMin,'String', num2str(umin)) |
---|
| 3094 | set(handles.num_UMax,'String', num2str(umax)) |
---|
[273] | 3095 | end |
---|
| 3096 | if vmax<=vmin |
---|
| 3097 | vmin_old=vmin; |
---|
| 3098 | vmin=vmax; |
---|
| 3099 | vmax=vmin_old; |
---|
[415] | 3100 | set(handles.num_VMin,'String', num2str(vmin)) |
---|
| 3101 | set(handles.num_VMax,'String', num2str(vmax)) |
---|
[273] | 3102 | end |
---|
[415] | 3103 | if ~(isempty(umin)||isempty(umax)||isempty(vmin)||isempty(vmax)) |
---|
[282] | 3104 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
| 3105 | index=get(handles.ListPairCiv1,'Value'); |
---|
[415] | 3106 | pair_string=list_pair{index}; |
---|
[273] | 3107 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[415] | 3108 | pxcm=get(handles.SearchRange,'UserData'); |
---|
[282] | 3109 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 3110 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[415] | 3111 | mode=mode_list{mode_value}; |
---|
[273] | 3112 | if isequal (mode, 'series(Di)' ) |
---|
| 3113 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3114 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3115 | num2=ref_i+ceil(index/2); |
---|
| 3116 | num_a=1; |
---|
| 3117 | num_b=1; |
---|
| 3118 | elseif isequal (mode, 'series(Dj)') |
---|
| 3119 | num1=1; |
---|
| 3120 | num2=1; |
---|
| 3121 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 3122 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3123 | num_b=ref_j+ceil(index/2); |
---|
[415] | 3124 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[273] | 3125 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3126 | num1=ref_i; |
---|
| 3127 | num2=ref_i; |
---|
[415] | 3128 | r=regexp(pair_string,'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
| 3129 | if isempty(r) |
---|
| 3130 | r=regexp(pair_string,'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names'); |
---|
| 3131 | end |
---|
| 3132 | num_a=str2num(r.num1); |
---|
| 3133 | num_b=str2num(r.num2); |
---|
[273] | 3134 | end |
---|
[415] | 3135 | dt=time(num2+1,num_b+1)-time(num1+1,num_a+1); |
---|
[437] | 3136 | ibx=str2double(get(handles.num_CorrBoxSize_1,'String')); |
---|
| 3137 | iby=str2double(get(handles.num_CorrBoxSize_2,'String')); |
---|
[415] | 3138 | umin=dt*pxcm*umin; |
---|
| 3139 | umax=dt*pxcm*umax; |
---|
| 3140 | vmin=dt*pxcm*vmin; |
---|
| 3141 | vmax=dt*pxcm*vmax; |
---|
[273] | 3142 | shiftx=round((umin+umax)/2); |
---|
| 3143 | shifty=round((vmin+vmax)/2); |
---|
[415] | 3144 | isx=(umax+2-shiftx)*2+param_civ1.Bx; |
---|
[273] | 3145 | isx=2*ceil(isx/2)+1; |
---|
[415] | 3146 | isy=(vmax+2-shifty)*2+param_civ1.Bx; |
---|
[273] | 3147 | isy=2*ceil(isy/2)+1; |
---|
[437] | 3148 | set(handles.num_SearchBoxShift_1,'String',num2str(shiftx)); |
---|
| 3149 | set(handles.num_SearchBoxShift_2,'String',num2str(shifty)); |
---|
| 3150 | set(handles.num_SearchBoxSize_1,'String',num2str(isx)); |
---|
| 3151 | set(handles.num_SearchBoxSize_2,'String',num2str(isy)); |
---|
[273] | 3152 | end |
---|
| 3153 | |
---|
[315] | 3154 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3155 | % Callbacks in the uipanel Fix1 |
---|
| 3156 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[12] | 3157 | %------------------------------------------------------------------------ |
---|
[282] | 3158 | % --- Executes on button press in CheckMask. |
---|
[2] | 3159 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3160 | %------------------------------------------------------------------------ |
---|
[282] | 3161 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3162 | if isequal(maskval,0) |
---|
[384] | 3163 | set(handles.Mask,'String','') |
---|
[2] | 3164 | else |
---|
[112] | 3165 | mask_displ='no mask'; %default |
---|
[371] | 3166 | filebase=get(handles.RootPath,'String'); |
---|
[112] | 3167 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3168 | if isequal(flag_mask,1) |
---|
| 3169 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3170 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[371] | 3171 | filebase_a=get(handles.RootFile_1,'String'); |
---|
[2] | 3172 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3173 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3174 | mask_displ='no mask'; |
---|
| 3175 | end |
---|
[112] | 3176 | end |
---|
| 3177 | if isequal(mask_displ,'no mask') |
---|
| 3178 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3179 | {'*.png', ' (*.png)'; |
---|
[12] | 3180 | '*.png', '.png files '; ... |
---|
| 3181 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3182 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3183 | mask_displ=fullfile(PathName,FileName); |
---|
| 3184 | if ~exist(mask_displ,'file') |
---|
| 3185 | mask_displ='no mask'; |
---|
| 3186 | end |
---|
[12] | 3187 | end |
---|
[112] | 3188 | if isequal(mask_displ,'no mask') |
---|
[282] | 3189 | set(handles.CheckMask,'Value',0) |
---|
| 3190 | set(handles.CheckMask,'Value',0) |
---|
| 3191 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3192 | else |
---|
[282] | 3193 | %set(handles.CheckMask,'Value',1) |
---|
| 3194 | set(handles.CheckMask,'Value',1) |
---|
[112] | 3195 | end |
---|
[384] | 3196 | set(handles.Mask,'String',mask_displ) |
---|
| 3197 | set(handles.Mask,'String',mask_displ) |
---|
| 3198 | set(handles.Mask,'String',mask_displ) |
---|
[12] | 3199 | end |
---|
| 3200 | |
---|
| 3201 | %------------------------------------------------------------------------ |
---|
[282] | 3202 | % --- Executes on button press in CheckMask: select box for mask option |
---|
[2] | 3203 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3204 | %------------------------------------------------------------------------ |
---|
[282] | 3205 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3206 | if isequal(maskval,0) |
---|
[384] | 3207 | set(handles.Mask,'String','') |
---|
[2] | 3208 | else |
---|
[112] | 3209 | mask_displ='no mask'; %default |
---|
[371] | 3210 | filebase=get(handles.RootPath,'String'); |
---|
[112] | 3211 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3212 | if isequal(flag_mask,1) |
---|
| 3213 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3214 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[371] | 3215 | filebase_a=get(handles.RootFile_1,'String'); |
---|
[2] | 3216 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3217 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3218 | mask_displ='no mask'; |
---|
| 3219 | end |
---|
[112] | 3220 | end |
---|
| 3221 | if isequal(mask_displ,'no mask') |
---|
| 3222 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3223 | {'*.png', ' (*.png)'; |
---|
[12] | 3224 | '*.png', '.png files '; ... |
---|
| 3225 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3226 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3227 | mask_displ=fullfile(PathName,FileName); |
---|
| 3228 | if ~exist(mask_displ,'file') |
---|
| 3229 | mask_displ='no mask'; |
---|
| 3230 | end |
---|
[12] | 3231 | end |
---|
[112] | 3232 | if isequal(mask_displ,'no mask') |
---|
[282] | 3233 | set(handles.CheckMask,'Value',0) |
---|
| 3234 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3235 | else |
---|
[282] | 3236 | set(handles.CheckMask,'Value',1) |
---|
[112] | 3237 | end |
---|
[384] | 3238 | set(handles.Mask,'String',mask_displ) |
---|
| 3239 | set(handles.Mask,'String',mask_displ) |
---|
[12] | 3240 | end |
---|
| 3241 | |
---|
| 3242 | %------------------------------------------------------------------------ |
---|
[282] | 3243 | % --- Executes on button press in CheckMask. |
---|
[2] | 3244 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3245 | %------------------------------------------------------------------------ |
---|
[282] | 3246 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3247 | if isequal(maskval,0) |
---|
[384] | 3248 | set(handles.Mask,'String','') |
---|
[2] | 3249 | else |
---|
[12] | 3250 | mask_displ='no mask'; %default |
---|
[371] | 3251 | filebase=get(handles.RootPath,'String'); |
---|
[12] | 3252 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3253 | if isequal(flag_mask,1) |
---|
[112] | 3254 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3255 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[371] | 3256 | filebase_a=get(handles.RootFile_1,'String'); |
---|
[112] | 3257 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3258 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[112] | 3259 | mask_displ='no mask'; |
---|
| 3260 | end |
---|
[12] | 3261 | end |
---|
| 3262 | if isequal(mask_displ,'no mask') |
---|
| 3263 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3264 | {'*.png', ' (*.png)'; |
---|
| 3265 | '*.png', '.png files '; ... |
---|
| 3266 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3267 | 'Pick a mask file *.png',filebase); |
---|
| 3268 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3269 | if ~exist(mask_displ,'file') |
---|
[2] | 3270 | mask_displ='no mask'; |
---|
| 3271 | end |
---|
[12] | 3272 | end |
---|
| 3273 | if isequal(mask_displ,'no mask') |
---|
[282] | 3274 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3275 | end |
---|
[384] | 3276 | set(handles.Mask,'String',mask_displ) |
---|
[2] | 3277 | end |
---|
| 3278 | |
---|
[12] | 3279 | %------------------------------------------------------------------------ |
---|
| 3280 | % --- function called to look for mask files |
---|
[2] | 3281 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3282 | %------------------------------------------------------------------------ |
---|
[112] | 3283 | %detect mask files, images with appropriate file base |
---|
[2] | 3284 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3285 | %flag_mask=1 indicates detection |
---|
| 3286 | |
---|
| 3287 | flag_mask=0;%default |
---|
| 3288 | nbslice=1; |
---|
| 3289 | |
---|
[363] | 3290 | % subdir=get(handles.SubdirCiv1,'String'); |
---|
[2] | 3291 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3292 | if ~isdir(Path) |
---|
| 3293 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3294 | return |
---|
| 3295 | end |
---|
[272] | 3296 | % currentdir=pwd; |
---|
| 3297 | % cd(Path);%move in the dir of the root name filebase |
---|
| 3298 | maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files |
---|
| 3299 | % cd(currentdir);%come back to the current working directory |
---|
[12] | 3300 | if ~isempty(maskfiles) |
---|
[112] | 3301 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3302 | % else |
---|
[2] | 3303 | flag_mask=1; |
---|
| 3304 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3305 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3306 | Namedouble=double(Name); |
---|
| 3307 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3308 | ind_mask=findstr('mask',Name); |
---|
| 3309 | i=ind_mask-1; |
---|
[137] | 3310 | while val(i)==0 && i>0 |
---|
[112] | 3311 | i=i-1; |
---|
[2] | 3312 | end |
---|
[137] | 3313 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3314 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3315 | flag_mask=1; |
---|
[2] | 3316 | else |
---|
[112] | 3317 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3318 | return |
---|
| 3319 | nbslice=1; |
---|
[2] | 3320 | end |
---|
[112] | 3321 | end |
---|
[2] | 3322 | |
---|
[12] | 3323 | %------------------------------------------------------------------------ |
---|
| 3324 | % --- function called to look for grid files |
---|
[2] | 3325 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 3326 | %------------------------------------------------------------------------ |
---|
[2] | 3327 | flag_mask=0;%default |
---|
| 3328 | nbslice=1; |
---|
| 3329 | [Path,Name]=fileparts(filebase); |
---|
| 3330 | currentdir=pwd; |
---|
| 3331 | cd(Path);%move in the dir of the root name filebase |
---|
| 3332 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 3333 | cd(currentdir);%come back to the current working directory |
---|
| 3334 | if ~isempty(maskfiles) |
---|
| 3335 | flag_mask=1; |
---|
| 3336 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3337 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3338 | Namedouble=double(Name); |
---|
| 3339 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3340 | ind_mask=findstr('grid',Name); |
---|
| 3341 | i=ind_mask-1; |
---|
[137] | 3342 | while val(i)==0 && i>0 |
---|
[112] | 3343 | i=i-1; |
---|
[2] | 3344 | end |
---|
[137] | 3345 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3346 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3347 | flag_mask=1; |
---|
[2] | 3348 | else |
---|
[112] | 3349 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3350 | return |
---|
| 3351 | nbslice=1; |
---|
[2] | 3352 | end |
---|
[12] | 3353 | end |
---|
[2] | 3354 | |
---|
[12] | 3355 | %------------------------------------------------------------------------ |
---|
| 3356 | % --- transform numbers to letters |
---|
[122] | 3357 | function str=num2stra(num,nom_type) |
---|
[12] | 3358 | %------------------------------------------------------------------------ |
---|
[122] | 3359 | if isempty(nom_type) |
---|
| 3360 | str=''; |
---|
| 3361 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3362 | str=char(96+num); |
---|
[122] | 3363 | elseif strcmp(nom_type(end),'A') |
---|
| 3364 | str=char(96+num); |
---|
| 3365 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3366 | str=''; |
---|
| 3367 | else |
---|
| 3368 | str=num2str(num); |
---|
| 3369 | end |
---|
[12] | 3370 | |
---|
[441] | 3371 | % %------------------------------------------------------------------------ |
---|
| 3372 | % % --- Executes on button press in ListSubdirCiv1. |
---|
| 3373 | % function ListSubdirCiv1_Callback(hObject, eventdata, handles) |
---|
| 3374 | % %------------------------------------------------------------------------ |
---|
| 3375 | % list_subdir_civ1=get(handles.ListSubdirCiv1,'String'); |
---|
| 3376 | % val=get(handles.ListSubdirCiv1,'Value'); |
---|
| 3377 | % SubDir=list_subdir_civ1{val}; |
---|
| 3378 | % if strcmp(SubDir,'new...') |
---|
| 3379 | % if get(handles.CheckCiv1,'Value') |
---|
| 3380 | % SubDir='CIV'; %default subdirectory |
---|
| 3381 | % else |
---|
| 3382 | % msgbox_uvmat('ERROR','select CheckCiv1 to perform a new Civ operation') |
---|
| 3383 | % return |
---|
| 3384 | % end |
---|
| 3385 | % end |
---|
| 3386 | % set(handles.SubdirCiv1,'String',SubDir); |
---|
| 3387 | % errormsg=find_netcpair_civ(handles,1); |
---|
| 3388 | % if ~isempty(errormsg) |
---|
| 3389 | % msgbox_uvmat('ERROR',errormsg) |
---|
| 3390 | % end |
---|
| 3391 | % |
---|
[12] | 3392 | %------------------------------------------------------------------------ |
---|
[441] | 3393 | % % --- Executes on button press in ListSubdirCiv2. |
---|
| 3394 | % function ListSubdirCiv2_Callback(hObject, eventdata, handles) |
---|
| 3395 | % %------------------------------------------------------------------------ |
---|
| 3396 | % list_subdir_civ2=get(handles.ListSubdirCiv2,'String'); |
---|
| 3397 | % val=get(handles.ListSubdirCiv2,'Value'); |
---|
| 3398 | % SubDir=list_subdir_civ2{val}; |
---|
| 3399 | % if strcmp(SubDir,'new...') |
---|
| 3400 | % if get(handles.CheckCiv2,'Value') |
---|
| 3401 | % SubDir='CIV'; %default subdirectory |
---|
| 3402 | % else |
---|
| 3403 | % msgbox_uvmat('ERROR','select CheckCiv2 to perform a new Civ operation') |
---|
| 3404 | % return |
---|
| 3405 | % end |
---|
| 3406 | % end |
---|
| 3407 | % set(handles.SubdirCiv2,'String',SubDir); |
---|
[2] | 3408 | |
---|
[12] | 3409 | %------------------------------------------------------------------------ |
---|
[282] | 3410 | % --- Executes on button press in CheckGrid. |
---|
| 3411 | function CheckGrid_Callback(hObject, eventdata, handles) |
---|
[12] | 3412 | %------------------------------------------------------------------------ |
---|
[276] | 3413 | value=get(hObject,'Value'); |
---|
| 3414 | hparent=get(hObject,'parent'); |
---|
| 3415 | hchildren=get(hparent,'children'); |
---|
[315] | 3416 | handle_txtbox=findobj(hchildren,'tag','txt_Grid'); |
---|
[276] | 3417 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 3418 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
[315] | 3419 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
| 3420 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
[2] | 3421 | testgrid=0; |
---|
[276] | 3422 | filegrid=''; |
---|
[2] | 3423 | if value |
---|
[371] | 3424 | filebase=get(handles.RootPath,'String'); |
---|
[276] | 3425 | [nbslice, flag_grid]=get_grid(filebase,handles);% look for a grid with appropriate name |
---|
[2] | 3426 | if isequal(flag_grid,1) |
---|
[112] | 3427 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3428 | testgrid=1; |
---|
[276] | 3429 | else % browse for a grid |
---|
| 3430 | filegrid=get(hObject,'UserData');%look for previous grid name stored as UserData |
---|
| 3431 | if exist(filegrid,'file') |
---|
| 3432 | filebase=filegrid; |
---|
| 3433 | end |
---|
[2] | 3434 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3435 | {'*.grid', ' (*.grid)'; |
---|
| 3436 | '*.grid', '.grid files '; ... |
---|
| 3437 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3438 | 'Pick a file',filebase); |
---|
[2] | 3439 | filegrid=fullfile(PathName,FileName); |
---|
[276] | 3440 | set(hObject,'UserData',filegrid);%store for future use |
---|
[2] | 3441 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3442 | testgrid=1; |
---|
| 3443 | end |
---|
[112] | 3444 | end |
---|
[2] | 3445 | end |
---|
| 3446 | if testgrid |
---|
[276] | 3447 | set(handle_dx,'Visible','off'); |
---|
| 3448 | set(handle_dy,'Visible','off'); |
---|
[315] | 3449 | set(handle_title_dy,'Visible','off'); |
---|
| 3450 | set(handle_title_dx,'Visible','off'); |
---|
[276] | 3451 | set(handle_txtbox,'Visible','on') |
---|
| 3452 | set(handle_txtbox,'String',filegrid) |
---|
[112] | 3453 | else |
---|
[276] | 3454 | set(hObject,'Value',0); |
---|
[315] | 3455 | set(handle_dx,'Visible','on'); |
---|
[276] | 3456 | set(handle_dy,'Visible','on'); |
---|
[315] | 3457 | set(handle_title_dy,'Visible','on'); |
---|
| 3458 | set(handle_title_dx,'Visible','on'); |
---|
[276] | 3459 | set(handle_txtbox,'Visible','off') |
---|
[2] | 3460 | end |
---|
| 3461 | |
---|
[282] | 3462 | %% if hObject is on the checkciv1 frame, duplicate action for checkciv2 frame |
---|
[319] | 3463 | PanelName=get(hparent,'tag'); |
---|
[315] | 3464 | if strcmp(PanelName,'Civ1') |
---|
[282] | 3465 | hchildren=get(handles.Civ2,'children'); |
---|
[315] | 3466 | handle_checkbox=findobj(hchildren,'tag','CheckGrid'); |
---|
| 3467 | handle_txtbox=findobj(hchildren,'tag','txt_Grid'); |
---|
[276] | 3468 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 3469 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
[315] | 3470 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
| 3471 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
[276] | 3472 | set(handle_checkbox,'UserData',filegrid);%store for future use |
---|
| 3473 | if testgrid |
---|
| 3474 | set(handle_checkbox,'Value',1); |
---|
| 3475 | set(handle_dx,'Visible','off'); |
---|
| 3476 | set(handle_dy,'Visible','off'); |
---|
[315] | 3477 | set(handle_title_dx,'Visible','off'); |
---|
| 3478 | set(handle_title_dy,'Visible','off'); |
---|
[276] | 3479 | set(handle_txtbox,'Visible','on') |
---|
| 3480 | set(handle_txtbox,'String',filegrid) |
---|
[315] | 3481 | % else |
---|
| 3482 | % set(handle_checkbox,'Value',0); |
---|
| 3483 | % set(handles.CheckGrid,'Value',0); |
---|
| 3484 | % set(handle_dx,'Visible','on'); |
---|
| 3485 | % set(handle_dy,'Visible','on'); |
---|
| 3486 | % set(handle_title_dx,'Visible','on'); |
---|
| 3487 | % set(handle_title_dy,'Visible','on'); |
---|
| 3488 | % set(handle_txtbox,'Visible','off') |
---|
[276] | 3489 | end |
---|
| 3490 | end |
---|
[387] | 3491 | |
---|
[12] | 3492 | %------------------------------------------------------------------------ |
---|
[387] | 3493 | % --- Executes on button press in CheckMask: common to all panels (civ1, Civ2..) |
---|
[282] | 3494 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
[276] | 3495 | %------------------------------------------------------------------------ |
---|
| 3496 | value=get(hObject,'Value'); |
---|
[315] | 3497 | hparent=get(hObject,'parent'); |
---|
| 3498 | parent_tag=get(hparent,'Tag'); |
---|
| 3499 | hchildren=get(hparent,'children'); |
---|
[387] | 3500 | handle_txtbox=findobj(hchildren,'tag','Mask');% look for the mask name box in the same panel |
---|
[276] | 3501 | testmask=0; |
---|
| 3502 | if value |
---|
[371] | 3503 | filebase=get(handles.RootPath,'String'); |
---|
[276] | 3504 | [nbslice, flag_mask]=get_mask(filebase,handles);% look for a mask with appropriate name |
---|
| 3505 | if isequal(flag_mask,1) |
---|
| 3506 | filemask=[num2str(nbslice) 'mask']; |
---|
| 3507 | testmask=1; |
---|
| 3508 | else % browse for a mask |
---|
[315] | 3509 | filemask=get(hObject,'UserData');%look for previous mask name stored as UserData |
---|
[276] | 3510 | if exist(filemask,'file') |
---|
| 3511 | filebase=filemask; |
---|
| 3512 | end |
---|
[315] | 3513 | [FileName, PathName] = uigetfile( ... |
---|
[276] | 3514 | {'*.png', ' (*.png)'; |
---|
| 3515 | '*.png', '.png files '; ... |
---|
| 3516 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3517 | 'Pick a mask file *.png',filebase); |
---|
| 3518 | filemask=fullfile(PathName,FileName); |
---|
[315] | 3519 | set(hObject,'UserData',filemask);%store for future use |
---|
[276] | 3520 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filemask,'file')) |
---|
| 3521 | testmask=1; |
---|
| 3522 | end |
---|
| 3523 | end |
---|
| 3524 | end |
---|
| 3525 | if testmask |
---|
[316] | 3526 | if strcmp(parent_tag,'Civ1') |
---|
[387] | 3527 | set(handles.Mask,'Visible','on') |
---|
[384] | 3528 | set(handles.Mask,'String',filemask) |
---|
[316] | 3529 | set(handles.CheckMask,'Value',1) |
---|
[315] | 3530 | end |
---|
[316] | 3531 | % switch parent_tag |
---|
| 3532 | % % case 'Fix1' |
---|
| 3533 | % % stage=2; |
---|
| 3534 | % case 'Civ2' |
---|
| 3535 | % stage=3; |
---|
| 3536 | % % case 'Fix2' |
---|
| 3537 | % % stage=4; |
---|
| 3538 | % end |
---|
[384] | 3539 | % set(handles.Mask(stage:end),'Visible','on') |
---|
| 3540 | % set(handles.Mask(stage:end),'String',filemask) |
---|
[316] | 3541 | % set(handles.CheckMask(stage:end),'Value',1) |
---|
[276] | 3542 | else |
---|
[315] | 3543 | set(hObject,'Value',0); |
---|
| 3544 | set(handle_txtbox,'Visible','off') |
---|
[276] | 3545 | end |
---|
| 3546 | |
---|
[2] | 3547 | |
---|
| 3548 | % --- Executes on button press in get_gridpatch1. |
---|
| 3549 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
[371] | 3550 | filebase=get(handles.RootPath,'String'); |
---|
[2] | 3551 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3552 | {'*.grid', ' (*.grid)'; |
---|
| 3553 | '*.grid', '.grid files '; ... |
---|
| 3554 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3555 | 'Pick a file',filebase); |
---|
[2] | 3556 | filegrid=fullfile(PathName,FileName); |
---|
| 3557 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3558 | |
---|
[371] | 3559 | |
---|
[12] | 3560 | %------------------------------------------------------------------------ |
---|
[2] | 3561 | % --- Executes on button press in get_gridpatch2. |
---|
| 3562 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3563 | %------------------------------------------------------------------------ |
---|
[2] | 3564 | |
---|
| 3565 | |
---|
[12] | 3566 | %------------------------------------------------------------------------ |
---|
[309] | 3567 | % --- STEREO Interp |
---|
| 3568 | 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] | 3569 | %------------------------------------------------------------------------ |
---|
[309] | 3570 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
| 3571 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
| 3572 | ' -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] | 3573 | |
---|
[494] | 3574 | % %------------------------------------------------------------------------ |
---|
| 3575 | % %--read images and convert them to the uint16 format used for PIV |
---|
| 3576 | % function A=read_image(filename,type_ima,num,movieobject) |
---|
| 3577 | % %------------------------------------------------------------------------ |
---|
| 3578 | % %num is the view number needed for an avi movie |
---|
| 3579 | % switch type_ima |
---|
| 3580 | % case 'movie' |
---|
| 3581 | % A=read(movieobject,num); |
---|
| 3582 | % case 'avi' |
---|
| 3583 | % mov=aviread(filename,num); |
---|
| 3584 | % A=frame2im(mov(1)); |
---|
| 3585 | % case 'multimage' |
---|
| 3586 | % A=imread(filename,num); |
---|
| 3587 | % case 'image' |
---|
| 3588 | % A=imread(filename); |
---|
| 3589 | % end |
---|
| 3590 | % siz=size(A); |
---|
| 3591 | % if length(siz)==3;%color images |
---|
| 3592 | % A=sum(double(A),3); |
---|
| 3593 | % A=uint16(A); |
---|
| 3594 | % end |
---|
[2] | 3595 | |
---|
| 3596 | |
---|
[12] | 3597 | %------------------------------------------------------------------------ |
---|
[2] | 3598 | % --- Executes on button press in get_ref_fix1. |
---|
| 3599 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3600 | %------------------------------------------------------------------------ |
---|
[371] | 3601 | filebase=get(handles.RootPath,'String'); |
---|
[2] | 3602 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3603 | {'*.nc', ' (*.nc)'; |
---|
| 3604 | '*.nc', 'netcdf files '; ... |
---|
| 3605 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3606 | 'Pick a file',filebase); |
---|
| 3607 | |
---|
[2] | 3608 | fileinput=[PathName FileName]; |
---|
| 3609 | sizf=size(fileinput); |
---|
[122] | 3610 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[343] | 3611 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 3612 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
[2] | 3613 | ref.filebase=fullfile(Path,File); |
---|
[343] | 3614 | % ref.num_a=stra2num(str_a); |
---|
| 3615 | % ref.num_b=stra2num(str_b); |
---|
| 3616 | % ref.num1=str2double(field_count); |
---|
| 3617 | % ref.num2=str2double(str2); |
---|
[2] | 3618 | browse=[];%initialisation |
---|
| 3619 | if ~isequal(ref.ext,'.nc') |
---|
| 3620 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 3621 | return |
---|
| 3622 | end |
---|
| 3623 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 3624 | set(handles.ref_fix1,'UserData',ref) |
---|
| 3625 | menu_field{1}='civ1'; |
---|
| 3626 | Data=nc2struct(fileinput,[]); |
---|
[45] | 3627 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 3628 | menu_field{2}='filter1'; |
---|
| 3629 | end |
---|
[45] | 3630 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 3631 | menu_field{3}='civ2'; |
---|
| 3632 | end |
---|
[45] | 3633 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 3634 | menu_field{4}='filter2'; |
---|
| 3635 | end |
---|
| 3636 | set(handles.field_ref1,'String',menu_field); |
---|
| 3637 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
[287] | 3638 | set(handles.num_MinVel,'Value',2); |
---|
| 3639 | set(handles.num_MinVel,'String','1');%default threshold |
---|
[2] | 3640 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 3641 | |
---|
| 3642 | %------------------------------------------------------------------------ |
---|
[2] | 3643 | % --- Executes on button press in get_ref_fix2. |
---|
| 3644 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3645 | %------------------------------------------------------------------------ |
---|
[2] | 3646 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
[371] | 3647 | filebase=get(handles.RootPath,'String'); |
---|
[2] | 3648 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3649 | {'*.nc', ' (*.nc)'; |
---|
| 3650 | '*.nc', 'netcdf files '; ... |
---|
| 3651 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3652 | 'Pick a file',filebase); |
---|
[2] | 3653 | fileinput=[PathName FileName]; |
---|
| 3654 | sizf=size(fileinput); |
---|
[45] | 3655 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[343] | 3656 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 3657 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
[2] | 3658 | ref.filebase=fullfile(Path,File); |
---|
[343] | 3659 | % ref.num_a=stra2num(str_a); |
---|
| 3660 | % ref.num_b=stra2num(str_b); |
---|
| 3661 | % ref.num1=str2num(field_count); |
---|
| 3662 | % ref.num2=str2num(str2); |
---|
[2] | 3663 | browse=[];%initialisation |
---|
| 3664 | if ~isequal(ref.ext,'.nc') |
---|
| 3665 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 3666 | return |
---|
| 3667 | end |
---|
| 3668 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
[112] | 3669 | set(handles.ref_fix2,'UserData',ref) |
---|
[2] | 3670 | menu_field{1}='civ1'; |
---|
| 3671 | Data=nc2struct(fileinput,[]); |
---|
[301] | 3672 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 3673 | menu_field{2}='filter1'; |
---|
| 3674 | end |
---|
[301] | 3675 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 3676 | menu_field{3}='civ2'; |
---|
| 3677 | end |
---|
[301] | 3678 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 3679 | menu_field{4}='filter2'; |
---|
| 3680 | end |
---|
| 3681 | set(handles.field_ref2,'String',menu_field); |
---|
| 3682 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
[287] | 3683 | set(handles.num_MinVel,'Value',2); |
---|
| 3684 | set(handles.num_MinVel,'String','1');%default threshold |
---|
[2] | 3685 | set(handles.ref_fix2,'Enable','on') |
---|
| 3686 | set(handles.ref_fix2,'Visible','on') |
---|
| 3687 | set(handles.field_ref2,'Visible','on') |
---|
| 3688 | else |
---|
| 3689 | set(handles.ref_fix2,'Visible','off') |
---|
| 3690 | set(handles.field_ref2,'Visible','off') |
---|
| 3691 | end |
---|
| 3692 | |
---|
[12] | 3693 | %------------------------------------------------------------------------ |
---|
[2] | 3694 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3695 | %------------------------------------------------------------------------ |
---|
[287] | 3696 | set(handles.num_MinVel,'Value',1); |
---|
[12] | 3697 | set(handles.field_ref1,'Value',1) |
---|
| 3698 | set(handles.field_ref1,'String',{' '}) |
---|
| 3699 | set(handles.ref_fix1,'UserData',[]); |
---|
| 3700 | set(handles.ref_fix1,'String',''); |
---|
| 3701 | set(handles.thresh_vel1,'String','0'); |
---|
[112] | 3702 | |
---|
[12] | 3703 | %------------------------------------------------------------------------ |
---|
[2] | 3704 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3705 | %------------------------------------------------------------------------ |
---|
[287] | 3706 | set(handles.num_MinVel,'Value',1); |
---|
[12] | 3707 | set(handles.field_ref2,'Value',1) |
---|
| 3708 | set(handles.field_ref2,'String',{' '}) |
---|
| 3709 | set(handles.ref_fix2,'UserData',[]); |
---|
| 3710 | set(handles.ref_fix2,'String',''); |
---|
[287] | 3711 | set(handles.num_MinVel,'String','0'); |
---|
[2] | 3712 | |
---|
[12] | 3713 | %------------------------------------------------------------------------ |
---|
[371] | 3714 | % --- TO ABANDON Executes on button press in test_stereo1. |
---|
| 3715 | function CheckStereo_Callback(hObject, eventdata, handles) |
---|
[12] | 3716 | %------------------------------------------------------------------------ |
---|
[371] | 3717 | hparent=get(hObject,'parent'); |
---|
| 3718 | parent_tag=get(hparent,'Tag'); |
---|
| 3719 | hchildren=get(hparent,'children'); |
---|
| 3720 | handle_txtbox=findobj(hchildren,'tag','txt_Mask'); |
---|
| 3721 | if isequal(get(hObject,'Value'),0) |
---|
[274] | 3722 | set(handles.num_SubdomainSize,'Visible','on') |
---|
[437] | 3723 | set(handles.num_FieldSmooth,'Visible','on') |
---|
[2] | 3724 | else |
---|
[274] | 3725 | set(handles.num_SubdomainSize,'Visible','off') |
---|
[437] | 3726 | set(handles.num_FieldSmooth,'Visible','off') |
---|
[2] | 3727 | end |
---|
| 3728 | |
---|
[371] | 3729 | % %------------------------------------------------------------------------ |
---|
| 3730 | % % --- Executes on button press in CheckStereo. |
---|
| 3731 | % function StereoCheck_Callback(hObject, eventdata, handles) |
---|
| 3732 | % %------------------------------------------------------------------------ |
---|
| 3733 | % if isequal(get(handles.CheckStereo,'Value'),0) |
---|
| 3734 | % set(handles.num_SubdomainSize,'Visible','on') |
---|
[437] | 3735 | % set(handles.num_FieldSmooth,'Visible','on') |
---|
[371] | 3736 | % else |
---|
| 3737 | % set(handles.num_SubdomainSize,'Visible','off') |
---|
[437] | 3738 | % set(handles.num_FieldSmooth,'Visible','off') |
---|
[371] | 3739 | % end |
---|
| 3740 | |
---|
[12] | 3741 | %------------------------------------------------------------------------ |
---|
[413] | 3742 | % --- Executes on button press in TestCiv1: prepare the image correlation function |
---|
| 3743 | % activated by mouse motion |
---|
[150] | 3744 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
[224] | 3745 | %------------------------------------------------------------------------ |
---|
[233] | 3746 | drawnow |
---|
[309] | 3747 | if get(handles.TestCiv1,'Value') |
---|
[413] | 3748 | set(handles.TestCiv1,'BackgroundColor',[0.7 0.7 0.7])% paint TestCiv1 button to grey to confirm civ launch |
---|
| 3749 | ref_i=str2double(get(handles.ref_i,'String'));% read reference i index |
---|
[227] | 3750 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
[413] | 3751 | ref_j=str2double(get(handles.ref_j,'String'));% read reference j index if relevant |
---|
[227] | 3752 | else |
---|
[413] | 3753 | ref_j=1;%default j index |
---|
[227] | 3754 | end |
---|
[437] | 3755 | [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] | 3756 | Data.ListVarName={'ny','nx','A'}; |
---|
[315] | 3757 | Data.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
[444] | 3758 | |
---|
[413] | 3759 | Data.A=imread(filecell.ima1.civ1{1}); % read the first image |
---|
[387] | 3760 | if ndims(Data.A)==3 %case of color image |
---|
| 3761 | Data.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; |
---|
| 3762 | end |
---|
[224] | 3763 | Data.ny=[size(Data.A,1) 1]; |
---|
| 3764 | Data.nx=[1 size(Data.A,2)]; |
---|
[413] | 3765 | Data.CoordUnit='pixel';% used to set equal scaling for x and y in image dispaly |
---|
[309] | 3766 | par_civ1=read_GUI(handles.Civ1); |
---|
[444] | 3767 | par_civ1.FileTypeA=get_file_type(filecell.ima1.civ1{1}); |
---|
[388] | 3768 | par_civ1.ImageWidth=size(Data.A,2); |
---|
| 3769 | par_civ1.ImageHeight=size(Data.A,1); |
---|
[315] | 3770 | par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation |
---|
[435] | 3771 | par_civ1.FrameIndexA=num2str(i1); |
---|
| 3772 | par_civ1.FrameIndexB=num2str(i2); |
---|
[246] | 3773 | Param.Civ1=par_civ1; |
---|
[315] | 3774 | Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV |
---|
[387] | 3775 | hview_field=view_field(Data); %view the image in the GUI view_field |
---|
[231] | 3776 | set(0,'CurrentFigure',hview_field) |
---|
| 3777 | hhview_field=guihandles(hview_field); |
---|
| 3778 | set(hview_field,'CurrentAxes',hhview_field.axes3) |
---|
| 3779 | ViewData=get(hview_field,'UserData'); |
---|
| 3780 | ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field |
---|
[224] | 3781 | ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field |
---|
[315] | 3782 | ViewData.axes3.X=Grid.Civ1_X; %keep the set of points in memeory |
---|
| 3783 | ViewData.axes3.Y=Grid.Civ1_Y; |
---|
[231] | 3784 | set(hview_field,'UserData',ViewData) |
---|
[224] | 3785 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 3786 | if isempty(corrfig) |
---|
| 3787 | corrfig=figure; |
---|
| 3788 | set(corrfig,'tag','corrfig') |
---|
| 3789 | set(corrfig,'name','image correlation') |
---|
| 3790 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
| 3791 | end |
---|
[233] | 3792 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
[224] | 3793 | else |
---|
[413] | 3794 | set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red |
---|
[224] | 3795 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 3796 | if ~isempty(corrfig) |
---|
| 3797 | delete(corrfig) |
---|
| 3798 | end |
---|
| 3799 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 3800 | if ~isempty(hview_field) |
---|
| 3801 | delete(hview_field) |
---|
| 3802 | end |
---|
[150] | 3803 | end |
---|
[71] | 3804 | |
---|
[415] | 3805 | %------------------------------------------------------------------------ |
---|
| 3806 | %----function introduced for the correlation window figure, activated by deleting this window |
---|
| 3807 | function closeview_field(gcbo,eventdata) |
---|
| 3808 | %------------------------------------------------------------------------ |
---|
| 3809 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 3810 | if ~isempty(hview_field) |
---|
| 3811 | delete(hview_field) |
---|
| 3812 | end |
---|
[150] | 3813 | |
---|
[252] | 3814 | %------------------------------------------------------------------------ |
---|
[315] | 3815 | % --- Executes on button press in CheckThreshold. |
---|
| 3816 | function CheckThreshold_Callback(hObject, eventdata, handles) |
---|
[252] | 3817 | %------------------------------------------------------------------------ |
---|
[315] | 3818 | huipanel=get(hObject,'parent'); |
---|
| 3819 | obj(1)=findobj(huipanel,'Tag','num_MinIma'); |
---|
| 3820 | obj(2)=findobj(huipanel,'Tag','num_MaxIma'); |
---|
| 3821 | obj(3)=findobj(huipanel,'Tag','title_Threshold'); |
---|
| 3822 | if get(hObject,'Value') |
---|
| 3823 | set(obj,'Visible','on') |
---|
| 3824 | else |
---|
| 3825 | set(obj,'Visible','off') |
---|
| 3826 | end |
---|
[220] | 3827 | |
---|
[465] | 3828 | |
---|
| 3829 | |
---|
| 3830 | |
---|
| 3831 | %'nomtype2pair': creates nomencalture for index pairs knowing the image nomenclature |
---|
| 3832 | %--------------------------------------------------------------------- |
---|
| 3833 | function NomTypeNc=nomtype2pair(NomTypeIma,mode) |
---|
| 3834 | %--------------------------------------------------------------------- |
---|
| 3835 | % OUTPUT: |
---|
| 3836 | % NomTypeNc |
---|
| 3837 | %--------------------------------------------------------------------- |
---|
| 3838 | % INPUT: |
---|
| 3839 | % 'NomTypeIma': string defining the kind of nomenclature used for images |
---|
| 3840 | |
---|
| 3841 | NomTypeNc=NomTypeIma;%default |
---|
| 3842 | switch mode |
---|
| 3843 | case 'pair j1-j2' |
---|
| 3844 | if ~isempty(regexp(NomTypeIma,'a$')) |
---|
| 3845 | NomTypeNc=[NomTypeIma 'b']; |
---|
| 3846 | elseif ~isempty(regexp(NomTypeIma,'A$')) |
---|
| 3847 | NomTypeNc=[NomTypeIma 'B']; |
---|
| 3848 | else |
---|
| 3849 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
| 3850 | if ~isempty(r) |
---|
| 3851 | NomTypeNc='_1_1-2'; |
---|
| 3852 | end |
---|
| 3853 | end |
---|
| 3854 | case 'series(Dj)' |
---|
[492] | 3855 | % r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
| 3856 | % if ~isempty(r) |
---|
[465] | 3857 | NomTypeNc='_1_1-2'; |
---|
[492] | 3858 | % end |
---|
[465] | 3859 | case 'series(Di)' |
---|
| 3860 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
| 3861 | if ~isempty(r) |
---|
| 3862 | NomTypeNc='_1-2_1'; |
---|
| 3863 | else |
---|
| 3864 | NomTypeNc='_1-2'; |
---|
| 3865 | end |
---|
| 3866 | end |
---|
| 3867 | |
---|
| 3868 | function NomType_Callback(hObject, eventdata, handles) |
---|
| 3869 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
| 3870 | RootPath=get(handles.RootPath,'String'); |
---|
| 3871 | RootFile=get(handles.RootFile,'String'); |
---|
[494] | 3872 | SubDirImages=get(handles.SubDirImages,'String'); |
---|
[465] | 3873 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3874 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 3875 | NomType=get(handles.NomType,'String'); |
---|
| 3876 | ImaExt=get(handles.ImaExt,'String'); |
---|
[494] | 3877 | fileinput=fullfile_uvmat(RootPath,SubDirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j); |
---|
[465] | 3878 | errormsg=display_file_name(handles,fileinput); |
---|
| 3879 | if ~isempty(errormsg) |
---|
| 3880 | msgbox_uvmat('ERROR',errormsg) |
---|
| 3881 | end |
---|
| 3882 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
| 3883 | |
---|
[469] | 3884 | % --- Executes on selection change in Program. |
---|
| 3885 | function Program_Callback(hObject, eventdata, handles) |
---|
| 3886 | ListProgram=get(handles.Program,'String'); |
---|
| 3887 | Program=ListProgram{get(handles.Program,'value')}; |
---|
[465] | 3888 | switch Program |
---|
| 3889 | case 'CivX' |
---|
| 3890 | set(handles.num_MaxDiff,'Visible','off') |
---|
| 3891 | set(handles.num_MaxVel,'Visible','off') |
---|
| 3892 | set(handles.title_MaxVel,'Visible','off') |
---|
| 3893 | set(handles.num_Nx,'Visible','on') |
---|
| 3894 | set(handles.num_Ny,'Visible','on') |
---|
| 3895 | set(handles.title_Nx,'Visible','on') |
---|
| 3896 | set(handles.title_Ny,'Visible','on') |
---|
| 3897 | set(handles.title_MaxDiff,'Visible','off') |
---|
| 3898 | set(handles.num_CorrSmooth,'Style','edit') |
---|
| 3899 | set(handles.num_CorrSmooth,'String','1') |
---|
| 3900 | set(handles.BATCH,'Enable','on') |
---|
| 3901 | set(handles.CheckThreshold,'Visible','off') |
---|
| 3902 | set(handles.CheckDeformation,'Value',1) |
---|
| 3903 | set(handles.CheckDecimal,'Value',1) |
---|
[469] | 3904 | case {'civ_matlab','civ_matlab.sh'} |
---|
[465] | 3905 | set(handles.num_MaxDiff,'Visible','on') |
---|
| 3906 | set(handles.num_MaxVel,'Visible','on') |
---|
| 3907 | set(handles.title_MaxVel,'Visible','on') |
---|
| 3908 | set(handles.title_MaxDiff,'Visible','on') |
---|
| 3909 | set(handles.num_Nx,'Visible','off') |
---|
| 3910 | set(handles.num_Ny,'Visible','off') |
---|
| 3911 | set(handles.title_Nx,'Visible','off') |
---|
| 3912 | set(handles.title_Ny,'Visible','off') |
---|
| 3913 | set(handles.num_CorrSmooth,'Style','popupmenu') |
---|
| 3914 | set(handles.num_CorrSmooth,'Value',1) |
---|
| 3915 | set(handles.num_CorrSmooth,'String',{'1';'2'}) |
---|
| 3916 | set(handles.CheckThreshold,'Visible','on') |
---|
| 3917 | set(handles.CheckDeformation,'Value',0)% desactivate (work in progress) |
---|
| 3918 | set(handles.CheckDecimal,'Value',0)% desactivate (work in progress) |
---|
| 3919 | end |
---|
| 3920 | |
---|
| 3921 | % --- Executes on button press in TestPatch1. |
---|
| 3922 | function TestPatch1_Callback(hObject, eventdata, handles) |
---|
| 3923 | set(handles.TestPatch1,'BackgroundColor',[1 1 0]) |
---|
| 3924 | drawnow |
---|
| 3925 | if get(handles.TestPatch1,'Value') |
---|
| 3926 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3927 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
| 3928 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 3929 | else |
---|
| 3930 | ref_j=1;%default |
---|
| 3931 | end |
---|
| 3932 | filecell=set_civ_filenames(handles,ref_i,ref_j,[0 0 1 0 0 0]); |
---|
| 3933 | Data.ListVarName={'ny','nx','A'}; |
---|
| 3934 | Data.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
| 3935 | param_patch1=read_GUI(handles.Patch1); |
---|
| 3936 | param_patch1.CivFile=filecell.nc.civ1{1}; |
---|
| 3937 | Param.Patch1=param_patch1; |
---|
| 3938 | for irho=1:7 |
---|
| 3939 | [Data,errormsg]=civ_matlab(Param);% get the grid of x, y positions set for PIV |
---|
| 3940 | if ~isempty(errormsg) |
---|
| 3941 | msgbox_uvmat('ERROR',errormsg) |
---|
| 3942 | return |
---|
| 3943 | end |
---|
| 3944 | SmoothingParam(irho)=Param.Patch1.FieldSmooth; |
---|
| 3945 | Data.Civ1_U_Diff=Data.Civ1_U_Diff(Data.Civ1_FF==0); |
---|
| 3946 | Data.Civ1_V_Diff=Data.Civ1_V_Diff(Data.Civ1_FF==0); |
---|
| 3947 | DiffVel(irho)=sqrt(mean(Data.Civ1_U_Diff.*Data.Civ1_U_Diff+Data.Civ1_V_Diff.*Data.Civ1_V_Diff)) |
---|
| 3948 | NbSites(irho,:)=Data.Civ1_NbSites*numel(Data.Civ1_NbSites)/numel(Data.Civ1_U_Diff); |
---|
| 3949 | Param.Patch1.SmoothingParam=2*Param.Patch1.FieldSmooth; |
---|
| 3950 | end |
---|
| 3951 | figure |
---|
| 3952 | plot(SmoothingParam,DiffVel,'b',SmoothingParam,NbSites,'r') |
---|
| 3953 | set(handles.TestPatch1,'BackgroundColor',[1 0 0]) |
---|
| 3954 | else |
---|
| 3955 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 3956 | if ~isempty(corrfig) |
---|
| 3957 | delete(corrfig) |
---|
| 3958 | end |
---|
| 3959 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 3960 | if ~isempty(hview_field) |
---|
| 3961 | delete(hview_field) |
---|
| 3962 | end |
---|
| 3963 | end |
---|
| 3964 | |
---|
| 3965 | |
---|
| 3966 | % --- Executes on button press in TestCiv2. |
---|
| 3967 | function TestCiv2_Callback(hObject, eventdata, handles) |
---|
| 3968 | |
---|
| 3969 | function RootFile_Callback(hObject, eventdata, handles) |
---|
| 3970 | |
---|
[494] | 3971 | function SubDirImages_Callback(hObject, eventdata, handles) |
---|
[465] | 3972 | |
---|
| 3973 | |
---|
| 3974 | |
---|
| 3975 | function errormsg=write_param(Param) |
---|
[252] | 3976 | %------------------------------------------------------------------------ |
---|
[284] | 3977 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 3978 | %changes : filename_cmx -> filename ( no extension ) |
---|
[465] | 3979 | errormsg=''; |
---|
[469] | 3980 | switch Param.Program |
---|
[465] | 3981 | case 'CivX' |
---|
| 3982 | if Param.CheckCiv1 |
---|
[487] | 3983 | filename=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_CMX$2$3.civ1.cmx'); |
---|
[465] | 3984 | if isequal(Param.Civ1.Dt,0) |
---|
| 3985 | Param.Civ1.Dt=1 ;%case of 'displacement' mode |
---|
| 3986 | end |
---|
| 3987 | Param.Civ1.ImageA=regexprep(Param.Civ1.ImageA,'.png',''); |
---|
| 3988 | Param.Civ1.ImageB=regexprep(Param.Civ1.ImageB,'.png',''); |
---|
| 3989 | [fid,errormsg]=fopen(filename,'w'); |
---|
| 3990 | if isequal(fid,-1) |
---|
| 3991 | errormsg=['cmd file ' filename ' cannot be created: ' errormsg]; |
---|
| 3992 | return |
---|
| 3993 | end |
---|
| 3994 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 3995 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ1.ImageA,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 3996 | fprintf(fid, ['LastImage ' regexprep(Param.Civ1.ImageB,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 3997 | fprintf(fid, ['XX' '\n' ]); |
---|
| 3998 | if isfield(Param.Civ1,'Mask') |
---|
| 3999 | fprintf(fid, ['Mask ' 'y' '\n' ]); |
---|
| 4000 | fprintf(fid, ['MaskName ' regexprep(Param.Civ1.Mask,'\\','\\\\') '\n' ]); |
---|
| 4001 | else |
---|
| 4002 | fprintf(fid, ['Mask ' 'n' '\n' ]); |
---|
| 4003 | fprintf(fid, ['MaskName ' 'noFile use default' '\n' ]); |
---|
| 4004 | end |
---|
| 4005 | fprintf(fid, ['ImageSize ' num2str(Param.Civ1.ImageWidth) ' ' num2str(Param.Civ1.ImageHeight) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4006 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ1.CorrBoxSize(1)) ' ' num2str(Param.Civ1.CorrBoxSize(2)) '\n' ]); |
---|
| 4007 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ1.SearchBoxSize(1)) ' ' num2str(Param.Civ1.SearchBoxSize(2)) '\n' ]); |
---|
| 4008 | fprintf(fid, ['RO ' num2str(Param.Civ1.CorrSmooth) '\n' ]); |
---|
| 4009 | if isfield(Param.Civ1,'Grid') |
---|
| 4010 | fprintf(fid, ['GridSpacing ' '25' ' ' '25' '\n' ]); |
---|
| 4011 | else |
---|
| 4012 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ1.Dx) ' ' num2str(Param.Civ1.Dy) '\n' ]); |
---|
| 4013 | end |
---|
| 4014 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4015 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ1.Dt) ' ' num2str(Param.Civ1.Time) '\n' ]); |
---|
| 4016 | fprintf(fid, ['PixCmXY ' '1' ' ' '1' '\n' ]); |
---|
| 4017 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4018 | fprintf(fid, ['ShiftXY ' num2str(Param.Civ1.SearchBoxShift(1)) ' ' num2str(Param.Civ1.SearchBoxShift(2)) '\n' ]); |
---|
| 4019 | if isfield(Param.Civ1,'Grid') |
---|
| 4020 | fprintf(fid, ['Grid ' 'y' '\n' ]); |
---|
| 4021 | fprintf(fid, ['GridName ' regexprep(Param.Civ1.Grid,'\\','\\\\') '\n' ]); |
---|
| 4022 | else |
---|
| 4023 | fprintf(fid, ['Grid ' 'n' '\n' ]); |
---|
| 4024 | fprintf(fid, ['GridName ' 'noFile use default' '\n' ]); |
---|
| 4025 | end |
---|
| 4026 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4027 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4028 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4029 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4030 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4031 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4032 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4033 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4034 | if ~isfield(Param.Civ1,'MinIma')% Image threshold not activated |
---|
| 4035 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4036 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]);%not used in principle |
---|
| 4037 | else% Image threshold activated |
---|
| 4038 | if isempty(Param.Civ1.MaxIma)||isnan(Param.Civ1.MaxIma) |
---|
| 4039 | Param.Civ1.MaxIma=2^Param.Civ1.ImageBitDepth;%take the max image value as upper bound by default |
---|
| 4040 | end |
---|
| 4041 | fprintf(fid, ['SeuilImage y' '\n' ]); |
---|
| 4042 | fprintf(fid, ['SeuilImageValues ' num2str(Param.Civ1.MinIma) ' ' num2str(Param.Civ1.MaxIma) '\n' ]); |
---|
| 4043 | end |
---|
| 4044 | fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? |
---|
| 4045 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 4046 | fclose(fid); |
---|
| 4047 | end |
---|
| 4048 | |
---|
| 4049 | if Param.CheckCiv2 |
---|
[487] | 4050 | filename=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_CMX$2$3.civ2.cmx'); |
---|
[465] | 4051 | |
---|
| 4052 | if isequal(Param.Civ2.Dt,'0') |
---|
| 4053 | Param.Civ2.Dt='1' ;%case of 'displacement' mode |
---|
| 4054 | end |
---|
| 4055 | Param.Civ2.ImageA=regexprep(Param.Civ2.ImageA,'.png',''); |
---|
| 4056 | Param.Civ2.ImageB=regexprep(Param.Civ2.ImageB,'.png','');% bug : .png appears two times ? |
---|
| 4057 | [fid,errormsg]=fopen(filename,'w'); |
---|
| 4058 | if isequal(fid,-1) |
---|
| 4059 | return |
---|
| 4060 | end |
---|
| 4061 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4062 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ2.ImageA,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4063 | fprintf(fid, ['LastImage ' regexprep(Param.Civ2.ImageB,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4064 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4065 | if isfield(Param.Civ2,'Mask') |
---|
| 4066 | fprintf(fid, ['Mask ' 'y' '\n' ]); |
---|
| 4067 | fprintf(fid, ['MaskName ' regexprep(Param.Civ2.Mask,'\\','\\\\') '\n' ]); |
---|
| 4068 | else |
---|
| 4069 | fprintf(fid, ['Mask ' 'n' '\n' ]); |
---|
| 4070 | fprintf(fid, ['MaskName ' 'noFile use default' '\n' ]); |
---|
| 4071 | end |
---|
| 4072 | % fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]); |
---|
| 4073 | % fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4074 | fprintf(fid, ['ImageSize ' num2str(Param.Civ2.ImageWidth) ' ' num2str(Param.Civ2.ImageHeight) '\n' ]); |
---|
| 4075 | % fprintf(fid, ['ImageSize ' num2str(Param.Civ2.npx) ' ' num2str(Param.Civ2.npy) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4076 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ2.CorrBoxSize(1)) ' ' num2str(Param.Civ2.CorrBoxSize(2)) '\n' ]); |
---|
| 4077 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ2.CorrBoxSize(1)) ' ' num2str(Param.Civ2.CorrBoxSize(2)) '\n']); |
---|
| 4078 | fprintf(fid, ['RO ' num2str(Param.Civ2.CorrSmooth) '\n']); |
---|
| 4079 | if isfield(Param.Civ2,'Grid') |
---|
| 4080 | fprintf(fid, ['GridSpacing ' '25' ' ' '25' '\n' ]); |
---|
| 4081 | else |
---|
| 4082 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n' ]); |
---|
| 4083 | end |
---|
| 4084 | % fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n']); |
---|
| 4085 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4086 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ2.Dt) ' ' num2str(Param.Civ2.Time) '\n' ]); |
---|
| 4087 | fprintf(fid, ['PixCmXY ' '1' ' ' '1' '\n' ]); |
---|
| 4088 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4089 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
| 4090 | if isfield(Param.Civ2,'Grid') |
---|
| 4091 | fprintf(fid, ['Grid ' 'y' '\n' ]); |
---|
| 4092 | fprintf(fid, ['GridName ' regexprep(Param.Civ2.Grid,'\\','\\\\') '\n' ]); |
---|
| 4093 | else |
---|
| 4094 | fprintf(fid, ['Grid ' 'n' '\n' ]); |
---|
| 4095 | fprintf(fid, ['GridName ' 'noFile use default' '\n' ]); |
---|
| 4096 | end |
---|
| 4097 | % fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); |
---|
| 4098 | % fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); |
---|
| 4099 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4100 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4101 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4102 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4103 | fprintf(fid, ['DecimalShift ' num2str(Param.Civ2.CheckDecimal) '\n']); |
---|
| 4104 | fprintf(fid, ['Deformation ' num2str(Param.Civ2.CheckDeformation) '\n']); |
---|
| 4105 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4106 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4107 | |
---|
| 4108 | if ~isfield(Param.Civ2,'MinIma')% Image threshold not activated |
---|
| 4109 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4110 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]);%not used in principle |
---|
| 4111 | else% Image threshold activated |
---|
| 4112 | if isempty(Param.Civ2.MaxIma)||isnan(Param.Civ2.MaxIma) |
---|
| 4113 | Param.Civ2.MaxIma=2^Param.Civ2.ImageBitDepth;%take the max image value as upper bound by default |
---|
| 4114 | end |
---|
| 4115 | fprintf(fid, ['SeuilImage y' '\n' ]); |
---|
| 4116 | fprintf(fid, ['SeuilImageValues ' num2str(Param.Civ2.MinIma) ' ' num2str(Param.Civ2.MaxIma) '\n' ]); |
---|
| 4117 | end |
---|
| 4118 | fprintf(fid, ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ? |
---|
| 4119 | fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']); |
---|
| 4120 | fclose(fid); |
---|
| 4121 | end |
---|
[469] | 4122 | case {'civ_matlab','civ_matlab.sh'} |
---|
[487] | 4123 | filename=regexprep(Param.OutputFile,'(.+)([/\\])(.+$)','$1$20_XML$2$3.xml'); |
---|
[465] | 4124 | save(struct2xml(Param),filename); |
---|
[284] | 4125 | end |
---|
[465] | 4126 | |
---|
| 4127 | |
---|
[469] | 4128 | function cmd=write_cmd(Param) |
---|
[465] | 4129 | |
---|
| 4130 | % initiate system command |
---|
| 4131 | cmd=[]; |
---|
| 4132 | |
---|
[469] | 4133 | switch Param.Program |
---|
[465] | 4134 | case 'CivX' |
---|
| 4135 | if isunix % check: necessaire aussi en RUN? |
---|
[487] | 4136 | cmd=[cmd '#!/bin/bash \n'... |
---|
| 4137 | '#$ -cwd \n'... |
---|
| 4138 | 'hostname && date \n'... |
---|
[465] | 4139 | 'umask 002 \n'];%allow writting access to created files for user group |
---|
| 4140 | end |
---|
| 4141 | case 'CivAll' |
---|
| 4142 | if isunix % check: necessaire aussi en RUN? |
---|
[487] | 4143 | cmd=[cmd '#!/bin/bash \n'... |
---|
| 4144 | '#$ -cwd \n'... |
---|
| 4145 | 'hostname && date \n'... |
---|
[465] | 4146 | 'umask 002 \n'];%allow writting access to created files for user group |
---|
| 4147 | end |
---|
[319] | 4148 | end |
---|
[465] | 4149 | |
---|
| 4150 | filename=regexprep(Param.OutputFile,'.nc',''); |
---|
| 4151 | |
---|
| 4152 | if Param.CheckCiv1 |
---|
[469] | 4153 | switch Param.Program |
---|
[465] | 4154 | case 'CivX' |
---|
| 4155 | if(isunix) %unix (or Mac) system |
---|
[487] | 4156 | cmd=[cmd 'cp -f ' regexprep(filename,'(.+)/(.+$)','$1/0_CMX/$2.civ1.cmx ') regexprep(filename,'(.+)/(.+$)','$1/$2.cmx \n')...% the cmx file gives the name to the nc file |
---|
| 4157 | Param.xml.Civ1Bin ' -f ' regexprep(filename,'(.+)/(.+$)','$1/$2.cmx >') regexprep(filename,'(.+)/(.+$)','$1/0_LOG/$2.civ1.log \n')... % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
| 4158 | 'rm ' regexprep(filename,'(.+)/(.+$)','$1/$2.cmx \n')]; |
---|
[465] | 4159 | else %Windows system |
---|
| 4160 | filename=regexprep(filename,'\\','\\\\'); |
---|
[494] | 4161 | cmd=['copy /Y ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_CMX\\\\$2.civ1.cmx" ') regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')... |
---|
[487] | 4162 | '"' regexprep(Param.xml.Civ1Bin,'\\','\\\\') '" -f ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" > ')... |
---|
| 4163 | regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_LOG\\\\$2.civ1.log" \n')... % redirect standard output to the log file |
---|
| 4164 | 'del ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')]; |
---|
[465] | 4165 | end |
---|
| 4166 | case 'CivAll' |
---|
| 4167 | CivAllCmd=[CivAllCmd ' civ1 ']; |
---|
| 4168 | str=CIV1_CMD_Unified(filecell.nc.civ1{ifile,j},'',Param.Civ1); |
---|
| 4169 | fieldnames=fields(str); |
---|
| 4170 | [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); |
---|
| 4171 | for ilist=1:length(fieldnames) |
---|
| 4172 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 4173 | if ischar(val) |
---|
| 4174 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 4175 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 4176 | end |
---|
| 4177 | end |
---|
| 4178 | end |
---|
[315] | 4179 | end |
---|
[465] | 4180 | |
---|
| 4181 | if Param.CheckFix1 |
---|
[469] | 4182 | switch Param.Program |
---|
[465] | 4183 | case 'CivX' |
---|
| 4184 | cmd=[cmd... |
---|
| 4185 | cmd_fix(Param,'Fix1') '\n']; |
---|
| 4186 | case 'CivAll'%to abandon |
---|
| 4187 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 4188 | fix1.fi1=num2str(param.fix1.flagindex1(1)); |
---|
| 4189 | fix1.fi2=num2str(param.fix1.flagindex1(2)); |
---|
| 4190 | fix1.fi3=num2str(param.fix1.flagindex1(3)); |
---|
| 4191 | fix1.threshC=num2str(param.fix1.thresh_vecC1); |
---|
| 4192 | fix1.threshV=num2str(param.fix1.thresh_vel1); |
---|
| 4193 | fieldnames=fields(fix1); |
---|
| 4194 | [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); |
---|
| 4195 | for ilist=1:length(fieldnames) |
---|
| 4196 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 4197 | if ischar(val) |
---|
| 4198 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 4199 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 4200 | end |
---|
| 4201 | end |
---|
| 4202 | CivAllCmd=[CivAllCmd ' fix1 ']; |
---|
| 4203 | end |
---|
[313] | 4204 | end |
---|
[465] | 4205 | |
---|
| 4206 | |
---|
| 4207 | %CheckPatch1 |
---|
| 4208 | if Param.CheckPatch1 |
---|
[469] | 4209 | switch Param.Program |
---|
[465] | 4210 | case 'CivX' |
---|
| 4211 | cmd=[cmd... |
---|
| 4212 | cmd_patch(Param,'Patch1') '\n']; |
---|
| 4213 | case 'CivAll' |
---|
| 4214 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 4215 | patch1.nopt=subdomain_patch1; |
---|
| 4216 | patch1.maxdiff=thresh_patch1; |
---|
| 4217 | patch1.ro=rho_patch1; |
---|
| 4218 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 4219 | if test_grid |
---|
| 4220 | patch1.gridflag='y'; |
---|
| 4221 | gridname=get(handles.grid_patch1,'String'); |
---|
| 4222 | if isequal(gridname(end-3:end),'grid') |
---|
| 4223 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 4224 | if ~isnan(nbslice_grid) |
---|
| 4225 | i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 4226 | patch1.gridPatch=[filecell.filebase '_' fullfile_uvmat('','',gridname,'.grid','_1',i1_grid)]; |
---|
| 4227 | % patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')]; |
---|
| 4228 | if ~exist(patch1.gridPatch,'file') |
---|
| 4229 | errormsg='grid file absent for patch1'; |
---|
| 4230 | return |
---|
| 4231 | end |
---|
| 4232 | elseif exist(gridname,'file') |
---|
| 4233 | patch1.gridPatch=gridname; |
---|
| 4234 | else |
---|
| 4235 | errormsg='grid file absent for patch1'; |
---|
| 4236 | return |
---|
| 4237 | end |
---|
| 4238 | end |
---|
| 4239 | else |
---|
| 4240 | patch1.gridPatch='none'; |
---|
| 4241 | patch1.gridflag='n'; |
---|
| 4242 | patch1.m=nx_patch1; |
---|
| 4243 | patch1.n=ny_patch1; |
---|
| 4244 | end |
---|
| 4245 | patch1.convectFlow='n'; |
---|
| 4246 | fieldnames=fields(patch1); |
---|
| 4247 | [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); |
---|
| 4248 | for ilist=1:length(fieldnames) |
---|
| 4249 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 4250 | if ischar(val) |
---|
| 4251 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 4252 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 4253 | end |
---|
| 4254 | end |
---|
| 4255 | CivAllCmd=[CivAllCmd ' patch1 ']; |
---|
| 4256 | end |
---|
[313] | 4257 | end |
---|
[465] | 4258 | |
---|
| 4259 | if Param.CheckCiv2 |
---|
[469] | 4260 | switch Param.Program |
---|
[465] | 4261 | case 'CivX' |
---|
| 4262 | if(isunix) |
---|
[487] | 4263 | cmd=[cmd 'cp -f ' regexprep(filename,'(.+)/(.+$)','$1/0_CMX/$2.civ2.cmx ') regexprep(filename,'(.+)/(.+$)','$1/$2.cmx \n')... |
---|
| 4264 | Param.xml.Civ2Bin ' -f ' regexprep(filename,'(.+)/(.+$)','$1/$2.cmx >') regexprep(filename,'(.+)/(.+$)','$1/0_LOG/$2.civ2.log \n')...% redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
| 4265 | 'rm ' regexprep(filename,'(.+)/(.+$)','$1/$2.cmx \n')];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
[465] | 4266 | else |
---|
[494] | 4267 | filename=regexprep(Param.OutputFile,'.nc',''); |
---|
[465] | 4268 | filename=regexprep(filename,'\\','\\\\'); |
---|
[487] | 4269 | cmd=[cmd 'copy /Y ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_CMX\\\\$2.civ2.cmx" ') regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')... |
---|
[494] | 4270 | '"' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" > ')... |
---|
[487] | 4271 | regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_LOG\\\\$2.civ2.log" \n')... % redirect standard output to the log file |
---|
[494] | 4272 | 'del ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')]; |
---|
[465] | 4273 | end |
---|
[494] | 4274 | |
---|
[465] | 4275 | case 'CivAll' |
---|
| 4276 | CivAllCmd=[CivAllCmd ' civ2 ']; |
---|
| 4277 | str=CIV2_CMD_Unified(filecell.nc.civ2{ifile,j},'',Param.Civ2); |
---|
| 4278 | fieldnames=fields(str); |
---|
| 4279 | [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); |
---|
| 4280 | for ilist=1:length(fieldnames) |
---|
| 4281 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 4282 | if ischar(val) |
---|
| 4283 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 4284 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 4285 | end |
---|
| 4286 | end |
---|
[309] | 4287 | end |
---|
| 4288 | end |
---|
[284] | 4289 | |
---|
[465] | 4290 | % CheckFix2 |
---|
| 4291 | if Param.CheckFix2==1 |
---|
[469] | 4292 | switch Param.Program |
---|
[465] | 4293 | case 'CivX' |
---|
| 4294 | cmd=[cmd... |
---|
| 4295 | cmd_fix(Param,'Fix2') '\n']; |
---|
| 4296 | case 'CivAll' |
---|
| 4297 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 4298 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 4299 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 4300 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 4301 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 4302 | fix2.threshV=num2str(thresh_vel2); |
---|
| 4303 | fieldnames=fields(fix2); |
---|
| 4304 | [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); |
---|
| 4305 | for ilist=1:length(fieldnames) |
---|
| 4306 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 4307 | if ischar(val) |
---|
| 4308 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 4309 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 4310 | end |
---|
| 4311 | end |
---|
| 4312 | CivAllCmd=[CivAllCmd ' fix2 ']; |
---|
| 4313 | end |
---|
[284] | 4314 | end |
---|
[285] | 4315 | |
---|
[465] | 4316 | %CheckPatch2 |
---|
| 4317 | if Param.CheckPatch2==1 |
---|
| 4318 | |
---|
[469] | 4319 | switch Param.Program |
---|
[465] | 4320 | |
---|
| 4321 | case 'CivX' |
---|
| 4322 | cmd=[cmd... |
---|
| 4323 | cmd_patch(Param,'Patch2') '\n']; |
---|
| 4324 | case 'CivAll' |
---|
| 4325 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 4326 | patch2.nopt=subdomain_patch2; |
---|
| 4327 | patch2.maxdiff=thresh_patch2; |
---|
| 4328 | patch2.ro=rho_patch2; |
---|
| 4329 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 4330 | if test_grid |
---|
| 4331 | patch2.gridflag='y'; |
---|
| 4332 | gridname=get(handles.grid_patch2,'String'); |
---|
| 4333 | if isequal(gridname(end-3:end),'grid') |
---|
| 4334 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 4335 | if ~isnan(nbslice_grid) |
---|
| 4336 | i1_grid=mod(i1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 4337 | patch2.gridPatch=[filecell.filebase '_' fullfile_uvmat('','',gridname,'.grid','_1',i1_grid)]; |
---|
| 4338 | % patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')]; |
---|
| 4339 | if ~exist(patch2.gridPatch,'file') |
---|
| 4340 | errormsg='grid file absent for patch2'; |
---|
| 4341 | return |
---|
| 4342 | end |
---|
| 4343 | elseif exist(gridname,'file') |
---|
| 4344 | patch2.gridPatch=gridname; |
---|
| 4345 | else |
---|
| 4346 | errormsg='grid file absent for patch2'; |
---|
| 4347 | return |
---|
| 4348 | end |
---|
| 4349 | end |
---|
| 4350 | else |
---|
| 4351 | patch2.gridPatch='none'; |
---|
| 4352 | patch2.gridflag='n'; |
---|
| 4353 | patch2.m=nx_patch2; |
---|
| 4354 | patch2.n=ny_patch2; |
---|
| 4355 | end |
---|
| 4356 | patch2.convectFlow='n'; |
---|
| 4357 | fieldnames=fields(patch2); |
---|
| 4358 | [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); |
---|
| 4359 | for ilist=1:length(fieldnames) |
---|
| 4360 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 4361 | if ischar(val) |
---|
| 4362 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 4363 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 4364 | end |
---|
| 4365 | end |
---|
| 4366 | CivAllCmd=[CivAllCmd ' patch2 ']; |
---|
| 4367 | end |
---|
| 4368 | end |
---|
[285] | 4369 | |
---|
[482] | 4370 | switch Param.Program |
---|
| 4371 | case 'CivAll' |
---|
| 4372 | save(CivAllxml,[Param.OutputFile '.xml']); |
---|
| 4373 | cmd=[cmd sparam.CivBin ' -f ' Param.OutputFile '.xml ' CivAllCmd ' >' Param.OutputFile '.log' '\n']; |
---|
| 4374 | case 'civ_matlab' |
---|
[486] | 4375 | switch computer |
---|
| 4376 | case {'PCWIN','PCWIN64'} |
---|
| 4377 | filename=regexprep(filename,'\\','\\\\');% add '\' so that '\' are left as characters |
---|
[492] | 4378 | cmd=['civ_matlab(''' regexprep(filename,'(.+)([/\\])(.+$)','$1$20_XML\\$2$3.xml') ''','''... |
---|
| 4379 | filename '.nc'');']; |
---|
[486] | 4380 | case {'GLNX86','GLNXA64','MACI64'} |
---|
[492] | 4381 | cmd=['civ_matlab(''' regexprep(filename,'(.+)([/\\])(.+$)','$1$20_XML$2$3.xml') ''','''... |
---|
| 4382 | filename '.nc'');']; |
---|
[486] | 4383 | end |
---|
[492] | 4384 | |
---|
| 4385 | |
---|
[482] | 4386 | case 'civ_matlab.sh' |
---|
[505] | 4387 | CivmBin=fullfile(fileparts(which('civ')),'civ_matlab.sh'); %path to the source directory of uvmat |
---|
[486] | 4388 | switch computer |
---|
| 4389 | case {'PCWIN','PCWIN64'} |
---|
| 4390 | filename=regexprep(filename,'\\','\\\\');% add '\' so that '\' are left as characters |
---|
| 4391 | % TODO launch command in DOS |
---|
| 4392 | case {'GLNX86','GLNXA64','MACI64'} |
---|
| 4393 | cmd=['#!/bin/bash \n '... |
---|
| 4394 | '#$ -cwd \n '... |
---|
| 4395 | 'hostname && date \n '... |
---|
| 4396 | 'umask 002 \n'... |
---|
[505] | 4397 | CivmBin ' ' Param.xml.RunTime ' ' regexprep(filename,'(.+)([/\\])(.+$)','$1$20_XML$2$3.xml') ' ' Param.OutputFile '.nc'];%allow writting access to created files for user group |
---|
[486] | 4398 | end |
---|
[482] | 4399 | end |
---|
[465] | 4400 | |
---|
| 4401 | |
---|
| 4402 | function cmd=cmd_fix(Param,fixname) |
---|
[285] | 4403 | %% |
---|
[291] | 4404 | switch fixname |
---|
| 4405 | case 'Fix1' |
---|
| 4406 | fi2_value=num2str(Param.(fixname).CheckF2); |
---|
[465] | 4407 | filename=regexprep(Param.OutputFile,'.nc',''); |
---|
[291] | 4408 | case 'Fix2' |
---|
| 4409 | fi2_value=num2str(Param.(fixname).CheckF4);%need to understand why... |
---|
[465] | 4410 | filename=regexprep(Param.OutputFile,'.nc',''); |
---|
[291] | 4411 | end |
---|
[465] | 4412 | |
---|
| 4413 | % filename=regexprep(Param.(fixname).OutFileName,'.nc',''); |
---|
[287] | 4414 | MaskName_string='';%default |
---|
| 4415 | MaxVel_string='';%default |
---|
[427] | 4416 | if ~isempty(Param.(fixname).MinVel) |
---|
| 4417 | MaxVel_string=[' -threshV ' num2str(Param.(fixname).MinVel)]; |
---|
[287] | 4418 | end |
---|
[285] | 4419 | if isunix |
---|
[287] | 4420 | cmd=[Param.xml.FixBin ' -f ' filename '.nc -fi1 ' num2str(Param.(fixname).CheckFmin2) ... |
---|
[291] | 4421 | ' -fi2 ' fi2_value ' -fi3 ' num2str(Param.(fixname).CheckF3) ... |
---|
[287] | 4422 | ' -threshC ' num2str(Param.(fixname).MinCorr) MaxVel_string MaskName_string... |
---|
[487] | 4423 | ' >' regexprep(filename,'(.+)/(.+$)','$1/0_LOG/$2.') lower(fixname) '.log 2>&1']; |
---|
[285] | 4424 | else |
---|
| 4425 | cmd=['"' Param.xml.FixBin '" -f "' filename '.nc" -fi1 ' num2str(Param.(fixname).CheckFmin2)... |
---|
[291] | 4426 | ' -fi2 ' fi2_value ' -fi3 ' num2str(Param.(fixname).CheckF3) ... |
---|
[288] | 4427 | ' -threshC ' num2str(Param.(fixname).MinCorr) MaxVel_string MaskName_string... |
---|
[465] | 4428 | ' > "' regexprep(filename,'(\w+)\\(\w+$)','$1\\0_LOG\\$2.') lower(fixname) '.log"']; |
---|
[285] | 4429 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
| 4430 | end |
---|
[286] | 4431 | |
---|
| 4432 | |
---|
[465] | 4433 | function cmd=cmd_patch(Param,patchname) |
---|
[286] | 4434 | %% ------------------------------------------------------------------------ |
---|
[465] | 4435 | switch patchname |
---|
| 4436 | case 'Patch1' |
---|
| 4437 | filename=regexprep(Param.OutputFile,'.nc',''); |
---|
| 4438 | case 'Patch2' |
---|
| 4439 | filename=regexprep(Param.OutputFile,'.nc',''); |
---|
| 4440 | end |
---|
| 4441 | % filename=regexprep(Param.(patchname).OutFileName,'.nc',''); |
---|
[286] | 4442 | if isunix |
---|
| 4443 | cmd=[Param.xml.PatchBin... |
---|
| 4444 | ' -f ' filename '.nc -m ' num2str(Param.(patchname).Nx)... |
---|
[437] | 4445 | ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).FieldSmooth)... |
---|
[286] | 4446 | ' -nopt ' num2str(Param.(patchname).SubdomainSize) ... |
---|
[487] | 4447 | ' > ' regexprep(filename,'(.+)/(.+$)','$1/0_LOG/$2.') lower(patchname) '.log 2>&1']; % redirect standard output to the log file |
---|
[286] | 4448 | else |
---|
| 4449 | cmd=['"' Param.xml.PatchBin... |
---|
| 4450 | '" -f "' filename '.nc" -m ' num2str(Param.(patchname).Nx)... |
---|
[437] | 4451 | ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).FieldSmooth)... |
---|
[286] | 4452 | ' -nopt ' num2str(Param.(patchname).SubdomainSize)... |
---|
| 4453 | ' > "' filename '.' lower(patchname) '.log" 2>&1']; % redirect standard output to the log file |
---|
| 4454 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
| 4455 | end |
---|
[290] | 4456 | |
---|
[309] | 4457 | |
---|
[465] | 4458 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4459 | % USELESS FUNCTIONS BELOW HERE, TO CLEAN |
---|
| 4460 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4461 | |
---|
[309] | 4462 | %------------------------------------------------------------------------ |
---|
| 4463 | % --- CheckCiv1 Unified: TO ABADON |
---|
| 4464 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
| 4465 | %------------------------------------------------------------------------ |
---|
| 4466 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4467 | %global CivBin%name of the executable for checkciv1 calculation |
---|
| 4468 | |
---|
[315] | 4469 | civ1.image1=par.ImageA; |
---|
| 4470 | civ1.image2=par.ImageB; |
---|
[309] | 4471 | civ1.imageSize_X=par.npx; |
---|
| 4472 | civ1.imageSize_Y=par.npy; |
---|
| 4473 | civ1.outputFileName=[filename '.nc']; |
---|
| 4474 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4475 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4476 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4477 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4478 | civ1.globalShift_X=par.shiftx; |
---|
| 4479 | civ1.globalShift_Y=par.shifty; |
---|
| 4480 | civ1.ro=par.rho; |
---|
| 4481 | civ1.hart='y'; |
---|
| 4482 | if isequal(par.gridflag,'y') |
---|
| 4483 | civ1.grid=par.gridname; |
---|
| 4484 | else |
---|
| 4485 | civ1.grid='n'; |
---|
| 4486 | civ1.gridSpacing_X=par.dx; |
---|
| 4487 | civ1.gridSpacing_Y=par.dy; |
---|
| 4488 | end |
---|
| 4489 | if isequal(par.maskflag,'y') |
---|
| 4490 | civ1.mask=par.maskname; |
---|
| 4491 | end |
---|
| 4492 | civ1.dt=par.Dt; |
---|
| 4493 | civ1.unit='pixel'; |
---|
[315] | 4494 | civ1.absolut_time_T0=par.Time; |
---|
| 4495 | civ1.pixcmx='1'; |
---|
| 4496 | civ1.pixcmy='1'; |
---|
[309] | 4497 | civ1.convectFlow='n'; |
---|
| 4498 | |
---|
| 4499 | xml_civ1_parameters=civ1; |
---|
| 4500 | |
---|
| 4501 | %------------------------------------------------------------------------ |
---|
| 4502 | % --- CheckCiv2 Unified: TO ABADON |
---|
| 4503 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
| 4504 | %------------------------------------------------------------------------ |
---|
| 4505 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4506 | %global CivBin%name of the executable for checkciv1 calculation |
---|
| 4507 | |
---|
| 4508 | filename=regexprep(filename,'.nc',''); |
---|
| 4509 | |
---|
[315] | 4510 | civ2.image1=par.ImageA; |
---|
| 4511 | civ2.image2=par.ImageB; |
---|
[309] | 4512 | civ2.imageSize_X=par.npx; |
---|
| 4513 | civ2.imageSize_Y=par.npy; |
---|
| 4514 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4515 | civ2.outputFileName=[filename '.nc']; |
---|
| 4516 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4517 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4518 | civ2.ro=par.rho; |
---|
| 4519 | %checkciv2.decimalShift=par.CheckDecimal; |
---|
| 4520 | %checkciv2.CheckDeformation=par.CheckDeformation; |
---|
| 4521 | if isequal(par.decimal,'1') |
---|
| 4522 | civ2.decimalShift='y'; |
---|
| 4523 | else |
---|
| 4524 | civ2.decimalShift='n'; |
---|
| 4525 | end |
---|
| 4526 | if isequal(par.deformation,'1') |
---|
| 4527 | civ2.deformation='y'; |
---|
| 4528 | else |
---|
| 4529 | civ2.deformation='n'; |
---|
| 4530 | end |
---|
| 4531 | if isequal(par.gridflag,'y') |
---|
| 4532 | civ2.grid=par.gridname; |
---|
| 4533 | else |
---|
| 4534 | civ2.grid='n'; |
---|
| 4535 | civ2.gridSpacing_X=par.dx; |
---|
| 4536 | civ2.gridSpacing_Y=par.dy; |
---|
| 4537 | end |
---|
| 4538 | civ2.gridSpacing_X='10'; |
---|
| 4539 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4540 | if isequal(par.maskflag,'y') |
---|
| 4541 | civ2.mask=par.maskname; |
---|
| 4542 | else |
---|
| 4543 | civ2.mask='n'; |
---|
| 4544 | end |
---|
| 4545 | civ2.dt=par.Dt; |
---|
| 4546 | civ2.unit='pixel'; |
---|
[315] | 4547 | civ2.absolut_time_T0=par.Time; |
---|
| 4548 | civ2.pixcmx='1'; |
---|
| 4549 | civ2.pixcmy='1'; |
---|
[309] | 4550 | civ2.convectFlow='n'; |
---|
[317] | 4551 | |
---|
| 4552 | |
---|
[467] | 4553 | % --- Executes on selection change in RunMode. |
---|
| 4554 | function RunMode_Callback(hObject, eventdata, handles) |
---|
[492] | 4555 | |
---|
| 4556 | |
---|
| 4557 | function nb_field2_Callback(hObject, eventdata, handles) |
---|
| 4558 | |
---|
| 4559 | |
---|
| 4560 | function last_j_Callback(hObject, eventdata, handles) |
---|
| 4561 | |
---|
| 4562 | |
---|
| 4563 | function last_i_Callback(hObject, eventdata, handles) |
---|