[435] | 1 | |
---|
[112] | 2 | %'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch) |
---|
[2] | 3 | %------------------------------------------------------------------------ |
---|
[309] | 4 | % provides an interface for the software menucivx |
---|
[2] | 5 | % function varargout = civ(varargin) |
---|
[309] | 6 | % provides an interface for the software menucivx |
---|
[2] | 7 | % |
---|
| 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
[282] | 9 | % Copyright Joel Sommeria, 2011, LEGI / CNRS-UJF-INPG, sommeria@legi.grenoble-inp.fr |
---|
[2] | 10 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
[112] | 11 | % This file is part of the toolbox UVMAT. |
---|
| 12 | % |
---|
[2] | 13 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 14 | % it under the terms of the GNU General Public License as published by |
---|
| 15 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 16 | % (at your option) any later version. |
---|
[112] | 17 | % |
---|
[2] | 18 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 21 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 22 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 23 | function varargout = civ(varargin) |
---|
[273] | 24 | %TODO: search range |
---|
[2] | 25 | |
---|
[437] | 26 | % Last Modified by GUIDE v2.5 03-Jun-2012 22:16:42 |
---|
[2] | 27 | % Begin initialization code - DO NOT EDIT |
---|
| 28 | gui_Singleton = 1; |
---|
| 29 | gui_State = struct('gui_Name', mfilename, ... |
---|
[112] | 30 | 'gui_Singleton', gui_Singleton, ... |
---|
| 31 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
---|
| 32 | 'gui_OutputFcn', @civ_OutputFcn, ... |
---|
| 33 | 'gui_LayoutFcn', [] , ... |
---|
| 34 | 'gui_Callback', []); |
---|
[382] | 35 | if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback$','once')) |
---|
[2] | 36 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 37 | end |
---|
| 38 | |
---|
| 39 | if nargout |
---|
| 40 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 41 | else |
---|
| 42 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 43 | end |
---|
| 44 | % End initialization code - DO NOT EDIT |
---|
| 45 | |
---|
[12] | 46 | %------------------------------------------------------------------------ |
---|
[2] | 47 | % --- Executes just before civ is made visible. |
---|
[298] | 48 | function civ_OpeningFcn(hObject, eventdata, handles, fileinput) |
---|
[12] | 49 | %------------------------------------------------------------------------ |
---|
[2] | 50 | % This function has no output args, see OutputFcn. |
---|
[298] | 51 | |
---|
| 52 | %% General settings |
---|
[2] | 53 | handles.output = hObject; |
---|
[298] | 54 | guidata(hObject, handles); % Update handles structure |
---|
[309] | 55 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[252] | 56 | |
---|
[298] | 57 | %% Adjust the GUI according to the binaries available in PARAM.xml |
---|
[276] | 58 | path_civ=fileparts(which('civ')); %path to civ |
---|
[298] | 59 | addpath (path_civ) ; %add the path to civ, (useful in case of change of working directory after civ has been s opened in the working directory) |
---|
[273] | 60 | errormsg=[];%default error message |
---|
| 61 | xmlfile='PARAM.xml'; |
---|
| 62 | if exist(xmlfile,'file') |
---|
| 63 | try |
---|
| 64 | t=xmltree(xmlfile); |
---|
| 65 | sparam=convert(t); |
---|
[435] | 66 | catch ME |
---|
| 67 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message}; |
---|
[273] | 68 | end |
---|
| 69 | else |
---|
| 70 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
| 71 | end |
---|
| 72 | if ~isempty(errormsg) |
---|
[301] | 73 | msgbox_uvmat('WARNING',errormsg); |
---|
[273] | 74 | end |
---|
| 75 | test_batch=0;%default: ,no batch mode available |
---|
| 76 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
| 77 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
| 78 | end |
---|
| 79 | if test_batch==0 |
---|
| 80 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
---|
| 81 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 82 | end |
---|
| 83 | if isfield(sparam.RunParam,'CivBin') |
---|
| 84 | if ~exist(sparam.RunParam.CivBin,'file') |
---|
[276] | 85 | sparam.RunParam.CivBin=fullfile(path_civ,sparam.RunParam.CivBin); |
---|
[273] | 86 | end |
---|
| 87 | else |
---|
| 88 | sparam.RunParam.CivBin=''; |
---|
| 89 | end |
---|
| 90 | |
---|
[298] | 91 | %% load the list of previously browsed files in the upper bar menu Open/ |
---|
[296] | 92 | dir_perso=prefdir; % path to the directory .matlab for personal data |
---|
| 93 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab |
---|
| 94 | if exist(profil_perso,'file') |
---|
| 95 | h=load (profil_perso); |
---|
| 96 | if isfield(h,'MenuFile') |
---|
| 97 | for ifile=1:min(length(h.MenuFile),5) |
---|
| 98 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
| 99 | end |
---|
| 100 | end |
---|
[273] | 101 | end |
---|
| 102 | |
---|
[298] | 103 | %% prepare the GUI with parameters from the input file if opened from uvmat |
---|
| 104 | if exist('fileinput','var')% && isfield(param,'RootName') && ~isempty(param.RootName) |
---|
[371] | 105 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[298] | 106 | errormsg=display_file_name(handles,fileinput); |
---|
| 107 | if ~isempty(errormsg) |
---|
| 108 | msgbox_uvmat('ERROR',errormsg) |
---|
[112] | 109 | end |
---|
[371] | 110 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[2] | 111 | end |
---|
| 112 | |
---|
[12] | 113 | %------------------------------------------------------------------------ |
---|
[2] | 114 | % --- Outputs from this function are returned to the command line. |
---|
| 115 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 116 | %------------------------------------------------------------------------ |
---|
[2] | 117 | % Get default command line output from handles structure |
---|
| 118 | varargout{1} = handles.output; |
---|
| 119 | |
---|
[307] | 120 | %------------------------------------------------------------------------ |
---|
[309] | 121 | % --- Function activated by the Open/Browse... option in the upper menu bar. |
---|
[307] | 122 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
| 123 | %------------------------------------------------------------------------ |
---|
[343] | 124 | %% get the current input root file name to initiate the browser |
---|
[371] | 125 | filebase=get(handles.RootPath,'String'); |
---|
[307] | 126 | oldfile=''; %default |
---|
[309] | 127 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored root file name |
---|
[307] | 128 | dir_perso=prefdir; |
---|
| 129 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 130 | if exist(profil_perso,'file') |
---|
| 131 | h=load (profil_perso); |
---|
| 132 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 133 | oldfile=h.filebase; |
---|
| 134 | end |
---|
| 135 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 136 | oldfile=h.RootPath; |
---|
| 137 | end |
---|
| 138 | end |
---|
| 139 | else |
---|
| 140 | oldfile=filebase; |
---|
| 141 | end |
---|
[360] | 142 | |
---|
| 143 | %% get the new input file with the browser |
---|
[307] | 144 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
[309] | 145 | '*.xml', '.xml files '; ... |
---|
| 146 | '*.civ', '.civ files '; ... |
---|
| 147 | '*.png','.png image files'; ... |
---|
| 148 | '*.jpg',' jpeg image files'; ... |
---|
| 149 | '*.tif','.tif image files'; ... |
---|
| 150 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 151 | '*.nc','.netcdf files'; ... |
---|
| 152 | '*.*', 'All Files (*.*)'}; |
---|
[307] | 153 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 154 | fileinput=[PathName FileName];%complete file name |
---|
| 155 | sizf=size(fileinput); |
---|
| 156 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 157 | |
---|
[343] | 158 | %% case of the xml file opened as input (TODO: check and see whether it is useful) |
---|
[307] | 159 | [path,name,ext]=fileparts(fileinput); |
---|
| 160 | testeditxml=0; |
---|
[360] | 161 | % if isequal(ext,'.xml') |
---|
| 162 | % testeditxml=1; |
---|
| 163 | % t_browse=xmltree(fileinput); |
---|
| 164 | % head_element=get(t_browse,1); |
---|
| 165 | % if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
| 166 | % testeditxml=0; |
---|
| 167 | % end |
---|
[343] | 168 | % end |
---|
[360] | 169 | % if testeditxml==1 || isequal(ext,'.xls') |
---|
| 170 | % heditxml=editxml({fileinput}); |
---|
| 171 | % set(heditxml,'Tag','browser') |
---|
| 172 | % waitfor(heditxml,'Tag','idle') |
---|
| 173 | % if ~ishandle(heditxml) |
---|
| 174 | % return |
---|
| 175 | % end |
---|
| 176 | % attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 177 | % set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 178 | % fileinput=get(attr,'UserData'); |
---|
| 179 | % if ~exist(fileinput,'file') |
---|
| 180 | % return |
---|
| 181 | % end |
---|
[343] | 182 | % end |
---|
[360] | 183 | [tild,tild,tild,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput); |
---|
[343] | 184 | |
---|
| 185 | %% prepare the GUI with parameters from the input file |
---|
[371] | 186 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[343] | 187 | errormsg=display_file_name(handles,fileinput); |
---|
| 188 | if ~isempty(errormsg) |
---|
| 189 | msgbox_uvmat('ERROR',erromsg) |
---|
[307] | 190 | end |
---|
[371] | 191 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[307] | 192 | |
---|
[309] | 193 | %------------------------------------------------------------------------ |
---|
[273] | 194 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
| 195 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
[12] | 196 | %------------------------------------------------------------------------ |
---|
[371] | 197 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 198 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
[298] | 199 | errormsg=display_file_name(handles,fileinput); |
---|
| 200 | if ~isempty(errormsg) |
---|
[355] | 201 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 202 | end |
---|
[371] | 203 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[273] | 204 | |
---|
| 205 | % ----------------------------------------------------------------------- |
---|
| 206 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
| 207 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 208 | %------------------------------------------------------------------------ |
---|
[371] | 209 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 210 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
[298] | 211 | errormsg=display_file_name(handles,fileinput); |
---|
| 212 | if ~isempty(errormsg) |
---|
[355] | 213 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 214 | end |
---|
[371] | 215 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[309] | 216 | |
---|
[273] | 217 | % ----------------------------------------------------------------------- |
---|
| 218 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
| 219 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 220 | %------------------------------------------------------------------------ |
---|
[371] | 221 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 222 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
[298] | 223 | errormsg=display_file_name(handles,fileinput); |
---|
| 224 | if ~isempty(errormsg) |
---|
[355] | 225 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 226 | end |
---|
[371] | 227 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[309] | 228 | |
---|
[273] | 229 | % ----------------------------------------------------------------------- |
---|
| 230 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
| 231 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 232 | %------------------------------------------------------------------------ |
---|
[371] | 233 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 234 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
[298] | 235 | errormsg=display_file_name(handles,fileinput); |
---|
| 236 | if ~isempty(errormsg) |
---|
[355] | 237 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 238 | end |
---|
[371] | 239 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[309] | 240 | |
---|
[273] | 241 | % ----------------------------------------------------------------------- |
---|
| 242 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
| 243 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 244 | %------------------------------------------------------------------------ |
---|
[371] | 245 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
[273] | 246 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
[298] | 247 | errormsg=display_file_name(handles,fileinput); |
---|
| 248 | if ~isempty(errormsg) |
---|
[355] | 249 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 250 | end |
---|
[371] | 251 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[309] | 252 | |
---|
| 253 | % ----------------------------------------------------------------------- |
---|
| 254 | % ----------------------------------------------------------------------- |
---|
| 255 | % --- Open the help html file |
---|
| 256 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
| 257 | % ----------------------------------------------------------------------- |
---|
| 258 | path_civ=fileparts(which ('civ')); |
---|
| 259 | helpfile=fullfile(path_civ,'uvmat_doc','uvmat_doc.html'); |
---|
| 260 | if isempty(dir(helpfile)) |
---|
| 261 | msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
| 262 | else |
---|
| 263 | addpath (fullfile(path_civ,'uvmat_doc')) |
---|
| 264 | web([helpfile '#civ']) |
---|
| 265 | end |
---|
| 266 | |
---|
[12] | 267 | %------------------------------------------------------------------------ |
---|
[309] | 268 | % --- Function activated when a new filebase (image series) is introduced |
---|
[371] | 269 | function RootPath_Callback(hObject, eventdata, handles) |
---|
[12] | 270 | %------------------------------------------------------------------------ |
---|
[371] | 271 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
| 272 | RootPath=get(handles.RootPath,'String'); |
---|
[437] | 273 | SubdirImages=get(handles.SubdirImages,'String'); |
---|
[371] | 274 | RootFile=get(handles.RootFile,'String'); |
---|
[360] | 275 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 276 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 277 | NomType=get(handles.NomType,'String'); |
---|
| 278 | ImaExt=get(handles.ImaExt,'String'); |
---|
[437] | 279 | fileinput=fullfile_uvmat(RootPath,SubdirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j); |
---|
[360] | 280 | errormsg=display_file_name(handles,fileinput); |
---|
[298] | 281 | if ~isempty(errormsg) |
---|
[360] | 282 | msgbox_uvmat('ERROR',errormsg) |
---|
[298] | 283 | end |
---|
[371] | 284 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
[384] | 285 | |
---|
[273] | 286 | %------------------------------------------------------------------------ |
---|
[309] | 287 | % --- general function activated for an input file series |
---|
[298] | 288 | function errormsg=display_file_name(handles,fileinput) |
---|
[273] | 289 | %------------------------------------------------------------------------ |
---|
[282] | 290 | set(handles.ListCompareMode,'Visible','on') |
---|
[298] | 291 | errormsg='';%default empty error message |
---|
[355] | 292 | drawnow |
---|
[273] | 293 | |
---|
[298] | 294 | %% enable RUN, BATCH button and 'status' display |
---|
| 295 | set(handles.RUN, 'Enable','On') |
---|
| 296 | set(handles.RUN,'BackgroundColor',[1 0 0])%set RUN button to red color |
---|
| 297 | set(handles.BATCH,'Enable','On') |
---|
| 298 | set(handles.BATCH,'BackgroundColor',[1 0 0])%set BATCH button to red color |
---|
| 299 | if isfield(handles,'status') |
---|
| 300 | set(handles.status,'Value',0); %suppress the 'status' display |
---|
| 301 | status_Callback([], [], handles) |
---|
[2] | 302 | end |
---|
| 303 | |
---|
[298] | 304 | %% determine nomenclature types and extension of the input files |
---|
[355] | 305 | [RootPath,SubDir,RootFile,i1,i2,j1,j2,ExtInput,NomTypeInput]=fileparts_uvmat(fileinput); |
---|
[360] | 306 | NomTypeNc='';%default |
---|
| 307 | |
---|
[438] | 308 | %% case of xml file as input, read the civ parameters |
---|
[355] | 309 | ind_opening=0;%default |
---|
[360] | 310 | if strcmp(ExtInput,'.xml') |
---|
| 311 | Param=xml2struct(fileinput); |
---|
| 312 | fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file |
---|
| 313 | return |
---|
| 314 | end |
---|
[438] | 315 | |
---|
| 316 | %% case of netcdf file as input, get the civ processing stage and look for a coresponding image |
---|
[360] | 317 | if strcmp(ExtInput,'.nc') |
---|
| 318 | NomTypeNc=NomTypeInput; |
---|
[438] | 319 | if isempty(regexp(NomTypeInput,'[ab|AB|-]')) |
---|
[371] | 320 | set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomencalture does not involve index pairs |
---|
[438] | 321 | % [RootPath,SubDir]=fileparts(RootPath); |
---|
| 322 | set(handles.RootFile_1,'Visible','On'); |
---|
[371] | 323 | else |
---|
[438] | 324 | set(handles.ListCompareMode,'Value',1) |
---|
| 325 | set(handles.RootFile_1,'Visible','Off'); |
---|
[371] | 326 | end |
---|
| 327 | Data=nc2struct(fileinput,'ListGlobalAttribute','Conventions','absolut_time_T0','CivStage','Civ2_ImageA','Civ1_ImageA','Civ2_ImageB','Civ1_ImageB','fix','patch','civ2','fix2'); |
---|
[360] | 328 | if isfield(Data,'Txt') |
---|
| 329 | errormsg=Data.Txt; |
---|
| 330 | return |
---|
| 331 | end |
---|
[438] | 332 | % settings for new civ data, |
---|
[360] | 333 | if strcmp(Data.Conventions,'uvmat/civdata')% case of new civ data, |
---|
[370] | 334 | set(handles.ListProgram,'Value',2) %select civ/Matlab by default |
---|
| 335 | ListProgram_Callback([],[], handles) |
---|
[355] | 336 | if ~isempty(Data.CivStage)%test for civ files |
---|
| 337 | ind_opening=Data.CivStage; |
---|
[343] | 338 | end |
---|
[371] | 339 | if ~isempty(Data.Civ2_ImageB)%get the corresponding input image in the netcdf file |
---|
| 340 | imageinput=Data.Civ2_ImageB; |
---|
| 341 | [tild,ImaName,ImaExt]=fileparts(Data.Civ2_ImageA); |
---|
| 342 | set(handles.RootFile_1,'String',[ImaName ImaExt]) |
---|
| 343 | elseif ~isempty(Data.Civ1_ImageB) |
---|
| 344 | imageinput=Data.Civ1_ImageB; |
---|
| 345 | [tild,ImaName,ImaExt]=fileparts(Data.Civ1_ImageA); |
---|
| 346 | set(handles.RootFile_1,'String',[ImaName ImaExt]) |
---|
[298] | 347 | end |
---|
[438] | 348 | % settings for civx data, |
---|
[360] | 349 | elseif ~isempty(Data.absolut_time_T0')% case of civx data, |
---|
[370] | 350 | set(handles.ListProgram,'Value',1) %select Cix by default |
---|
| 351 | ListProgram_Callback([],[], handles) |
---|
[355] | 352 | if ~isempty(Data.fix2) |
---|
| 353 | ind_opening=5; |
---|
| 354 | elseif ~isempty(Data.civ2) |
---|
| 355 | ind_opening=4; |
---|
| 356 | elseif ~isempty(Data.patch) |
---|
| 357 | ind_opening=3; |
---|
| 358 | elseif ~isempty(Data.fix) |
---|
| 359 | ind_opening=2; |
---|
| 360 | end |
---|
[360] | 361 | else |
---|
| 362 | errormsg='the input netcdf file is not civ data'; |
---|
| 363 | return |
---|
| 364 | end |
---|
[438] | 365 | % look for the corresponding input images |
---|
| 366 | check_letter=~isempty(regexp(NomTypeInput,'[ab|AB]$','once'));%detect pair label by letter |
---|
| 367 | NomTypeIma=NomTypeInput; |
---|
| 368 | if check_letter |
---|
| 369 | NomTypeIma=NomTypeInput(1:end-1); |
---|
| 370 | else |
---|
| 371 | r=regexp(NomTypeIma,'.-(?<num2>\d+)$','names'); |
---|
| 372 | if ~isempty(r) |
---|
| 373 | NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); |
---|
| 374 | end |
---|
| 375 | r=regexp(NomTypeIma,'.-(?<num2>\d+)','names'); |
---|
| 376 | if ~isempty(r) |
---|
| 377 | NomTypeIma=regexprep(NomTypeIma,['-' r.num2],''); |
---|
| 378 | end |
---|
| 379 | end |
---|
| 380 | imageinput=fullfile_uvmat(RootPath,regexprep(SubDir,'.civ(_?)(\d*)$',''),RootFile,'.png',NomTypeIma,i1,[],j1); |
---|
[360] | 381 | end |
---|
| 382 | |
---|
[371] | 383 | %no corresponding image found, select manually with the browser |
---|
[360] | 384 | ImaExt=ExtInput; |
---|
| 385 | if ~isempty(NomTypeNc) |
---|
| 386 | %no corresponding image found, select manually with the browser |
---|
| 387 | if ~exist(imageinput,'file') |
---|
| 388 | menu={'*.png;*.jpg;*.tif;*.avi;*.AVI', '(*.png,*.jpg ,*.tif, *.avi,*.AVI)'; |
---|
| 389 | '*.png','.png image files'; ... |
---|
| 390 | '*.jpg',' jpeg image files'; ... |
---|
| 391 | '*.tif','.tif image files'; ... |
---|
| 392 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 393 | '*.*', 'All Files (*.*)'}; |
---|
| 394 | [FileName, PathName] = uigetfile( menu, 'Pick an input image file',fileparts(fileparts(fileinput))); |
---|
| 395 | imageinput=[PathName FileName];%complete file name |
---|
| 396 | |
---|
| 397 | end |
---|
| 398 | fileinput=imageinput; |
---|
| 399 | end |
---|
[371] | 400 | |
---|
| 401 | %% scan the image file series |
---|
[398] | 402 | [FilePath,FileName,ImaExt]=fileparts(fileinput); |
---|
| 403 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 404 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
[438] | 405 | [RootPath,SubdirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName ImaExt]); |
---|
[398] | 406 | |
---|
[360] | 407 | switch FileType |
---|
[435] | 408 | case {'image','multimage','video','mmreader'} |
---|
[355] | 409 | otherwise |
---|
[360] | 410 | errormsg='invalid input file: enter an image, a movie or civ .nc file'; |
---|
| 411 | return |
---|
[2] | 412 | end |
---|
[371] | 413 | set(handles.RootPath,'String',RootPath) |
---|
[438] | 414 | set(handles.SubdirImages,'String',SubdirImages) |
---|
[371] | 415 | set(handles.RootFile,'String',RootFile) |
---|
[438] | 416 | if strcmp(ExtInput,'.nc') |
---|
[441] | 417 | SubDirCiv=regexprep(SubDir,[SuddirImages '^'],'');%suppress the root SuddirImages; |
---|
[438] | 418 | else |
---|
[441] | 419 | SubDirCiv= '.civ'; |
---|
[438] | 420 | end |
---|
| 421 | set(handles.SubdirCiv1,'String',SubDirCiv) |
---|
| 422 | set(handles.SubdirCiv2,'String',SubDirCiv) |
---|
[371] | 423 | browse=get(handles.RootPath,'UserData'); |
---|
[355] | 424 | browse.incr_pair=[0 0];%default |
---|
| 425 | |
---|
[360] | 426 | %% fill reference indices from the input file indices |
---|
| 427 | num_ref_i=i1;%efaulmt ref index |
---|
| 428 | if ~isempty(i2) |
---|
| 429 | num_ref_i=floor((num_ref_i+i2)/2); |
---|
| 430 | end |
---|
| 431 | num_ref_j=j1; |
---|
| 432 | if ~isempty(j2) |
---|
[362] | 433 | num_ref_j=floor((num_ref_j+j2)/2); |
---|
[360] | 434 | end |
---|
[355] | 435 | |
---|
[360] | 436 | %% scan the images if a civ file has been opened |
---|
[370] | 437 | MinIndex_i=min(i1_series(i1_series>0)); |
---|
| 438 | MinIndex_j=min(j1_series(j1_series>0)); |
---|
[360] | 439 | MaxIndex_i=max(i1_series(i1_series>0)); |
---|
| 440 | MaxIndex_j=max(j1_series(j1_series>0)); |
---|
[355] | 441 | |
---|
[298] | 442 | %% look for an image documentation file |
---|
| 443 | ext_imadoc='';%default |
---|
[441] | 444 | SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
| 445 | filexml=fullfile(RootPath,[SubDirBase '.xml']);% new convention: xml above the image dir |
---|
| 446 | if ~exist(filexml,'file') |
---|
| 447 | filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy |
---|
| 448 | end |
---|
[371] | 449 | RootName=fullfile(RootPath,RootFile); |
---|
[441] | 450 | if exist(filexml,'file') |
---|
[298] | 451 | ext_imadoc='.xml'; |
---|
[441] | 452 | elseif exist(fullfile(RootPath,SubDir,[RootFile '.civ']),'file') |
---|
[298] | 453 | ext_imadoc='.civ'; |
---|
[441] | 454 | fileciv=fullfile(RootPath,SubDir,[RootFile '.civ']); |
---|
[298] | 455 | elseif exist([RootName '.avi'],'file') |
---|
| 456 | ext_imadoc='.avi'; |
---|
| 457 | elseif exist([RootName '.AVI'],'file') |
---|
| 458 | ext_imadoc='.AVI'; |
---|
| 459 | end |
---|
| 460 | set(handles.ImaDoc,'String',ext_imadoc)% display the extension name for the image documentation file used |
---|
[343] | 461 | |
---|
| 462 | %% read the time in the image documentation file |
---|
[298] | 463 | time=[]; |
---|
[343] | 464 | TimeUnit=''; %default |
---|
| 465 | CoordUnit='';%default |
---|
[416] | 466 | pxcm_search=1; |
---|
[343] | 467 | if ~isempty(ext_imadoc) |
---|
| 468 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) % set edit box to yellow cloro to indicate that the file reading is beginning |
---|
| 469 | drawnow |
---|
| 470 | switch ext_imadoc |
---|
| 471 | case '.xml' |
---|
[441] | 472 | [XmlData,warntext]=imadoc2struct(filexml); |
---|
[343] | 473 | ext_ima_read=[]; |
---|
| 474 | nom_type_read=[]; |
---|
| 475 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
| 476 | %[PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[353] | 477 | [tild,tild,tild,tild,tild,tild,tild,tild,nom_type_read]=fileparts_uvmat(XmlData.Heading.ImageName); |
---|
[343] | 478 | fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
| 479 | if ~exist(fullname,'file') |
---|
| 480 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 481 | end |
---|
| 482 | end |
---|
| 483 | if isfield(XmlData,'Time') |
---|
| 484 | time=XmlData.Time; |
---|
| 485 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
| 486 | if isequal(MaxIndex_i,1) && ~isequal(MaxIndex_j,1)% .Time is a line vector |
---|
| 487 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once')) |
---|
| 488 | time=time'; |
---|
| 489 | MaxIndex_i=MaxIndex_j; |
---|
| 490 | MaxIndex_j=1; |
---|
| 491 | end |
---|
| 492 | end |
---|
| 493 | end |
---|
| 494 | if isfield(XmlData,'TimeUnit') |
---|
| 495 | TimeUnit=XmlData.TimeUnit; |
---|
| 496 | end |
---|
[416] | 497 | |
---|
[343] | 498 | if isfield(XmlData,'GeometryCalib') |
---|
| 499 | tsai=XmlData.GeometryCalib; |
---|
[415] | 500 | if isfield(tsai,'fx_fy') |
---|
| 501 | pxcm_search=max(tsai.fx_fy(1),tsai.fx_fy(2));%pixels:cm estimated for the search range |
---|
[343] | 502 | end |
---|
| 503 | if isfield(tsai,'CoordUnit') |
---|
| 504 | CoordUnit=tsai.CoordUnit; |
---|
| 505 | end |
---|
| 506 | end |
---|
| 507 | case '.civ'% OBSOLETE: case of .civ image documentation file |
---|
[441] | 508 | [error,time,TimeUnit,mode,npx,npy]=read_imatext(fileciv); |
---|
| 509 | if error==2, msgbox_uvmat('WARNING',['no file ' fileciv]); |
---|
[343] | 510 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
| 511 | end |
---|
| 512 | nom_type_ima='001a'; |
---|
| 513 | case {'.avi','.AVI'} |
---|
| 514 | nom_type_ima='*'; |
---|
[360] | 515 | ImaExt=ext_imadoc; |
---|
[343] | 516 | set(handles.ListPairMode,'Value',1); |
---|
| 517 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
| 518 | dt=0.04;%default |
---|
| 519 | if exist([RootName ext_imadoc],'file')==2 |
---|
[397] | 520 | hhh=which('videoreader'); |
---|
| 521 | if isempty(hhh)%use old video function of matlab |
---|
[441] | 522 | imainfo=aviinfo([RootName ext_imadoc]);%read infos on the avi movie TO REPLACE mmreader |
---|
[397] | 523 | dt=1/imainfo.FramesPerSecond;%time interval between successive frames |
---|
| 524 | MaxIndex_i=imainfo.NumFrames;%number of frames |
---|
| 525 | % XmlData.Time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)'; |
---|
| 526 | % nbfield=imainfo.NumFrames; |
---|
| 527 | % set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FramesPerSecond) 'ms']);%display the elementary time interval in millisec |
---|
| 528 | % ColorType=imainfo.ImageType;%='truecolor' for color images |
---|
| 529 | else %use video function videoreader of matlab |
---|
| 530 | imainfo=get(videoreader([RootName ext_imadoc]));%read infos on the avi movie |
---|
| 531 | dt=1/imainfo.FrameRate;%time interval between successive frames |
---|
| 532 | MaxIndex_i=imainfo.NumberOfFrames;%number of frames |
---|
| 533 | % XmlData.Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)'; |
---|
| 534 | % nbfield=imainfo.NumberOfFrames; |
---|
| 535 | % set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
| 536 | % ColorType='truecolor'; |
---|
| 537 | end |
---|
| 538 | |
---|
| 539 | time=(dt*(0:MaxIndex_i-1))';%list of image times |
---|
| 540 | TimeUnit='s'; |
---|
[343] | 541 | end |
---|
[397] | 542 | set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter |
---|
[84] | 543 | end |
---|
[2] | 544 | end |
---|
[298] | 545 | %% timing display |
---|
| 546 | %show the reference image edit box if relevant (not needed for movies or in the absence of time information |
---|
[343] | 547 | if numel(time)>=2 % if there are at least two time values to define dt |
---|
| 548 | MaxIndex_i=min(size(time,1),MaxIndex_i); |
---|
| 549 | MaxIndex_j=min(size(time,2),MaxIndex_j); |
---|
| 550 | time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices) |
---|
| 551 | time=[zeros(1,size(time,2)); time]; %insert a horizontal line of zeros |
---|
| 552 | set(handles.ImaDoc,'UserData',time); %store the matrix of times |
---|
| 553 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
| 554 | set(handles.TimeUnit,'String',TimeUnit); |
---|
| 555 | else |
---|
| 556 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 557 | time=(i1_series(:,1)+0:size(i1_series,1)-1);% time=index i |
---|
| 558 | time=time'*ones(1,size(i1_series,2),1); %makes a time matrix with the same time for all j indices |
---|
| 559 | TimeUnit='frame'; |
---|
[2] | 560 | end |
---|
[343] | 561 | set(handles.ImaDoc,'UserData',time); %store the matrix of times |
---|
| 562 | set(handles.dt_unit,'String',['dt in m' TimeUnit]);%display dt in unit 10-3 of the time (e.g ms) |
---|
| 563 | set(handles.TimeUnit,'String',TimeUnit); |
---|
| 564 | set(handles.nb_field,'String',num2str(MaxIndex_i)); |
---|
| 565 | set(handles.nb_field2,'String',num2str(MaxIndex_j)); |
---|
[71] | 566 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[415] | 567 | set(handles.SearchRange,'UserData', pxcm_search); |
---|
[360] | 568 | set(handles.ImaExt,'String',ImaExt) |
---|
| 569 | set(handles.NomType,'String',NomTypeIma) |
---|
[298] | 570 | set(handles.ref_i,'String',num2str(num_ref_i)) |
---|
[370] | 571 | set(handles.ref_j,'String',num2str(num_ref_j)) |
---|
| 572 | |
---|
| 573 | %% update i and j index range if a nc file has been opened or pb withmin max image indices: |
---|
| 574 | % then set first and last to the inputfile index by default |
---|
| 575 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 576 | last_i=str2num(get(handles.last_i,'String')); |
---|
[371] | 577 | if isempty(first_i) || isempty(last_i)||isempty(MinIndex_i)||isempty(MaxIndex_i) |
---|
| 578 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 579 | set(handles.last_i,'String',num2str(num_ref_i));% |
---|
| 580 | end |
---|
| 581 | if ind_opening~=0 || isempty(first_i) || isempty(last_i)|| first_i<MinIndex_i || last_i>MaxIndex_i |
---|
[438] | 582 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 583 | set(handles.last_i,'String',num2str(num_ref_i));% |
---|
[370] | 584 | end |
---|
| 585 | |
---|
| 586 | %j index range |
---|
| 587 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 588 | last_j=str2num(get(handles.last_i,'String')); |
---|
[371] | 589 | if isempty(first_j) || isempty(last_j)||isempty(MinIndex_j)||isempty(MaxIndex_j) |
---|
| 590 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 591 | set(handles.last_j,'String',num2str(num_ref_j));% |
---|
| 592 | elseif ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j |
---|
| 593 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
[298] | 594 | set(handles.last_j,'String',num2str(num_ref_j));% |
---|
[370] | 595 | end |
---|
[2] | 596 | |
---|
[370] | 597 | %% set the civ options depending on the input file content when a nc file has been opened |
---|
[371] | 598 | ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; |
---|
[370] | 599 | if ind_opening~=0 |
---|
| 600 | for index = 1:ind_opening |
---|
| 601 | set(handles.(ListOptions{index}),'value',0) |
---|
| 602 | end |
---|
[298] | 603 | end |
---|
[371] | 604 | for index = ind_opening+2:6 |
---|
| 605 | set(handles.(ListOptions{index}),'value',0) |
---|
| 606 | end |
---|
[364] | 607 | set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1) |
---|
[438] | 608 | update_CivOptions(handles,ind_opening) |
---|
[298] | 609 | |
---|
[273] | 610 | %% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[362] | 611 | %check_letter=~isempty(regexp(NomTypeIma,'[ab|AB]$'));%detect pair label by letter |
---|
[371] | 612 | if isequal(NomTypeNc,'_1-2')||isempty(MaxIndex_j)|| (MaxIndex_j==1) |
---|
[282] | 613 | set(handles.ListPairMode,'Value',1) |
---|
| 614 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
[353] | 615 | elseif MaxIndex_i==1 && MaxIndex_j>1% simple series in j |
---|
[343] | 616 | set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)'}) |
---|
| 617 | if MaxIndex_j <= 10 |
---|
| 618 | set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large |
---|
| 619 | end |
---|
[2] | 620 | else |
---|
[282] | 621 | set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[360] | 622 | if strcmp(NomTypeNc,'_1-2_1') |
---|
| 623 | set(handles.ListPairMode,'Value',3)% advise 'series(Di)' |
---|
| 624 | elseif MaxIndex_j <= 10 |
---|
[343] | 625 | set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large |
---|
[2] | 626 | end |
---|
| 627 | end |
---|
| 628 | |
---|
[368] | 629 | %% scan files to update the subdirectory list display |
---|
[300] | 630 | listot=dir(RootPath);%directory of RootPath |
---|
[273] | 631 | idir=0; |
---|
| 632 | listdir={''};%default |
---|
[300] | 633 | % get the list of existing civ subdirectories in the path of theinput root file |
---|
[273] | 634 | for ilist=1:length(listot) |
---|
| 635 | if listot(ilist).isdir |
---|
| 636 | name=listot(ilist).name; |
---|
| 637 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 638 | idir=idir+1; |
---|
| 639 | listdir{idir,1}=listot(ilist).name; |
---|
| 640 | end |
---|
| 641 | end |
---|
| 642 | end |
---|
[368] | 643 | |
---|
[300] | 644 | %% store info |
---|
[371] | 645 | set(handles.RootPath,'UserData',browse)% store the nomenclature type |
---|
[273] | 646 | |
---|
[298] | 647 | %% list the possible index pairs, depending on the option set in ListPairMode |
---|
| 648 | ListPairMode_Callback([], [], handles) |
---|
| 649 | |
---|
| 650 | %% store the root input filename for future opening |
---|
| 651 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 652 | if exist(profil_perso,'file') |
---|
| 653 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 654 | else |
---|
| 655 | txt=ver('MATLAB'); |
---|
| 656 | Release=txt.Release; |
---|
| 657 | relnumb=str2double(Release(3:4)); |
---|
| 658 | if relnumb >= 14 |
---|
| 659 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
| 660 | else |
---|
| 661 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 662 | end |
---|
| 663 | end |
---|
[371] | 664 | set(handles.RootPath,'BackgroundColor',[1 1 1]) |
---|
[298] | 665 | |
---|
[12] | 666 | %------------------------------------------------------------------------ |
---|
[309] | 667 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
[363] | 668 | function SubdirCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 669 | %------------------------------------------------------------------------ |
---|
[363] | 670 | SubDir=get(handles.SubdirCiv1,'String'); |
---|
[309] | 671 | menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update |
---|
[343] | 672 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
[309] | 673 | if isempty(ichoice) |
---|
| 674 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
[2] | 675 | else |
---|
[309] | 676 | ilist=ichoice; |
---|
[2] | 677 | end |
---|
[309] | 678 | set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu |
---|
| 679 | if get(handles.CheckCiv1,'Value')% if Civ1 is performed |
---|
[363] | 680 | set(handles.SubdirCiv2,'String',SubDir);% set by default civ2 directory the same as civ1 |
---|
[441] | 681 | % set(handles.ListSubdirCiv2,'Value',ilist) |
---|
[309] | 682 | else % if Civ1 data already exist |
---|
[362] | 683 | errormsg=find_netcpair_civ(handles,1); %update the list of available pairs from netcdf files in the new directory |
---|
| 684 | if ~isempty(errormsg) |
---|
| 685 | msgbox_uvmat('ERROR',errormsg) |
---|
| 686 | end |
---|
[112] | 687 | end |
---|
[2] | 688 | |
---|
[12] | 689 | %------------------------------------------------------------------------ |
---|
[343] | 690 | % --- Executes on carriage return on the SubDir checkciv1 edit window |
---|
[363] | 691 | function SubdirCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 692 | %------------------------------------------------------------------------ |
---|
[363] | 693 | SubDir=get(handles.SubdirCiv1,'String'); |
---|
[309] | 694 | menu_str=get(handles.ListSubdirCiv2,'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.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu |
---|
| 702 | %update the list of available pairs from netcdf files in the new directory |
---|
| 703 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
[362] | 704 | errormsg=find_netcpair_civ(handles,2); |
---|
| 705 | if ~isempty(errormsg) |
---|
| 706 | msgbox_uvmat('ERROR',errormsg) |
---|
| 707 | end |
---|
[2] | 708 | end |
---|
| 709 | |
---|
[309] | 710 | %------------------------------------------------------------------------ |
---|
| 711 | % --- Executes on button press in CheckCiv1. |
---|
| 712 | function CheckCiv1_Callback(hObject, eventdata, handles) |
---|
| 713 | %------------------------------------------------------------------------ |
---|
[343] | 714 | update_CivOptions(handles,0) |
---|
[2] | 715 | |
---|
[309] | 716 | %------------------------------------------------------------------------ |
---|
| 717 | % --- Executes on button press in CheckFix1. |
---|
| 718 | function CheckFix1_Callback(hObject, eventdata, handles) |
---|
| 719 | %------------------------------------------------------------------------ |
---|
[343] | 720 | update_CivOptions(handles,0) |
---|
[2] | 721 | |
---|
[309] | 722 | %------------------------------------------------------------------------ |
---|
| 723 | % --- Executes on button press in CheckPatch1. |
---|
| 724 | function CheckPatch1_Callback(hObject, eventdata, handles) |
---|
| 725 | %------------------------------------------------------------------------ |
---|
[343] | 726 | update_CivOptions(handles,0) |
---|
[2] | 727 | |
---|
[309] | 728 | %------------------------------------------------------------------------ |
---|
| 729 | % --- Executes on button press in CheckCiv2. |
---|
| 730 | function CheckCiv2_Callback(hObject, eventdata, handles) |
---|
| 731 | %------------------------------------------------------------------------ |
---|
[343] | 732 | update_CivOptions(handles,0) |
---|
[301] | 733 | |
---|
[309] | 734 | %------------------------------------------------------------------------ |
---|
| 735 | % --- Executes on button press in CheckFix2. |
---|
| 736 | function CheckFix2_Callback(hObject, eventdata, handles) |
---|
| 737 | %------------------------------------------------------------------------ |
---|
[343] | 738 | update_CivOptions(handles,0) |
---|
[301] | 739 | |
---|
[309] | 740 | %------------------------------------------------------------------------ |
---|
| 741 | % --- Executes on button press in CheckPatch2. |
---|
| 742 | function CheckPatch2_Callback(hObject, eventdata, handles) |
---|
| 743 | %------------------------------------------------------------------------ |
---|
[343] | 744 | update_CivOptions(handles,0) |
---|
[300] | 745 | |
---|
[12] | 746 | %------------------------------------------------------------------------ |
---|
[309] | 747 | % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 |
---|
[343] | 748 | function update_CivOptions(handles,opening) |
---|
[12] | 749 | %------------------------------------------------------------------------ |
---|
[309] | 750 | checkbox=zeros(1,6); |
---|
| 751 | checkbox(1)=get(handles.CheckCiv1,'Value'); |
---|
| 752 | checkbox(2)=get(handles.CheckFix1,'Value'); |
---|
| 753 | checkbox(3)=get(handles.CheckPatch1,'Value'); |
---|
| 754 | checkbox(4)=get(handles.CheckCiv2,'Value'); |
---|
| 755 | checkbox(5)=get(handles.CheckFix2,'Value'); |
---|
| 756 | checkbox(6)=get(handles.CheckPatch2,'Value'); |
---|
| 757 | ind_selected=find(checkbox,1); |
---|
| 758 | if ~isempty(ind_selected) |
---|
[371] | 759 | RootPath=get(handles.RootPath,'String'); |
---|
| 760 | if isempty(RootPath) |
---|
[362] | 761 | msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...') |
---|
| 762 | return |
---|
[270] | 763 | end |
---|
[2] | 764 | end |
---|
[309] | 765 | set(handles.PairIndices,'Visible','on') |
---|
[363] | 766 | set(handles.SubdirCiv1,'Visible','on') |
---|
[371] | 767 | set(handles.TitleSubdirCiv1,'Visible','on') |
---|
[440] | 768 | if opening==0 |
---|
[362] | 769 | errormsg=find_netcpair_civ(handles,1); % select the available netcdf files |
---|
| 770 | if ~isempty(errormsg) |
---|
| 771 | msgbox_uvmat('ERROR',errormsg) |
---|
| 772 | end |
---|
[343] | 773 | end |
---|
[309] | 774 | if max(checkbox(4:6))% case of civ2 pair choice needed |
---|
| 775 | set(handles.TitlePairCiv2,'Visible','on') |
---|
| 776 | set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[363] | 777 | set(handles.SubdirCiv2,'Visible','on') |
---|
[437] | 778 | %set(handles.ListSubdirCiv2,'Visible','on') |
---|
[309] | 779 | set(handles.ListPairCiv2,'Visible','on') |
---|
[343] | 780 | if ~opening |
---|
[362] | 781 | errormsg=find_netcpair_civ(handles,2); % select the available netcdf files |
---|
| 782 | if ~isempty(errormsg) |
---|
| 783 | msgbox_uvmat('ERROR',errormsg) |
---|
| 784 | end |
---|
[343] | 785 | end |
---|
[309] | 786 | else |
---|
| 787 | set(handles.TitleSubdirCiv2,'Visible','off') |
---|
[363] | 788 | set(handles.SubdirCiv2,'Visible','off') |
---|
[309] | 789 | set(handles.ListPairCiv2,'Visible','off') |
---|
[2] | 790 | end |
---|
[309] | 791 | options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
| 792 | for ilist=1:length(options) |
---|
| 793 | if checkbox(ilist) |
---|
| 794 | set(handles.(options{ilist}),'Visible','on') |
---|
[2] | 795 | else |
---|
[309] | 796 | set(handles.(options{ilist}),'Visible','off') |
---|
[112] | 797 | end |
---|
[2] | 798 | end |
---|
| 799 | |
---|
[12] | 800 | %------------------------------------------------------------------------ |
---|
[177] | 801 | % --- Executes on button press in RUN: processing on local computer |
---|
[67] | 802 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 803 | %------------------------------------------------------------------------ |
---|
[73] | 804 | set(handles.RUN, 'Enable','Off') |
---|
| 805 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 806 | batch=0; |
---|
[229] | 807 | errormsg=launch_jobs(hObject, eventdata, handles,batch); |
---|
[73] | 808 | set(handles.RUN, 'Enable','On') |
---|
| 809 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 810 | |
---|
[371] | 811 | % display errors or start status callback to visualise results |
---|
[229] | 812 | if ~isempty(errormsg) |
---|
| 813 | display(errormsg) |
---|
| 814 | msgbox_uvmat('ERROR',errormsg) |
---|
[282] | 815 | elseif isfield(handles,'status') %&& ~isequal(get(handles.ListPairMode,'Value'),3) |
---|
[225] | 816 | set(handles.status,'Value',1);%suppress status display |
---|
| 817 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 818 | end |
---|
[177] | 819 | |
---|
[12] | 820 | %------------------------------------------------------------------------ |
---|
[2] | 821 | % --- Executes on button press in BATCH: remote processing |
---|
| 822 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[177] | 823 | % ----------------------------------------------------------------------- |
---|
[73] | 824 | set(handles.BATCH, 'Enable','Off') |
---|
| 825 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 826 | batch=1; |
---|
[229] | 827 | errormsg=launch_jobs(hObject, eventdata, handles, batch); |
---|
[73] | 828 | set(handles.BATCH, 'Enable','On') |
---|
| 829 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[67] | 830 | |
---|
[371] | 831 | % display errors or start status callback to visualise results |
---|
[229] | 832 | if ~isempty(errormsg) |
---|
| 833 | display(errormsg) |
---|
| 834 | msgbox_uvmat('ERROR',errormsg) |
---|
| 835 | elseif isfield(handles,'status') |
---|
| 836 | set(handles.status,'Value',1);%suppress status display |
---|
| 837 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 838 | end |
---|
[227] | 839 | |
---|
[309] | 840 | %------------------------------------------------------------------- |
---|
| 841 | % --- Executes on button press in status. |
---|
| 842 | function status_Callback(hObject, eventdata, handles) |
---|
| 843 | %------------------------------------------------------------------- |
---|
| 844 | val=get(handles.status,'Value'); |
---|
| 845 | if val==0 |
---|
| 846 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
| 847 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 848 | if ~isempty(hfig) |
---|
| 849 | delete(hfig) |
---|
| 850 | end |
---|
| 851 | return |
---|
| 852 | end |
---|
| 853 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
| 854 | drawnow |
---|
| 855 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 856 | Param.CheckCiv1=get(handles.CheckCiv1,'Value'); |
---|
| 857 | Param.CheckFix1=get(handles.CheckFix1,'Value'); |
---|
| 858 | Param.CheckPatch1=get(handles.CheckPatch1,'Value'); |
---|
| 859 | Param.CheckCiv2=get(handles.CheckCiv2,'Value'); |
---|
| 860 | Param.CheckFix2=get(handles.CheckFix2,'Value'); |
---|
| 861 | Param.CheckPatch2=get(handles.CheckPatch2,'Value'); |
---|
| 862 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
| 863 | |
---|
| 864 | option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) |
---|
| 865 | filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV |
---|
| 866 | test_new=0; |
---|
| 867 | if ~isfield(filecell,'nc') |
---|
| 868 | test_new=1; |
---|
| 869 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 870 | if ~isempty(errormsg) |
---|
| 871 | msgbox_uvmat('ERROR',errormsg) |
---|
| 872 | return |
---|
| 873 | end |
---|
| 874 | filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status |
---|
| 875 | end |
---|
| 876 | if ~isequal(box_test(4:6),[0 0 0]) |
---|
| 877 | civ_files=filecell.nc.civ2;%case of civ2 operations |
---|
| 878 | else |
---|
| 879 | civ_files=filecell.nc.civ1; |
---|
| 880 | end |
---|
| 881 | [root,filename,ext]=fileparts(civ_files{1}); |
---|
[343] | 882 | [rootroot,SubDir,extdir]=fileparts(root); |
---|
[309] | 883 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 884 | if isempty(hfig) |
---|
| 885 | hfig=figure('DeleteFcn',@stop_status); |
---|
[421] | 886 | set(hfig,'MenuBar','none')% suppress the menu bar |
---|
| 887 | set(hfig,'NumberTitle','off')%suppress the fig number in the title |
---|
[309] | 888 | set(hfig,'name','civ_status') |
---|
[421] | 889 | set(hfig,'tag','civ_status') |
---|
| 890 | set(hfig,'UserData',civ_files) |
---|
| 891 | hlist= uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list'); |
---|
[309] | 892 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); |
---|
| 893 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
[421] | 894 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI); |
---|
| 895 | hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@refresh_GUI); |
---|
[309] | 896 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
[421] | 897 | uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
| 898 | drawnow |
---|
[309] | 899 | end |
---|
[421] | 900 | set(hrefresh,'UserData',option_civ) |
---|
| 901 | filepath=fileparts(civ_files{1}); |
---|
| 902 | set(hlist,'UserData',fileparts(filepath)) |
---|
| 903 | refresh_GUI(hrefresh,[]) |
---|
| 904 | |
---|
| 905 | %------------------------------------------------------------------------ |
---|
| 906 | % launched by refreshing the status figure |
---|
| 907 | function refresh_GUI(hObject, eventdata) |
---|
| 908 | %------------------------------------------------------------------------ |
---|
[309] | 909 | Tabchar={}; |
---|
[421] | 910 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
| 911 | hfig=get(hObject,'parent'); |
---|
| 912 | civ_files=get(hfig,'UserData'); |
---|
| 913 | [filepath,filename,ext]=fileparts(civ_files{1}); |
---|
| 914 | [tild,SubDir,extdir]=fileparts(filepath); |
---|
| 915 | SubDir=[SubDir extdir]; |
---|
| 916 | option_civ=get(hObject,'UserData'); |
---|
[309] | 917 | nbfiles=numel(civ_files); |
---|
| 918 | count=0; |
---|
| 919 | testrecent=0; |
---|
[421] | 920 | % while count<nbfiles |
---|
[309] | 921 | count=0; |
---|
| 922 | datnum=zeros(1,nbfiles); |
---|
| 923 | for ifile=1:nbfiles |
---|
| 924 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
| 925 | option=0; |
---|
| 926 | if detect==0 |
---|
| 927 | option_str='not created'; |
---|
| 928 | else |
---|
| 929 | datfile=dir(civ_files{ifile}); |
---|
| 930 | if isfield(datfile,'datenum') |
---|
| 931 | datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
| 932 | testrecent=1; |
---|
| 933 | end |
---|
| 934 | filefound(ifile)={datfile.name}; |
---|
| 935 | lastfield=''; |
---|
| 936 | % check the content netcdf file |
---|
[316] | 937 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix'); |
---|
| 938 | option_list={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 939 | if ~isempty(Data.CivStage) |
---|
[371] | 940 | option=Data.CivStage;%case of Matlab civ |
---|
[309] | 941 | else |
---|
[316] | 942 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
| 943 | option=6; |
---|
| 944 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
| 945 | option=5; |
---|
| 946 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
| 947 | option=4; |
---|
| 948 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
| 949 | option=3; |
---|
| 950 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
| 951 | option=2; |
---|
| 952 | else |
---|
| 953 | option=1; |
---|
| 954 | end |
---|
[309] | 955 | end |
---|
[316] | 956 | option_str=option_list{option}; |
---|
[309] | 957 | end |
---|
| 958 | if option >= option_civ |
---|
| 959 | count=count+1; |
---|
| 960 | end |
---|
[421] | 961 | [filepath,filename,ext]=fileparts(civ_files{ifile}); |
---|
| 962 | Tabchar{ifile,1}=[fullfile(SubDir,filename) ext '...' option_str]; |
---|
[309] | 963 | end |
---|
| 964 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
| 965 | if isempty(datnum) |
---|
| 966 | if testrecent |
---|
| 967 | message='no civ result created yet'; |
---|
| 968 | else |
---|
| 969 | message=''; |
---|
| 970 | end |
---|
| 971 | else |
---|
| 972 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
| 973 | [first,ind]=min(datnum); |
---|
| 974 | [last,indlast]=max(datnum); |
---|
[421] | 975 | % if test_new |
---|
| 976 | % message='existing file status, no processing launched yet'; |
---|
| 977 | % else |
---|
[309] | 978 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
| 979 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
[421] | 980 | % end |
---|
[309] | 981 | end |
---|
[421] | 982 | %hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 983 | % if isempty(hfig)% the status list has been deleted |
---|
| 984 | % return |
---|
| 985 | % else |
---|
[309] | 986 | hlist=findobj(hfig,'tag','list'); |
---|
| 987 | hmsgbox=findobj(hfig,'tag','msgbox'); |
---|
| 988 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
| 989 | set(hlist,'String',Tabchar) |
---|
| 990 | set(hmsgbox,'String', message) |
---|
[421] | 991 | if count>0 %&& ~test_new |
---|
[309] | 992 | BarPosition(3)=0.9*count/nbfiles; |
---|
| 993 | set(hwaitbar,'Position',BarPosition) |
---|
| 994 | end |
---|
[421] | 995 | % end |
---|
| 996 | % [root,filename,ext]=fileparts(civ_files{1}); |
---|
| 997 | % [rootroot,SubDir,extdir]=fileparts(root); |
---|
| 998 | % |
---|
| 999 | % set(hlist,'UserData',rootroot) |
---|
| 1000 | % if count<10||(nbfiles-count)<10 |
---|
| 1001 | % pause(.5)% wait 0.5 seconds for next check |
---|
| 1002 | % else |
---|
| 1003 | % pause(10)% wait 10 seconds for next check |
---|
| 1004 | % end |
---|
| 1005 | % end |
---|
[309] | 1006 | |
---|
[421] | 1007 | %------------------------------------------------------------------------ |
---|
| 1008 | % launched by deleting the status figure |
---|
| 1009 | function stop_status(hObject, eventdata) |
---|
[67] | 1010 | %------------------------------------------------------------------------ |
---|
[421] | 1011 | hciv=findobj(allchild(0),'tag','civ'); |
---|
| 1012 | hhciv=guidata(hciv); |
---|
| 1013 | set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ |
---|
| 1014 | set(hhciv.status,'BackgroundColor',[0 1 0]) |
---|
| 1015 | |
---|
| 1016 | %------------------------------------------------------------------------ |
---|
| 1017 | % launched by pressing OK on the status figure |
---|
| 1018 | function close_GUI(hObject, eventdata) |
---|
| 1019 | %------------------------------------------------------------------------ |
---|
| 1020 | delete(gcbf) |
---|
| 1021 | |
---|
| 1022 | |
---|
[446] | 1023 | %------------------------------------------------------------------------ |
---|
[309] | 1024 | % --- Main lauch command, called by RUN and BATCH |
---|
[229] | 1025 | function errormsg=launch_jobs(hObject, eventdata, handles, batch) |
---|
[446] | 1026 | %------------------------------------------------------------------------ |
---|
[229] | 1027 | errormsg='';%default |
---|
[313] | 1028 | |
---|
| 1029 | %% read the input parameters from the GUI civ |
---|
[309] | 1030 | Param=read_GUI(handles.civ); |
---|
[272] | 1031 | |
---|
[133] | 1032 | %% check the selected list of operations: |
---|
[289] | 1033 | operations={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
[282] | 1034 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
[180] | 1035 | index_first=find(box_test==1,1); |
---|
| 1036 | if isempty(index_first) |
---|
[229] | 1037 | errormsg='no selected operation'; |
---|
[2] | 1038 | return |
---|
| 1039 | end |
---|
[180] | 1040 | index_last=find(box_test==1,1,'last'); |
---|
[159] | 1041 | box_used=box_test(index_first : index_last); |
---|
[2] | 1042 | [box_missing,ind_missing]=min(box_used); |
---|
[180] | 1043 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
[229] | 1044 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
[2] | 1045 | return |
---|
| 1046 | end |
---|
| 1047 | |
---|
[272] | 1048 | %% check mask if selecetd |
---|
| 1049 | %could be included in get_mask callback ? |
---|
[282] | 1050 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[384] | 1051 | maskname=get(handles.Mask,'String'); |
---|
[12] | 1052 | if ~exist(maskname,'file') |
---|
| 1053 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1054 | end |
---|
[2] | 1055 | end |
---|
[282] | 1056 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[384] | 1057 | maskname=get(handles.Mask,'String'); |
---|
[12] | 1058 | if ~exist(maskname,'file') |
---|
| 1059 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1060 | end |
---|
[2] | 1061 | end |
---|
[282] | 1062 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[384] | 1063 | maskname=get(handles.Mask,'String'); |
---|
[12] | 1064 | if ~exist(maskname,'file') |
---|
[112] | 1065 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1066 | end |
---|
[2] | 1067 | end |
---|
[282] | 1068 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[384] | 1069 | maskname=get(handles.Mask,'String'); |
---|
[12] | 1070 | if ~exist(maskname,'file') |
---|
[112] | 1071 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1072 | end |
---|
[2] | 1073 | end |
---|
| 1074 | |
---|
[177] | 1075 | %% reinitialise status callback |
---|
[178] | 1076 | if isfield(handles,'status') |
---|
[180] | 1077 | set(handles.status,'Value',0);%suppress status display |
---|
[446] | 1078 | status_Callback([], [], handles) |
---|
[178] | 1079 | end |
---|
[133] | 1080 | |
---|
[272] | 1081 | %% read the PARAM.xml file to get the binaries (and batch_mode if batch) |
---|
[276] | 1082 | path_civ=fileparts(which('civ')); %path to the source directory of uvmat |
---|
[112] | 1083 | xmlfile='PARAM.xml'; |
---|
[133] | 1084 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
[54] | 1085 | t=xmltree(xmlfile); |
---|
[67] | 1086 | s=convert(t); |
---|
[272] | 1087 | else |
---|
| 1088 | errormsg=['no file ' xmlfile]; |
---|
| 1089 | return |
---|
[2] | 1090 | end |
---|
[272] | 1091 | test_interp=0; %eviter les variables test_ (LG) |
---|
[127] | 1092 | if batch |
---|
[67] | 1093 | if isfield(s,'BatchParam') |
---|
[284] | 1094 | Param.xml=s.BatchParam; |
---|
| 1095 | if isfield(Param.xml,'BatchMode') |
---|
| 1096 | batch_mode=Param.xml.BatchMode; |
---|
[257] | 1097 | if ~ismember(batch_mode,{'sge','oar'}) |
---|
| 1098 | errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; |
---|
| 1099 | return |
---|
| 1100 | end |
---|
[67] | 1101 | end |
---|
| 1102 | else |
---|
[229] | 1103 | errormsg='no batch civ binaries defined in PARAM.xml'; |
---|
[67] | 1104 | return |
---|
| 1105 | end |
---|
[257] | 1106 | else % run |
---|
[67] | 1107 | if isfield(s,'RunParam') |
---|
[284] | 1108 | Param.xml=s.RunParam; |
---|
[67] | 1109 | else |
---|
[387] | 1110 | errormsg='no run civ binaries defined in PARAM.xml'; |
---|
[67] | 1111 | return |
---|
| 1112 | end |
---|
[225] | 1113 | end |
---|
[238] | 1114 | |
---|
[272] | 1115 | %% check batch mode supported |
---|
| 1116 | if batch |
---|
| 1117 | switch batch_mode |
---|
| 1118 | case 'sge' |
---|
| 1119 | test_command='qstat'; |
---|
| 1120 | case 'oar' |
---|
[290] | 1121 | test_command='oarstat'; |
---|
[272] | 1122 | end |
---|
| 1123 | [s,w]=system(test_command); |
---|
| 1124 | if ~isequal(s,0) |
---|
[387] | 1125 | errormsg=[batch_mode ' batch system not available']; |
---|
[272] | 1126 | return |
---|
| 1127 | end |
---|
| 1128 | end |
---|
| 1129 | |
---|
| 1130 | %% check if the binaries exist |
---|
[370] | 1131 | ListProgram=get(handles.ListProgram,'String'); |
---|
[465] | 1132 | Param.CivMode=ListProgram{get(handles.ListProgram,'Value')}; |
---|
[280] | 1133 | binary_list={}; |
---|
[465] | 1134 | switch Param.CivMode |
---|
[280] | 1135 | case 'CivX' |
---|
| 1136 | binary_list={'Civ1Bin','Civ2Bin','PatchBin','FixBin'}; |
---|
[371] | 1137 | case 'CivAll'% desactivated option |
---|
[289] | 1138 | binary_list={'Civ'}; |
---|
[257] | 1139 | case 'Matlab' |
---|
| 1140 | if batch |
---|
[426] | 1141 | binary_list={'CivmBin'}; |
---|
[371] | 1142 | % verifier MenuMatlab installe sur le cluster |
---|
[272] | 1143 | % difficile a faire a priori |
---|
[257] | 1144 | end |
---|
[225] | 1145 | end |
---|
[309] | 1146 | for bin_name=binary_list %loop on the list of binaries |
---|
| 1147 | if isfield(Param.xml,bin_name{1})% bin_name{1} =current name in the list |
---|
[421] | 1148 | if exist(Param.xml.(bin_name{1}),'file') |
---|
| 1149 | [path,name,ext]=fileparts(Param.xml.(bin_name{1})); |
---|
| 1150 | currentdir=pwd; |
---|
| 1151 | if exist(path,'dir') |
---|
| 1152 | cd(path); |
---|
| 1153 | binpath=pwd;%path of the binary |
---|
| 1154 | Param.xml.(bin_name{1})=fullfile(binpath,[name ext]); |
---|
| 1155 | cd(currentdir) |
---|
| 1156 | else |
---|
| 1157 | errormsg=['path ' path ' for binaries defined in PARAM.xml does not exist']; |
---|
| 1158 | return |
---|
| 1159 | end |
---|
[465] | 1160 | |
---|
[421] | 1161 | else %look for the full path if the file name has been defined with a relative path in PARAM.xm |
---|
[289] | 1162 | fullname=fullfile(path_civ,Param.xml.(bin_name{1})); |
---|
[280] | 1163 | if exist(fullname,'file') |
---|
[284] | 1164 | Param.xml.(bin_name{1})=fullname; |
---|
[280] | 1165 | else |
---|
[387] | 1166 | errormsg=['Binary ' Param.xml.(bin_name{1}) ' defined in PARAM.xml does not exist']; |
---|
[280] | 1167 | return |
---|
| 1168 | end |
---|
| 1169 | end |
---|
| 1170 | end |
---|
| 1171 | end |
---|
[272] | 1172 | display('files OK, processing...') |
---|
[2] | 1173 | |
---|
[313] | 1174 | %% set the list of files and check them |
---|
| 1175 | display('checking the files...') |
---|
| 1176 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 1177 | if ~isempty(errormsg) |
---|
| 1178 | return |
---|
| 1179 | end |
---|
[437] | 1180 | [filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,nom_type_nc,tild,tild,compare,errormsg]=... |
---|
[313] | 1181 | set_civ_filenames(handles,ref_i,ref_j,box_test); |
---|
[437] | 1182 | if ~isempty(errormsg) |
---|
| 1183 | return |
---|
| 1184 | end |
---|
[313] | 1185 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
[465] | 1186 | |
---|
| 1187 | |
---|
| 1188 | %% create subfolders for log, cmx, nml, xml, bat |
---|
| 1189 | RootBat=fileparts(filecell.nc.civ1{1,1}) |
---|
| 1190 | dir_list={'0_BAT','0_CMX','0_XML','0_LOG',} |
---|
| 1191 | for k=1:length(dir_list) |
---|
| 1192 | if ~exist(fullfile(RootBat,dir_list{k}),'dir') |
---|
| 1193 | mkdir(fullfile(RootBat,dir_list{k})); |
---|
| 1194 | end |
---|
| 1195 | end |
---|
| 1196 | |
---|
| 1197 | |
---|
| 1198 | %% PARTIE A VERIFIER |
---|
| 1199 | %output netcdf file (without extention) Joel what does this mean ? |
---|
[313] | 1200 | nbfield=numel(i1_civ1); |
---|
| 1201 | nbslice=numel(j1_civ1); |
---|
[465] | 1202 | if ~strcmp(Param.CivMode,'CivX') |
---|
[389] | 1203 | if Param.CheckCiv1 |
---|
[435] | 1204 | [Param.Civ1.FileTypeA,FileInfo,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1}); |
---|
| 1205 | [Param.Civ1.FileTypeB,FileInfo,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1}); |
---|
[389] | 1206 | end |
---|
| 1207 | if Param.CheckCiv2 |
---|
[435] | 1208 | [Param.Civ2.FileTypeA,FileInfo,Param.Civ2.ImageA]=get_file_type(filecell.ima1.civ2{1}); |
---|
| 1209 | [Param.Civ2.FileTypeB,FileInfo,Param.Civ2.ImageB]=get_file_type(filecell.ima2.civ2{1}); |
---|
[389] | 1210 | end |
---|
[388] | 1211 | end |
---|
[2] | 1212 | |
---|
[133] | 1213 | %% MAIN LOOP |
---|
[273] | 1214 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[343] | 1215 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 1216 | checkframe=strcmp(TimeUnit,'frame'); |
---|
[322] | 1217 | batch_file_list=[];%should be renamed file_list, can be used for xml or bash files |
---|
[309] | 1218 | |
---|
[2] | 1219 | for ifile=1:nbfield |
---|
| 1220 | for j=1:nbslice |
---|
[465] | 1221 | |
---|
[313] | 1222 | |
---|
[272] | 1223 | % define output file name |
---|
[282] | 1224 | if Param.CheckCiv2==1 || Param.CheckFix2==1 || Param.CheckPatch2==1 |
---|
[465] | 1225 | Param.OutputFile=filecell.nc.civ2{ifile,j}; |
---|
[272] | 1226 | else |
---|
[465] | 1227 | Param.OutputFile=filecell.nc.civ1{ifile,j}; |
---|
[272] | 1228 | end |
---|
[465] | 1229 | Param.OutputFile=regexprep(Param.OutputFile,'.nc',''); |
---|
| 1230 | |
---|
[282] | 1231 | if Param.CheckCiv1 |
---|
[272] | 1232 | % read image-dependent parameters |
---|
[435] | 1233 | |
---|
[343] | 1234 | if ~checkframe% && size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j) |
---|
| 1235 | Param.Civ1.Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)-time(i1_civ1(ifile)+1,j1_civ1(j)+1)); |
---|
[301] | 1236 | else |
---|
| 1237 | Param.Civ1.Dt=1; |
---|
| 1238 | end |
---|
[343] | 1239 | Param.Civ1.Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2); |
---|
[465] | 1240 | if strcmp(Param.CivMode,'CivX') |
---|
[435] | 1241 | Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE? |
---|
| 1242 | Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);% |
---|
[399] | 1243 | end |
---|
[437] | 1244 | if isfield(Param.Civ1,'FileTypeA')&&(strcmp(Param.Civ1.FileTypeA,'video')|| strcmp(Param.Civ1.FileTypeA,'mmreader')) |
---|
[435] | 1245 | % ImageInfo=get(VideoReader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt]))); |
---|
| 1246 | ImageInfo=get(Param.Civ1.ImageA); |
---|
| 1247 | % elseif strcmp(Param.Civ1.FileTypeA,'mmreader') |
---|
| 1248 | % ImageInfo=get(mmreader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt]))); |
---|
[397] | 1249 | Param.Civ1.ImageBitDepth=ImageInfo.BitsPerPixel/3; |
---|
[435] | 1250 | if batch |
---|
| 1251 | Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};%file name must be used for batch instead of video object |
---|
| 1252 | Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j}; |
---|
| 1253 | end |
---|
[397] | 1254 | else |
---|
[435] | 1255 | Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j}; |
---|
| 1256 | Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j}; |
---|
[437] | 1257 | % form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats |
---|
[397] | 1258 | ImageInfo=imfinfo(filecell.ima1.civ1{1,1});%read the first image to get the size |
---|
| 1259 | Param.Civ1.ImageBitDepth=ImageInfo.BitDepth; |
---|
| 1260 | end |
---|
[315] | 1261 | Param.Civ1.ImageWidth=ImageInfo.Width; |
---|
| 1262 | Param.Civ1.ImageHeight=ImageInfo.Height; |
---|
[435] | 1263 | Param.Civ1.FrameIndexA=i1_civ1(ifile); |
---|
| 1264 | Param.Civ1.FrameIndexB=i2_civ1(ifile); |
---|
| 1265 | % read mask )parameters |
---|
[284] | 1266 | if Param.Civ1.CheckMask % the lines below should be changed with the new gui |
---|
[315] | 1267 | if ~exist(Param.Civ1.Mask,'file') |
---|
| 1268 | maskbase=[filecell.filebase '_' Param.Civ1.Mask]; % |
---|
| 1269 | nbslice_mask=str2double(Param.Civ1.Mask(1:end-4)); % |
---|
[313] | 1270 | i1_mask=mod(i1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[354] | 1271 | [RootPathMask,RootFileMask]=fileparts(maskbase); |
---|
| 1272 | Param.Civ1.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask); |
---|
[2] | 1273 | end |
---|
| 1274 | end |
---|
[313] | 1275 | % read grid parameters |
---|
[284] | 1276 | if Param.Civ1.CheckGrid |
---|
[315] | 1277 | if numel(Param.Civ1.Grid)>=4 && isequal(Param.Civ1.Grid(end-3:end),'grid') |
---|
| 1278 | nbslice_grid=str2double(Param.Civ1.Grid(1:end-4)); % |
---|
[137] | 1279 | if ~isnan(nbslice_grid) |
---|
[313] | 1280 | i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[354] | 1281 | Param.Civ1.Grid=[filecell.filebase '_' fullfile_uvmat('','',Param.Civ1.Grid,'.grid','_1',i1_grid)]; |
---|
[435] | 1282 | % Param.Civ1.Grid=[filecell.filebase '_' name_generator(Param.Civ1.Grid,i1_grid,1,'.grid','_i')]; |
---|
[285] | 1283 | if ~exist(Param.Civ1.GridName,'file') |
---|
[387] | 1284 | errormsg='grid file absent for civ1'; |
---|
| 1285 | return |
---|
[2] | 1286 | end |
---|
[315] | 1287 | elseif ~exist(Param.Civ1.Grid,'file') |
---|
[387] | 1288 | errormsg='grid file absent for civ1'; |
---|
| 1289 | return |
---|
[2] | 1290 | end |
---|
| 1291 | end |
---|
| 1292 | end |
---|
[257] | 1293 | |
---|
[2] | 1294 | end |
---|
| 1295 | |
---|
[282] | 1296 | if Param.CheckCiv2==1 |
---|
[437] | 1297 | if isfield(Param.Civ2,'FileTypeA') &&(strcmp(Param.Civ2.FileTypeA,'video')|| strcmp(Param.Civ2.FileTypeA,'mmreader')) |
---|
[435] | 1298 | % ImageInfo=get(VideoReader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt]))); |
---|
| 1299 | ImageInfo=get(Param.Civ2.ImageA); |
---|
| 1300 | % elseif strcmp(Param.Civ1.FileTypeA,'mmreader') |
---|
| 1301 | % ImageInfo=get(mmreader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt]))); |
---|
| 1302 | Param.Civ2.ImageBitDepth=ImageInfo.BitsPerPixel/3; |
---|
| 1303 | if batch |
---|
| 1304 | Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};%file name must be used for batch instead of video object |
---|
| 1305 | Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j}; |
---|
| 1306 | end |
---|
| 1307 | else |
---|
| 1308 | Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j}; |
---|
| 1309 | Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j}; |
---|
| 1310 | form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats |
---|
| 1311 | ImageInfo=imfinfo(filecell.ima1.civ2{1,1});%read the first image to get the size |
---|
| 1312 | Param.Civ2.ImageBitDepth=ImageInfo.BitDepth; |
---|
| 1313 | end |
---|
| 1314 | |
---|
[343] | 1315 | if ~checkframe %&& size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j) |
---|
[372] | 1316 | Param.Civ2.Dt=time(i2_civ2(ifile)+1,j2_civ2(j)+1)-time(i1_civ2(ifile)+1,j1_civ2(j)+1); |
---|
[301] | 1317 | else |
---|
| 1318 | Param.Civ2.Dt=1; |
---|
[309] | 1319 | end |
---|
[372] | 1320 | Param.Civ2.Time=(time(i2_civ2(ifile)+1,j2_civ2(j)+1)+time(i1_civ2(ifile)+1,j1_civ2(j)+1))/2; |
---|
[465] | 1321 | if strcmp(Param.CivMode,'CivX') |
---|
| 1322 | Param.Civ2.term_a=num2stra(j1_civ2(j),nom_type_nc); |
---|
| 1323 | Param.Civ2.term_b=num2stra(j2_civ2(j),nom_type_nc); |
---|
[399] | 1324 | end |
---|
[290] | 1325 | Param.Civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 1326 | Param.Civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
[315] | 1327 | |
---|
[465] | 1328 | % mask |
---|
[287] | 1329 | if Param.Civ2.CheckMask |
---|
[315] | 1330 | if ~exist(Param.Civ2.Mask,'file') |
---|
| 1331 | maskbase=[filecell.filebase '_' Param.Civ2.Mask]; % |
---|
| 1332 | nbslice_mask=str2double(Param.Civ2.Mask(1:end-4)); % |
---|
[313] | 1333 | i1_mask=mod(i1_civ2(ifile)-1,nbslice_mask)+1; |
---|
[354] | 1334 | [RootPathMask,RootFileMask]=fileparts(maskbase); |
---|
| 1335 | Param.Civ2.Mask=fullfile_uvmat(RootPathMask,[],RootFileMask,'.png','_1',i1_mask); |
---|
[465] | 1336 | % Param.Civ2.Mask=name_generator(maskbase,i1_mask,1,'.png','_i'); |
---|
[2] | 1337 | end |
---|
| 1338 | end |
---|
[315] | 1339 | %grid |
---|
| 1340 | if Param.Civ2.CheckGrid |
---|
| 1341 | if numel(Param.Civ2.Grid)>=4 && isequal(Param.Civ2.Grid(end-3:end),'grid') |
---|
| 1342 | nbslice_grid=str2double(Param.Civ2.Grid(1:end-4)); % |
---|
| 1343 | if ~isnan(nbslice_grid) |
---|
| 1344 | i1_grid=mod(i1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[354] | 1345 | Param.Civ2.Grid=[filecell.filebase '_' fullfile_uvmat('','',gridname,'.grid','_1',i1_grid)]; |
---|
[465] | 1346 | % Param.Civ2.Grid=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')]; |
---|
[315] | 1347 | end |
---|
[2] | 1348 | end |
---|
| 1349 | end |
---|
[397] | 1350 | form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats |
---|
| 1351 | if isempty(form) |
---|
[465] | 1352 | % ImageInfo=get(VideoReader(fullfile()); |
---|
[397] | 1353 | Param.Civ2.ImageBitDepth=ImageInfo.BitsPerPixel/3; |
---|
| 1354 | else |
---|
| 1355 | ImageInfo=imfinfo(filecell.ima1.civ2{1,1});%read the first image to get the size |
---|
| 1356 | Param.Civ2.ImageBitDepth=ImageInfo.BitDepth; |
---|
| 1357 | end |
---|
[315] | 1358 | Param.Civ2.ImageWidth=ImageInfo.Width; |
---|
| 1359 | Param.Civ2.ImageHeight=ImageInfo.Height; |
---|
[435] | 1360 | Param.Civ2.FrameIndexA=i1_civ2(ifile); |
---|
[465] | 1361 | Param.Civ2.FrameIndexB=i2_civ2(ifile); |
---|
| 1362 | |
---|
[112] | 1363 | end |
---|
| 1364 | |
---|
[465] | 1365 | |
---|
| 1366 | % write the command and eventually the cmx, xml or nml files |
---|
| 1367 | cmd=write_cmd(Param,batch); |
---|
| 1368 | write_param(Param); |
---|
| 1369 | |
---|
| 1370 | |
---|
| 1371 | |
---|
| 1372 | % create the file used in run or batch |
---|
| 1373 | switch Param.CivMode |
---|
| 1374 | case 'Matlab' |
---|
| 1375 | filename_bat=regexprep(Param.OutputFile,'(\w+)([/\\])(\w+$)','$1$20_BAT$2$3.m'); |
---|
| 1376 | case {'CivX','CivAll'} |
---|
| 1377 | filename_bat=regexprep(Param.OutputFile,'(\w+)([/\\])(\w+$)','$1$20_BAT$2$3.bat'); |
---|
[112] | 1378 | end |
---|
| 1379 | |
---|
[465] | 1380 | % print the command in the file |
---|
| 1381 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 1382 | if isequal(fid,-1) |
---|
| 1383 | errormsg=['creation of .bat file: ' message]; |
---|
| 1384 | return |
---|
[12] | 1385 | end |
---|
[465] | 1386 | fprintf(fid,cmd); |
---|
| 1387 | fclose(fid); |
---|
| 1388 | if isunix |
---|
| 1389 | system(['chmod +x ' filename_bat]); |
---|
| 1390 | end |
---|
| 1391 | batch_file_list{length(batch_file_list)+1}=filename_bat; |
---|
[309] | 1392 | |
---|
[112] | 1393 | end |
---|
[2] | 1394 | end |
---|
[134] | 1395 | |
---|
[465] | 1396 | %% start calculation |
---|
| 1397 | |
---|
[313] | 1398 | if batch |
---|
| 1399 | switch batch_mode |
---|
[378] | 1400 | case 'sge' %at the moment only psmn ENS Lyon uses it |
---|
[269] | 1401 | for p=1:length(batch_file_list) |
---|
[378] | 1402 | %cmd=['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}]; |
---|
| 1403 | cmd=['!qsub -q piv1,piv2,piv3 '... |
---|
| 1404 | '-e ' regexprep(batch_file_list{p},'.bat','.errors') ' -o ' regexprep(batch_file_list{p},'.bat','.log ')... |
---|
| 1405 | ' -v ' 'LD_LIBRARY_PATH=/home/sjoubaud/matlab_sylvain/civx/lib ' batch_file_list{p}]; |
---|
[269] | 1406 | display(cmd);eval(cmd); |
---|
[314] | 1407 | end |
---|
[279] | 1408 | case 'oar_old' |
---|
| 1409 | for p=1:length(batch_file_list) |
---|
| 1410 | oar_command=['!oarsub -n CIVX -q nicejob '... |
---|
| 1411 | '-E ' regexprep(batch_file_list{p},'.bat','.errors') ' -O ' regexprep(batch_file_list{p},'.bat','.log ')... |
---|
| 1412 | '-l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00" ' batch_file_list{p}]; |
---|
| 1413 | display(oar_command);eval(oar_command); |
---|
[314] | 1414 | end |
---|
| 1415 | case 'oar' |
---|
| 1416 | |
---|
[418] | 1417 | max_walltime=3600*12; % 12h max |
---|
[417] | 1418 | oar_modes={'oar-parexec','oar-dispatch','mpilauncher'}; |
---|
[314] | 1419 | text={'Batch processing on servcalcul3 LEGI';... |
---|
| 1420 | 'Please choose one of the followint modes';... |
---|
[418] | 1421 | '* oar-parexec : default and best choice';... |
---|
[336] | 1422 | '* oar-dispatch : jobs in a container of several cores';... |
---|
| 1423 | '* mpilauncher : one single parallel mpi job using several cores';... |
---|
[314] | 1424 | '**********************************'... |
---|
| 1425 | }; |
---|
| 1426 | [S,v]=listdlg('PromptString',text,'ListString',oar_modes,... |
---|
| 1427 | 'SelectionMode','single','ListSize',[400 100],'Name','LEGI job mode'); |
---|
| 1428 | switch oar_modes{S} |
---|
[336] | 1429 | case 'oar-parexec' %oar-dispatch.pl |
---|
[417] | 1430 | answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''}); |
---|
| 1431 | ncores=str2double(answer{1}); |
---|
| 1432 | extra_oar=answer{2}; |
---|
[336] | 1433 | walltime_onejob=600;%seconds |
---|
[465] | 1434 | filename_joblist=fullfile(RootBat,'job_list.txt'); |
---|
[336] | 1435 | fid=fopen(filename_joblist,'w'); |
---|
| 1436 | for p=1:length(batch_file_list) |
---|
| 1437 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
| 1438 | end |
---|
| 1439 | fclose(fid) |
---|
[417] | 1440 | oar_command=['oarsub -n CIVX '... |
---|
| 1441 | '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '... |
---|
| 1442 | '-l /core=' num2str(ncores) ','... |
---|
[419] | 1443 | 'walltime=' datestr(min(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,max_walltime/86400),13) ' '... |
---|
[417] | 1444 | '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '... |
---|
| 1445 | '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '... |
---|
| 1446 | extra_oar ' '... |
---|
| 1447 | '"oar-parexec -s -f ' filename_joblist ' '... |
---|
| 1448 | '-l ' filename_joblist '.log"']; |
---|
[465] | 1449 | filename_oarcommand=fullfile(RootBat,'oar_command'); |
---|
[336] | 1450 | fid=fopen(filename_oarcommand,'w'); |
---|
| 1451 | fprintf(fid,[oar_command '\n']); |
---|
| 1452 | fclose(fid); |
---|
| 1453 | display(oar_command); |
---|
| 1454 | eval(['! . ' filename_oarcommand]) |
---|
[314] | 1455 | case 'oar-dispatch' %oar-dispatch.pl |
---|
[336] | 1456 | ncores=str2double(... |
---|
[367] | 1457 | inputdlg('Number of cores (max 36)','oarsub parameter',1,{'6'})... |
---|
[336] | 1458 | ); |
---|
[322] | 1459 | walltime_onejob=600;%seconds |
---|
[465] | 1460 | filename_joblist=fullfile(RootBat,'job_list.txt'); |
---|
[314] | 1461 | fid=fopen(filename_joblist,'w'); |
---|
| 1462 | for p=1:length(batch_file_list) |
---|
| 1463 | oar_command=['oarsub -n CIVX '... |
---|
[417] | 1464 | '-E ' regexprep(batch_file_list{p},'\.bat\>','.stderr') ' -O ' regexprep(batch_file_list{p},'\.bat\>','.stdout ')... |
---|
[314] | 1465 | '-l "/core=1,walltime=' datestr(walltime_onejob/86400,13) '" ' batch_file_list{p}]; |
---|
| 1466 | fprintf(fid,[oar_command '\n']); |
---|
| 1467 | end |
---|
| 1468 | fclose(fid); |
---|
| 1469 | oar_command=['oarsub -t container -n civx-container '... |
---|
| 1470 | '-l /core=' num2str(ncores)... |
---|
[336] | 1471 | ',walltime=' datestr(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,13) ' '... |
---|
[417] | 1472 | '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '... |
---|
| 1473 | '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '... |
---|
[336] | 1474 | '"oar-dispatch -f ' filename_joblist '"']; |
---|
[465] | 1475 | filename_oarcommand=fullfile(RootBat,'oar_command'); |
---|
[314] | 1476 | fid=fopen(filename_oarcommand,'w'); |
---|
[313] | 1477 | fprintf(fid,[oar_command '\n']); |
---|
[314] | 1478 | fclose(fid); |
---|
| 1479 | display(oar_command); |
---|
| 1480 | eval(['! . ' filename_oarcommand]) |
---|
| 1481 | case 'mpilauncher' |
---|
[465] | 1482 | filename_joblist=fullfile(RootBat,'job_list.txt'); |
---|
[314] | 1483 | fid=fopen(filename_joblist,'w'); |
---|
| 1484 | |
---|
| 1485 | for p=1:length(batch_file_list) |
---|
| 1486 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
| 1487 | end |
---|
| 1488 | fclose(fid) |
---|
| 1489 | text_oarscript=[... |
---|
| 1490 | '#!/bin/bash \n'... |
---|
| 1491 | '#OAR -n Mylauncher \n'... |
---|
| 1492 | '#OAR -l node=4/core=5,walltime=0:15:00 \n'... |
---|
[465] | 1493 | '#OAR -E ' fullfile(RootBat,'stderrfile.log') ' \n'... |
---|
| 1494 | '#OAR -O ' fullfile(RootBat,'stdoutfile.log') ' \n'... |
---|
[314] | 1495 | '# ========================================================= \n'... |
---|
| 1496 | '# This simple program launch a multinode parallel OpenMPI mpilauncher \n'... |
---|
| 1497 | '# application for coriolis PIV post-processing. \n'... |
---|
| 1498 | '# OAR uses oarshmost wrapper to propagate the user environement. \n'... |
---|
| 1499 | '# This wrapper assert that the user has the same environment on all the \n'... |
---|
| 1500 | '# allocated nodes (basic behavior needed by most MPI applications). \n'... |
---|
| 1501 | '# \n'... |
---|
| 1502 | '# REQUIREMENT: \n'... |
---|
| 1503 | '# the oarshmost wrapper should be installed in $HOME/bin directory. \n'... |
---|
| 1504 | '# If a different location is used, change the line following the comment "Bidouille" \n'... |
---|
| 1505 | '# ========================================================= \n'... |
---|
| 1506 | '# USER should only modify these 2 lines \n'... |
---|
| 1507 | 'WORKDIR=' pwd ' \n'... |
---|
| 1508 | 'COMMANDE="mpilauncher -f ' filename_joblist '" \n'... |
---|
| 1509 | '# ========================================================= \n'... |
---|
| 1510 | '# DO NOT MODIFY the FOLOWING LINES. (or be carefull) \n'... |
---|
| 1511 | 'echo "job starting on: "`hostname` \n'... |
---|
| 1512 | 'MPINODES="-host `tr [\\\\\\n] [,] <$OAR_NODEFILE |sed -e "s/,$/ /"`" \n'... |
---|
| 1513 | 'NCPUS=`cat $OAR_NODEFILE |wc -l` \n'... |
---|
| 1514 | '#========== Bidouille ============== \n'... |
---|
| 1515 | 'export OMPI_MCA_plm_rsh_agent=oar-envsh \n'...% 'cd $WORKDIR \n'... |
---|
| 1516 | 'CMD="mpirun -np $NCPUS -wdir $WORKDIR $MPINODES $COMMANDE" \n'... |
---|
| 1517 | 'echo "I run: $CMD" \n'... |
---|
| 1518 | '$CMD \n'... |
---|
| 1519 | 'echo "job ending" \n'... |
---|
| 1520 | ]; |
---|
| 1521 | % oarsub -S ./oar.sub |
---|
[465] | 1522 | filename_oarscript=fullfile(RootBat,'oar_command'); |
---|
[314] | 1523 | fid=fopen(filename_oarscript,'w'); |
---|
| 1524 | fprintf(fid,[text_oarscript]); |
---|
| 1525 | fclose(fid); |
---|
| 1526 | eval(['!chmod +x ' filename_oarscript]); |
---|
| 1527 | eval(['!oarsub -S ' filename_oarscript]); |
---|
| 1528 | end |
---|
[269] | 1529 | end |
---|
| 1530 | else |
---|
[465] | 1531 | switch Param.CivMode |
---|
| 1532 | case 'Matlab' |
---|
| 1533 | |
---|
| 1534 | background=1; |
---|
| 1535 | if background |
---|
| 1536 | filename_superbat=fullfile(RootBat,'job_list.m'); |
---|
| 1537 | fid=fopen(filename_superbat,'w'); |
---|
| 1538 | if fid==-1 |
---|
| 1539 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 1540 | return |
---|
| 1541 | end |
---|
| 1542 | fprintf(fid,['addpath(''' path_civ ''');\n']); |
---|
| 1543 | for p=1:length(batch_file_list) |
---|
| 1544 | % if isunix |
---|
| 1545 | % fprintf(fid,['sh ' batch_file_list{p} '\n']); |
---|
| 1546 | % else |
---|
| 1547 | % fprintf(fid,['@call "' regexprep(batch_file_list{p},'\\','\\\\') '"' '\n']); |
---|
| 1548 | % end |
---|
| 1549 | fprintf(fid,['run ' batch_file_list{p} '\n']); |
---|
| 1550 | |
---|
| 1551 | end |
---|
| 1552 | fclose(fid); |
---|
| 1553 | eval(['run ' filename_superbat]); |
---|
[269] | 1554 | else |
---|
[465] | 1555 | for p=1:length(batch_file_list) |
---|
| 1556 | fid=fopen( batch_file_list{p}); |
---|
| 1557 | eval(fscanf(fid,'%s')); |
---|
| 1558 | fclose(fid); |
---|
| 1559 | end |
---|
[265] | 1560 | end |
---|
[465] | 1561 | |
---|
| 1562 | |
---|
| 1563 | case {'CivX','CivAll'} |
---|
| 1564 | filename_superbat=fullfile(RootBat,'job_list.bat'); |
---|
| 1565 | fid=fopen(filename_superbat,'w'); |
---|
| 1566 | if fid==-1 |
---|
| 1567 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 1568 | return |
---|
| 1569 | end |
---|
| 1570 | for p=1:length(batch_file_list) |
---|
| 1571 | if isunix |
---|
| 1572 | fprintf(fid,['sh ' batch_file_list{p} '\n']); |
---|
| 1573 | else |
---|
| 1574 | fprintf(fid,['@call "' regexprep(batch_file_list{p},'\\','\\\\') '"' '\n']); |
---|
| 1575 | end |
---|
| 1576 | end |
---|
| 1577 | fclose(fid); |
---|
| 1578 | if(isunix) |
---|
| 1579 | system(['chmod +x ' filename_superbat]); |
---|
| 1580 | end |
---|
| 1581 | background=0; |
---|
| 1582 | if background |
---|
| 1583 | system([filename_superbat ' &']);% execute main commmand |
---|
| 1584 | else |
---|
| 1585 | system(filename_superbat); |
---|
| 1586 | end |
---|
[313] | 1587 | end |
---|
[265] | 1588 | end |
---|
| 1589 | |
---|
[2] | 1590 | |
---|
[137] | 1591 | %% save interface state |
---|
[2] | 1592 | if isfield(filecell,'nc') |
---|
| 1593 | if isfield(filecell.nc,'civ2') |
---|
| 1594 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 1595 | else |
---|
| 1596 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 1597 | end |
---|
| 1598 | end |
---|
[343] | 1599 | [RootPath,SubDir,RootFile]=fileparts_uvmat(fileresu); |
---|
| 1600 | namedoc=fullfile(RootPath,SubDir,RootFile); |
---|
[112] | 1601 | detect=1; |
---|
[2] | 1602 | while detect==1 |
---|
| 1603 | namefigfull=[namedoc '.fig']; |
---|
| 1604 | hh=dir(namefigfull); |
---|
| 1605 | if ~isempty(hh) |
---|
| 1606 | detect=1; |
---|
| 1607 | namedoc=[namedoc '.0']; |
---|
| 1608 | else |
---|
| 1609 | detect=0; |
---|
| 1610 | end |
---|
| 1611 | end |
---|
[363] | 1612 | Param=rmfield(Param,'status'); |
---|
| 1613 | Param=rmfield(Param,'xml'); |
---|
[360] | 1614 | t=struct2xml(Param); |
---|
[437] | 1615 | t=set(t,1,'name','Civ');% set the head label |
---|
| 1616 | save(t,[namedoc '.civ.xml']); %save GUI parameters as xml file |
---|
[465] | 1617 | % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
[2] | 1618 | |
---|
[273] | 1619 | %Save info in personal profile (initiate browser next time) TODO |
---|
| 1620 | MenuFile={}; |
---|
| 1621 | dir_perso=prefdir; |
---|
| 1622 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 1623 | if exist(profil_perso,'file') |
---|
| 1624 | hh=load (profil_perso); |
---|
| 1625 | if isfield(hh,'MenuFile') |
---|
| 1626 | MenuFile=hh.MenuFile; |
---|
| 1627 | end |
---|
[289] | 1628 | if isfield(filecell.nc,'civ2') |
---|
| 1629 | MenuFile=[filecell.nc.civ2{1,1}; MenuFile]; |
---|
| 1630 | else |
---|
| 1631 | MenuFile=[filecell.nc.civ1{1,1}; MenuFile]; |
---|
| 1632 | end |
---|
[273] | 1633 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
| 1634 | else |
---|
| 1635 | MenuFile=filecell.ima1.civ1(1,1); |
---|
| 1636 | save (profil_perso,'MenuFile') |
---|
| 1637 | end |
---|
| 1638 | |
---|
[227] | 1639 | %------------------------------------------------------------------------ |
---|
| 1640 | % --- determine the list of reference indices of processing file |
---|
| 1641 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
| 1642 | %------------------------------------------------------------------------ |
---|
| 1643 | errormsg=''; %default error message |
---|
| 1644 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 1645 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 1646 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
| 1647 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 1648 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 1649 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 1650 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
| 1651 | else |
---|
| 1652 | first_j=1; |
---|
| 1653 | last_j=1; |
---|
| 1654 | incr_j=1; |
---|
| 1655 | end |
---|
| 1656 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
| 1657 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
| 1658 | if isnan(first_i)||isnan(first_j) |
---|
| 1659 | errormsg='first field number not defined'; |
---|
| 1660 | elseif isnan(last_i)||isnan(last_j) |
---|
| 1661 | errormsg='last field number not defined'; |
---|
| 1662 | elseif isnan(incr_i)||isnan(incr_j) |
---|
| 1663 | errormsg='increment in field number not defined'; |
---|
| 1664 | elseif last_i < first_i || last_j < first_j |
---|
| 1665 | errormsg='last field number must be larger than the first one'; |
---|
| 1666 | end |
---|
[134] | 1667 | |
---|
[227] | 1668 | %------------------------------------------------------------------------ |
---|
| 1669 | % --- determine the list of filenames and indices needed for launch_job |
---|
[371] | 1670 | %------------------------------------------------------------------------ |
---|
| 1671 | % OUTPUT: |
---|
| 1672 | % filecell: structure of cell arrays {ref_i,ref_j} containing all the filenames involved in the civ process |
---|
| 1673 | % the indices ref_i and ref_j correspond to the list of reference indices |
---|
| 1674 | % .filebase=fullfile(RootPath,RootFile) used to construct mask names, grid names, CivDoc xml file |
---|
| 1675 | % .ima1.civ1,.ima1.civ2: first image for civ1 and civ2 respectively (possibly different) |
---|
| 1676 | % .ima2.civ1,.ima2.civ2: second image for civ1 and civ2 respectively (possibly different) |
---|
| 1677 | % .nc.civ1,.nc.civ2: netcdf files containing civ1 and civ2 data respectively (possibly different) |
---|
| 1678 | % i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2: arrays of files indices, needed for timing records |
---|
[437] | 1679 | function [filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,NomType_nc,file_ref_fix1,file_ref_fix2,compare,errormsg]=... |
---|
[282] | 1680 | set_civ_filenames(handles,ref_i,ref_j,checkbox) |
---|
[12] | 1681 | %------------------------------------------------------------------------ |
---|
[85] | 1682 | filecell=[];%default |
---|
[437] | 1683 | errormsg=''; |
---|
[388] | 1684 | ListProgram=get(handles.ListProgram,'String'); |
---|
| 1685 | CivMode=ListProgram{get(handles.ListProgram,'Value')};%Program to use , CivX or Matlab |
---|
[136] | 1686 | |
---|
[371] | 1687 | %% get the root name and check dir |
---|
| 1688 | RootPath=get(handles.RootPath,'String'); |
---|
[437] | 1689 | SubdirImages=get(handles.SubdirImages,'String'); |
---|
[371] | 1690 | RootFile=get(handles.RootFile,'String'); |
---|
[437] | 1691 | filecell.filebase=fullfile(RootPath,SubdirImages,RootFile); |
---|
[371] | 1692 | if isempty(filecell.filebase) |
---|
[437] | 1693 | errormsg='please open an image with the upper menu option Open/Browse...'; |
---|
[136] | 1694 | return |
---|
| 1695 | end |
---|
[371] | 1696 | if ~exist(RootPath,'dir') |
---|
[437] | 1697 | errormsg=['path to images ' RootPath ' not found']; |
---|
[371] | 1698 | return |
---|
| 1699 | end |
---|
[388] | 1700 | [tild,message]=fileattrib(RootPath); |
---|
[371] | 1701 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[437] | 1702 | errormsg=['No writting access to ' RootPath]; |
---|
[371] | 1703 | return |
---|
| 1704 | end |
---|
| 1705 | %check result directory |
---|
[441] | 1706 | subdir_civ1=regexprep(get(handles.SubdirCiv1,'String'),'^.','');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 1707 | subdir_civ2=regexprep(get(handles.SubdirCiv2,'String'),'^.',''); |
---|
| 1708 | if isequal(subdir_civ1,''),subdir_civ1='civ'; end% put default subdir |
---|
| 1709 | % subdir_civ1=[ '.' subdir_civ1]; |
---|
| 1710 | % subdir_civ2=[ '.' subdir_civ2]; |
---|
[371] | 1711 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[441] | 1712 | subdir_civ1=[SubdirImages '.' subdir_civ1]; |
---|
| 1713 | subdir_civ2=[SubdirImages '.' subdir_civ2]; |
---|
[136] | 1714 | |
---|
[371] | 1715 | %% choose root names depending on ListCompareMode =displacement, shift, PIV or stereo PIV |
---|
| 1716 | ListCompareMode=get(handles.ListCompareMode,'String'); |
---|
| 1717 | compare=ListCompareMode{get(handles.ListCompareMode,'Value')}; |
---|
[136] | 1718 | |
---|
[371] | 1719 | % set the nomenclature type of the nc files depending on the pair mode |
---|
[360] | 1720 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
[2] | 1721 | mode='displacement'; |
---|
| 1722 | else |
---|
[282] | 1723 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 1724 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 1725 | mode=mode_list{mode_value}; |
---|
| 1726 | end |
---|
[371] | 1727 | NomType_ima2=get(handles.NomType,'String'); |
---|
| 1728 | NomType_nc=nomtype2pair(NomType_ima2,mode); |
---|
| 1729 | |
---|
| 1730 | % set the rootfile and image indexing |
---|
| 1731 | RootFile_ima2=get(handles.RootFile,'String');%root file for the second image series |
---|
| 1732 | ext_ima=get(handles.ImaExt,'String'); % image extension (the same for all images) |
---|
| 1733 | switch compare |
---|
| 1734 | case 'PIV' |
---|
| 1735 | RootFile_ima1=RootFile_ima2;% root name of the two image series is the same |
---|
| 1736 | NomType_ima1=NomType_ima2;% the index of the first image follows the index of the second one |
---|
| 1737 | RootFile_nc=RootFile_ima2; |
---|
| 1738 | case 'displacement' |
---|
| 1739 | RootFile_ima1=get(handles.RootFile_1,'String');% root name of the first image series set by handles.RootFile_1 |
---|
| 1740 | NomType_ima1='';% no indexing of the first image, a fixed reference for the whole series |
---|
| 1741 | RootFile_nc=RootFile_ima2; |
---|
| 1742 | case 'shift' |
---|
| 1743 | RootFile_ima1=get(handles.RootFile_1,'String');% root name of the first image series set by handles.RootFile_1 |
---|
| 1744 | NomType_ima1=NomType_ima2;% the index of the first image follows the index of the second one |
---|
| 1745 | RootFile_nc=[RootFile_ima1 '-' RootFile_ima2]; |
---|
[122] | 1746 | end |
---|
[360] | 1747 | |
---|
[371] | 1748 | %determine the list of file indices involved |
---|
| 1749 | [i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2]=... |
---|
[227] | 1750 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
[371] | 1751 | |
---|
[282] | 1752 | %determine the new filebase for 'displacement' ListPairMode (comparison of two series) |
---|
[371] | 1753 | %filebase_B=filebase;% root name of the second field series for stereo |
---|
| 1754 | % filebase_A=filebase;%default |
---|
| 1755 | % if strcmp(compare,'PIV') |
---|
| 1756 | % filebase_AB=filebase; |
---|
| 1757 | % else |
---|
| 1758 | % [Path2,Name2]=fileparts(filebase_B); |
---|
| 1759 | % Name1=RootFile_ima1; |
---|
| 1760 | % filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 1761 | % end |
---|
| 1762 | % [RootPath_AB,RootFile_AB]=fileparts(filebase_AB); |
---|
| 1763 | % % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_B); |
---|
| 1764 | % [RootPath_ima2,RootFile_ima2]=fileparts(filebase_B); |
---|
| 1765 | % [RootPath_nc,RootFile_nc]=fileparts(filebase_B);%default |
---|
| 1766 | % if strcmp(compare,'displacement') |
---|
| 1767 | % % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_B); |
---|
| 1768 | % % [RootPath_ima2,RootFile_ima2]=fileparts(filebase_B); |
---|
| 1769 | % [RootPath_nc,RootFile_nc]=fileparts(filebase_B); |
---|
| 1770 | % elseif strcmp(compare,'shift') |
---|
| 1771 | % RootPath_nc=RootPath_AB; |
---|
| 1772 | % RootFile_nc=RootFile_AB; |
---|
| 1773 | % end |
---|
| 1774 | % else |
---|
| 1775 | % filebase_ima1=filebase_B; |
---|
| 1776 | % filebase_ima2=filebase_B; |
---|
| 1777 | % filebase_nc=filebase_B; |
---|
| 1778 | % [RootPath_ima1,RootFile_ima1]=fileparts(filebase_ima1); |
---|
| 1779 | % [RootPath_ima2,RootFile_ima2]=fileparts(filebase_ima2); |
---|
| 1780 | % [RootPath_nc,RootFile_nc]=fileparts(filebase_nc); |
---|
| 1781 | % [RootPath_A,RootFile_A]=fileparts(filebase_A); |
---|
| 1782 | |
---|
[353] | 1783 | |
---|
[371] | 1784 | %% determine reference files for fix: |
---|
[2] | 1785 | file_ref_fix1={};%default |
---|
| 1786 | file_ref_fix2={}; |
---|
[371] | 1787 | nbfield=length(i1_civ1); |
---|
| 1788 | nbslice=length(j1_civ1); |
---|
[282] | 1789 | if checkbox(2)==1% fix1 performed |
---|
[2] | 1790 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 1791 | if ~isempty(ref) |
---|
[137] | 1792 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1793 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1794 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 1795 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1796 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1797 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 1798 | num_i_ref=first_i:incr_i:last_i; |
---|
| 1799 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 1800 | if isequal(mode,'displacement') |
---|
| 1801 | num_i1=num_i_ref; |
---|
[371] | 1802 | num_i2=num_i_ref; |
---|
[2] | 1803 | num_j1=num_j_ref; |
---|
| 1804 | num_j2=num_j_ref; |
---|
| 1805 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 1806 | num_i1=num_i_ref; |
---|
| 1807 | num_i2=num_i1; |
---|
| 1808 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 1809 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 1810 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 1811 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 1812 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 1813 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 1814 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 1815 | if isempty(ref.num_a) |
---|
| 1816 | ref.num_a=1; |
---|
| 1817 | end |
---|
| 1818 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 1819 | num_j2=num_j1; |
---|
| 1820 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 1821 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 1822 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 1823 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 1824 | num_i2=num_i1; |
---|
| 1825 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 1826 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 1827 | end |
---|
| 1828 | for ifile=1:nbfield |
---|
| 1829 | for j=1:nbslice |
---|
[371] | 1830 | [RootPathRef,RootFile]=fileparts(ref.filebase); |
---|
| 1831 | file_ref=fullfile_uvmat(RootPathRef,ref.subdir,RootFile,'.nc',ref.NomType,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j)); |
---|
[2] | 1832 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 1833 | if ~exist(file_ref,'file') |
---|
[437] | 1834 | errormsg=['reference file ' file_ref ' not found for fix1']; |
---|
[2] | 1835 | return |
---|
| 1836 | end |
---|
| 1837 | end |
---|
| 1838 | end |
---|
| 1839 | end |
---|
| 1840 | end |
---|
| 1841 | |
---|
[371] | 1842 | %% determine reference files for fix2: |
---|
[282] | 1843 | if checkbox(5)==1% fix2 performed |
---|
[2] | 1844 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 1845 | if ~isempty(ref) |
---|
[127] | 1846 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1847 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1848 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 1849 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1850 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1851 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[229] | 1852 | num_i_ref=first_i:incr_i:last_i; |
---|
| 1853 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 1854 | if isequal(mode,'displacement') |
---|
| 1855 | num_i1=num_i_ref; |
---|
| 1856 | num_i2=num_i_ref; |
---|
| 1857 | num_j1=num_j_ref; |
---|
| 1858 | num_j2=num_j_ref; |
---|
| 1859 | elseif isequal(mode,'pair j1-j2') |
---|
| 1860 | num_i1=num_i_ref; |
---|
| 1861 | num_i2=num_i1; |
---|
| 1862 | num_j1=ref.num_a; |
---|
| 1863 | num_j2=ref.num_b; |
---|
| 1864 | elseif isequal(mode,'series(Di)') |
---|
| 1865 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 1866 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 1867 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 1868 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 1869 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 1870 | num_j2=num_j1; |
---|
| 1871 | elseif isequal(mode,'series(Dj)') |
---|
| 1872 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 1873 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 1874 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 1875 | num_i2=num_i1; |
---|
| 1876 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 1877 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 1878 | end |
---|
| 1879 | for ifile=1:nbfield |
---|
| 1880 | for j=1:nbslice |
---|
[371] | 1881 | [RootPathRef,RootFile]=fileparts(ref.filebase); |
---|
| 1882 | file_ref=fullfile_uvmat(RootPathRef,ref.subdir,RootFile,'.nc',ref.NomType,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j)); |
---|
[2] | 1883 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 1884 | if ~exist(file_ref,'file') |
---|
[437] | 1885 | errormsg=['reference file ' file_ref ' not found for fix2']; |
---|
[2] | 1886 | return |
---|
| 1887 | end |
---|
| 1888 | end |
---|
| 1889 | end |
---|
| 1890 | end |
---|
| 1891 | end |
---|
| 1892 | |
---|
[371] | 1893 | %% check the existence of the netcdf and image files involved |
---|
[282] | 1894 | % %%%%%%%%%%%% case CheckCiv1 activated %%%%%%%%%%%%% |
---|
| 1895 | if checkbox(1)==1; |
---|
[112] | 1896 | detect=1; |
---|
[127] | 1897 | vers=0; |
---|
| 1898 | subdir_civ1_new=subdir_civ1; |
---|
[153] | 1899 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[122] | 1900 | for ifile=1:nbfield |
---|
[112] | 1901 | for j=1:nbslice |
---|
[371] | 1902 | 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] | 1903 | detect=exist(filename,'file')==2; |
---|
| 1904 | if detect% if a netcdf file already exists |
---|
[452] | 1905 | answer=msgbox_uvmat('INPUT_Y-N',['overwrite existing civ files in ' subdir_civ1_new]); |
---|
| 1906 | if strcmp(answer,'Yes') |
---|
| 1907 | detect=0; |
---|
| 1908 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 1909 | else |
---|
[446] | 1910 | r=regexp(subdir_civ1_new,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number |
---|
| 1911 | if isempty(r) |
---|
| 1912 | r(1).root=[subdir_civ1_new '_']; |
---|
| 1913 | r(1).num1='0'; |
---|
| 1914 | end |
---|
| 1915 | subdir_civ1_new=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 |
---|
| 1916 | subdir_civ2=subdir_civ1_new; |
---|
[127] | 1917 | end |
---|
[112] | 1918 | break |
---|
| 1919 | end |
---|
| 1920 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 1921 | end |
---|
| 1922 | if detect% if a netcdf file already exists |
---|
| 1923 | break |
---|
| 1924 | end |
---|
| 1925 | end |
---|
[134] | 1926 | |
---|
[363] | 1927 | %create the new SubdirCiv1 |
---|
[371] | 1928 | if ~exist(fullfile(RootPath,subdir_civ1_new),'dir') |
---|
| 1929 | [xx,msg1]=mkdir(fullfile(RootPath,subdir_civ1_new)); |
---|
[128] | 1930 | if ~strcmp(msg1,'') |
---|
[437] | 1931 | errormsg=['cannot create ' subdir_civ1_new ': ' msg1];%error message for directory creation |
---|
[122] | 1932 | return |
---|
[163] | 1933 | elseif isunix |
---|
[371] | 1934 | [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 1935 | if ~strcmp(msg2,'') |
---|
[437] | 1936 | errormsg=['pb of permission for ' fullfile(RootPath,subdir_civ1_new) ': ' msg2];%error message for directory creation |
---|
[128] | 1937 | return |
---|
| 1938 | end |
---|
[112] | 1939 | end |
---|
| 1940 | end |
---|
| 1941 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 1942 | for ifile=1:nbfield |
---|
| 1943 | for j=1:nbslice |
---|
[371] | 1944 | filename=fullfile_uvmat(RootPath,subdir_civ1_new,RootFile_A,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); |
---|
| 1945 | % 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] | 1946 | detect=exist(filename,'file')==2; |
---|
[2] | 1947 | if detect% if a netcdf file already exists |
---|
[137] | 1948 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 1949 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 1950 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 1951 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 1952 | else |
---|
| 1953 | vers=vers+1; |
---|
[137] | 1954 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 1955 | end |
---|
| 1956 | subdir_civ2=subdir_civ1; |
---|
| 1957 | break |
---|
[2] | 1958 | end |
---|
[112] | 1959 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 1960 | end |
---|
| 1961 | if detect% if a netcdf file already exists |
---|
| 1962 | break |
---|
| 1963 | end |
---|
| 1964 | end |
---|
[363] | 1965 | %create the new SubdirCiv1 |
---|
[371] | 1966 | if ~exist(fullfile(RootPath,subdir_civ1_new),'dir') |
---|
| 1967 | [xx,msg1]=mkdir(fullfile(RootPath,subdir_civ1_new)); |
---|
[252] | 1968 | if ~strcmp(msg1,'') |
---|
[437] | 1969 | errormsg=['cannot create ' subdir_civ1_new ': ' msg1]; |
---|
[122] | 1970 | return |
---|
[128] | 1971 | else |
---|
[371] | 1972 | [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 1973 | if ~strcmp(msg2,'') |
---|
[437] | 1974 | errormsg=['pb of permission for ' subdir_civ1_new ': ' msg2];%error message for directory creation |
---|
[128] | 1975 | return |
---|
| 1976 | end |
---|
[112] | 1977 | end |
---|
| 1978 | end |
---|
| 1979 | end |
---|
| 1980 | end |
---|
[127] | 1981 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 1982 | % get image names |
---|
| 1983 | for ifile=1:nbfield |
---|
[112] | 1984 | for j=1:nbslice |
---|
[437] | 1985 | filename=fullfile_uvmat(RootPath,SubdirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j)); |
---|
[2] | 1986 | idetect(j)=exist(filename,'file')==2; |
---|
| 1987 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
[437] | 1988 | filename=fullfile_uvmat(RootPath,SubdirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j)); |
---|
[2] | 1989 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 1990 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 1991 | end |
---|
| 1992 | [idetectmin,indexj]=min(idetect); |
---|
| 1993 | if idetectmin==0, |
---|
[437] | 1994 | errormsg=[filecell.ima1.civ1{ifile,indexj} ' not found']; |
---|
[112] | 1995 | return |
---|
| 1996 | end |
---|
| 1997 | [idetectmin,indexj]=min(idetect_1); |
---|
| 1998 | if idetectmin==0, |
---|
[437] | 1999 | errormsg=[filecell.ima2.civ1{ifile,indexj} ' not found']; |
---|
[112] | 2000 | return |
---|
| 2001 | end |
---|
| 2002 | end |
---|
| 2003 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2004 | for ifile=1:nbfield |
---|
| 2005 | for j=1:nbslice |
---|
[371] | 2006 | filename=fullfile_uvmat(RootPath,'',RootFile_A,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j)); |
---|
[112] | 2007 | idetect(j)=exist(filename,'file')==2; |
---|
| 2008 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
[371] | 2009 | filename=fullfile_uvmat(RootPath,'',RootFile_A,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j)); |
---|
[112] | 2010 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2011 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2012 | end |
---|
[2] | 2013 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2014 | if idetectmin==0, |
---|
[437] | 2015 | errormsg=[filecell.imaA1.civ1{ifile,indexj} ' not found']; |
---|
[2] | 2016 | return |
---|
[112] | 2017 | end |
---|
[2] | 2018 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2019 | if idetectmin==0, |
---|
[437] | 2020 | errormsg=[filecell.imaA2.civ1{ifile,indexj} ' not found']; |
---|
[2] | 2021 | return |
---|
[112] | 2022 | end |
---|
| 2023 | end |
---|
[2] | 2024 | end |
---|
[112] | 2025 | |
---|
[282] | 2026 | %%%%%%%%%%%%% checkfix1 or checkpatch1 activated but no checkciv1 %%%%%%%%%%%%% |
---|
| 2027 | elseif (checkbox(2)==1 || checkbox(3)==1); |
---|
[2] | 2028 | for ifile=1:nbfield |
---|
| 2029 | for j=1:nbslice |
---|
[371] | 2030 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); |
---|
[112] | 2031 | detect=exist(filename,'file')==2; |
---|
[122] | 2032 | if detect==0 |
---|
[437] | 2033 | errormsg=[filename ' not found']; |
---|
[122] | 2034 | return |
---|
| 2035 | end |
---|
[2] | 2036 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2037 | end |
---|
| 2038 | end |
---|
| 2039 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2040 | for ifile=1:nbfield |
---|
| 2041 | for j=1:nbslice |
---|
[371] | 2042 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_A,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); |
---|
[112] | 2043 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2044 | if ~exist(filename,'file') |
---|
[437] | 2045 | errormsg=['input file ' filename ' not found']; |
---|
[112] | 2046 | return |
---|
[2] | 2047 | end |
---|
| 2048 | end |
---|
[112] | 2049 | end |
---|
[2] | 2050 | end |
---|
| 2051 | end |
---|
| 2052 | |
---|
[282] | 2053 | %%%%%%%%%%%%% if checkciv2 performed with pairs different than checkciv1 %%%%%%%%%%%%% |
---|
[2] | 2054 | testdiff=0; |
---|
[282] | 2055 | if (checkbox(4)==1)&&... |
---|
| 2056 | ((get(handles.ListPairCiv1,'Value')~=get(handles.ListPairCiv2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2057 | testdiff=1; |
---|
[112] | 2058 | detect=1; |
---|
[127] | 2059 | vers=0; |
---|
| 2060 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2061 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2062 | for ifile=1:nbfield |
---|
| 2063 | for j=1:nbslice |
---|
[371] | 2064 | 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] | 2065 | detect=exist(filename,'file')==2; |
---|
| 2066 | if detect% if a netcdf file already exists |
---|
[127] | 2067 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2068 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2069 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2070 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2071 | else |
---|
| 2072 | vers=vers+1; |
---|
| 2073 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2074 | end |
---|
[112] | 2075 | break |
---|
| 2076 | end |
---|
| 2077 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2078 | end |
---|
| 2079 | if detect% if a netcdf file already exists |
---|
| 2080 | break |
---|
| 2081 | end |
---|
| 2082 | end |
---|
[128] | 2083 | %create the new subdir_civ2_new |
---|
[371] | 2084 | if ~exist(fullfile(RootPath,subdir_civ2_new),'dir') |
---|
| 2085 | [xx,m2]=mkdir(fullfile(RootPath,subdir_civ2_new)); |
---|
| 2086 | [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2087 | if ~isequal(m2,'') |
---|
[437] | 2088 | errormsg=['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2]; |
---|
[122] | 2089 | return |
---|
[112] | 2090 | end |
---|
| 2091 | end |
---|
| 2092 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2093 | for ifile=1:nbfield |
---|
| 2094 | for j=1:nbslice |
---|
[371] | 2095 | 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] | 2096 | detect=exist(filename,'file')==2; |
---|
[2] | 2097 | if detect% if a netcdf file already exists |
---|
[127] | 2098 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2099 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2100 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2101 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2102 | else |
---|
| 2103 | vers=vers+1; |
---|
| 2104 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2105 | end |
---|
[112] | 2106 | break |
---|
[2] | 2107 | end |
---|
[112] | 2108 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2109 | end |
---|
| 2110 | if detect% if a netcdf file already exists |
---|
| 2111 | break |
---|
| 2112 | end |
---|
| 2113 | end |
---|
[122] | 2114 | subdir_civ2=subdir_civ2_new; |
---|
[363] | 2115 | %create the new SubdirCiv1 |
---|
[371] | 2116 | if ~exist(fullfile(RootPath,subdir_civ2_new),'dir') |
---|
[127] | 2117 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
[371] | 2118 | [xx,msg2] = fileattrib(fullfile(RootPath,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2119 | if ~isequal(m2,'') |
---|
[437] | 2120 | errormsg= ['cannot create ' fullfile(RootPath,subdir_civ2_new) ': ' m2];%error message for directory creation |
---|
[122] | 2121 | return |
---|
[112] | 2122 | end |
---|
| 2123 | end |
---|
| 2124 | end |
---|
| 2125 | end |
---|
[127] | 2126 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2127 | end |
---|
| 2128 | |
---|
[282] | 2129 | %%%%%%%%%%%%% if checkciv2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2130 | if checkbox(4)==1 || checkbox(5)==1 || checkbox(6)==1 %civ2 |
---|
| 2131 | %check source netcdf file of checkciv1 estimates |
---|
| 2132 | if checkbox(1)==0; %no civ1 performed |
---|
[2] | 2133 | for ifile=1:nbfield |
---|
| 2134 | for j=1:nbslice |
---|
[371] | 2135 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_nc,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j));% |
---|
[2] | 2136 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2137 | if ~exist(filename,'file') |
---|
[437] | 2138 | errormsg=['input file ' filename ' not found']; |
---|
[2] | 2139 | return |
---|
| 2140 | end |
---|
| 2141 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
[282] | 2142 | if checkbox(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
[248] | 2143 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
[364] | 2144 | if isfield(Data,'Txt') |
---|
[437] | 2145 | errormsg=Data.Txt; |
---|
[364] | 2146 | return |
---|
| 2147 | elseif ~isempty(Data.CivStage)% case of new civ files |
---|
| 2148 | if Data.CivStage<4 %test for civ files |
---|
[437] | 2149 | errormsg=['no civ2 data in ' filename]; |
---|
[2] | 2150 | return |
---|
[364] | 2151 | end |
---|
[248] | 2152 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[437] | 2153 | errormsg=['no civ2 data in ' filename]; |
---|
[248] | 2154 | return |
---|
[112] | 2155 | end |
---|
[282] | 2156 | elseif checkbox(3)==0; %check the existence of patch if it is not calculated |
---|
[275] | 2157 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch'); |
---|
[437] | 2158 | if isfield(Data,'Txt') |
---|
| 2159 | errormsg=Data.Txt; |
---|
| 2160 | return |
---|
| 2161 | elseif ~isempty(Data.CivStage) |
---|
[248] | 2162 | if Data.CivStage<3 %test for civ files |
---|
[437] | 2163 | errormsg=['no patch data in ' filename]; |
---|
[248] | 2164 | return |
---|
| 2165 | end |
---|
| 2166 | elseif isempty(Data.patch)||isequal(Data.patch,0) |
---|
[437] | 2167 | errormsg=['no patch data in ' filename]; |
---|
[2] | 2168 | return |
---|
| 2169 | end |
---|
[112] | 2170 | end |
---|
[2] | 2171 | end |
---|
| 2172 | end |
---|
| 2173 | end |
---|
| 2174 | if strcmp(compare,'stereo PIV') |
---|
| 2175 | for ifile=1:nbfield |
---|
| 2176 | for j=1:nbslice |
---|
[371] | 2177 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_A,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[2] | 2178 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2179 | if ~exist(filename,'file') |
---|
[437] | 2180 | errormsg=['input file ' filename ' not found']; |
---|
[2] | 2181 | return |
---|
| 2182 | end |
---|
| 2183 | end |
---|
| 2184 | end |
---|
| 2185 | end |
---|
| 2186 | end |
---|
[112] | 2187 | |
---|
| 2188 | detect=1; |
---|
[282] | 2189 | % while detect==1%creates a new subdir if the netcdf files already contain checkciv2 data |
---|
[112] | 2190 | for ifile=1:nbfield |
---|
| 2191 | for j=1:nbslice |
---|
[371] | 2192 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[112] | 2193 | detect=exist(filename,'file')==2; |
---|
| 2194 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2195 | end |
---|
[112] | 2196 | end |
---|
[282] | 2197 | %get first image names for checkciv2 |
---|
[371] | 2198 | if checkbox(1)==1 && isequal(i1_civ1,i1_civ2) && isequal(j1_civ1,j1_civ2) |
---|
[2] | 2199 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
[282] | 2200 | elseif checkbox(4)==1 |
---|
[2] | 2201 | for ifile=1:nbfield |
---|
| 2202 | for j=1:nbslice |
---|
[371] | 2203 | filename=fullfile_uvmat(RootPath,[],RootFile_ima1,ext_ima,NomType_ima1,i1_civ2(ifile),[],j1_civ2(j)); |
---|
[2] | 2204 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2205 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2206 | end |
---|
[112] | 2207 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2208 | if idetectmin==0, |
---|
[437] | 2209 | errormsg=['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']; |
---|
[112] | 2210 | return |
---|
[2] | 2211 | end |
---|
| 2212 | end |
---|
| 2213 | end |
---|
| 2214 | |
---|
[282] | 2215 | %get second image names for checkciv2 |
---|
[371] | 2216 | if checkbox(1)==1 && isequal(i2_civ1,i2_civ2) && isequal(j2_civ1,j2_civ2) |
---|
[2] | 2217 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
[282] | 2218 | elseif checkbox(4)==1 |
---|
[2] | 2219 | for ifile=1:nbfield |
---|
| 2220 | for j=1:nbslice |
---|
[371] | 2221 | filename=fullfile_uvmat(RootPath,[],RootFile_ima2,ext_ima,NomType_ima2,i2_civ2(ifile),[],j2_civ2(j)); |
---|
[2] | 2222 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2223 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2224 | end |
---|
[112] | 2225 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2226 | if idetectmin==0, |
---|
[437] | 2227 | errormsg=['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']; |
---|
[112] | 2228 | return |
---|
[2] | 2229 | end |
---|
| 2230 | end |
---|
| 2231 | end |
---|
| 2232 | end |
---|
[282] | 2233 | if (checkbox(5) || checkbox(6)) && ~checkbox(4) % need to read an existing netcdf civ2 file |
---|
[2] | 2234 | if ~testdiff |
---|
| 2235 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2236 | else % check the civ2 files |
---|
[2] | 2237 | for ifile=1:nbfield |
---|
| 2238 | for j=1:nbslice |
---|
[371] | 2239 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_nc,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[2] | 2240 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2241 | if ~exist(filename,'file') |
---|
[437] | 2242 | errormsg=['input file ' filename ' not found']; |
---|
[2] | 2243 | return |
---|
| 2244 | else |
---|
[248] | 2245 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2246 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
[437] | 2247 | errormsg=['no civ2 data in ' filename]; |
---|
[248] | 2248 | return |
---|
| 2249 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[437] | 2250 | errormsg=['no civ2 data in ' filename]; |
---|
[2] | 2251 | return |
---|
| 2252 | end |
---|
| 2253 | end |
---|
| 2254 | end |
---|
| 2255 | end |
---|
| 2256 | end |
---|
| 2257 | end |
---|
| 2258 | |
---|
| 2259 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2260 | if strcmp(compare,'stereo PIV') |
---|
[282] | 2261 | if checkbox(3) && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2262 | for ifile=1:nbfield |
---|
| 2263 | for j=1:nbslice |
---|
[371] | 2264 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile_AB,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j)); |
---|
[2] | 2265 | filecell.st(ifile,j)={filename}; |
---|
| 2266 | end |
---|
| 2267 | end |
---|
| 2268 | end |
---|
[282] | 2269 | if checkbox(6) && isequal(get(handles.CheckStereo,'Value'),1) |
---|
[2] | 2270 | for ifile=1:nbfield |
---|
| 2271 | for j=1:nbslice |
---|
[371] | 2272 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile_AB,'.nc',NomType_nc,i1_civ2(ifile),i2_civ2(ifile),j1_civ2(j),j2_civ2(j)); |
---|
[2] | 2273 | filecell.st(ifile,j)={filename}; |
---|
| 2274 | end |
---|
| 2275 | end |
---|
[112] | 2276 | end |
---|
[2] | 2277 | end |
---|
[441] | 2278 | set(handles.SubdirCiv1,'String',regexprep(subdir_civ1,['^' SubdirImages],''));%suppress the root SuddirImages;);%update the edit box |
---|
| 2279 | set(handles.SubdirCiv2,'String',regexprep(subdir_civ2,['^' SubdirImages],''));%update the edit box |
---|
[2] | 2280 | |
---|
[388] | 2281 | % For CivX COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
| 2282 | if strcmp(CivMode,'CivX') |
---|
| 2283 | if isequal(NomType_ima1,'*')%case of movie files |
---|
| 2284 | NomType_imanew1='_i'; |
---|
| 2285 | else |
---|
| 2286 | NomType_imanew1=NomType_ima1; |
---|
| 2287 | end |
---|
| 2288 | if isequal(NomType_ima2,'*')%case of movie files |
---|
| 2289 | NomType_imanew2='_i'; |
---|
| 2290 | else |
---|
| 2291 | NomType_imanew2=NomType_ima2; |
---|
| 2292 | end |
---|
| 2293 | if ~isequal(ext_ima,'.png') |
---|
| 2294 | %%type of image file |
---|
| 2295 | type_ima1='none';%default |
---|
| 2296 | movieobject1=[];%default |
---|
| 2297 | if strcmpi(ext_ima,'.avi') |
---|
| 2298 | if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab) |
---|
| 2299 | type_ima1='movie'; |
---|
| 2300 | movieobject1=mmreader([filecell.filebase ext_ima]); |
---|
[112] | 2301 | else |
---|
[388] | 2302 | type_ima1='avi'; |
---|
[112] | 2303 | end |
---|
[388] | 2304 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
| 2305 | form=imformats(ext_ima(2:end)); |
---|
| 2306 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2307 | if isequal(NomType_ima1,'*'); |
---|
| 2308 | type_ima1='multimage';%image series in a single image file |
---|
| 2309 | else |
---|
| 2310 | type_ima1='image'; |
---|
| 2311 | end |
---|
| 2312 | end |
---|
[112] | 2313 | end |
---|
[388] | 2314 | type_ima2='none';%default |
---|
| 2315 | movieobject2=[]; |
---|
| 2316 | if strcmpi(ext_ima,'.avi') |
---|
| 2317 | if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab) |
---|
| 2318 | type_ima2='movie'; |
---|
| 2319 | movieobject2=mmreader([filecell.filebase ext_ima]); |
---|
[112] | 2320 | else |
---|
[388] | 2321 | type_ima2='avi'; |
---|
[112] | 2322 | end |
---|
[388] | 2323 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
| 2324 | form=imformats(ext_ima(2:end)); |
---|
| 2325 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2326 | if isequal(NomType_ima1,'*'); |
---|
| 2327 | type_ima2='multimage';%image series in a single image file |
---|
| 2328 | else |
---|
| 2329 | type_ima2='image'; |
---|
| 2330 | end |
---|
| 2331 | end |
---|
[112] | 2332 | end |
---|
[388] | 2333 | if checkbox(1) %if civ1 is performed |
---|
| 2334 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
| 2335 | for ifile=1:nbfield |
---|
| 2336 | waitbar(ifile/nbfield); |
---|
| 2337 | for j=1:nbslice |
---|
| 2338 | filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j)); |
---|
| 2339 | if ~exist(filename,'file') |
---|
| 2340 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,i1_civ1(ifile),movieobject1); |
---|
| 2341 | imwrite(A,filename,'BitDepth',16); |
---|
| 2342 | end |
---|
| 2343 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 2344 | filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ1(ifile),[],j2_civ1(j)); |
---|
| 2345 | if ~exist(filename,'file') |
---|
| 2346 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,i2_civ1(ifile),movieobject2); |
---|
| 2347 | imwrite(A,filename,'BitDepth',16); |
---|
| 2348 | end |
---|
| 2349 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[112] | 2350 | end |
---|
[2] | 2351 | end |
---|
[388] | 2352 | close(h) |
---|
[2] | 2353 | end |
---|
[388] | 2354 | if checkbox(4) %if civ2 is performed |
---|
| 2355 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
| 2356 | for ifile=1:nbfield |
---|
| 2357 | waitbar(ifile/nbfield); |
---|
| 2358 | for j=1:nbslice |
---|
| 2359 | filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j)); |
---|
| 2360 | if ~exist(filename,'file') |
---|
| 2361 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,i1_civ2(ifile)); |
---|
| 2362 | imwrite(A,filename,'BitDepth',16); |
---|
| 2363 | end |
---|
| 2364 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 2365 | filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j)); |
---|
| 2366 | if ~exist(filename,'file') |
---|
| 2367 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,i2_civ2(ifile)); |
---|
| 2368 | imwrite(A,filename,'BitDepth',16); |
---|
| 2369 | end |
---|
| 2370 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[112] | 2371 | end |
---|
[2] | 2372 | end |
---|
[388] | 2373 | close(h); |
---|
[2] | 2374 | end |
---|
| 2375 | end |
---|
| 2376 | end |
---|
| 2377 | |
---|
[12] | 2378 | %------------------------------------------------------------------------ |
---|
[227] | 2379 | % --- determine the list of index pairs of processing file |
---|
| 2380 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 2381 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
| 2382 | %------------------------------------------------------------------------ |
---|
| 2383 | |
---|
[282] | 2384 | list_civ1=get(handles.ListPairCiv1,'String'); |
---|
| 2385 | index_civ1=get(handles.ListPairCiv1,'Value'); |
---|
[227] | 2386 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
| 2387 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 2388 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 2389 | return |
---|
| 2390 | end |
---|
[282] | 2391 | list_civ2=get(handles.ListPairCiv2,'String'); |
---|
| 2392 | index_civ2=get(handles.ListPairCiv2,'Value'); |
---|
[227] | 2393 | if index_civ2>length(list_civ2) |
---|
| 2394 | list_civ2=list_civ1; |
---|
| 2395 | index_civ2=index_civ1; |
---|
| 2396 | end |
---|
| 2397 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 2398 | |
---|
| 2399 | if isequal (mode,'series(Di)') |
---|
| 2400 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2401 | num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
| 2402 | num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
| 2403 | num_a_civ1=ref_j; |
---|
| 2404 | num_b_civ1=ref_j; |
---|
[229] | 2405 | num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
[227] | 2406 | num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
| 2407 | num_a_civ2=ref_j; |
---|
| 2408 | num_b_civ2=ref_j; |
---|
| 2409 | |
---|
| 2410 | % adjust the first and last field number |
---|
| 2411 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2412 | if isnan(lastfield) |
---|
| 2413 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 2414 | else |
---|
| 2415 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 2416 | end |
---|
| 2417 | if length(indsel)>=1 |
---|
| 2418 | firstind=indsel(1); |
---|
| 2419 | lastind=indsel(end); |
---|
| 2420 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
| 2421 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
| 2422 | ref_i=ref_i(indsel); |
---|
| 2423 | num1_civ1=num1_civ1(indsel); |
---|
| 2424 | num1_civ2=num1_civ2(indsel); |
---|
| 2425 | num2_civ1=num2_civ1(indsel); |
---|
| 2426 | num2_civ2=num2_civ2(indsel); |
---|
| 2427 | end |
---|
| 2428 | elseif isequal (mode,'series(Dj)') |
---|
| 2429 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
| 2430 | num1_civ1=ref_i;% set of first image numbers |
---|
| 2431 | num2_civ1=ref_i; |
---|
| 2432 | num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
| 2433 | num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
| 2434 | num1_civ2=ref_i; |
---|
| 2435 | num2_civ2=ref_i; |
---|
| 2436 | num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
| 2437 | num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
| 2438 | % adjust the first and last field number |
---|
| 2439 | if isnan(lastfield_j) |
---|
| 2440 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 2441 | else |
---|
| 2442 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 2443 | end |
---|
| 2444 | if length(indsel)>=1 |
---|
| 2445 | firstind=indsel(1); |
---|
| 2446 | lastind=indsel(end); |
---|
| 2447 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
| 2448 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
| 2449 | ref_j=ref_j(indsel); |
---|
| 2450 | num_a_civ1=num_a_civ1(indsel); |
---|
| 2451 | num_b_civ1=num_b_civ1(indsel); |
---|
| 2452 | num_a_civ2=num_a_civ2(indsel); |
---|
| 2453 | num_b_civ2=num_b_civ2(indsel); |
---|
| 2454 | end |
---|
| 2455 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[282] | 2456 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[227] | 2457 | num1_civ1=ref_i; |
---|
| 2458 | num2_civ1=ref_i; |
---|
| 2459 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 2460 | num_b_civ1=displ_num(2,index_civ1); |
---|
| 2461 | num1_civ2=ref_i; |
---|
| 2462 | num2_civ2=ref_i; |
---|
| 2463 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 2464 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 2465 | elseif isequal(mode,'displacement') |
---|
| 2466 | num1_civ1=ref_i; |
---|
| 2467 | num2_civ1=ref_i; |
---|
| 2468 | num_a_civ1=ref_j; |
---|
| 2469 | num_b_civ1=ref_j; |
---|
| 2470 | num1_civ2=ref_i; |
---|
| 2471 | num2_civ2=ref_i; |
---|
| 2472 | num_a_civ2=ref_j; |
---|
| 2473 | num_b_civ2=ref_j; |
---|
| 2474 | end |
---|
| 2475 | |
---|
| 2476 | %------------------------------------------------------------------------ |
---|
[309] | 2477 | % --- Executes on button press in ListCompareMode. |
---|
| 2478 | function ListCompareMode_Callback(hObject, eventdata, handles) |
---|
[12] | 2479 | %------------------------------------------------------------------------ |
---|
[371] | 2480 | ListCompareMode=get(handles.ListCompareMode,'String'); |
---|
| 2481 | option=ListCompareMode{get(handles.ListCompareMode,'Value')}; |
---|
[360] | 2482 | if ~strcmp(option,'PIV') % case 'displacement' or 'stereo PIV' |
---|
[371] | 2483 | filebase=get(handles.RootPath,'String'); |
---|
[309] | 2484 | set(handles.sub_txt,'Visible','on') |
---|
[371] | 2485 | set(handles.RootFile_1,'Visible','On');%mkes the second file input window visible |
---|
[309] | 2486 | mode_store=get(handles.ListPairMode,'String');%get the present 'mode' |
---|
| 2487 | set(handles.ListCompareMode,'UserData',mode_store);%store the mode display |
---|
| 2488 | set(handles.ListPairMode,'Visible','off') |
---|
| 2489 | |
---|
[371] | 2490 | %% open an image file with the browser |
---|
[309] | 2491 | ind_opening=1;%default |
---|
| 2492 | browse.incr_pair=[0 0]; %default |
---|
[371] | 2493 | oldfile=get(handles.RootPath,'String'); |
---|
| 2494 | menu={'*.png;*.jpg;*.tif;*.avi;*.AVI;', ' (*.png,*.jpg ,.tif, *.avi,*.AVI)'; |
---|
[309] | 2495 | '*.png','.png image files'; ... |
---|
| 2496 | '*.jpg',' jpeg image files'; ... |
---|
| 2497 | '*.tif','.tif image files'; ... |
---|
| 2498 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 2499 | '*.*', 'All Files (*.*)'}; |
---|
[371] | 2500 | if strcmp(option,'displacement') |
---|
| 2501 | comment='Pick the reference file for displacements'; |
---|
| 2502 | else |
---|
| 2503 | comment='Pick a file of the second series'; |
---|
| 2504 | end |
---|
| 2505 | [FileName, PathName] = uigetfile( menu, comment,oldfile); |
---|
[309] | 2506 | fileinput=[PathName FileName];%complete file name |
---|
| 2507 | sizf=size(fileinput); |
---|
| 2508 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 2509 | [path,name,ext]=fileparts(fileinput); |
---|
| 2510 | [path1]=fileparts(filebase); |
---|
| 2511 | if isunix |
---|
| 2512 | [status,path]=system(['readlink ' path]); |
---|
| 2513 | [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths |
---|
| 2514 | end |
---|
| 2515 | if ~strcmp(path1,path) |
---|
[371] | 2516 | msgbox_uvmat('ERROR','The second image or series must be in the same directory as the first one') |
---|
[309] | 2517 | return |
---|
[360] | 2518 | end |
---|
[371] | 2519 | if strcmp(option,'displacement') |
---|
| 2520 | [tild,RootFile_1]=fileparts(name); |
---|
| 2521 | else |
---|
[398] | 2522 | [FilePath,FileName,Ext]=fileparts(fileinput); |
---|
| 2523 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 2524 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
| 2525 | [RootPath,SubDir,RootFile_1,i1_series,i2_series,j1_series,j2_series,nom_type_1,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName Ext]); |
---|
| 2526 | |
---|
| 2527 | % [tild,tild,RootFile_1,tild,tild,tild,tild,tild,nom_type_1]=fileparts_uvmat(fileinput); |
---|
| 2528 | %[RootFile_1,i1_series,tild,j1_series,tild,nom_type_1,FileType,Object]=find_file_series(PathName,FileName); |
---|
[371] | 2529 | %check image nom type |
---|
| 2530 | if ~strcmp(nom_type_1,get(handles.NomType,'String')) |
---|
| 2531 | 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') |
---|
| 2532 | return |
---|
| 2533 | end |
---|
| 2534 | end |
---|
| 2535 | %check image extension |
---|
[309] | 2536 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
| 2537 | msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one') |
---|
| 2538 | return |
---|
[371] | 2539 | end |
---|
| 2540 | set(handles.RootFile_1,'String',RootFile_1); |
---|
[309] | 2541 | else |
---|
| 2542 | set(handles.ListPairMode,'Visible','on') |
---|
[371] | 2543 | set(handles.RootFile_1,'Visible','Off'); |
---|
[309] | 2544 | set(handles.sub_txt,'Visible','off') |
---|
[371] | 2545 | set(handles.RootFile_1,'String',[]); |
---|
[309] | 2546 | mode_store=get(handles.ListCompareMode,'UserData'); |
---|
| 2547 | set(handles.ListPairMode,'Value',1) |
---|
| 2548 | set(handles.ListPairMode,'String',mode_store) |
---|
| 2549 | set(handles.CheckStereo,'Value',0) |
---|
| 2550 | set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default |
---|
| 2551 | end |
---|
[371] | 2552 | % if strcmp(option,'stereo PIV') && get(handles.CheckPatch1,'Value') |
---|
| 2553 | % set(handles.CheckStereo,'Visible','on') |
---|
| 2554 | % else |
---|
| 2555 | % set(handles.CheckStereo,'Visible','off') |
---|
| 2556 | % end |
---|
| 2557 | % if strcmp(option,'stereo PIV') && get(handles.CheckPatch2,'Value') |
---|
| 2558 | % set(handles.CheckStereo,'Visible','on') |
---|
| 2559 | % else |
---|
| 2560 | % set(handles.CheckStereo,'Visible','off') |
---|
| 2561 | % end |
---|
[319] | 2562 | ListPairMode_Callback(hObject, eventdata, handles) |
---|
[2] | 2563 | |
---|
[309] | 2564 | |
---|
| 2565 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 2566 | % Callbacks in the uipanel Pair Indices |
---|
| 2567 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[12] | 2568 | %------------------------------------------------------------------------ |
---|
[309] | 2569 | % --- Executes on button press in ListPairMode. |
---|
| 2570 | function ListPairMode_Callback(hObject, eventdata, handles) |
---|
[12] | 2571 | %------------------------------------------------------------------------ |
---|
[309] | 2572 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 2573 | val=get(handles.ListCompareMode,'Value'); |
---|
| 2574 | compare=compare_list{val}; |
---|
[360] | 2575 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
[309] | 2576 | mode='displacement'; |
---|
| 2577 | else |
---|
| 2578 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2579 | if ischar(mode_list) |
---|
| 2580 | mode_list={mode_list}; |
---|
| 2581 | end |
---|
| 2582 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2583 | mode=mode_list{mode_value}; |
---|
| 2584 | end |
---|
| 2585 | displ_num=[];%default |
---|
| 2586 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 2587 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 2588 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[343] | 2589 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 2590 | checkframe=strcmp(TimeUnit,'frame'); |
---|
[309] | 2591 | siztime=size(time); |
---|
[343] | 2592 | nbfield=siztime(1)-1; |
---|
| 2593 | nbfield2=siztime(2)-1; |
---|
[309] | 2594 | indchosen=1; %%first pair selected by default |
---|
| 2595 | %displ_num used to define the indices of the civ pairs |
---|
| 2596 | % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices |
---|
| 2597 | % are relative to the reference indices ref_i and ref_j respectively. |
---|
| 2598 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 2599 | dt=1; |
---|
| 2600 | displ=''; |
---|
| 2601 | index=0; |
---|
| 2602 | numlist_a=[]; |
---|
| 2603 | numlist_B=[]; |
---|
| 2604 | %get all the time intervals in bursts |
---|
| 2605 | displ_dt=1;%default |
---|
| 2606 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 2607 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 2608 | for numod_b=(numod_a+1):nbfield2 |
---|
| 2609 | index=index+1; |
---|
| 2610 | numlist_a(index)=numod_a; |
---|
| 2611 | numlist_b(index)=numod_b; |
---|
[343] | 2612 | if size(time,2)>1 && ~checkframe |
---|
| 2613 | dt(numod_a,numod_b)=time(ref_i+1,numod_b+1)-time(ref_i+1,numod_a+1);%first time interval dt |
---|
[309] | 2614 | displ_dt(index)=dt(numod_a,numod_b); |
---|
| 2615 | else |
---|
| 2616 | displ_dt(index)=1; |
---|
| 2617 | end |
---|
| 2618 | end |
---|
| 2619 | end |
---|
| 2620 | [dtsort,indsort]=sort(displ_dt); |
---|
| 2621 | if ~isempty(numlist_a) |
---|
| 2622 | displ_num(1,:)=numlist_a(indsort); |
---|
| 2623 | displ_num(2,:)=numlist_b(indsort); |
---|
| 2624 | end |
---|
| 2625 | displ_num(3,:)=0; |
---|
| 2626 | displ_num(4,:)=0; |
---|
[360] | 2627 | enable_j(handles, 'off') |
---|
[309] | 2628 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
| 2629 | index=1:200; |
---|
| 2630 | displ_num(1,index)=-floor(index/2); |
---|
| 2631 | displ_num(2,index)=ceil(index/2); |
---|
| 2632 | displ_num(3:4,index)=zeros(2,200); |
---|
[360] | 2633 | enable_j(handles, 'on') |
---|
[309] | 2634 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 2635 | index=1:200; |
---|
| 2636 | displ_num(1:2,index)=zeros(2,200); |
---|
| 2637 | displ_num(3,index)=-floor(index/2); |
---|
| 2638 | displ_num(4,index)=ceil(index/2); |
---|
[360] | 2639 | enable_i(handles, 'on') |
---|
[309] | 2640 | if nbfield2 > 1 |
---|
[360] | 2641 | enable_j(handles, 'on') |
---|
[309] | 2642 | else |
---|
[360] | 2643 | enable_j(handles, 'off') |
---|
[309] | 2644 | end |
---|
| 2645 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
| 2646 | displ_num(1,1)=0; |
---|
| 2647 | displ_num(2,1)=0; |
---|
| 2648 | displ_num(3,1)=0; |
---|
| 2649 | displ_num(4,1)=0; |
---|
[319] | 2650 | if nbfield > 1 || nbfield==0 |
---|
[360] | 2651 | enable_i(handles, 'on') |
---|
[309] | 2652 | else |
---|
[360] | 2653 | enable_j(handles, 'off') |
---|
[309] | 2654 | end |
---|
| 2655 | if nbfield2 > 1 |
---|
[360] | 2656 | enable_j(handles, 'on') |
---|
[309] | 2657 | else |
---|
[360] | 2658 | enable_j(handles, 'off') |
---|
[309] | 2659 | end |
---|
| 2660 | end |
---|
| 2661 | set(handles.ListPairCiv1,'UserData',displ_num); |
---|
[362] | 2662 | errormsg=find_netcpair_civ( handles,1); |
---|
| 2663 | if ~isempty(errormsg) |
---|
| 2664 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2665 | end |
---|
[360] | 2666 | % find_netcpair_civ2(handles) |
---|
[2] | 2667 | |
---|
[360] | 2668 | function enable_i(handles, state) |
---|
| 2669 | set(handles.itext,'Visible',state) |
---|
| 2670 | set(handles.first_i,'Visible',state) |
---|
| 2671 | set(handles.last_i,'Visible',state) |
---|
| 2672 | set(handles.incr_i,'Visible',state) |
---|
| 2673 | set(handles.nb_field,'Visible',state) |
---|
| 2674 | set(handles.ref_i,'Visible',state) |
---|
| 2675 | |
---|
| 2676 | function enable_j(handles, state) |
---|
| 2677 | set(handles.jtext,'Visible',state) |
---|
| 2678 | set(handles.first_j,'Visible',state) |
---|
| 2679 | set(handles.last_j,'Visible',state) |
---|
| 2680 | set(handles.incr_j,'Visible',state) |
---|
| 2681 | set(handles.nb_field2,'Visible',state) |
---|
| 2682 | set(handles.ref_j,'Visible',state) |
---|
| 2683 | |
---|
| 2684 | |
---|
[12] | 2685 | %------------------------------------------------------------------------ |
---|
[309] | 2686 | % --- Executes on selection change in ListPairCiv1. |
---|
| 2687 | function ListPairCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 2688 | %------------------------------------------------------------------------ |
---|
[309] | 2689 | %reproduce by default the chosen pair in the checkciv2 menu |
---|
| 2690 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
| 2691 | index_pair=get(handles.ListPairCiv1,'Value'); |
---|
| 2692 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
| 2693 | % num_a=displ_num(1,index_pair); |
---|
| 2694 | % num_b=displ_num(2,index_pair); |
---|
| 2695 | list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs |
---|
| 2696 | if index_pair<=length(list_pair2) |
---|
| 2697 | set(handles.ListPairCiv2,'Value',index_pair); |
---|
| 2698 | end |
---|
[2] | 2699 | |
---|
[309] | 2700 | %update first_i and last_i according to the chosen image pairs |
---|
| 2701 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2702 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2703 | mode=mode_list{mode_value}; |
---|
| 2704 | if isequal(mode,'series(Di)') |
---|
| 2705 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2706 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2707 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2708 | num1=first_i:incr_i:last_i; |
---|
| 2709 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2710 | if ~isnan(lastfield) |
---|
| 2711 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 2712 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 2713 | num1=num1(test_find); |
---|
| 2714 | end |
---|
| 2715 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 2716 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 2717 | elseif isequal(mode,'series(Dj)') |
---|
| 2718 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2719 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2720 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 2721 | num_j=first_j:incr_j:last_j; |
---|
| 2722 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 2723 | if ~isnan(lastfield2) |
---|
| 2724 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 2725 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 2726 | num1=num_j(test_find); |
---|
| 2727 | end |
---|
| 2728 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 2729 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 2730 | end |
---|
| 2731 | |
---|
[12] | 2732 | %------------------------------------------------------------------------ |
---|
[309] | 2733 | % --- Executes on selection change in ListPairCiv2. |
---|
| 2734 | function ListPairCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 2735 | %------------------------------------------------------------------------ |
---|
[309] | 2736 | index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu |
---|
[2] | 2737 | |
---|
[309] | 2738 | %update first_i and last_i according to the chosen image pairs |
---|
| 2739 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2740 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2741 | mode=mode_list{mode_value}; |
---|
| 2742 | if isequal(mode,'series(Di)') |
---|
| 2743 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2744 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2745 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2746 | num1=first_i:incr_i:last_i; |
---|
| 2747 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2748 | if ~isnan(lastfield) |
---|
| 2749 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 2750 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 2751 | num1=num1(test_find); |
---|
| 2752 | end |
---|
| 2753 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 2754 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 2755 | elseif isequal(mode,'series(Dj)') |
---|
| 2756 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2757 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2758 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 2759 | num_j=first_j:incr_j:last_j; |
---|
| 2760 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 2761 | if ~isnan(lastfield2) |
---|
| 2762 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 2763 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 2764 | num1=num_j(test_find); |
---|
| 2765 | end |
---|
| 2766 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 2767 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 2768 | end |
---|
| 2769 | |
---|
[12] | 2770 | %------------------------------------------------------------------------ |
---|
[309] | 2771 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 2772 | %------------------------------------------------------------------------ |
---|
[309] | 2773 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2774 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2775 | mode=mode_list{mode_value}; |
---|
[362] | 2776 | errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files |
---|
[309] | 2777 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
| 2778 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
[362] | 2779 | errormsg=find_netcpair_civ( handles,2); |
---|
[309] | 2780 | end |
---|
[362] | 2781 | if ~isempty(errormsg) |
---|
| 2782 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2783 | end |
---|
[2] | 2784 | |
---|
[12] | 2785 | %------------------------------------------------------------------------ |
---|
[309] | 2786 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 2787 | %------------------------------------------------------------------------ |
---|
[309] | 2788 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2789 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2790 | mode=mode_list{mode_value}; |
---|
| 2791 | if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[362] | 2792 | errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files |
---|
[309] | 2793 | end |
---|
| 2794 | if isequal(mode,'series(Dj)') || ... |
---|
| 2795 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
[362] | 2796 | errormsg=find_netcpair_civ(handles,2); |
---|
[309] | 2797 | end |
---|
[362] | 2798 | if ~isempty(errormsg) |
---|
| 2799 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2800 | end |
---|
[360] | 2801 | |
---|
[12] | 2802 | %------------------------------------------------------------------------ |
---|
[309] | 2803 | % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of |
---|
| 2804 | % the field series set by first_i, incr, last_i |
---|
[389] | 2805 | % index=1: look for pairs for civ1 |
---|
| 2806 | % index=2: look for pairs for civ2 |
---|
[362] | 2807 | function errormsg=find_netcpair_civ(handles,index) |
---|
[12] | 2808 | %------------------------------------------------------------------------ |
---|
[362] | 2809 | set(gcf,'Pointer','watch')% set the mouse pointer to 'watch' (clock) |
---|
| 2810 | |
---|
| 2811 | %% initialisation |
---|
| 2812 | errormsg=''; |
---|
[371] | 2813 | browse=get(handles.RootPath,'UserData'); |
---|
[309] | 2814 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 2815 | val=get(handles.ListCompareMode,'Value'); |
---|
| 2816 | compare=compare_list{val}; |
---|
[371] | 2817 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
[309] | 2818 | mode='displacement'; |
---|
| 2819 | else |
---|
| 2820 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2821 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 2822 | if isempty(mode_list) |
---|
| 2823 | return |
---|
| 2824 | end |
---|
| 2825 | mode=mode_list{mode_value}; |
---|
| 2826 | end |
---|
[360] | 2827 | nom_type_ima=get(handles.NomType,'String'); |
---|
[289] | 2828 | |
---|
[360] | 2829 | %% determine nom_type_nc, nomenclature type of the .nc files: |
---|
[389] | 2830 | [nom_type_nc]=nomtype2pair(nom_type_ima,mode); |
---|
[309] | 2831 | |
---|
[362] | 2832 | %% reads .nc subdirectoy and image numbers from the interface |
---|
[363] | 2833 | subdir_civ1=get(handles.SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 2834 | subdir_civ2=get(handles.SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[309] | 2835 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 2836 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 2837 | ref_j=0; |
---|
| 2838 | else |
---|
| 2839 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[414] | 2840 | if isnan(ref_j) |
---|
| 2841 | ref_j=1; |
---|
| 2842 | end |
---|
[309] | 2843 | end |
---|
| 2844 | time=get(handles.ImaDoc,'UserData');%get the set of times |
---|
[343] | 2845 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 2846 | checkframe=strcmp(TimeUnit,'frame'); |
---|
[309] | 2847 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
| 2848 | |
---|
[362] | 2849 | %% eliminate the first pairs inconsistent with the position |
---|
[309] | 2850 | if isempty(displ_num) |
---|
| 2851 | nbpair=0; |
---|
| 2852 | else |
---|
| 2853 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 2854 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 2855 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 2856 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 2857 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 2858 | end |
---|
| 2859 | end |
---|
| 2860 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 2861 | |
---|
[362] | 2862 | %% case with no Civ1 operation, netcdf files need to exist for reading |
---|
[309] | 2863 | displ_pair={''}; |
---|
| 2864 | select=ones(size(1:nbpair));%flag for displayed pairs =1 for display |
---|
| 2865 | testpair=0; |
---|
[371] | 2866 | RootPath=get(handles.RootPath,'String'); |
---|
| 2867 | RootFile=get(handles.RootFile,'String'); |
---|
[360] | 2868 | if index==1 % case civ1 |
---|
[362] | 2869 | if ~get(handles.CheckCiv1,'Value') % |
---|
[371] | 2870 | if ~exist(fullfile(RootPath,subdir_civ1),'dir') |
---|
[362] | 2871 | errormsg=['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']; |
---|
| 2872 | set(handles.ListPairCiv1,'String',{}); |
---|
| 2873 | return |
---|
| 2874 | end |
---|
| 2875 | for ipair=1:nbpair |
---|
| 2876 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,... |
---|
| 2877 | ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair)); |
---|
| 2878 | select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist |
---|
| 2879 | end |
---|
| 2880 | % case of no displayed pair |
---|
| 2881 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 2882 | if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0]) |
---|
| 2883 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 2884 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 2885 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 2886 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 2887 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2); |
---|
| 2888 | select(1)=exist(filename,'file')==2; |
---|
| 2889 | testpair=1; |
---|
[309] | 2890 | else |
---|
[362] | 2891 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 2892 | errormsg=['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]; |
---|
| 2893 | else |
---|
[389] | 2894 | errormsg=['no civ1 file available for the selected reference indices (i,j)= ' num2str(ref_i) ', ' num2str(ref_j) ' and subdirectory ' subdir_civ1]; |
---|
[362] | 2895 | end |
---|
| 2896 | set(handles.ListPairCiv1,'String',{''}); |
---|
| 2897 | %COMPLETER CAS STEREO |
---|
| 2898 | return |
---|
[309] | 2899 | end |
---|
| 2900 | end |
---|
| 2901 | end |
---|
[362] | 2902 | else %case civ2 alone |
---|
| 2903 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
[438] | 2904 | if ~exist(fullfile(RootPath,subdir_civ2),'dir') |
---|
| 2905 | msgbox_uvmat('ERROR',['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
[360] | 2906 | set(handles.ListPairCiv2,'Value',1); |
---|
| 2907 | set(handles.ListPairCiv2,'String',{''}); |
---|
| 2908 | return |
---|
| 2909 | end |
---|
[362] | 2910 | for ipair=1:nbpair |
---|
| 2911 | filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,... |
---|
| 2912 | ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair)); |
---|
| 2913 | select(ipair)=exist(filename,'file')==2; |
---|
| 2914 | end |
---|
| 2915 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 2916 | if isfield(browse,'incr_pair') |
---|
| 2917 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 2918 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 2919 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 2920 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 2921 | filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2); |
---|
| 2922 | select(1)=exist(filename,'file')==2; |
---|
| 2923 | else |
---|
| 2924 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 2925 | errormsg=['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]; |
---|
| 2926 | else |
---|
| 2927 | errormsg=['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]; |
---|
| 2928 | end |
---|
| 2929 | set(handles.ListPairCiv2,'Value',1); |
---|
| 2930 | set(handles.ListPairCiv2,'String',{''}); |
---|
| 2931 | return |
---|
| 2932 | end |
---|
| 2933 | end |
---|
[360] | 2934 | end |
---|
| 2935 | end |
---|
[309] | 2936 | |
---|
| 2937 | %% determine the menu display in .ListPairCiv1 |
---|
| 2938 | % the menu depends on the mode defined in ListPairMode_callback through the array displ_num: |
---|
| 2939 | % displ_num(1,:)=indices j1 |
---|
| 2940 | % displ_num(2,:)=indices j2 |
---|
| 2941 | % displ_num(3,:)=indices i1 |
---|
| 2942 | % displ_num(4,:)=indices i2 |
---|
| 2943 | % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices |
---|
| 2944 | % are relative to the reference indices ref_i and ref_j respectively. |
---|
| 2945 | if isequal(mode,'series(Di)') |
---|
| 2946 | if testpair |
---|
| 2947 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 2948 | else |
---|
| 2949 | for ipair=1:nbpair |
---|
| 2950 | if select(ipair) |
---|
| 2951 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
[389] | 2952 | %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 |
---|
| 2953 | % 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 |
---|
| 2954 | if ~checkframe && size(time,1)>=ref_i+1+ceil(ipair/2) && size(time,2)>=ref_j+1&& ref_i-floor(ipair/2)>=0 && ref_j>=0 |
---|
| 2955 | dt=time(ref_i+1+ceil(ipair/2),ref_j+1)-time(ref_i+1-floor(ipair/2),ref_j+1);%time interval dtref_j+1 |
---|
[343] | 2956 | else |
---|
| 2957 | dt=1; |
---|
[309] | 2958 | end |
---|
[343] | 2959 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
[309] | 2960 | else |
---|
| 2961 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 2962 | end |
---|
| 2963 | end |
---|
| 2964 | end |
---|
| 2965 | elseif isequal(mode,'series(Dj)') |
---|
| 2966 | if testpair |
---|
| 2967 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 2968 | else |
---|
| 2969 | for ipair=1:nbpair |
---|
| 2970 | if select(ipair) |
---|
| 2971 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
[343] | 2972 | if ~checkframe && size(time,1)>=ref_i+1+displ_num(4,ipair) && size(time,2)>=ref_j+1+displ_num(2,ipair) |
---|
| 2973 | 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] | 2974 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
| 2975 | end |
---|
| 2976 | else |
---|
| 2977 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 2978 | end |
---|
| 2979 | end |
---|
| 2980 | end |
---|
| 2981 | elseif isequal(mode,'pair j1-j2')%case of pairs |
---|
| 2982 | for ipair=1:nbpair |
---|
| 2983 | if select(ipair) |
---|
[343] | 2984 | if ~checkframe && size(time,2)>1 |
---|
| 2985 | 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 |
---|
| 2986 | else % time set by default to i index |
---|
| 2987 | dt=1; |
---|
| 2988 | end |
---|
[309] | 2989 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 2990 | ' :dt= ' num2str(dt*1000)]; |
---|
| 2991 | else |
---|
| 2992 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 2993 | end |
---|
| 2994 | end |
---|
| 2995 | elseif isequal(mode,'displacement') |
---|
| 2996 | displ_pair={'Di=Dj=0'}; |
---|
| 2997 | end |
---|
[362] | 2998 | if index==1 |
---|
[309] | 2999 | set(handles.ListPairCiv1,'String',displ_pair'); |
---|
[362] | 3000 | end |
---|
[309] | 3001 | |
---|
| 3002 | %% determine the default selection in the pair menu |
---|
| 3003 | ichoice=find(select,1);% index of selected pair |
---|
| 3004 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 3005 | initial=get(handles.ListPairCiv1,'Value');%initial choice of pair |
---|
| 3006 | if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1)) |
---|
| 3007 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 3008 | end |
---|
| 3009 | initial=get(handles.ListPairCiv2,'Value'); |
---|
| 3010 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 3011 | if ichoice <= length(displ_pair') |
---|
| 3012 | set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 3013 | else |
---|
| 3014 | set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2 |
---|
| 3015 | end |
---|
| 3016 | end |
---|
| 3017 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
| 3018 | set(gcf,'Pointer','arrow') |
---|
| 3019 | |
---|
[415] | 3020 | |
---|
[315] | 3021 | |
---|
[415] | 3022 | % %------------------------------------------------------------------------ |
---|
| 3023 | % % call 'view_field.fig' to display the field selected in the list of 'status' |
---|
| 3024 | % function open_view_field(hObject, eventdata) |
---|
| 3025 | % %------------------------------------------------------------------------ |
---|
| 3026 | % list=get(hObject,'String'); |
---|
| 3027 | % index=get(hObject,'Value'); |
---|
| 3028 | % rootroot=get(hObject,'UserData'); |
---|
| 3029 | % filename=list{index}; |
---|
| 3030 | % ind_dot=strfind(filename,'...'); |
---|
| 3031 | % filename=filename(1:ind_dot-1); |
---|
| 3032 | % filename=fullfile(rootroot,filename); |
---|
| 3033 | % delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
| 3034 | % if exist(filename,'file')%visualise the vel field if it exists |
---|
| 3035 | % uvmat(filename) |
---|
| 3036 | % set(gcbo,'Value',1) |
---|
| 3037 | % end |
---|
[309] | 3038 | |
---|
| 3039 | |
---|
| 3040 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3041 | % Callbacks in the uipanel Reference Indices |
---|
| 3042 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[12] | 3043 | %------------------------------------------------------------------------ |
---|
| 3044 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3045 | %------------------------------------------------------------------------ |
---|
[137] | 3046 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3047 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
| 3048 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3049 | |
---|
[12] | 3050 | %------------------------------------------------------------------------ |
---|
| 3051 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3052 | %------------------------------------------------------------------------ |
---|
| 3053 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3054 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3055 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3056 | |
---|
[309] | 3057 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3058 | % Callbacks in the uipanel Civ1 |
---|
| 3059 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[12] | 3060 | %------------------------------------------------------------------------ |
---|
[437] | 3061 | % --- Executes on button press in SearchRange: determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 |
---|
[273] | 3062 | function SearchRange_Callback(hObject, eventdata, handles) |
---|
[12] | 3063 | %------------------------------------------------------------------------ |
---|
[2] | 3064 | %determine pair numbers |
---|
[415] | 3065 | if strcmp(get(handles.num_UMin,'Visible'),'off') |
---|
[273] | 3066 | set(handles.u_title,'Visible','on') |
---|
| 3067 | set(handles.v_title,'Visible','on') |
---|
[415] | 3068 | set(handles.num_UMin,'Visible','on') |
---|
| 3069 | set(handles.num_UMax,'Visible','on') |
---|
| 3070 | set(handles.num_VMin,'Visible','on') |
---|
| 3071 | set(handles.num_VMax,'Visible','on') |
---|
[273] | 3072 | set(handles.CoordUnit,'Visible','on') |
---|
| 3073 | set(handles.TimeUnit,'Visible','on') |
---|
| 3074 | set(handles.slash_title,'Visible','on') |
---|
| 3075 | set(handles.min_title,'Visible','on') |
---|
| 3076 | set(handles.max_title,'Visible','on') |
---|
| 3077 | set(handles.unit_title,'Visible','on') |
---|
| 3078 | else |
---|
| 3079 | get_search_range(hObject, eventdata, handles) |
---|
[2] | 3080 | end |
---|
| 3081 | |
---|
[12] | 3082 | %------------------------------------------------------------------------ |
---|
[437] | 3083 | % --- determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 and shift |
---|
[273] | 3084 | function get_search_range(hObject, eventdata, handles) |
---|
[415] | 3085 | %------------------------------------------------------------------------ |
---|
| 3086 | param_civ1=read_GUI(handles.Civ1); |
---|
| 3087 | umin=param_civ1.UMin; |
---|
| 3088 | umax=param_civ1.UMax; |
---|
| 3089 | vmin=param_civ1.VMin; |
---|
| 3090 | vmax=param_civ1.VMax; |
---|
[273] | 3091 | %switch min_title and max_title in case of error |
---|
| 3092 | if umax<=umin |
---|
| 3093 | umin_old=umin; |
---|
| 3094 | umin=umax; |
---|
| 3095 | umax=umin_old; |
---|
[415] | 3096 | set(handles.num_UMin,'String', num2str(umin)) |
---|
| 3097 | set(handles.num_UMax,'String', num2str(umax)) |
---|
[273] | 3098 | end |
---|
| 3099 | if vmax<=vmin |
---|
| 3100 | vmin_old=vmin; |
---|
| 3101 | vmin=vmax; |
---|
| 3102 | vmax=vmin_old; |
---|
[415] | 3103 | set(handles.num_VMin,'String', num2str(vmin)) |
---|
| 3104 | set(handles.num_VMax,'String', num2str(vmax)) |
---|
[273] | 3105 | end |
---|
[415] | 3106 | if ~(isempty(umin)||isempty(umax)||isempty(vmin)||isempty(vmax)) |
---|
[282] | 3107 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
| 3108 | index=get(handles.ListPairCiv1,'Value'); |
---|
[415] | 3109 | pair_string=list_pair{index}; |
---|
[273] | 3110 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[415] | 3111 | pxcm=get(handles.SearchRange,'UserData'); |
---|
[282] | 3112 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 3113 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[415] | 3114 | mode=mode_list{mode_value}; |
---|
[273] | 3115 | if isequal (mode, 'series(Di)' ) |
---|
| 3116 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3117 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3118 | num2=ref_i+ceil(index/2); |
---|
| 3119 | num_a=1; |
---|
| 3120 | num_b=1; |
---|
| 3121 | elseif isequal (mode, 'series(Dj)') |
---|
| 3122 | num1=1; |
---|
| 3123 | num2=1; |
---|
| 3124 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 3125 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3126 | num_b=ref_j+ceil(index/2); |
---|
[415] | 3127 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[273] | 3128 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3129 | num1=ref_i; |
---|
| 3130 | num2=ref_i; |
---|
[415] | 3131 | r=regexp(pair_string,'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
| 3132 | if isempty(r) |
---|
| 3133 | r=regexp(pair_string,'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names'); |
---|
| 3134 | end |
---|
| 3135 | num_a=str2num(r.num1); |
---|
| 3136 | num_b=str2num(r.num2); |
---|
[273] | 3137 | end |
---|
[415] | 3138 | dt=time(num2+1,num_b+1)-time(num1+1,num_a+1); |
---|
[437] | 3139 | ibx=str2double(get(handles.num_CorrBoxSize_1,'String')); |
---|
| 3140 | iby=str2double(get(handles.num_CorrBoxSize_2,'String')); |
---|
[415] | 3141 | umin=dt*pxcm*umin; |
---|
| 3142 | umax=dt*pxcm*umax; |
---|
| 3143 | vmin=dt*pxcm*vmin; |
---|
| 3144 | vmax=dt*pxcm*vmax; |
---|
[273] | 3145 | shiftx=round((umin+umax)/2); |
---|
| 3146 | shifty=round((vmin+vmax)/2); |
---|
[415] | 3147 | isx=(umax+2-shiftx)*2+param_civ1.Bx; |
---|
[273] | 3148 | isx=2*ceil(isx/2)+1; |
---|
[415] | 3149 | isy=(vmax+2-shifty)*2+param_civ1.Bx; |
---|
[273] | 3150 | isy=2*ceil(isy/2)+1; |
---|
[437] | 3151 | set(handles.num_SearchBoxShift_1,'String',num2str(shiftx)); |
---|
| 3152 | set(handles.num_SearchBoxShift_2,'String',num2str(shifty)); |
---|
| 3153 | set(handles.num_SearchBoxSize_1,'String',num2str(isx)); |
---|
| 3154 | set(handles.num_SearchBoxSize_2,'String',num2str(isy)); |
---|
[273] | 3155 | end |
---|
| 3156 | |
---|
[315] | 3157 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3158 | % Callbacks in the uipanel Fix1 |
---|
| 3159 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[12] | 3160 | %------------------------------------------------------------------------ |
---|
[282] | 3161 | % --- Executes on button press in CheckMask. |
---|
[2] | 3162 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3163 | %------------------------------------------------------------------------ |
---|
[282] | 3164 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3165 | if isequal(maskval,0) |
---|
[384] | 3166 | set(handles.Mask,'String','') |
---|
[2] | 3167 | else |
---|
[112] | 3168 | mask_displ='no mask'; %default |
---|
[371] | 3169 | filebase=get(handles.RootPath,'String'); |
---|
[112] | 3170 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3171 | if isequal(flag_mask,1) |
---|
| 3172 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3173 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[371] | 3174 | filebase_a=get(handles.RootFile_1,'String'); |
---|
[2] | 3175 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3176 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3177 | mask_displ='no mask'; |
---|
| 3178 | end |
---|
[112] | 3179 | end |
---|
| 3180 | if isequal(mask_displ,'no mask') |
---|
| 3181 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3182 | {'*.png', ' (*.png)'; |
---|
[12] | 3183 | '*.png', '.png files '; ... |
---|
| 3184 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3185 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3186 | mask_displ=fullfile(PathName,FileName); |
---|
| 3187 | if ~exist(mask_displ,'file') |
---|
| 3188 | mask_displ='no mask'; |
---|
| 3189 | end |
---|
[12] | 3190 | end |
---|
[112] | 3191 | if isequal(mask_displ,'no mask') |
---|
[282] | 3192 | set(handles.CheckMask,'Value',0) |
---|
| 3193 | set(handles.CheckMask,'Value',0) |
---|
| 3194 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3195 | else |
---|
[282] | 3196 | %set(handles.CheckMask,'Value',1) |
---|
| 3197 | set(handles.CheckMask,'Value',1) |
---|
[112] | 3198 | end |
---|
[384] | 3199 | set(handles.Mask,'String',mask_displ) |
---|
| 3200 | set(handles.Mask,'String',mask_displ) |
---|
| 3201 | set(handles.Mask,'String',mask_displ) |
---|
[12] | 3202 | end |
---|
| 3203 | |
---|
| 3204 | %------------------------------------------------------------------------ |
---|
[282] | 3205 | % --- Executes on button press in CheckMask: select box for mask option |
---|
[2] | 3206 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3207 | %------------------------------------------------------------------------ |
---|
[282] | 3208 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3209 | if isequal(maskval,0) |
---|
[384] | 3210 | set(handles.Mask,'String','') |
---|
[2] | 3211 | else |
---|
[112] | 3212 | mask_displ='no mask'; %default |
---|
[371] | 3213 | filebase=get(handles.RootPath,'String'); |
---|
[112] | 3214 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3215 | if isequal(flag_mask,1) |
---|
| 3216 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3217 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[371] | 3218 | filebase_a=get(handles.RootFile_1,'String'); |
---|
[2] | 3219 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3220 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3221 | mask_displ='no mask'; |
---|
| 3222 | end |
---|
[112] | 3223 | end |
---|
| 3224 | if isequal(mask_displ,'no mask') |
---|
| 3225 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3226 | {'*.png', ' (*.png)'; |
---|
[12] | 3227 | '*.png', '.png files '; ... |
---|
| 3228 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3229 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3230 | mask_displ=fullfile(PathName,FileName); |
---|
| 3231 | if ~exist(mask_displ,'file') |
---|
| 3232 | mask_displ='no mask'; |
---|
| 3233 | end |
---|
[12] | 3234 | end |
---|
[112] | 3235 | if isequal(mask_displ,'no mask') |
---|
[282] | 3236 | set(handles.CheckMask,'Value',0) |
---|
| 3237 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3238 | else |
---|
[282] | 3239 | set(handles.CheckMask,'Value',1) |
---|
[112] | 3240 | end |
---|
[384] | 3241 | set(handles.Mask,'String',mask_displ) |
---|
| 3242 | set(handles.Mask,'String',mask_displ) |
---|
[12] | 3243 | end |
---|
| 3244 | |
---|
| 3245 | %------------------------------------------------------------------------ |
---|
[282] | 3246 | % --- Executes on button press in CheckMask. |
---|
[2] | 3247 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3248 | %------------------------------------------------------------------------ |
---|
[282] | 3249 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3250 | if isequal(maskval,0) |
---|
[384] | 3251 | set(handles.Mask,'String','') |
---|
[2] | 3252 | else |
---|
[12] | 3253 | mask_displ='no mask'; %default |
---|
[371] | 3254 | filebase=get(handles.RootPath,'String'); |
---|
[12] | 3255 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3256 | if isequal(flag_mask,1) |
---|
[112] | 3257 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3258 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[371] | 3259 | filebase_a=get(handles.RootFile_1,'String'); |
---|
[112] | 3260 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3261 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[112] | 3262 | mask_displ='no mask'; |
---|
| 3263 | end |
---|
[12] | 3264 | end |
---|
| 3265 | if isequal(mask_displ,'no mask') |
---|
| 3266 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3267 | {'*.png', ' (*.png)'; |
---|
| 3268 | '*.png', '.png files '; ... |
---|
| 3269 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3270 | 'Pick a mask file *.png',filebase); |
---|
| 3271 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3272 | if ~exist(mask_displ,'file') |
---|
[2] | 3273 | mask_displ='no mask'; |
---|
| 3274 | end |
---|
[12] | 3275 | end |
---|
| 3276 | if isequal(mask_displ,'no mask') |
---|
[282] | 3277 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3278 | end |
---|
[384] | 3279 | set(handles.Mask,'String',mask_displ) |
---|
[2] | 3280 | end |
---|
| 3281 | |
---|
[12] | 3282 | %------------------------------------------------------------------------ |
---|
| 3283 | % --- function called to look for mask files |
---|
[2] | 3284 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3285 | %------------------------------------------------------------------------ |
---|
[112] | 3286 | %detect mask files, images with appropriate file base |
---|
[2] | 3287 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3288 | %flag_mask=1 indicates detection |
---|
| 3289 | |
---|
| 3290 | flag_mask=0;%default |
---|
| 3291 | nbslice=1; |
---|
| 3292 | |
---|
[363] | 3293 | % subdir=get(handles.SubdirCiv1,'String'); |
---|
[2] | 3294 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3295 | if ~isdir(Path) |
---|
| 3296 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3297 | return |
---|
| 3298 | end |
---|
[272] | 3299 | % currentdir=pwd; |
---|
| 3300 | % cd(Path);%move in the dir of the root name filebase |
---|
| 3301 | maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files |
---|
| 3302 | % cd(currentdir);%come back to the current working directory |
---|
[12] | 3303 | if ~isempty(maskfiles) |
---|
[112] | 3304 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3305 | % else |
---|
[2] | 3306 | flag_mask=1; |
---|
| 3307 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3308 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3309 | Namedouble=double(Name); |
---|
| 3310 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3311 | ind_mask=findstr('mask',Name); |
---|
| 3312 | i=ind_mask-1; |
---|
[137] | 3313 | while val(i)==0 && i>0 |
---|
[112] | 3314 | i=i-1; |
---|
[2] | 3315 | end |
---|
[137] | 3316 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3317 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3318 | flag_mask=1; |
---|
[2] | 3319 | else |
---|
[112] | 3320 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3321 | return |
---|
| 3322 | nbslice=1; |
---|
[2] | 3323 | end |
---|
[112] | 3324 | end |
---|
[2] | 3325 | |
---|
[12] | 3326 | %------------------------------------------------------------------------ |
---|
| 3327 | % --- function called to look for grid files |
---|
[2] | 3328 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 3329 | %------------------------------------------------------------------------ |
---|
[2] | 3330 | flag_mask=0;%default |
---|
| 3331 | nbslice=1; |
---|
| 3332 | [Path,Name]=fileparts(filebase); |
---|
| 3333 | currentdir=pwd; |
---|
| 3334 | cd(Path);%move in the dir of the root name filebase |
---|
| 3335 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 3336 | cd(currentdir);%come back to the current working directory |
---|
| 3337 | if ~isempty(maskfiles) |
---|
| 3338 | flag_mask=1; |
---|
| 3339 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3340 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3341 | Namedouble=double(Name); |
---|
| 3342 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3343 | ind_mask=findstr('grid',Name); |
---|
| 3344 | i=ind_mask-1; |
---|
[137] | 3345 | while val(i)==0 && i>0 |
---|
[112] | 3346 | i=i-1; |
---|
[2] | 3347 | end |
---|
[137] | 3348 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3349 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3350 | flag_mask=1; |
---|
[2] | 3351 | else |
---|
[112] | 3352 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3353 | return |
---|
| 3354 | nbslice=1; |
---|
[2] | 3355 | end |
---|
[12] | 3356 | end |
---|
[2] | 3357 | |
---|
[12] | 3358 | %------------------------------------------------------------------------ |
---|
| 3359 | % --- transform numbers to letters |
---|
[122] | 3360 | function str=num2stra(num,nom_type) |
---|
[12] | 3361 | %------------------------------------------------------------------------ |
---|
[122] | 3362 | if isempty(nom_type) |
---|
| 3363 | str=''; |
---|
| 3364 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3365 | str=char(96+num); |
---|
[122] | 3366 | elseif strcmp(nom_type(end),'A') |
---|
| 3367 | str=char(96+num); |
---|
| 3368 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3369 | str=''; |
---|
| 3370 | else |
---|
| 3371 | str=num2str(num); |
---|
| 3372 | end |
---|
[12] | 3373 | |
---|
[441] | 3374 | % %------------------------------------------------------------------------ |
---|
| 3375 | % % --- Executes on button press in ListSubdirCiv1. |
---|
| 3376 | % function ListSubdirCiv1_Callback(hObject, eventdata, handles) |
---|
| 3377 | % %------------------------------------------------------------------------ |
---|
| 3378 | % list_subdir_civ1=get(handles.ListSubdirCiv1,'String'); |
---|
| 3379 | % val=get(handles.ListSubdirCiv1,'Value'); |
---|
| 3380 | % SubDir=list_subdir_civ1{val}; |
---|
| 3381 | % if strcmp(SubDir,'new...') |
---|
| 3382 | % if get(handles.CheckCiv1,'Value') |
---|
| 3383 | % SubDir='CIV'; %default subdirectory |
---|
| 3384 | % else |
---|
| 3385 | % msgbox_uvmat('ERROR','select CheckCiv1 to perform a new Civ operation') |
---|
| 3386 | % return |
---|
| 3387 | % end |
---|
| 3388 | % end |
---|
| 3389 | % set(handles.SubdirCiv1,'String',SubDir); |
---|
| 3390 | % errormsg=find_netcpair_civ(handles,1); |
---|
| 3391 | % if ~isempty(errormsg) |
---|
| 3392 | % msgbox_uvmat('ERROR',errormsg) |
---|
| 3393 | % end |
---|
| 3394 | % |
---|
[12] | 3395 | %------------------------------------------------------------------------ |
---|
[441] | 3396 | % % --- Executes on button press in ListSubdirCiv2. |
---|
| 3397 | % function ListSubdirCiv2_Callback(hObject, eventdata, handles) |
---|
| 3398 | % %------------------------------------------------------------------------ |
---|
| 3399 | % list_subdir_civ2=get(handles.ListSubdirCiv2,'String'); |
---|
| 3400 | % val=get(handles.ListSubdirCiv2,'Value'); |
---|
| 3401 | % SubDir=list_subdir_civ2{val}; |
---|
| 3402 | % if strcmp(SubDir,'new...') |
---|
| 3403 | % if get(handles.CheckCiv2,'Value') |
---|
| 3404 | % SubDir='CIV'; %default subdirectory |
---|
| 3405 | % else |
---|
| 3406 | % msgbox_uvmat('ERROR','select CheckCiv2 to perform a new Civ operation') |
---|
| 3407 | % return |
---|
| 3408 | % end |
---|
| 3409 | % end |
---|
| 3410 | % set(handles.SubdirCiv2,'String',SubDir); |
---|
[2] | 3411 | |
---|
[12] | 3412 | %------------------------------------------------------------------------ |
---|
[282] | 3413 | % --- Executes on button press in CheckGrid. |
---|
| 3414 | function CheckGrid_Callback(hObject, eventdata, handles) |
---|
[12] | 3415 | %------------------------------------------------------------------------ |
---|
[276] | 3416 | value=get(hObject,'Value'); |
---|
| 3417 | hparent=get(hObject,'parent'); |
---|
| 3418 | hchildren=get(hparent,'children'); |
---|
[315] | 3419 | handle_txtbox=findobj(hchildren,'tag','txt_Grid'); |
---|
[276] | 3420 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 3421 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
[315] | 3422 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
| 3423 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
[2] | 3424 | testgrid=0; |
---|
[276] | 3425 | filegrid=''; |
---|
[2] | 3426 | if value |
---|
[371] | 3427 | filebase=get(handles.RootPath,'String'); |
---|
[276] | 3428 | [nbslice, flag_grid]=get_grid(filebase,handles);% look for a grid with appropriate name |
---|
[2] | 3429 | if isequal(flag_grid,1) |
---|
[112] | 3430 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3431 | testgrid=1; |
---|
[276] | 3432 | else % browse for a grid |
---|
| 3433 | filegrid=get(hObject,'UserData');%look for previous grid name stored as UserData |
---|
| 3434 | if exist(filegrid,'file') |
---|
| 3435 | filebase=filegrid; |
---|
| 3436 | end |
---|
[2] | 3437 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3438 | {'*.grid', ' (*.grid)'; |
---|
| 3439 | '*.grid', '.grid files '; ... |
---|
| 3440 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3441 | 'Pick a file',filebase); |
---|
[2] | 3442 | filegrid=fullfile(PathName,FileName); |
---|
[276] | 3443 | set(hObject,'UserData',filegrid);%store for future use |
---|
[2] | 3444 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3445 | testgrid=1; |
---|
| 3446 | end |
---|
[112] | 3447 | end |
---|
[2] | 3448 | end |
---|
| 3449 | if testgrid |
---|
[276] | 3450 | set(handle_dx,'Visible','off'); |
---|
| 3451 | set(handle_dy,'Visible','off'); |
---|
[315] | 3452 | set(handle_title_dy,'Visible','off'); |
---|
| 3453 | set(handle_title_dx,'Visible','off'); |
---|
[276] | 3454 | set(handle_txtbox,'Visible','on') |
---|
| 3455 | set(handle_txtbox,'String',filegrid) |
---|
[112] | 3456 | else |
---|
[276] | 3457 | set(hObject,'Value',0); |
---|
[315] | 3458 | set(handle_dx,'Visible','on'); |
---|
[276] | 3459 | set(handle_dy,'Visible','on'); |
---|
[315] | 3460 | set(handle_title_dy,'Visible','on'); |
---|
| 3461 | set(handle_title_dx,'Visible','on'); |
---|
[276] | 3462 | set(handle_txtbox,'Visible','off') |
---|
[2] | 3463 | end |
---|
| 3464 | |
---|
[282] | 3465 | %% if hObject is on the checkciv1 frame, duplicate action for checkciv2 frame |
---|
[319] | 3466 | PanelName=get(hparent,'tag'); |
---|
[315] | 3467 | if strcmp(PanelName,'Civ1') |
---|
[282] | 3468 | hchildren=get(handles.Civ2,'children'); |
---|
[315] | 3469 | handle_checkbox=findobj(hchildren,'tag','CheckGrid'); |
---|
| 3470 | handle_txtbox=findobj(hchildren,'tag','txt_Grid'); |
---|
[276] | 3471 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 3472 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
[315] | 3473 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
| 3474 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
[276] | 3475 | set(handle_checkbox,'UserData',filegrid);%store for future use |
---|
| 3476 | if testgrid |
---|
| 3477 | set(handle_checkbox,'Value',1); |
---|
| 3478 | set(handle_dx,'Visible','off'); |
---|
| 3479 | set(handle_dy,'Visible','off'); |
---|
[315] | 3480 | set(handle_title_dx,'Visible','off'); |
---|
| 3481 | set(handle_title_dy,'Visible','off'); |
---|
[276] | 3482 | set(handle_txtbox,'Visible','on') |
---|
| 3483 | set(handle_txtbox,'String',filegrid) |
---|
[315] | 3484 | % else |
---|
| 3485 | % set(handle_checkbox,'Value',0); |
---|
| 3486 | % set(handles.CheckGrid,'Value',0); |
---|
| 3487 | % set(handle_dx,'Visible','on'); |
---|
| 3488 | % set(handle_dy,'Visible','on'); |
---|
| 3489 | % set(handle_title_dx,'Visible','on'); |
---|
| 3490 | % set(handle_title_dy,'Visible','on'); |
---|
| 3491 | % set(handle_txtbox,'Visible','off') |
---|
[276] | 3492 | end |
---|
| 3493 | end |
---|
[387] | 3494 | |
---|
[12] | 3495 | %------------------------------------------------------------------------ |
---|
[387] | 3496 | % --- Executes on button press in CheckMask: common to all panels (civ1, Civ2..) |
---|
[282] | 3497 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
[276] | 3498 | %------------------------------------------------------------------------ |
---|
| 3499 | value=get(hObject,'Value'); |
---|
[315] | 3500 | hparent=get(hObject,'parent'); |
---|
| 3501 | parent_tag=get(hparent,'Tag'); |
---|
| 3502 | hchildren=get(hparent,'children'); |
---|
[387] | 3503 | handle_txtbox=findobj(hchildren,'tag','Mask');% look for the mask name box in the same panel |
---|
[276] | 3504 | testmask=0; |
---|
| 3505 | if value |
---|
[371] | 3506 | filebase=get(handles.RootPath,'String'); |
---|
[276] | 3507 | [nbslice, flag_mask]=get_mask(filebase,handles);% look for a mask with appropriate name |
---|
| 3508 | if isequal(flag_mask,1) |
---|
| 3509 | filemask=[num2str(nbslice) 'mask']; |
---|
| 3510 | testmask=1; |
---|
| 3511 | else % browse for a mask |
---|
[315] | 3512 | filemask=get(hObject,'UserData');%look for previous mask name stored as UserData |
---|
[276] | 3513 | if exist(filemask,'file') |
---|
| 3514 | filebase=filemask; |
---|
| 3515 | end |
---|
[315] | 3516 | [FileName, PathName] = uigetfile( ... |
---|
[276] | 3517 | {'*.png', ' (*.png)'; |
---|
| 3518 | '*.png', '.png files '; ... |
---|
| 3519 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3520 | 'Pick a mask file *.png',filebase); |
---|
| 3521 | filemask=fullfile(PathName,FileName); |
---|
[315] | 3522 | set(hObject,'UserData',filemask);%store for future use |
---|
[276] | 3523 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filemask,'file')) |
---|
| 3524 | testmask=1; |
---|
| 3525 | end |
---|
| 3526 | end |
---|
| 3527 | end |
---|
| 3528 | if testmask |
---|
[316] | 3529 | if strcmp(parent_tag,'Civ1') |
---|
[387] | 3530 | set(handles.Mask,'Visible','on') |
---|
[384] | 3531 | set(handles.Mask,'String',filemask) |
---|
[316] | 3532 | set(handles.CheckMask,'Value',1) |
---|
[315] | 3533 | end |
---|
[316] | 3534 | % switch parent_tag |
---|
| 3535 | % % case 'Fix1' |
---|
| 3536 | % % stage=2; |
---|
| 3537 | % case 'Civ2' |
---|
| 3538 | % stage=3; |
---|
| 3539 | % % case 'Fix2' |
---|
| 3540 | % % stage=4; |
---|
| 3541 | % end |
---|
[384] | 3542 | % set(handles.Mask(stage:end),'Visible','on') |
---|
| 3543 | % set(handles.Mask(stage:end),'String',filemask) |
---|
[316] | 3544 | % set(handles.CheckMask(stage:end),'Value',1) |
---|
[276] | 3545 | else |
---|
[315] | 3546 | set(hObject,'Value',0); |
---|
| 3547 | set(handle_txtbox,'Visible','off') |
---|
[276] | 3548 | end |
---|
| 3549 | |
---|
[2] | 3550 | |
---|
| 3551 | % --- Executes on button press in get_gridpatch1. |
---|
| 3552 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
[371] | 3553 | filebase=get(handles.RootPath,'String'); |
---|
[2] | 3554 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3555 | {'*.grid', ' (*.grid)'; |
---|
| 3556 | '*.grid', '.grid files '; ... |
---|
| 3557 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3558 | 'Pick a file',filebase); |
---|
[2] | 3559 | filegrid=fullfile(PathName,FileName); |
---|
| 3560 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3561 | |
---|
[371] | 3562 | |
---|
[12] | 3563 | %------------------------------------------------------------------------ |
---|
[2] | 3564 | % --- Executes on button press in get_gridpatch2. |
---|
| 3565 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3566 | %------------------------------------------------------------------------ |
---|
[2] | 3567 | |
---|
| 3568 | |
---|
[12] | 3569 | %------------------------------------------------------------------------ |
---|
[309] | 3570 | % --- STEREO Interp |
---|
| 3571 | 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] | 3572 | %------------------------------------------------------------------------ |
---|
[309] | 3573 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
| 3574 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
| 3575 | ' -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] | 3576 | |
---|
[12] | 3577 | %------------------------------------------------------------------------ |
---|
[2] | 3578 | %--read images and convert them to the uint16 format used for PIV |
---|
[45] | 3579 | function A=read_image(filename,type_ima,num,movieobject) |
---|
[12] | 3580 | %------------------------------------------------------------------------ |
---|
[2] | 3581 | %num is the view number needed for an avi movie |
---|
[45] | 3582 | switch type_ima |
---|
| 3583 | case 'movie' |
---|
| 3584 | A=read(movieobject,num); |
---|
| 3585 | case 'avi' |
---|
[112] | 3586 | mov=aviread(filename,num); |
---|
| 3587 | A=frame2im(mov(1)); |
---|
[45] | 3588 | case 'multimage' |
---|
| 3589 | A=imread(filename,num); |
---|
[112] | 3590 | case 'image' |
---|
[45] | 3591 | A=imread(filename); |
---|
| 3592 | end |
---|
| 3593 | siz=size(A); |
---|
| 3594 | if length(siz)==3;%color images |
---|
[2] | 3595 | A=sum(double(A),3); |
---|
| 3596 | A=uint16(A); |
---|
| 3597 | end |
---|
| 3598 | |
---|
| 3599 | |
---|
[12] | 3600 | %------------------------------------------------------------------------ |
---|
[2] | 3601 | % --- Executes on button press in get_ref_fix1. |
---|
| 3602 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3603 | %------------------------------------------------------------------------ |
---|
[371] | 3604 | filebase=get(handles.RootPath,'String'); |
---|
[2] | 3605 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3606 | {'*.nc', ' (*.nc)'; |
---|
| 3607 | '*.nc', 'netcdf files '; ... |
---|
| 3608 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3609 | 'Pick a file',filebase); |
---|
| 3610 | |
---|
[2] | 3611 | fileinput=[PathName FileName]; |
---|
| 3612 | sizf=size(fileinput); |
---|
[122] | 3613 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[343] | 3614 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 3615 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
[2] | 3616 | ref.filebase=fullfile(Path,File); |
---|
[343] | 3617 | % ref.num_a=stra2num(str_a); |
---|
| 3618 | % ref.num_b=stra2num(str_b); |
---|
| 3619 | % ref.num1=str2double(field_count); |
---|
| 3620 | % ref.num2=str2double(str2); |
---|
[2] | 3621 | browse=[];%initialisation |
---|
| 3622 | if ~isequal(ref.ext,'.nc') |
---|
| 3623 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 3624 | return |
---|
| 3625 | end |
---|
| 3626 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 3627 | set(handles.ref_fix1,'UserData',ref) |
---|
| 3628 | menu_field{1}='civ1'; |
---|
| 3629 | Data=nc2struct(fileinput,[]); |
---|
[45] | 3630 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 3631 | menu_field{2}='filter1'; |
---|
| 3632 | end |
---|
[45] | 3633 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 3634 | menu_field{3}='civ2'; |
---|
| 3635 | end |
---|
[45] | 3636 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 3637 | menu_field{4}='filter2'; |
---|
| 3638 | end |
---|
| 3639 | set(handles.field_ref1,'String',menu_field); |
---|
| 3640 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
[287] | 3641 | set(handles.num_MinVel,'Value',2); |
---|
| 3642 | set(handles.num_MinVel,'String','1');%default threshold |
---|
[2] | 3643 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 3644 | |
---|
| 3645 | %------------------------------------------------------------------------ |
---|
[2] | 3646 | % --- Executes on button press in get_ref_fix2. |
---|
| 3647 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3648 | %------------------------------------------------------------------------ |
---|
[2] | 3649 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
[371] | 3650 | filebase=get(handles.RootPath,'String'); |
---|
[2] | 3651 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3652 | {'*.nc', ' (*.nc)'; |
---|
| 3653 | '*.nc', 'netcdf files '; ... |
---|
| 3654 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3655 | 'Pick a file',filebase); |
---|
[2] | 3656 | fileinput=[PathName FileName]; |
---|
| 3657 | sizf=size(fileinput); |
---|
[45] | 3658 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[343] | 3659 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 3660 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
[2] | 3661 | ref.filebase=fullfile(Path,File); |
---|
[343] | 3662 | % ref.num_a=stra2num(str_a); |
---|
| 3663 | % ref.num_b=stra2num(str_b); |
---|
| 3664 | % ref.num1=str2num(field_count); |
---|
| 3665 | % ref.num2=str2num(str2); |
---|
[2] | 3666 | browse=[];%initialisation |
---|
| 3667 | if ~isequal(ref.ext,'.nc') |
---|
| 3668 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 3669 | return |
---|
| 3670 | end |
---|
| 3671 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
[112] | 3672 | set(handles.ref_fix2,'UserData',ref) |
---|
[2] | 3673 | menu_field{1}='civ1'; |
---|
| 3674 | Data=nc2struct(fileinput,[]); |
---|
[301] | 3675 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 3676 | menu_field{2}='filter1'; |
---|
| 3677 | end |
---|
[301] | 3678 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 3679 | menu_field{3}='civ2'; |
---|
| 3680 | end |
---|
[301] | 3681 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 3682 | menu_field{4}='filter2'; |
---|
| 3683 | end |
---|
| 3684 | set(handles.field_ref2,'String',menu_field); |
---|
| 3685 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
[287] | 3686 | set(handles.num_MinVel,'Value',2); |
---|
| 3687 | set(handles.num_MinVel,'String','1');%default threshold |
---|
[2] | 3688 | set(handles.ref_fix2,'Enable','on') |
---|
| 3689 | set(handles.ref_fix2,'Visible','on') |
---|
| 3690 | set(handles.field_ref2,'Visible','on') |
---|
| 3691 | else |
---|
| 3692 | set(handles.ref_fix2,'Visible','off') |
---|
| 3693 | set(handles.field_ref2,'Visible','off') |
---|
| 3694 | end |
---|
| 3695 | |
---|
[12] | 3696 | %------------------------------------------------------------------------ |
---|
[2] | 3697 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3698 | %------------------------------------------------------------------------ |
---|
[287] | 3699 | set(handles.num_MinVel,'Value',1); |
---|
[12] | 3700 | set(handles.field_ref1,'Value',1) |
---|
| 3701 | set(handles.field_ref1,'String',{' '}) |
---|
| 3702 | set(handles.ref_fix1,'UserData',[]); |
---|
| 3703 | set(handles.ref_fix1,'String',''); |
---|
| 3704 | set(handles.thresh_vel1,'String','0'); |
---|
[112] | 3705 | |
---|
[12] | 3706 | %------------------------------------------------------------------------ |
---|
[2] | 3707 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3708 | %------------------------------------------------------------------------ |
---|
[287] | 3709 | set(handles.num_MinVel,'Value',1); |
---|
[12] | 3710 | set(handles.field_ref2,'Value',1) |
---|
| 3711 | set(handles.field_ref2,'String',{' '}) |
---|
| 3712 | set(handles.ref_fix2,'UserData',[]); |
---|
| 3713 | set(handles.ref_fix2,'String',''); |
---|
[287] | 3714 | set(handles.num_MinVel,'String','0'); |
---|
[2] | 3715 | |
---|
[12] | 3716 | %------------------------------------------------------------------------ |
---|
[371] | 3717 | % --- TO ABANDON Executes on button press in test_stereo1. |
---|
| 3718 | function CheckStereo_Callback(hObject, eventdata, handles) |
---|
[12] | 3719 | %------------------------------------------------------------------------ |
---|
[371] | 3720 | hparent=get(hObject,'parent'); |
---|
| 3721 | parent_tag=get(hparent,'Tag'); |
---|
| 3722 | hchildren=get(hparent,'children'); |
---|
| 3723 | handle_txtbox=findobj(hchildren,'tag','txt_Mask'); |
---|
| 3724 | if isequal(get(hObject,'Value'),0) |
---|
[274] | 3725 | set(handles.num_SubdomainSize,'Visible','on') |
---|
[437] | 3726 | set(handles.num_FieldSmooth,'Visible','on') |
---|
[2] | 3727 | else |
---|
[274] | 3728 | set(handles.num_SubdomainSize,'Visible','off') |
---|
[437] | 3729 | set(handles.num_FieldSmooth,'Visible','off') |
---|
[2] | 3730 | end |
---|
| 3731 | |
---|
[371] | 3732 | % %------------------------------------------------------------------------ |
---|
| 3733 | % % --- Executes on button press in CheckStereo. |
---|
| 3734 | % function StereoCheck_Callback(hObject, eventdata, handles) |
---|
| 3735 | % %------------------------------------------------------------------------ |
---|
| 3736 | % if isequal(get(handles.CheckStereo,'Value'),0) |
---|
| 3737 | % set(handles.num_SubdomainSize,'Visible','on') |
---|
[437] | 3738 | % set(handles.num_FieldSmooth,'Visible','on') |
---|
[371] | 3739 | % else |
---|
| 3740 | % set(handles.num_SubdomainSize,'Visible','off') |
---|
[437] | 3741 | % set(handles.num_FieldSmooth,'Visible','off') |
---|
[371] | 3742 | % end |
---|
| 3743 | |
---|
[12] | 3744 | %------------------------------------------------------------------------ |
---|
[413] | 3745 | % --- Executes on button press in TestCiv1: prepare the image correlation function |
---|
| 3746 | % activated by mouse motion |
---|
[150] | 3747 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
[224] | 3748 | %------------------------------------------------------------------------ |
---|
[233] | 3749 | drawnow |
---|
[309] | 3750 | if get(handles.TestCiv1,'Value') |
---|
[413] | 3751 | set(handles.TestCiv1,'BackgroundColor',[0.7 0.7 0.7])% paint TestCiv1 button to grey to confirm civ launch |
---|
| 3752 | ref_i=str2double(get(handles.ref_i,'String'));% read reference i index |
---|
[227] | 3753 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
[413] | 3754 | ref_j=str2double(get(handles.ref_j,'String'));% read reference j index if relevant |
---|
[227] | 3755 | else |
---|
[413] | 3756 | ref_j=1;%default j index |
---|
[227] | 3757 | end |
---|
[437] | 3758 | [filecell,i1,i2]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);% get the corresponding file name and indices |
---|
[224] | 3759 | Data.ListVarName={'ny','nx','A'}; |
---|
[315] | 3760 | Data.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
[444] | 3761 | |
---|
[413] | 3762 | Data.A=imread(filecell.ima1.civ1{1}); % read the first image |
---|
[387] | 3763 | if ndims(Data.A)==3 %case of color image |
---|
| 3764 | Data.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; |
---|
| 3765 | end |
---|
[224] | 3766 | Data.ny=[size(Data.A,1) 1]; |
---|
| 3767 | Data.nx=[1 size(Data.A,2)]; |
---|
[413] | 3768 | Data.CoordUnit='pixel';% used to set equal scaling for x and y in image dispaly |
---|
[309] | 3769 | par_civ1=read_GUI(handles.Civ1); |
---|
[444] | 3770 | par_civ1.FileTypeA=get_file_type(filecell.ima1.civ1{1}); |
---|
[388] | 3771 | par_civ1.ImageWidth=size(Data.A,2); |
---|
| 3772 | par_civ1.ImageHeight=size(Data.A,1); |
---|
[315] | 3773 | par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation |
---|
[435] | 3774 | par_civ1.FrameIndexA=num2str(i1); |
---|
| 3775 | par_civ1.FrameIndexB=num2str(i2); |
---|
[246] | 3776 | Param.Civ1=par_civ1; |
---|
[315] | 3777 | Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV |
---|
[387] | 3778 | hview_field=view_field(Data); %view the image in the GUI view_field |
---|
[231] | 3779 | set(0,'CurrentFigure',hview_field) |
---|
| 3780 | hhview_field=guihandles(hview_field); |
---|
| 3781 | set(hview_field,'CurrentAxes',hhview_field.axes3) |
---|
| 3782 | ViewData=get(hview_field,'UserData'); |
---|
| 3783 | ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field |
---|
[224] | 3784 | ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field |
---|
[315] | 3785 | ViewData.axes3.X=Grid.Civ1_X; %keep the set of points in memeory |
---|
| 3786 | ViewData.axes3.Y=Grid.Civ1_Y; |
---|
[231] | 3787 | set(hview_field,'UserData',ViewData) |
---|
[224] | 3788 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 3789 | if isempty(corrfig) |
---|
| 3790 | corrfig=figure; |
---|
| 3791 | set(corrfig,'tag','corrfig') |
---|
| 3792 | set(corrfig,'name','image correlation') |
---|
| 3793 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
| 3794 | end |
---|
[233] | 3795 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
[224] | 3796 | else |
---|
[413] | 3797 | set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red |
---|
[224] | 3798 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 3799 | if ~isempty(corrfig) |
---|
| 3800 | delete(corrfig) |
---|
| 3801 | end |
---|
| 3802 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 3803 | if ~isempty(hview_field) |
---|
| 3804 | delete(hview_field) |
---|
| 3805 | end |
---|
[150] | 3806 | end |
---|
[71] | 3807 | |
---|
[415] | 3808 | %------------------------------------------------------------------------ |
---|
| 3809 | %----function introduced for the correlation window figure, activated by deleting this window |
---|
| 3810 | function closeview_field(gcbo,eventdata) |
---|
| 3811 | %------------------------------------------------------------------------ |
---|
| 3812 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 3813 | if ~isempty(hview_field) |
---|
| 3814 | delete(hview_field) |
---|
| 3815 | end |
---|
[150] | 3816 | |
---|
[252] | 3817 | %------------------------------------------------------------------------ |
---|
[315] | 3818 | % --- Executes on button press in CheckThreshold. |
---|
| 3819 | function CheckThreshold_Callback(hObject, eventdata, handles) |
---|
[252] | 3820 | %------------------------------------------------------------------------ |
---|
[315] | 3821 | huipanel=get(hObject,'parent'); |
---|
| 3822 | obj(1)=findobj(huipanel,'Tag','num_MinIma'); |
---|
| 3823 | obj(2)=findobj(huipanel,'Tag','num_MaxIma'); |
---|
| 3824 | obj(3)=findobj(huipanel,'Tag','title_Threshold'); |
---|
| 3825 | if get(hObject,'Value') |
---|
| 3826 | set(obj,'Visible','on') |
---|
| 3827 | else |
---|
| 3828 | set(obj,'Visible','off') |
---|
| 3829 | end |
---|
[220] | 3830 | |
---|
[465] | 3831 | |
---|
| 3832 | |
---|
| 3833 | |
---|
| 3834 | %'nomtype2pair': creates nomencalture for index pairs knowing the image nomenclature |
---|
| 3835 | %--------------------------------------------------------------------- |
---|
| 3836 | function NomTypeNc=nomtype2pair(NomTypeIma,mode) |
---|
| 3837 | %--------------------------------------------------------------------- |
---|
| 3838 | % OUTPUT: |
---|
| 3839 | % NomTypeNc |
---|
| 3840 | %--------------------------------------------------------------------- |
---|
| 3841 | % INPUT: |
---|
| 3842 | % 'NomTypeIma': string defining the kind of nomenclature used for images |
---|
| 3843 | |
---|
| 3844 | NomTypeNc=NomTypeIma;%default |
---|
| 3845 | switch mode |
---|
| 3846 | case 'pair j1-j2' |
---|
| 3847 | if ~isempty(regexp(NomTypeIma,'a$')) |
---|
| 3848 | NomTypeNc=[NomTypeIma 'b']; |
---|
| 3849 | elseif ~isempty(regexp(NomTypeIma,'A$')) |
---|
| 3850 | NomTypeNc=[NomTypeIma 'B']; |
---|
| 3851 | else |
---|
| 3852 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
| 3853 | if ~isempty(r) |
---|
| 3854 | NomTypeNc='_1_1-2'; |
---|
| 3855 | end |
---|
| 3856 | end |
---|
| 3857 | case 'series(Dj)' |
---|
| 3858 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
| 3859 | if ~isempty(r) |
---|
| 3860 | NomTypeNc='_1_1-2'; |
---|
| 3861 | end |
---|
| 3862 | case 'series(Di)' |
---|
| 3863 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
| 3864 | if ~isempty(r) |
---|
| 3865 | NomTypeNc='_1-2_1'; |
---|
| 3866 | else |
---|
| 3867 | NomTypeNc='_1-2'; |
---|
| 3868 | end |
---|
| 3869 | end |
---|
| 3870 | |
---|
| 3871 | function NomType_Callback(hObject, eventdata, handles) |
---|
| 3872 | set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding |
---|
| 3873 | RootPath=get(handles.RootPath,'String'); |
---|
| 3874 | RootFile=get(handles.RootFile,'String'); |
---|
| 3875 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3876 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 3877 | NomType=get(handles.NomType,'String'); |
---|
| 3878 | ImaExt=get(handles.ImaExt,'String'); |
---|
| 3879 | fileinput=fullfile_uvmat(RootPath,'',RootFile,ImaExt,NomType,ref_i,[],ref_j); |
---|
| 3880 | errormsg=display_file_name(handles,fileinput); |
---|
| 3881 | if ~isempty(errormsg) |
---|
| 3882 | msgbox_uvmat('ERROR',errormsg) |
---|
| 3883 | end |
---|
| 3884 | set(handles.RootPath,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished |
---|
| 3885 | |
---|
| 3886 | % --- Executes on selection change in ListProgram. |
---|
| 3887 | function ListProgram_Callback(hObject, eventdata, handles) |
---|
| 3888 | ListProgram=get(handles.ListProgram,'String'); |
---|
| 3889 | Program=ListProgram{get(handles.ListProgram,'value')}; |
---|
| 3890 | switch Program |
---|
| 3891 | case 'CivX' |
---|
| 3892 | set(handles.num_MaxDiff,'Visible','off') |
---|
| 3893 | set(handles.num_MaxVel,'Visible','off') |
---|
| 3894 | set(handles.title_MaxVel,'Visible','off') |
---|
| 3895 | set(handles.num_Nx,'Visible','on') |
---|
| 3896 | set(handles.num_Ny,'Visible','on') |
---|
| 3897 | set(handles.title_Nx,'Visible','on') |
---|
| 3898 | set(handles.title_Ny,'Visible','on') |
---|
| 3899 | set(handles.title_MaxDiff,'Visible','off') |
---|
| 3900 | set(handles.num_CorrSmooth,'Style','edit') |
---|
| 3901 | set(handles.num_CorrSmooth,'String','1') |
---|
| 3902 | set(handles.BATCH,'Enable','on') |
---|
| 3903 | set(handles.CheckThreshold,'Visible','off') |
---|
| 3904 | set(handles.CheckDeformation,'Value',1) |
---|
| 3905 | set(handles.CheckDecimal,'Value',1) |
---|
| 3906 | case 'Matlab' |
---|
| 3907 | set(handles.num_MaxDiff,'Visible','on') |
---|
| 3908 | set(handles.num_MaxVel,'Visible','on') |
---|
| 3909 | set(handles.title_MaxVel,'Visible','on') |
---|
| 3910 | set(handles.title_MaxDiff,'Visible','on') |
---|
| 3911 | set(handles.num_Nx,'Visible','off') |
---|
| 3912 | set(handles.num_Ny,'Visible','off') |
---|
| 3913 | set(handles.title_Nx,'Visible','off') |
---|
| 3914 | set(handles.title_Ny,'Visible','off') |
---|
| 3915 | set(handles.num_CorrSmooth,'Style','popupmenu') |
---|
| 3916 | set(handles.num_CorrSmooth,'Value',1) |
---|
| 3917 | set(handles.num_CorrSmooth,'String',{'1';'2'}) |
---|
| 3918 | set(handles.CheckThreshold,'Visible','on') |
---|
| 3919 | set(handles.CheckDeformation,'Value',0)% desactivate (work in progress) |
---|
| 3920 | set(handles.CheckDecimal,'Value',0)% desactivate (work in progress) |
---|
| 3921 | end |
---|
| 3922 | |
---|
| 3923 | % --- Executes on button press in TestPatch1. |
---|
| 3924 | function TestPatch1_Callback(hObject, eventdata, handles) |
---|
| 3925 | set(handles.TestPatch1,'BackgroundColor',[1 1 0]) |
---|
| 3926 | drawnow |
---|
| 3927 | if get(handles.TestPatch1,'Value') |
---|
| 3928 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3929 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
| 3930 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 3931 | else |
---|
| 3932 | ref_j=1;%default |
---|
| 3933 | end |
---|
| 3934 | filecell=set_civ_filenames(handles,ref_i,ref_j,[0 0 1 0 0 0]); |
---|
| 3935 | Data.ListVarName={'ny','nx','A'}; |
---|
| 3936 | Data.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
| 3937 | param_patch1=read_GUI(handles.Patch1); |
---|
| 3938 | param_patch1.CivFile=filecell.nc.civ1{1}; |
---|
| 3939 | Param.Patch1=param_patch1; |
---|
| 3940 | for irho=1:7 |
---|
| 3941 | [Data,errormsg]=civ_matlab(Param);% get the grid of x, y positions set for PIV |
---|
| 3942 | if ~isempty(errormsg) |
---|
| 3943 | msgbox_uvmat('ERROR',errormsg) |
---|
| 3944 | return |
---|
| 3945 | end |
---|
| 3946 | SmoothingParam(irho)=Param.Patch1.FieldSmooth; |
---|
| 3947 | Data.Civ1_U_Diff=Data.Civ1_U_Diff(Data.Civ1_FF==0); |
---|
| 3948 | Data.Civ1_V_Diff=Data.Civ1_V_Diff(Data.Civ1_FF==0); |
---|
| 3949 | DiffVel(irho)=sqrt(mean(Data.Civ1_U_Diff.*Data.Civ1_U_Diff+Data.Civ1_V_Diff.*Data.Civ1_V_Diff)) |
---|
| 3950 | NbSites(irho,:)=Data.Civ1_NbSites*numel(Data.Civ1_NbSites)/numel(Data.Civ1_U_Diff); |
---|
| 3951 | Param.Patch1.SmoothingParam=2*Param.Patch1.FieldSmooth; |
---|
| 3952 | end |
---|
| 3953 | figure |
---|
| 3954 | plot(SmoothingParam,DiffVel,'b',SmoothingParam,NbSites,'r') |
---|
| 3955 | set(handles.TestPatch1,'BackgroundColor',[1 0 0]) |
---|
| 3956 | else |
---|
| 3957 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 3958 | if ~isempty(corrfig) |
---|
| 3959 | delete(corrfig) |
---|
| 3960 | end |
---|
| 3961 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 3962 | if ~isempty(hview_field) |
---|
| 3963 | delete(hview_field) |
---|
| 3964 | end |
---|
| 3965 | end |
---|
| 3966 | |
---|
| 3967 | |
---|
| 3968 | % --- Executes on button press in TestCiv2. |
---|
| 3969 | function TestCiv2_Callback(hObject, eventdata, handles) |
---|
| 3970 | |
---|
| 3971 | function RootFile_Callback(hObject, eventdata, handles) |
---|
| 3972 | |
---|
| 3973 | function SubdirImages_Callback(hObject, eventdata, handles) |
---|
| 3974 | |
---|
| 3975 | |
---|
| 3976 | |
---|
| 3977 | function errormsg=write_param(Param) |
---|
[252] | 3978 | %------------------------------------------------------------------------ |
---|
[284] | 3979 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 3980 | %changes : filename_cmx -> filename ( no extension ) |
---|
[465] | 3981 | errormsg=''; |
---|
| 3982 | switch Param.CivMode |
---|
| 3983 | case 'CivX' |
---|
| 3984 | if Param.CheckCiv1 |
---|
| 3985 | filename=regexprep(Param.OutputFile,'(\w+)([/\\])(\w+$)','$1$20_CMX$2$3.civ1.cmx'); |
---|
| 3986 | if isequal(Param.Civ1.Dt,0) |
---|
| 3987 | Param.Civ1.Dt=1 ;%case of 'displacement' mode |
---|
| 3988 | end |
---|
| 3989 | Param.Civ1.ImageA=regexprep(Param.Civ1.ImageA,'.png',''); |
---|
| 3990 | Param.Civ1.ImageB=regexprep(Param.Civ1.ImageB,'.png',''); |
---|
| 3991 | [fid,errormsg]=fopen(filename,'w'); |
---|
| 3992 | if isequal(fid,-1) |
---|
| 3993 | errormsg=['cmd file ' filename ' cannot be created: ' errormsg]; |
---|
| 3994 | return |
---|
| 3995 | end |
---|
| 3996 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 3997 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ1.ImageA,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 3998 | fprintf(fid, ['LastImage ' regexprep(Param.Civ1.ImageB,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 3999 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4000 | if isfield(Param.Civ1,'Mask') |
---|
| 4001 | fprintf(fid, ['Mask ' 'y' '\n' ]); |
---|
| 4002 | fprintf(fid, ['MaskName ' regexprep(Param.Civ1.Mask,'\\','\\\\') '\n' ]); |
---|
| 4003 | else |
---|
| 4004 | fprintf(fid, ['Mask ' 'n' '\n' ]); |
---|
| 4005 | fprintf(fid, ['MaskName ' 'noFile use default' '\n' ]); |
---|
| 4006 | end |
---|
| 4007 | fprintf(fid, ['ImageSize ' num2str(Param.Civ1.ImageWidth) ' ' num2str(Param.Civ1.ImageHeight) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4008 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ1.CorrBoxSize(1)) ' ' num2str(Param.Civ1.CorrBoxSize(2)) '\n' ]); |
---|
| 4009 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ1.SearchBoxSize(1)) ' ' num2str(Param.Civ1.SearchBoxSize(2)) '\n' ]); |
---|
| 4010 | fprintf(fid, ['RO ' num2str(Param.Civ1.CorrSmooth) '\n' ]); |
---|
| 4011 | if isfield(Param.Civ1,'Grid') |
---|
| 4012 | fprintf(fid, ['GridSpacing ' '25' ' ' '25' '\n' ]); |
---|
| 4013 | else |
---|
| 4014 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ1.Dx) ' ' num2str(Param.Civ1.Dy) '\n' ]); |
---|
| 4015 | end |
---|
| 4016 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4017 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ1.Dt) ' ' num2str(Param.Civ1.Time) '\n' ]); |
---|
| 4018 | fprintf(fid, ['PixCmXY ' '1' ' ' '1' '\n' ]); |
---|
| 4019 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4020 | fprintf(fid, ['ShiftXY ' num2str(Param.Civ1.SearchBoxShift(1)) ' ' num2str(Param.Civ1.SearchBoxShift(2)) '\n' ]); |
---|
| 4021 | if isfield(Param.Civ1,'Grid') |
---|
| 4022 | fprintf(fid, ['Grid ' 'y' '\n' ]); |
---|
| 4023 | fprintf(fid, ['GridName ' regexprep(Param.Civ1.Grid,'\\','\\\\') '\n' ]); |
---|
| 4024 | else |
---|
| 4025 | fprintf(fid, ['Grid ' 'n' '\n' ]); |
---|
| 4026 | fprintf(fid, ['GridName ' 'noFile use default' '\n' ]); |
---|
| 4027 | end |
---|
| 4028 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4029 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4030 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4031 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4032 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4033 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4034 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4035 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4036 | if ~isfield(Param.Civ1,'MinIma')% Image threshold not activated |
---|
| 4037 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4038 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]);%not used in principle |
---|
| 4039 | else% Image threshold activated |
---|
| 4040 | if isempty(Param.Civ1.MaxIma)||isnan(Param.Civ1.MaxIma) |
---|
| 4041 | Param.Civ1.MaxIma=2^Param.Civ1.ImageBitDepth;%take the max image value as upper bound by default |
---|
| 4042 | end |
---|
| 4043 | fprintf(fid, ['SeuilImage y' '\n' ]); |
---|
| 4044 | fprintf(fid, ['SeuilImageValues ' num2str(Param.Civ1.MinIma) ' ' num2str(Param.Civ1.MaxIma) '\n' ]); |
---|
| 4045 | end |
---|
| 4046 | fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? |
---|
| 4047 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 4048 | fclose(fid); |
---|
| 4049 | end |
---|
| 4050 | |
---|
| 4051 | if Param.CheckCiv2 |
---|
| 4052 | filename=regexprep(Param.OutputFile,'(\w+)([/\\])(\w+$)','$1$20_CMX$2$3.civ2.cmx'); |
---|
| 4053 | |
---|
| 4054 | if isequal(Param.Civ2.Dt,'0') |
---|
| 4055 | Param.Civ2.Dt='1' ;%case of 'displacement' mode |
---|
| 4056 | end |
---|
| 4057 | Param.Civ2.ImageA=regexprep(Param.Civ2.ImageA,'.png',''); |
---|
| 4058 | Param.Civ2.ImageB=regexprep(Param.Civ2.ImageB,'.png','');% bug : .png appears two times ? |
---|
| 4059 | [fid,errormsg]=fopen(filename,'w'); |
---|
| 4060 | if isequal(fid,-1) |
---|
| 4061 | return |
---|
| 4062 | end |
---|
| 4063 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4064 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ2.ImageA,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4065 | fprintf(fid, ['LastImage ' regexprep(Param.Civ2.ImageB,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4066 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4067 | if isfield(Param.Civ2,'Mask') |
---|
| 4068 | fprintf(fid, ['Mask ' 'y' '\n' ]); |
---|
| 4069 | fprintf(fid, ['MaskName ' regexprep(Param.Civ2.Mask,'\\','\\\\') '\n' ]); |
---|
| 4070 | else |
---|
| 4071 | fprintf(fid, ['Mask ' 'n' '\n' ]); |
---|
| 4072 | fprintf(fid, ['MaskName ' 'noFile use default' '\n' ]); |
---|
| 4073 | end |
---|
| 4074 | % fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]); |
---|
| 4075 | % fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4076 | fprintf(fid, ['ImageSize ' num2str(Param.Civ2.ImageWidth) ' ' num2str(Param.Civ2.ImageHeight) '\n' ]); |
---|
| 4077 | % fprintf(fid, ['ImageSize ' num2str(Param.Civ2.npx) ' ' num2str(Param.Civ2.npy) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4078 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ2.CorrBoxSize(1)) ' ' num2str(Param.Civ2.CorrBoxSize(2)) '\n' ]); |
---|
| 4079 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ2.CorrBoxSize(1)) ' ' num2str(Param.Civ2.CorrBoxSize(2)) '\n']); |
---|
| 4080 | fprintf(fid, ['RO ' num2str(Param.Civ2.CorrSmooth) '\n']); |
---|
| 4081 | if isfield(Param.Civ2,'Grid') |
---|
| 4082 | fprintf(fid, ['GridSpacing ' '25' ' ' '25' '\n' ]); |
---|
| 4083 | else |
---|
| 4084 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n' ]); |
---|
| 4085 | end |
---|
| 4086 | % fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n']); |
---|
| 4087 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4088 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ2.Dt) ' ' num2str(Param.Civ2.Time) '\n' ]); |
---|
| 4089 | fprintf(fid, ['PixCmXY ' '1' ' ' '1' '\n' ]); |
---|
| 4090 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4091 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
| 4092 | if isfield(Param.Civ2,'Grid') |
---|
| 4093 | fprintf(fid, ['Grid ' 'y' '\n' ]); |
---|
| 4094 | fprintf(fid, ['GridName ' regexprep(Param.Civ2.Grid,'\\','\\\\') '\n' ]); |
---|
| 4095 | else |
---|
| 4096 | fprintf(fid, ['Grid ' 'n' '\n' ]); |
---|
| 4097 | fprintf(fid, ['GridName ' 'noFile use default' '\n' ]); |
---|
| 4098 | end |
---|
| 4099 | % fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); |
---|
| 4100 | % fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); |
---|
| 4101 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4102 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4103 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4104 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4105 | fprintf(fid, ['DecimalShift ' num2str(Param.Civ2.CheckDecimal) '\n']); |
---|
| 4106 | fprintf(fid, ['Deformation ' num2str(Param.Civ2.CheckDeformation) '\n']); |
---|
| 4107 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4108 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4109 | |
---|
| 4110 | if ~isfield(Param.Civ2,'MinIma')% Image threshold not activated |
---|
| 4111 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4112 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]);%not used in principle |
---|
| 4113 | else% Image threshold activated |
---|
| 4114 | if isempty(Param.Civ2.MaxIma)||isnan(Param.Civ2.MaxIma) |
---|
| 4115 | Param.Civ2.MaxIma=2^Param.Civ2.ImageBitDepth;%take the max image value as upper bound by default |
---|
| 4116 | end |
---|
| 4117 | fprintf(fid, ['SeuilImage y' '\n' ]); |
---|
| 4118 | fprintf(fid, ['SeuilImageValues ' num2str(Param.Civ2.MinIma) ' ' num2str(Param.Civ2.MaxIma) '\n' ]); |
---|
| 4119 | end |
---|
| 4120 | fprintf(fid, ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ? |
---|
| 4121 | fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']); |
---|
| 4122 | fclose(fid); |
---|
| 4123 | end |
---|
| 4124 | case 'Matlab' |
---|
| 4125 | filename=regexprep(Param.OutputFile,'(\w+)([/\\])(\w+$)','$1$20_XML$2$3.xml'); |
---|
| 4126 | save(struct2xml(Param),filename); |
---|
[284] | 4127 | end |
---|
[465] | 4128 | |
---|
| 4129 | |
---|
| 4130 | function cmd=write_cmd(Param,batch) |
---|
| 4131 | |
---|
| 4132 | % initiate system command |
---|
| 4133 | cmd=[]; |
---|
| 4134 | |
---|
| 4135 | switch Param.CivMode |
---|
| 4136 | case 'CivX' |
---|
| 4137 | if isunix % check: necessaire aussi en RUN? |
---|
| 4138 | cmd=[cmd '#!/bin/bash \n '... |
---|
| 4139 | '#$ -cwd \n '... |
---|
| 4140 | 'hostname && date \n '... |
---|
| 4141 | 'umask 002 \n'];%allow writting access to created files for user group |
---|
| 4142 | end |
---|
| 4143 | case 'CivAll' |
---|
| 4144 | if isunix % check: necessaire aussi en RUN? |
---|
| 4145 | cmd=[cmd '#!/bin/bash \n '... |
---|
| 4146 | '#$ -cwd \n '... |
---|
| 4147 | 'hostname && date \n '... |
---|
| 4148 | 'umask 002 \n'];%allow writting access to created files for user group |
---|
| 4149 | end |
---|
[319] | 4150 | end |
---|
[465] | 4151 | |
---|
| 4152 | filename=regexprep(Param.OutputFile,'.nc',''); |
---|
| 4153 | |
---|
| 4154 | if Param.CheckCiv1 |
---|
| 4155 | switch Param.CivMode |
---|
| 4156 | case 'CivX' |
---|
| 4157 | if(isunix) %unix (or Mac) system |
---|
| 4158 | cmd=[cmd 'cp -f ' regexprep(filename,'(\w+)/(\w+$)','$1/0_CMX/$2.civ1.cmx ') regexprep(filename,'(\w+)/(\w+$)','$1/$2.cmx \n')...% the cmx file gives the name to the nc file |
---|
| 4159 | Param.xml.Civ1Bin ' -f ' regexprep(filename,'(\w+)/(\w+$)','$1/$2.cmx >') regexprep(filename,'(\w+)/(\w+$)','$1/0_LOG/$2.civ1.log \n')... % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
| 4160 | 'rm ' regexprep(filename,'(\w+)/(\w+$)','$1/$2.cmx \n')]; |
---|
| 4161 | else %Windows system |
---|
| 4162 | filename=regexprep(filename,'\\','\\\\'); |
---|
| 4163 | cmd=['copy /Y ' regexprep(filename,'(\w+)\\\\(\w+$)','"$1\\\\0_CMX\\\\$2.civ1.cmx" ') regexprep(filename,'(\w+)\\\\(\w+$)','"$1\\\\$2.civ1.cmx" \n')... |
---|
| 4164 | '"' regexprep(Param.xml.Civ1Bin,'\\','\\\\') '" -f ' regexprep(filename,'(\w+)\\\\(\w+$)','"$1\\\\$2.cmx" > ')... |
---|
| 4165 | regexprep(filename,'(\w+)\\\\(\w+$)','"$1\\\\0_LOG\\\\$2.civ1.log" \n')... % redirect standard output to the log file |
---|
| 4166 | 'del ' regexprep(filename,'(\w+)\\\\(\w+$)','"$1\\\\$2.cmx" \n')]; |
---|
| 4167 | end |
---|
| 4168 | case 'CivAll' |
---|
| 4169 | CivAllCmd=[CivAllCmd ' civ1 ']; |
---|
| 4170 | str=CIV1_CMD_Unified(filecell.nc.civ1{ifile,j},'',Param.Civ1); |
---|
| 4171 | fieldnames=fields(str); |
---|
| 4172 | [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); |
---|
| 4173 | for ilist=1:length(fieldnames) |
---|
| 4174 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 4175 | if ischar(val) |
---|
| 4176 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 4177 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 4178 | end |
---|
| 4179 | end |
---|
| 4180 | end |
---|
[315] | 4181 | end |
---|
[465] | 4182 | |
---|
| 4183 | if Param.CheckFix1 |
---|
| 4184 | switch Param.CivMode |
---|
| 4185 | case 'CivX' |
---|
| 4186 | cmd=[cmd... |
---|
| 4187 | cmd_fix(Param,'Fix1') '\n']; |
---|
| 4188 | case 'CivAll'%to abandon |
---|
| 4189 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 4190 | fix1.fi1=num2str(param.fix1.flagindex1(1)); |
---|
| 4191 | fix1.fi2=num2str(param.fix1.flagindex1(2)); |
---|
| 4192 | fix1.fi3=num2str(param.fix1.flagindex1(3)); |
---|
| 4193 | fix1.threshC=num2str(param.fix1.thresh_vecC1); |
---|
| 4194 | fix1.threshV=num2str(param.fix1.thresh_vel1); |
---|
| 4195 | fieldnames=fields(fix1); |
---|
| 4196 | [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); |
---|
| 4197 | for ilist=1:length(fieldnames) |
---|
| 4198 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 4199 | if ischar(val) |
---|
| 4200 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 4201 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 4202 | end |
---|
| 4203 | end |
---|
| 4204 | CivAllCmd=[CivAllCmd ' fix1 ']; |
---|
| 4205 | end |
---|
[313] | 4206 | end |
---|
[465] | 4207 | |
---|
| 4208 | |
---|
| 4209 | %CheckPatch1 |
---|
| 4210 | if Param.CheckPatch1 |
---|
| 4211 | switch Param.CivMode |
---|
| 4212 | case 'CivX' |
---|
| 4213 | cmd=[cmd... |
---|
| 4214 | cmd_patch(Param,'Patch1') '\n']; |
---|
| 4215 | case 'CivAll' |
---|
| 4216 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 4217 | patch1.nopt=subdomain_patch1; |
---|
| 4218 | patch1.maxdiff=thresh_patch1; |
---|
| 4219 | patch1.ro=rho_patch1; |
---|
| 4220 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 4221 | if test_grid |
---|
| 4222 | patch1.gridflag='y'; |
---|
| 4223 | gridname=get(handles.grid_patch1,'String'); |
---|
| 4224 | if isequal(gridname(end-3:end),'grid') |
---|
| 4225 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 4226 | if ~isnan(nbslice_grid) |
---|
| 4227 | i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 4228 | patch1.gridPatch=[filecell.filebase '_' fullfile_uvmat('','',gridname,'.grid','_1',i1_grid)]; |
---|
| 4229 | % patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')]; |
---|
| 4230 | if ~exist(patch1.gridPatch,'file') |
---|
| 4231 | errormsg='grid file absent for patch1'; |
---|
| 4232 | return |
---|
| 4233 | end |
---|
| 4234 | elseif exist(gridname,'file') |
---|
| 4235 | patch1.gridPatch=gridname; |
---|
| 4236 | else |
---|
| 4237 | errormsg='grid file absent for patch1'; |
---|
| 4238 | return |
---|
| 4239 | end |
---|
| 4240 | end |
---|
| 4241 | else |
---|
| 4242 | patch1.gridPatch='none'; |
---|
| 4243 | patch1.gridflag='n'; |
---|
| 4244 | patch1.m=nx_patch1; |
---|
| 4245 | patch1.n=ny_patch1; |
---|
| 4246 | end |
---|
| 4247 | patch1.convectFlow='n'; |
---|
| 4248 | fieldnames=fields(patch1); |
---|
| 4249 | [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); |
---|
| 4250 | for ilist=1:length(fieldnames) |
---|
| 4251 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 4252 | if ischar(val) |
---|
| 4253 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 4254 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 4255 | end |
---|
| 4256 | end |
---|
| 4257 | CivAllCmd=[CivAllCmd ' patch1 ']; |
---|
| 4258 | end |
---|
[313] | 4259 | end |
---|
[465] | 4260 | |
---|
| 4261 | if Param.CheckCiv2 |
---|
| 4262 | switch Param.CivMode |
---|
| 4263 | case 'CivX' |
---|
| 4264 | if(isunix) |
---|
| 4265 | cmd=[cmd 'cp -f ' regexprep(filename,'(\w+)/(\w+$)','$1/0_CMX/$2.civ2.cmx ') regexprep(filename,'(\w+)/(\w+$)','$1/$2.cmx \n')... |
---|
| 4266 | Param.xml.Civ2Bin ' -f ' regexprep(filename,'(\w+)/(\w+$)','$1/$2.cmx >') regexprep(filename,'(\w+)/(\w+$)','$1/0_LOG/$2.civ2.log \n')...% redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
| 4267 | 'rm ' regexprep(filename,'(\w+)/(\w+$)','$1/$2.cmx \n')];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
| 4268 | else |
---|
| 4269 | filename=regexprep(filename,'\\','\\\\'); |
---|
| 4270 | cmd=[cmd 'copy /Y ' regexprep(filename,'(\w+)\\\\(\w+$)','"$1\\\\0_CMX\\\\$2.civ2.cmx" ') regexprep(filename,'(\w+)\\\\(\w+$)','"$1\\\\$2.cmx" \n')... |
---|
| 4271 | '"' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' regexprep(filename,'(\w+)\\\\(\w+$)','"$1\\\\$2.cmx" > ')... |
---|
| 4272 | regexprep(filename,'(\w+)\\\\(\w+$)','"$1\\\\0_LOG\\\\$2.civ2.log" \n')... % redirect standard output to the log file |
---|
| 4273 | 'del ' regexprep(filename,'(\w+)\\\\(\w+$)','"$1\\\\$2.cmx" \n')]; |
---|
| 4274 | end |
---|
| 4275 | case 'CivAll' |
---|
| 4276 | CivAllCmd=[CivAllCmd ' civ2 ']; |
---|
| 4277 | str=CIV2_CMD_Unified(filecell.nc.civ2{ifile,j},'',Param.Civ2); |
---|
| 4278 | fieldnames=fields(str); |
---|
| 4279 | [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); |
---|
| 4280 | for ilist=1:length(fieldnames) |
---|
| 4281 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 4282 | if ischar(val) |
---|
| 4283 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 4284 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 4285 | end |
---|
| 4286 | end |
---|
[309] | 4287 | end |
---|
| 4288 | end |
---|
[284] | 4289 | |
---|
[465] | 4290 | % CheckFix2 |
---|
| 4291 | if Param.CheckFix2==1 |
---|
| 4292 | switch Param.CivMode |
---|
| 4293 | case 'CivX' |
---|
| 4294 | cmd=[cmd... |
---|
| 4295 | cmd_fix(Param,'Fix2') '\n']; |
---|
| 4296 | case 'CivAll' |
---|
| 4297 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 4298 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 4299 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 4300 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 4301 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 4302 | fix2.threshV=num2str(thresh_vel2); |
---|
| 4303 | fieldnames=fields(fix2); |
---|
| 4304 | [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); |
---|
| 4305 | for ilist=1:length(fieldnames) |
---|
| 4306 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 4307 | if ischar(val) |
---|
| 4308 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 4309 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 4310 | end |
---|
| 4311 | end |
---|
| 4312 | CivAllCmd=[CivAllCmd ' fix2 ']; |
---|
| 4313 | end |
---|
[284] | 4314 | end |
---|
[285] | 4315 | |
---|
[465] | 4316 | %CheckPatch2 |
---|
| 4317 | if Param.CheckPatch2==1 |
---|
| 4318 | |
---|
| 4319 | switch Param.CivMode |
---|
| 4320 | |
---|
| 4321 | case 'CivX' |
---|
| 4322 | cmd=[cmd... |
---|
| 4323 | cmd_patch(Param,'Patch2') '\n']; |
---|
| 4324 | case 'CivAll' |
---|
| 4325 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 4326 | patch2.nopt=subdomain_patch2; |
---|
| 4327 | patch2.maxdiff=thresh_patch2; |
---|
| 4328 | patch2.ro=rho_patch2; |
---|
| 4329 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 4330 | if test_grid |
---|
| 4331 | patch2.gridflag='y'; |
---|
| 4332 | gridname=get(handles.grid_patch2,'String'); |
---|
| 4333 | if isequal(gridname(end-3:end),'grid') |
---|
| 4334 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 4335 | if ~isnan(nbslice_grid) |
---|
| 4336 | i1_grid=mod(i1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 4337 | patch2.gridPatch=[filecell.filebase '_' fullfile_uvmat('','',gridname,'.grid','_1',i1_grid)]; |
---|
| 4338 | % patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')]; |
---|
| 4339 | if ~exist(patch2.gridPatch,'file') |
---|
| 4340 | errormsg='grid file absent for patch2'; |
---|
| 4341 | return |
---|
| 4342 | end |
---|
| 4343 | elseif exist(gridname,'file') |
---|
| 4344 | patch2.gridPatch=gridname; |
---|
| 4345 | else |
---|
| 4346 | errormsg='grid file absent for patch2'; |
---|
| 4347 | return |
---|
| 4348 | end |
---|
| 4349 | end |
---|
| 4350 | else |
---|
| 4351 | patch2.gridPatch='none'; |
---|
| 4352 | patch2.gridflag='n'; |
---|
| 4353 | patch2.m=nx_patch2; |
---|
| 4354 | patch2.n=ny_patch2; |
---|
| 4355 | end |
---|
| 4356 | patch2.convectFlow='n'; |
---|
| 4357 | fieldnames=fields(patch2); |
---|
| 4358 | [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); |
---|
| 4359 | for ilist=1:length(fieldnames) |
---|
| 4360 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 4361 | if ischar(val) |
---|
| 4362 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 4363 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 4364 | end |
---|
| 4365 | end |
---|
| 4366 | CivAllCmd=[CivAllCmd ' patch2 ']; |
---|
| 4367 | end |
---|
| 4368 | end |
---|
[285] | 4369 | |
---|
[465] | 4370 | if isequal(Param.CivMode,'CivAll') |
---|
| 4371 | save(CivAllxml,[Param.OutputFile '.xml']); |
---|
| 4372 | cmd=[cmd sparam.CivBin ' -f ' Param.OutputFile '.xml ' CivAllCmd ' >' Param.OutputFile '.log' '\n']; |
---|
| 4373 | end |
---|
| 4374 | |
---|
| 4375 | if isequal(Param.CivMode,'Matlab') |
---|
| 4376 | if batch |
---|
| 4377 | cmd=['#!/bin/bash \n '... |
---|
| 4378 | '#$ -cwd \n '... |
---|
| 4379 | 'hostname && date \n '... |
---|
| 4380 | 'umask 002 \n'... |
---|
| 4381 | Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' Param.OutputFile '.nc'];%allow writting access to created files for user group |
---|
| 4382 | |
---|
| 4383 | fprintf(fid,cmd); |
---|
| 4384 | fclose(fid); |
---|
| 4385 | if isunix |
---|
| 4386 | system(['chmod +x ' filename_bat]); |
---|
| 4387 | end |
---|
| 4388 | batch_file_list{length(batch_file_list)+1}=filename_bat; |
---|
| 4389 | else |
---|
| 4390 | cmd=['civ_matlab(''' regexprep(filename,'(\w+)([/\\])(\w+$)','$1$20_XML$2$3.xml') ''','''... |
---|
| 4391 | filename '.nc'');'] |
---|
| 4392 | % [tild,errormsg]=civ_matlab(Param,filecell.nc.civ1{ifile,j}); |
---|
| 4393 | end |
---|
| 4394 | end |
---|
| 4395 | |
---|
| 4396 | |
---|
| 4397 | if isequal(Param.CivMode,'MatlabCompile') |
---|
| 4398 | cmd=['#!/bin/bash \n '... |
---|
| 4399 | '#$ -cwd \n '... |
---|
| 4400 | 'hostname && date \n '... |
---|
| 4401 | 'umask 002 \n'... |
---|
| 4402 | Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' Param.OutputFile '.nc'];%allow writting access to created files for user group |
---|
| 4403 | end |
---|
| 4404 | |
---|
| 4405 | |
---|
| 4406 | if isequal(Param.CivMode,'MatlabNonCompile') |
---|
| 4407 | % cmd=[regexprep(which(civ_matlab),'.m$','')... |
---|
| 4408 | % '(' regexprep(filename,'(\w+)/(\w+$)','$1/0_XML$2.xml,')... |
---|
| 4409 | % filename '.nc);']; |
---|
| 4410 | % [tild,errormsg]=civ_matlab(Param,filecell.nc.civ1{ifile,j}); |
---|
| 4411 | end |
---|
| 4412 | |
---|
| 4413 | |
---|
| 4414 | |
---|
| 4415 | |
---|
| 4416 | |
---|
| 4417 | |
---|
| 4418 | function cmd=cmd_fix(Param,fixname) |
---|
[285] | 4419 | %% |
---|
[291] | 4420 | switch fixname |
---|
| 4421 | case 'Fix1' |
---|
| 4422 | fi2_value=num2str(Param.(fixname).CheckF2); |
---|
[465] | 4423 | filename=regexprep(Param.OutputFile,'.nc',''); |
---|
[291] | 4424 | case 'Fix2' |
---|
| 4425 | fi2_value=num2str(Param.(fixname).CheckF4);%need to understand why... |
---|
[465] | 4426 | filename=regexprep(Param.OutputFile,'.nc',''); |
---|
[291] | 4427 | end |
---|
[465] | 4428 | |
---|
| 4429 | % filename=regexprep(Param.(fixname).OutFileName,'.nc',''); |
---|
[287] | 4430 | MaskName_string='';%default |
---|
| 4431 | MaxVel_string='';%default |
---|
[427] | 4432 | if ~isempty(Param.(fixname).MinVel) |
---|
| 4433 | MaxVel_string=[' -threshV ' num2str(Param.(fixname).MinVel)]; |
---|
[287] | 4434 | end |
---|
[285] | 4435 | if isunix |
---|
[287] | 4436 | cmd=[Param.xml.FixBin ' -f ' filename '.nc -fi1 ' num2str(Param.(fixname).CheckFmin2) ... |
---|
[291] | 4437 | ' -fi2 ' fi2_value ' -fi3 ' num2str(Param.(fixname).CheckF3) ... |
---|
[287] | 4438 | ' -threshC ' num2str(Param.(fixname).MinCorr) MaxVel_string MaskName_string... |
---|
[465] | 4439 | ' >' regexprep(filename,'(\w+)/(\w+$)','$1/0_LOG/$2.') lower(fixname) '.log 2>&1']; |
---|
[285] | 4440 | else |
---|
| 4441 | cmd=['"' Param.xml.FixBin '" -f "' filename '.nc" -fi1 ' num2str(Param.(fixname).CheckFmin2)... |
---|
[291] | 4442 | ' -fi2 ' fi2_value ' -fi3 ' num2str(Param.(fixname).CheckF3) ... |
---|
[288] | 4443 | ' -threshC ' num2str(Param.(fixname).MinCorr) MaxVel_string MaskName_string... |
---|
[465] | 4444 | ' > "' regexprep(filename,'(\w+)\\(\w+$)','$1\\0_LOG\\$2.') lower(fixname) '.log"']; |
---|
[285] | 4445 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
| 4446 | end |
---|
[286] | 4447 | |
---|
| 4448 | |
---|
[465] | 4449 | function cmd=cmd_patch(Param,patchname) |
---|
[286] | 4450 | %% ------------------------------------------------------------------------ |
---|
[465] | 4451 | switch patchname |
---|
| 4452 | case 'Patch1' |
---|
| 4453 | filename=regexprep(Param.OutputFile,'.nc',''); |
---|
| 4454 | case 'Patch2' |
---|
| 4455 | filename=regexprep(Param.OutputFile,'.nc',''); |
---|
| 4456 | end |
---|
| 4457 | % filename=regexprep(Param.(patchname).OutFileName,'.nc',''); |
---|
[286] | 4458 | if isunix |
---|
| 4459 | cmd=[Param.xml.PatchBin... |
---|
| 4460 | ' -f ' filename '.nc -m ' num2str(Param.(patchname).Nx)... |
---|
[437] | 4461 | ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).FieldSmooth)... |
---|
[286] | 4462 | ' -nopt ' num2str(Param.(patchname).SubdomainSize) ... |
---|
[465] | 4463 | ' > ' regexprep(filename,'(\w+)/(\w+$)','$1/0_LOG/$2.') lower(patchname) '.log 2>&1']; % redirect standard output to the log file |
---|
[286] | 4464 | else |
---|
| 4465 | cmd=['"' Param.xml.PatchBin... |
---|
| 4466 | '" -f "' filename '.nc" -m ' num2str(Param.(patchname).Nx)... |
---|
[437] | 4467 | ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).FieldSmooth)... |
---|
[286] | 4468 | ' -nopt ' num2str(Param.(patchname).SubdomainSize)... |
---|
| 4469 | ' > "' filename '.' lower(patchname) '.log" 2>&1']; % redirect standard output to the log file |
---|
| 4470 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
| 4471 | end |
---|
[290] | 4472 | |
---|
[309] | 4473 | |
---|
[290] | 4474 | |
---|
[309] | 4475 | |
---|
[465] | 4476 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4477 | % USELESS FUNCTIONS BELOW HERE, TO CLEAN |
---|
| 4478 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4479 | |
---|
| 4480 | |
---|
| 4481 | |
---|
| 4482 | |
---|
| 4483 | |
---|
[309] | 4484 | %------------------------------------------------------------------------ |
---|
| 4485 | % --- CheckCiv1 Unified: TO ABADON |
---|
| 4486 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
| 4487 | %------------------------------------------------------------------------ |
---|
| 4488 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4489 | %global CivBin%name of the executable for checkciv1 calculation |
---|
| 4490 | |
---|
[315] | 4491 | civ1.image1=par.ImageA; |
---|
| 4492 | civ1.image2=par.ImageB; |
---|
[309] | 4493 | civ1.imageSize_X=par.npx; |
---|
| 4494 | civ1.imageSize_Y=par.npy; |
---|
| 4495 | civ1.outputFileName=[filename '.nc']; |
---|
| 4496 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4497 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4498 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4499 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4500 | civ1.globalShift_X=par.shiftx; |
---|
| 4501 | civ1.globalShift_Y=par.shifty; |
---|
| 4502 | civ1.ro=par.rho; |
---|
| 4503 | civ1.hart='y'; |
---|
| 4504 | if isequal(par.gridflag,'y') |
---|
| 4505 | civ1.grid=par.gridname; |
---|
| 4506 | else |
---|
| 4507 | civ1.grid='n'; |
---|
| 4508 | civ1.gridSpacing_X=par.dx; |
---|
| 4509 | civ1.gridSpacing_Y=par.dy; |
---|
| 4510 | end |
---|
| 4511 | if isequal(par.maskflag,'y') |
---|
| 4512 | civ1.mask=par.maskname; |
---|
| 4513 | end |
---|
| 4514 | civ1.dt=par.Dt; |
---|
| 4515 | civ1.unit='pixel'; |
---|
[315] | 4516 | civ1.absolut_time_T0=par.Time; |
---|
| 4517 | civ1.pixcmx='1'; |
---|
| 4518 | civ1.pixcmy='1'; |
---|
[309] | 4519 | civ1.convectFlow='n'; |
---|
| 4520 | |
---|
| 4521 | xml_civ1_parameters=civ1; |
---|
| 4522 | |
---|
| 4523 | %------------------------------------------------------------------------ |
---|
| 4524 | % --- CheckCiv2 Unified: TO ABADON |
---|
| 4525 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
| 4526 | %------------------------------------------------------------------------ |
---|
| 4527 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4528 | %global CivBin%name of the executable for checkciv1 calculation |
---|
| 4529 | |
---|
| 4530 | filename=regexprep(filename,'.nc',''); |
---|
| 4531 | |
---|
[315] | 4532 | civ2.image1=par.ImageA; |
---|
| 4533 | civ2.image2=par.ImageB; |
---|
[309] | 4534 | civ2.imageSize_X=par.npx; |
---|
| 4535 | civ2.imageSize_Y=par.npy; |
---|
| 4536 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4537 | civ2.outputFileName=[filename '.nc']; |
---|
| 4538 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4539 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4540 | civ2.ro=par.rho; |
---|
| 4541 | %checkciv2.decimalShift=par.CheckDecimal; |
---|
| 4542 | %checkciv2.CheckDeformation=par.CheckDeformation; |
---|
| 4543 | if isequal(par.decimal,'1') |
---|
| 4544 | civ2.decimalShift='y'; |
---|
| 4545 | else |
---|
| 4546 | civ2.decimalShift='n'; |
---|
| 4547 | end |
---|
| 4548 | if isequal(par.deformation,'1') |
---|
| 4549 | civ2.deformation='y'; |
---|
| 4550 | else |
---|
| 4551 | civ2.deformation='n'; |
---|
| 4552 | end |
---|
| 4553 | if isequal(par.gridflag,'y') |
---|
| 4554 | civ2.grid=par.gridname; |
---|
| 4555 | else |
---|
| 4556 | civ2.grid='n'; |
---|
| 4557 | civ2.gridSpacing_X=par.dx; |
---|
| 4558 | civ2.gridSpacing_Y=par.dy; |
---|
| 4559 | end |
---|
| 4560 | civ2.gridSpacing_X='10'; |
---|
| 4561 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4562 | if isequal(par.maskflag,'y') |
---|
| 4563 | civ2.mask=par.maskname; |
---|
| 4564 | else |
---|
| 4565 | civ2.mask='n'; |
---|
| 4566 | end |
---|
| 4567 | civ2.dt=par.Dt; |
---|
| 4568 | civ2.unit='pixel'; |
---|
[315] | 4569 | civ2.absolut_time_T0=par.Time; |
---|
| 4570 | civ2.pixcmx='1'; |
---|
| 4571 | civ2.pixcmy='1'; |
---|
[309] | 4572 | civ2.convectFlow='n'; |
---|
[317] | 4573 | |
---|
| 4574 | |
---|
[356] | 4575 | |
---|