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