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