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